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§

source

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.

source

fn epoch_ptr(&self) -> *const AtomicU64

Returns a pointer to the global epoch counter.

Used to configure the VMContext on initialization.

source

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.

source

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.

source

fn memory_grow_failed(&mut self, error: &Error)

Callback invoked to notify the store’s resource limiter that a memory grow operation has failed.

source

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.

source

fn table_grow_failed(&mut self, error: &Error)

Callback invoked to notify the store’s resource limiter that a table grow operation has failed.

source

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.

source

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.

Implementors§