Struct wasmtime_runtime::VMOpaqueContext
source · pub struct VMOpaqueContext { /* private fields */ }
Expand description
An “opaque” version of VMContext
which must be explicitly casted to a
target context.
This context is used to represent that contexts specified in
VMFuncRef
can have any type and don’t have an implicit
structure. Neither wasmtime nor cranelift-generated code can rely on the
structure of an opaque context in general and only the code which configured
the context is able to rely on a particular structure. This is because the
context pointer configured for VMFuncRef
is guaranteed to be
the first parameter passed.
Note that Wasmtime currently has a layout where all contexts that are casted to an opaque context start with a 32-bit “magic” which can be used in debug mode to debug-assert that the casts here are correct and have at least a little protection against incorrect casts.
Implementations§
source§impl VMOpaqueContext
impl VMOpaqueContext
sourcepub fn from_vmcontext(ptr: *mut VMContext) -> *mut VMOpaqueContext
pub fn from_vmcontext(ptr: *mut VMContext) -> *mut VMOpaqueContext
Helper function to clearly indicate that casts are desired.
sourcepub fn from_vm_array_call_host_func_context(
ptr: *mut VMArrayCallHostFuncContext
) -> *mut VMOpaqueContext
pub fn from_vm_array_call_host_func_context( ptr: *mut VMArrayCallHostFuncContext ) -> *mut VMOpaqueContext
Helper function to clearly indicate that casts are desired.
sourcepub fn from_vm_native_call_host_func_context(
ptr: *mut VMNativeCallHostFuncContext
) -> *mut VMOpaqueContext
pub fn from_vm_native_call_host_func_context( ptr: *mut VMNativeCallHostFuncContext ) -> *mut VMOpaqueContext
Helper function to clearly indicate that casts are desired.