Struct wasmtime_runtime::VMMemoryDefinition
source · #[repr(C)]pub struct VMMemoryDefinition {
pub base: *mut u8,
pub current_length: AtomicUsize,
}
Expand description
The fields compiled code needs to access to utilize a WebAssembly linear memory defined within the instance, namely the start address and the size in bytes.
Fields§
§base: *mut u8
The start address.
current_length: AtomicUsize
The current logical size of this linear memory in bytes.
This is atomic because shared memories must be able to grow their length
atomically. For relaxed access, see
VMMemoryDefinition::current_length()
.
Implementations§
source§impl VMMemoryDefinition
impl VMMemoryDefinition
sourcepub fn current_length(&self) -> usize
pub fn current_length(&self) -> usize
Return the current length of the VMMemoryDefinition
by performing a
relaxed load; do not use this function for situations in which a precise
length is needed. Owned memories (i.e., non-shared) will always return a
precise result (since no concurrent modification is possible) but shared
memories may see an imprecise value–a current_length
potentially
smaller than what some other thread observes. Since Wasm memory only
grows, this under-estimation may be acceptable in certain cases.
sourcepub unsafe fn load(ptr: *mut Self) -> Self
pub unsafe fn load(ptr: *mut Self) -> Self
Return a copy of the VMMemoryDefinition
using the relaxed value of
current_length
; see VMMemoryDefinition::current_length()
.