Enum wasmtime_runtime::Memory [−][src]
pub enum Memory {
Static {
base: &'static mut [u8],
size: usize,
make_accessible: fn(_: *mut u8, _: usize) -> Result<()>,
},
Dynamic(Box<dyn RuntimeLinearMemory>),
}Expand description
Representation of a runtime wasm linear memory.
Variants
Static
Fields
base: &'static mut [u8]The memory in the host for this wasm memory. The length of this slice is the maximum size of the memory that can be grown to.
size: usizeThe current size, in bytes, of this memory.
A “static” memory where the lifetime of the backing memory is managed elsewhere. Currently used with the pooling allocator.
Dynamic(Box<dyn RuntimeLinearMemory>)
Tuple Fields
0: Box<dyn RuntimeLinearMemory>A “dynamic” memory whose data is managed at runtime and lifetime is tied to this instance.
Implementations
pub fn new_dynamic(
plan: &MemoryPlan,
creator: &dyn RuntimeMemoryCreator,
store: &mut dyn Store
) -> Result<Self>
pub fn new_dynamic(
plan: &MemoryPlan,
creator: &dyn RuntimeMemoryCreator,
store: &mut dyn Store
) -> Result<Self>
Create a new dynamic (movable) memory instance for the specified plan.
pub fn new_static(
plan: &MemoryPlan,
base: &'static mut [u8],
make_accessible: fn(_: *mut u8, _: usize) -> Result<()>,
store: &mut dyn Store
) -> Result<Self>
pub fn new_static(
plan: &MemoryPlan,
base: &'static mut [u8],
make_accessible: fn(_: *mut u8, _: usize) -> Result<()>,
store: &mut dyn Store
) -> Result<Self>
Create a new static (immovable) memory instance for the specified plan.
Returns the maximum number of pages the memory can grow to at runtime.
Returns None if the memory is unbounded.
The runtime maximum may not be equal to the maximum from the linear memory’s Wasm type when it is being constrained by an instance allocator.
Grow memory by the specified amount of wasm pages.
Returns None if memory can’t be grown by the specified amount
of wasm pages. Returns Some with the old size of memory, in bytes, on
successful growth.
Safety
Resizing the memory can reallocate the memory buffer for dynamic memories.
An instance’s VMContext may have pointers to the memory’s base and will
need to be fixed up after growing the memory.
Generally, prefer using InstanceHandle::memory_grow, which encapsulates
this unsafety.
Ensure that the provided Store is not used to get access any Memory which lives inside it.
Return a VMMemoryDefinition for exposing the memory to compiled wasm code.
