[][src]Struct wasmtime_runtime::VMExternRefActivationsTable

#[repr(C)]pub struct VMExternRefActivationsTable { /* fields omitted */ }

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

impl VMExternRefActivationsTable[src]

pub fn new() -> Self[src]

Create a new VMExternRefActivationsTable.

pub fn try_insert(&self, externref: VMExternRef) -> Result<(), VMExternRef>[src]

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).

pub unsafe fn insert_with_gc(
    &self,
    externref: VMExternRef,
    stack_maps_registry: &StackMapRegistry
)
[src]

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.

pub fn set_stack_canary<'a>(&'a self, canary: &u8) -> impl Drop + 'a[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.