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
.
Alloc
s are not to be created directly, but rather are created by Region
s during instance
creation.
Fields§
§heap_accessible_size: usize
§heap_inaccessible_size: usize
§slot: Option<Slot>
§region: Arc<dyn RegionInternal>
Implementations§
Source§impl Alloc
impl Alloc
Sourcepub fn addr_location(&self, addr: *const c_void) -> AddrLocation
pub fn addr_location(&self, addr: *const c_void) -> AddrLocation
Where in an Alloc
does a particular address fall?
pub fn expand_heap( &mut self, expand_bytes: u32, module: &dyn Module, ) -> Result<u32, Error>
pub fn reset_heap(&mut self, module: &dyn Module) -> Result<(), Error>
pub fn heap_len(&self) -> usize
pub fn slot(&self) -> &Slot
Sourcepub unsafe fn heap_u32_mut(&mut self) -> &mut [u32]
pub unsafe fn heap_u32_mut(&mut self) -> &mut [u32]
Return the heap as a mutable slice of 32-bit words.
Sourcepub unsafe fn heap_u64_mut(&mut self) -> &mut [u64]
pub unsafe fn heap_u64_mut(&mut self) -> &mut [u64]
Return the heap as a mutable slice of 64-bit words.
Sourcepub unsafe fn stack_mut(&mut self) -> &mut [u8] ⓘ
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.
Sourcepub unsafe fn stack_u64_mut(&mut self) -> &mut [u64]
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.
Sourcepub unsafe fn globals(&self) -> &[GlobalValue]
pub unsafe fn globals(&self) -> &[GlobalValue]
Return the globals as a slice.
Sourcepub unsafe fn globals_mut(&mut self) -> &mut [GlobalValue]
pub unsafe fn globals_mut(&mut self) -> &mut [GlobalValue]
Return the globals as a mutable slice.
Sourcepub unsafe fn sigstack_mut(&mut self) -> &mut [u8] ⓘ
pub unsafe fn sigstack_mut(&mut self) -> &mut [u8] ⓘ
Return the sigstack as a mutable byte slice.