pub struct Memory(_);
Expand description

Representation of a runtime wasm linear memory.

Implementations§

source§

impl Memory

source

pub fn new_dynamic( plan: &MemoryPlan, creator: &dyn RuntimeMemoryCreator, store: &mut dyn Store, memory_image: Option<&Arc<MemoryImage>> ) -> Result<Self>

Create a new dynamic (movable) memory instance for the specified plan.

source

pub fn new_static( plan: &MemoryPlan, base: &'static mut [u8], memory_image: MemoryImageSlot, memory_and_guard_size: usize, store: &mut dyn Store ) -> Result<Self>

Create a new static (immovable) memory instance for the specified plan.

source

pub fn byte_size(&self) -> usize

Returns the number of allocated wasm pages.

source

pub fn maximum_byte_size(&self) -> Option<usize>

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.

source

pub unsafe fn grow( &mut self, delta_pages: u64, store: Option<&mut dyn Store> ) -> Result<Option<usize>, Error>

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.

source

pub fn vmmemory(&mut self) -> VMMemoryDefinition

Return a VMMemoryDefinition for exposing the memory to compiled wasm code.

source

pub fn as_shared_memory(&mut self) -> Option<&mut SharedMemory>

If the Memory is a SharedMemory, unwrap it and return a clone to that shared memory.

source

pub fn atomic_notify(&mut self, addr: u64, count: u32) -> Result<u32, Trap>

Implementation of memory.atomic.notify for all memories.

source

pub fn atomic_wait32( &mut self, addr: u64, expected: u32, deadline: Option<Instant> ) -> Result<WaitResult, Trap>

Implementation of memory.atomic.wait32 for all memories.

source

pub fn atomic_wait64( &mut self, addr: u64, expected: u64, deadline: Option<Instant> ) -> Result<WaitResult, Trap>

Implementation of memory.atomic.wait64 for all memories.

source

pub fn wasm_accessible(&self) -> Range<usize>

Returns the range of bytes that WebAssembly should be able to address in this linear memory. Note that this includes guard pages which wasm can hit.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Memory

§

impl Send for Memory

§

impl Sync for Memory

§

impl Unpin for Memory

§

impl !UnwindSafe for Memory

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.