Trait wasmtime_runtime::Store
source · pub unsafe trait Store {
// Required methods
fn vmruntime_limits(&self) -> *mut VMRuntimeLimits;
fn epoch_ptr(&self) -> *const AtomicU64;
fn externref_activations_table(
&mut self
) -> (&mut VMExternRefActivationsTable, &dyn ModuleInfoLookup);
fn memory_growing(
&mut self,
current: usize,
desired: usize,
maximum: Option<usize>
) -> Result<bool, Error>;
fn memory_grow_failed(&mut self, error: &Error);
fn table_growing(
&mut self,
current: u32,
desired: u32,
maximum: Option<u32>
) -> Result<bool, Error>;
fn table_grow_failed(&mut self, error: &Error);
fn out_of_gas(&mut self) -> Result<(), Error>;
fn new_epoch(&mut self) -> Result<u64, Error>;
}
Expand description
Dynamic runtime functionality needed by this crate throughout the execution of a wasm instance.
This trait is used to store a raw pointer trait object within each
VMContext
. This raw pointer trait object points back to the
wasmtime::Store
internally but is type-erased so this wasmtime_runtime
crate doesn’t need the entire wasmtime
crate to build.
Note that this is an extra-unsafe trait because no heed is paid to the
lifetime of this store or the Send/Sync-ness of this store. All of that must
be respected by embedders (e.g. the wasmtime::Store
structure). The theory
is that wasmtime::Store
handles all this correctly.
Required Methods§
sourcefn vmruntime_limits(&self) -> *mut VMRuntimeLimits
fn vmruntime_limits(&self) -> *mut VMRuntimeLimits
Returns the raw pointer in memory where this store’s shared
VMRuntimeLimits
structure is located.
Used to configure VMContext
initialization and store the right pointer
in the VMContext
.
sourcefn epoch_ptr(&self) -> *const AtomicU64
fn epoch_ptr(&self) -> *const AtomicU64
Returns a pointer to the global epoch counter.
Used to configure the VMContext
on initialization.
sourcefn externref_activations_table(
&mut self
) -> (&mut VMExternRefActivationsTable, &dyn ModuleInfoLookup)
fn externref_activations_table( &mut self ) -> (&mut VMExternRefActivationsTable, &dyn ModuleInfoLookup)
Returns the externref management structures necessary for this store.
The first element returned is the table in which externrefs are stored throughout wasm execution, and the second element is how to look up module information for gc requests.
sourcefn memory_growing(
&mut self,
current: usize,
desired: usize,
maximum: Option<usize>
) -> Result<bool, Error>
fn memory_growing( &mut self, current: usize, desired: usize, maximum: Option<usize> ) -> Result<bool, Error>
Callback invoked to allow the store’s resource limiter to reject a memory grow operation.
sourcefn memory_grow_failed(&mut self, error: &Error)
fn memory_grow_failed(&mut self, error: &Error)
Callback invoked to notify the store’s resource limiter that a memory grow operation has failed.
sourcefn table_growing(
&mut self,
current: u32,
desired: u32,
maximum: Option<u32>
) -> Result<bool, Error>
fn table_growing( &mut self, current: u32, desired: u32, maximum: Option<u32> ) -> Result<bool, Error>
Callback invoked to allow the store’s resource limiter to reject a table grow operation.
sourcefn table_grow_failed(&mut self, error: &Error)
fn table_grow_failed(&mut self, error: &Error)
Callback invoked to notify the store’s resource limiter that a table grow operation has failed.
sourcefn out_of_gas(&mut self) -> Result<(), Error>
fn out_of_gas(&mut self) -> Result<(), Error>
Callback invoked whenever fuel runs out by a wasm instance. If an error is returned that’s raised as a trap. Otherwise wasm execution will continue as normal.