#[repr(C)]
pub struct VMExternRefActivationsTable { /* private fields */ }
Expand description

A table that over-approximizes the set of VMExternRefs that any Wasm activation on this thread is currently using.

Under the covers, this is a simple bump allocator that allows duplicate entries. Deduplication happens at GC time.

Implementations

Create a new VMExternRefActivationsTable.

Try and insert a VMExternRef into this table.

This is a fast path that only succeeds when the bump chunk has the capacity for the requested insertion.

If the insertion fails, then the VMExternRef is given back. Callers may attempt a GC to free up space and try again, or may call insert_slow_path to infallibly insert the reference (potentially allocating additional space in the table to hold it).

Insert a reference into the table, falling back on a GC to clear up space if the table is already full.

Unsafety

The same as gc.

Set the stack canary around a call into Wasm.

The return value should not be dropped until after the Wasm call has returned.

While this method is always safe to call (or not call), it is unsafe to call the wasmtime_runtime::gc function unless this method is called at the proper times and its return value properly outlives its Wasm call.

For gc to be safe, this is only strictly required to surround the oldest host–>Wasm stack frame transition on this thread, but repeatedly calling it is idempotent and cheap, so it is recommended to call this for every host–>Wasm call.

Example
use wasmtime_runtime::*;

let table: &VMExternRefActivationsTable = get_table_from_somewhere();

// Set the canary before a Wasm call. The canary should always be a
// local on the stack.
let canary = 0;
let auto_reset_canary = table.set_stack_canary(&canary);

// Do the call into Wasm.
call_into_wasm();

// Only drop the value returned by `set_stack_canary` after the Wasm
// call has returned.
drop(auto_reset_canary);

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.