Struct wasmtime_runtime::InstanceAllocationRequest [−][src]
pub struct InstanceAllocationRequest<'a> {
pub module: Arc<Module>,
pub image_base: usize,
pub functions: &'a PrimaryMap<DefinedFuncIndex, FunctionInfo>,
pub imports: Imports<'a>,
pub shared_signatures: SharedSignatures<'a>,
pub host_state: Box<dyn Any + Send + Sync>,
pub store: Option<*mut dyn Store>,
pub wasm_data: *const [u8],
}
Expand description
Represents a request for a new runtime instance.
Fields
module: Arc<Module>
The module being instantiated.
image_base: usize
The base address of where JIT functions are located.
functions: &'a PrimaryMap<DefinedFuncIndex, FunctionInfo>
Descriptors about each compiled function, such as the offset from
image_base
.
imports: Imports<'a>
The imports to use for the instantiation.
Translation from SignatureIndex
to VMSharedSignatureIndex
host_state: Box<dyn Any + Send + Sync>
The host state to associate with the instance.
store: Option<*mut dyn Store>
A pointer to the “store” for this instance to be allocated. The store
correlates with the Store
in wasmtime itself, and lots of contextual
information about the execution of wasm can be learned through the store.
Note that this is a raw pointer and has a static lifetime, both of which are a bit of a lie. This is done purely so a store can learn about itself when it gets called as a host function, and additionally so this runtime can access internals as necessary (such as the VMExternRefActivationsTable or the ResourceLimiter).
Note that this ends up being a self-pointer to the instance when stored.
The reason is that the instance itself is then stored within the store.
We use a number of PhantomPinned
declarations to indicate this to the
compiler. More info on this in wasmtime/src/store.rs
wasm_data: *const [u8]
A list of all wasm data that can be referenced by the module that
will be allocated. The Module
given here has active/passive data
segments that are specified as relative indices into this list of bytes.
Note that this is an unsafe pointer. The pointer is expected to live for the entire duration of the instance at this time. It’s the responsibility of the callee when allocating to ensure that this data outlives the instance.