mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 12:48:20 +00:00
Cleanup:
Removed conditionnal toml on wasm for VM as it's not builded in that configuration Added unwind to wasm build Moved Trap back to vm (from types) as it's used only on Runtime Move MemoryError back to vm (from types) as it's used on Runtime only scenario Some cleanup and lint fixes Removed wasm build case from vfs/host_fs as it's not used
This commit is contained in:
@@ -15,7 +15,50 @@ use std::convert::TryInto;
|
||||
use std::fmt;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::Mutex;
|
||||
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages};
|
||||
use thiserror::Error;
|
||||
use wasmer_types::{Bytes, MemoryStyle, MemoryType, Pages};
|
||||
|
||||
/// Error type describing things that can go wrong when operating on Wasm Memories.
|
||||
#[derive(Error, Debug, Clone, PartialEq, Hash)]
|
||||
pub enum MemoryError {
|
||||
/// Low level error with mmap.
|
||||
#[error("Error when allocating memory: {0}")]
|
||||
Region(String),
|
||||
/// The operation would cause the size of the memory to exceed the maximum or would cause
|
||||
/// an overflow leading to unindexable memory.
|
||||
#[error("The memory could not grow: current size {} pages, requested increase: {} pages", current.0, attempted_delta.0)]
|
||||
CouldNotGrow {
|
||||
/// The current size in pages.
|
||||
current: Pages,
|
||||
/// The attempted amount to grow by in pages.
|
||||
attempted_delta: Pages,
|
||||
},
|
||||
/// The operation would cause the size of the memory size exceed the maximum.
|
||||
#[error("The memory is invalid because {}", reason)]
|
||||
InvalidMemory {
|
||||
/// The reason why the provided memory is invalid.
|
||||
reason: String,
|
||||
},
|
||||
/// Caller asked for more minimum memory than we can give them.
|
||||
#[error("The minimum requested ({} pages) memory is greater than the maximum allowed memory ({} pages)", min_requested.0, max_allowed.0)]
|
||||
MinimumMemoryTooLarge {
|
||||
/// The number of pages requested as the minimum amount of memory.
|
||||
min_requested: Pages,
|
||||
/// The maximum amount of memory we can allocate.
|
||||
max_allowed: Pages,
|
||||
},
|
||||
/// Caller asked for a maximum memory greater than we can give them.
|
||||
#[error("The maximum requested memory ({} pages) is greater than the maximum allowed memory ({} pages)", max_requested.0, max_allowed.0)]
|
||||
MaximumMemoryTooLarge {
|
||||
/// The number of pages requested as the maximum amount of memory.
|
||||
max_requested: Pages,
|
||||
/// The number of pages requested as the maximum amount of memory.
|
||||
max_allowed: Pages,
|
||||
},
|
||||
/// A user defined error value, used for error cases not listed above.
|
||||
#[error("A user-defined error occurred: {0}")]
|
||||
Generic(String),
|
||||
}
|
||||
|
||||
/// Trait for implementing Wasm Memory used by Wasmer.
|
||||
pub trait Memory: fmt::Debug + Send + Sync + MemoryUsage {
|
||||
|
||||
Reference in New Issue
Block a user