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

Method vmctx_sync

crates/wasmtime/src/runtime/func.rs:2276–2297  ·  view source on GitHub ↗

Constructor of a host function's `VMContext` for synchronous functions. This creates a `VMArrayCallHostFuncContext` which under the hood will be viewed as `VMContext` in the eventually created `VMFuncRef`.

(
        engine: &Engine,
        ty: FuncType,
        func: F,
    )

Source from the content-addressed store, hash-verified

2274 /// This creates a `VMArrayCallHostFuncContext` which under the hood will
2275 /// be viewed as `VMContext` in the eventually created `VMFuncRef`.
2276 fn vmctx_sync<F, T>(
2277 engine: &Engine,
2278 ty: FuncType,
2279 func: F,
2280 ) -> Result<StoreBox<VMArrayCallHostFuncContext>, OutOfMemory>
2281 where
2282 F: Fn(Caller<'_, T>, &mut [MaybeUninit<ValRaw>]) -> Result<()> + Send + Sync + 'static,
2283 T: 'static,
2284 {
2285 assert!(ty.comes_from_same_engine(engine));
2286
2287 unsafe {
2288 VMArrayCallHostFuncContext::new(
2289 Self::array_call_trampoline::<T, F>,
2290 ty.type_index(),
2291 try_new::<Box<_>>(HostFuncState {
2292 func,
2293 _ty: ty.into_registered_type(),
2294 })?,
2295 )
2296 }
2297 }
2298
2299 /// Constructor of a host function's `VMContext` for asynchronous functions.
2300 ///

Callers

nothing calls this directly

Calls 3

into_registered_typeMethod · 0.80
newFunction · 0.50
type_indexMethod · 0.45

Tested by

no test coverage detected