Struct Alloc

Source
pub struct Alloc {
    pub heap_accessible_size: usize,
    pub heap_inaccessible_size: usize,
    pub slot: Option<Slot>,
    pub region: Arc<dyn RegionInternal>,
}
Expand description

The structure that manages the allocations backing an Instance.

Allocs are not to be created directly, but rather are created by Regions during instance creation.

Fields§

§heap_accessible_size: usize§heap_inaccessible_size: usize§slot: Option<Slot>§region: Arc<dyn RegionInternal>

Implementations§

Source§

impl Alloc

Source

pub fn addr_location(&self, addr: *const c_void) -> AddrLocation

Where in an Alloc does a particular address fall?

Source

pub fn expand_heap( &mut self, expand_bytes: u32, module: &dyn Module, ) -> Result<u32, Error>

Source

pub fn reset_heap(&mut self, module: &dyn Module) -> Result<(), Error>

Source

pub fn heap_len(&self) -> usize

Source

pub fn slot(&self) -> &Slot

Source

pub unsafe fn heap(&self) -> &[u8]

Return the heap as a byte slice.

Source

pub unsafe fn heap_mut(&mut self) -> &mut [u8]

Return the heap as a mutable byte slice.

Source

pub unsafe fn heap_u32(&self) -> &[u32]

Return the heap as a slice of 32-bit words.

Source

pub unsafe fn heap_u32_mut(&mut self) -> &mut [u32]

Return the heap as a mutable slice of 32-bit words.

Source

pub unsafe fn heap_u64(&self) -> &[u64]

Return the heap as a slice of 64-bit words.

Source

pub unsafe fn heap_u64_mut(&mut self) -> &mut [u64]

Return the heap as a mutable slice of 64-bit words.

Source

pub unsafe fn stack_mut(&mut self) -> &mut [u8]

Return the stack as a mutable byte slice.

Since the stack grows down, alloc.stack_mut()[0] is the top of the stack, and alloc.stack_mut()[alloc.limits.stack_size - 1] is the last byte at the bottom of the stack.

Source

pub unsafe fn stack_u64_mut(&mut self) -> &mut [u64]

Return the stack as a mutable slice of 64-bit words.

Since the stack grows down, alloc.stack_mut()[0] is the top of the stack, and alloc.stack_mut()[alloc.limits.stack_size - 1] is the last word at the bottom of the stack.

Source

pub unsafe fn globals(&self) -> &[GlobalValue]

Return the globals as a slice.

Source

pub unsafe fn globals_mut(&mut self) -> &mut [GlobalValue]

Return the globals as a mutable slice.

Source

pub unsafe fn sigstack_mut(&mut self) -> &mut [u8]

Return the sigstack as a mutable byte slice.

Source

pub fn mem_in_heap<T>(&self, ptr: *const T, len: usize) -> bool

Trait Implementations§

Source§

impl Drop for Alloc

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Alloc

§

impl !RefUnwindSafe for Alloc

§

impl Send for Alloc

§

impl Sync for Alloc

§

impl Unpin for Alloc

§

impl !UnwindSafe for Alloc

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.