MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wasm_to_array_trampoline

Method wasm_to_array_trampoline

crates/wasmtime/src/runtime/module.rs:1132–1166  ·  view source on GitHub ↗

Return the address, in memory, of the trampoline that allows Wasm to call a array function of the given signature. Note that unlike all other code-pointer-returning functions, this *can* be present on `Module` (without a `StoreCode`) because we can execute the `EngineCode` for trampolines that leave the store to call the host.

(
        &self,
        signature: VMSharedTypeIndex,
    )

Source from the content-addressed store, hash-verified

1130 /// because we can execute the `EngineCode` for trampolines that
1131 /// leave the store to call the host.
1132 pub(crate) fn wasm_to_array_trampoline(
1133 &self,
1134 signature: VMSharedTypeIndex,
1135 ) -> Option<NonNull<VMWasmCallFunction>> {
1136 log::trace!("Looking up trampoline for {signature:?}");
1137 let trampoline_shared_ty = self.inner.engine.signatures().trampoline_type(signature);
1138 let trampoline_module_ty = self
1139 .inner
1140 .code
1141 .signatures()
1142 .trampoline_type(trampoline_shared_ty)?;
1143 debug_assert!(
1144 self.inner
1145 .engine
1146 .signatures()
1147 .borrow(
1148 self.inner
1149 .code
1150 .signatures()
1151 .shared_type(trampoline_module_ty)
1152 .unwrap()
1153 )
1154 .unwrap()
1155 .unwrap_func()
1156 .is_trampoline_type()
1157 );
1158
1159 let ptr = self
1160 .compiled_module()
1161 .wasm_to_array_trampoline(trampoline_module_ty)
1162 .as_ptr()
1163 .cast::<VMWasmCallFunction>()
1164 .cast_mut();
1165 Some(NonNull::new(ptr).unwrap())
1166 }
1167
1168 pub(crate) fn memory_images(&self) -> Result<Option<&ModuleMemoryImages>> {
1169 let images = self

Callers 1

newMethod · 0.45

Calls 6

compiled_moduleMethod · 0.80
newFunction · 0.50
trampoline_typeMethod · 0.45
signaturesMethod · 0.45
as_ptrMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected