#[repr(C, align(16))]
pub struct VMContext { pub _marker: PhantomPinned, }
Expand description

The VM “context”, which is pointed to by the vmctx arg in Cranelift. This has information about globals, memories, tables, and other runtime state associated with the current instance.

The struct here is empty, as the sizes of these fields are dynamic, and we can’t describe them in Rust’s type system. Sufficient memory is allocated at runtime.

Fields

_marker: PhantomPinned

There’s some more discussion about this within wasmtime/src/lib.rs but the idea is that we want to tell the compiler that this contains pointers which transitively refers to itself, to suppress some optimizations that might otherwise assume this doesn’t exist.

The self-referential pointer we care about is the *mut Store pointer early on in this context, which if you follow through enough levels of nesting, eventually can refer back to this VMContext

Implementations

Helper function to cast between context types using a debug assertion to protect against some mistakes.

Return a reference to the host state associated with this Instance.

Safety

This is unsafe because it doesn’t work on just any VMContext, it must be a VMContext allocated as part of an Instance.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.