Trait wasmtime_runtime::ModuleRuntimeInfo
source · pub trait ModuleRuntimeInfo: Send + Sync + 'static {
// Required methods
fn module(&self) -> &Arc<Module>;
fn engine_type_index(
&self,
module_index: ModuleInternedTypeIndex
) -> VMSharedTypeIndex;
fn function(&self, index: DefinedFuncIndex) -> NonNull<VMWasmCallFunction>;
fn native_to_wasm_trampoline(
&self,
index: DefinedFuncIndex
) -> Option<NonNull<VMNativeCallFunction>>;
fn array_to_wasm_trampoline(
&self,
index: DefinedFuncIndex
) -> Option<VMArrayCallFunction>;
fn wasm_to_native_trampoline(
&self,
signature: VMSharedTypeIndex
) -> Option<NonNull<VMWasmCallFunction>>;
fn memory_image(
&self,
memory: DefinedMemoryIndex
) -> Result<Option<&Arc<MemoryImage>>>;
fn unique_id(&self) -> Option<CompiledModuleId>;
fn wasm_data(&self) -> &[u8] ⓘ;
fn type_ids(&self) -> &[VMSharedTypeIndex];
fn offsets(&self) -> &VMOffsets<HostPtr>;
}
Expand description
Functionality required by this crate for a particular module. This is chiefly needed for lazy initialization of various bits of instance state.
When an instance is created, it holds an Arc<dyn ModuleRuntimeInfo>
so that it can get to signatures, metadata on functions, memory and
funcref-table images, etc. All of these things are ordinarily known
by the higher-level layers of Wasmtime. Specifically, the main
implementation of this trait is provided by
wasmtime::module::ModuleInner
. Since the runtime crate sits at
the bottom of the dependence DAG though, we don’t know or care about
that; we just need some implementor of this trait for each
allocation request.
Required Methods§
sourcefn engine_type_index(
&self,
module_index: ModuleInternedTypeIndex
) -> VMSharedTypeIndex
fn engine_type_index( &self, module_index: ModuleInternedTypeIndex ) -> VMSharedTypeIndex
Translate a module-level interned type index into an engine-level interned type index.
sourcefn function(&self, index: DefinedFuncIndex) -> NonNull<VMWasmCallFunction>
fn function(&self, index: DefinedFuncIndex) -> NonNull<VMWasmCallFunction>
Returns the address, in memory, that the function index
resides at.
sourcefn native_to_wasm_trampoline(
&self,
index: DefinedFuncIndex
) -> Option<NonNull<VMNativeCallFunction>>
fn native_to_wasm_trampoline( &self, index: DefinedFuncIndex ) -> Option<NonNull<VMNativeCallFunction>>
Returns the address, in memory, of the trampoline that allows the given defined Wasm function to be called by the native calling convention.
Returns None
for Wasm functions which do not escape, and therefore are
not callable from outside the Wasm module itself.
sourcefn array_to_wasm_trampoline(
&self,
index: DefinedFuncIndex
) -> Option<VMArrayCallFunction>
fn array_to_wasm_trampoline( &self, index: DefinedFuncIndex ) -> Option<VMArrayCallFunction>
Returns the address, in memory, of the trampoline that allows the given defined Wasm function to be called by the array calling convention.
Returns None
for Wasm functions which do not escape, and therefore are
not callable from outside the Wasm module itself.
sourcefn wasm_to_native_trampoline(
&self,
signature: VMSharedTypeIndex
) -> Option<NonNull<VMWasmCallFunction>>
fn wasm_to_native_trampoline( &self, signature: VMSharedTypeIndex ) -> Option<NonNull<VMWasmCallFunction>>
Return the address, in memory, of the trampoline that allows Wasm to call a native function of the given signature.
sourcefn memory_image(
&self,
memory: DefinedMemoryIndex
) -> Result<Option<&Arc<MemoryImage>>>
fn memory_image( &self, memory: DefinedMemoryIndex ) -> Result<Option<&Arc<MemoryImage>>>
Returns the MemoryImage
structure used for copy-on-write
initialization of the memory, if it’s applicable.
sourcefn unique_id(&self) -> Option<CompiledModuleId>
fn unique_id(&self) -> Option<CompiledModuleId>
A unique ID for this particular module. This can be used to allow for fastpaths to optimize a “re-instantiate the same module again” case.
sourcefn wasm_data(&self) -> &[u8] ⓘ
fn wasm_data(&self) -> &[u8] ⓘ
A slice pointing to all data that is referenced by this instance.
sourcefn type_ids(&self) -> &[VMSharedTypeIndex]
fn type_ids(&self) -> &[VMSharedTypeIndex]
Returns an array, indexed by ModuleInternedTypeIndex
of all
VMSharedSignatureIndex
entries corresponding to the SignatureIndex
.