#[repr(C)]pub struct VMExternRefActivationsTable { /* private fields */ }
Expand description
A table that over-approximizes the set of VMExternRef
s 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
sourceimpl VMExternRefActivationsTable
impl VMExternRefActivationsTable
sourcepub fn try_insert(&self, externref: VMExternRef) -> Result<(), VMExternRef>
pub fn try_insert(&self, externref: VMExternRef) -> Result<(), VMExternRef>
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).
sourcepub unsafe fn insert_with_gc(
&self,
externref: VMExternRef,
stack_maps_registry: &StackMapRegistry
)
pub unsafe fn insert_with_gc(
&self,
externref: VMExternRef,
stack_maps_registry: &StackMapRegistry
)
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
.
sourcepub fn set_stack_canary<'a>(&'a self, canary: &u8) -> impl Drop + 'a
pub fn set_stack_canary<'a>(&'a self, canary: &u8) -> impl Drop + 'a
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
impl !RefUnwindSafe for VMExternRefActivationsTable
impl !Send for VMExternRefActivationsTable
impl !Sync for VMExternRefActivationsTable
impl Unpin for VMExternRefActivationsTable
impl !UnwindSafe for VMExternRefActivationsTable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more