Trait wasmtime_runtime::Store
source · pub unsafe trait Store {
// Required methods
fn vmruntime_limits(&self) -> *mut VMRuntimeLimits;
fn epoch_ptr(&self) -> *const AtomicU64;
fn maybe_gc_store(&mut self) -> Option<&mut GcStore>;
fn memory_growing(
&mut self,
current: usize,
desired: usize,
maximum: Option<usize>
) -> Result<bool, Error>;
fn memory_grow_failed(&mut self, error: Error) -> Result<()>;
fn table_growing(
&mut self,
current: u32,
desired: u32,
maximum: Option<u32>
) -> Result<bool, Error>;
fn table_grow_failed(&mut self, error: Error) -> Result<()>;
fn out_of_gas(&mut self) -> Result<(), Error>;
fn new_epoch(&mut self) -> Result<u64, Error>;
fn gc(&mut self, root: Option<VMGcRef>) -> Result<Option<VMGcRef>>;
// Provided method
fn gc_store(&mut self) -> &mut GcStore { ... }
}
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 maybe_gc_store(&mut self) -> Option<&mut GcStore>
fn maybe_gc_store(&mut self) -> Option<&mut GcStore>
Get this store’s GC heap, if it has been allocated.
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) -> Result<()>
fn memory_grow_failed(&mut self, error: Error) -> Result<()>
Callback invoked to notify the store’s resource limiter that a memory grow operation has failed.
Note that this is not invoked if memory_growing
returns an error.
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) -> Result<()>
fn table_grow_failed(&mut self, error: Error) -> Result<()>
Callback invoked to notify the store’s resource limiter that a table grow operation has failed.
Note that this is not invoked if table_growing
returns an error.
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.
sourcefn new_epoch(&mut self) -> Result<u64, Error>
fn new_epoch(&mut self) -> Result<u64, Error>
Callback invoked whenever an instance observes a new epoch number. Cannot fail; cooperative epoch-based yielding is completely semantically transparent. Returns the new deadline.
sourcefn gc(&mut self, root: Option<VMGcRef>) -> Result<Option<VMGcRef>>
fn gc(&mut self, root: Option<VMGcRef>) -> Result<Option<VMGcRef>>
Callback invoked whenever an instance needs to trigger a GC.
Optionally given a GC reference that is rooted for the collection, and then whose updated GC reference is returned.
Cooperative, async-yielding (if configured) is completely transparent.
If the async GC was cancelled, returns an error. This should be raised as a trap to clean up Wasm execution.