Struct wasmtime_runtime::GcStore
source · pub struct GcStore {
pub allocation_index: GcHeapAllocationIndex,
pub gc_heap: Box<dyn GcHeap>,
pub host_data_table: ExternRefHostDataTable,
}
Expand description
GC-related data that is one-to-one with a wasmtime::Store
.
Contains everything we need to do collections, invoke barriers, etc…
In general, exposes a very similar interface to GcHeap
, but fills in some
of the context arguments for callers (such as the ExternRefHostDataTable
)
since they are all stored together inside GcStore
.
Fields§
§allocation_index: GcHeapAllocationIndex
This GC heap’s allocation index (primarily used for integrating with the pooling allocator).
gc_heap: Box<dyn GcHeap>
The actual GC heap.
host_data_table: ExternRefHostDataTable
The externref
host data table for this GC heap.
Implementations§
source§impl GcStore
impl GcStore
sourcepub fn new(
allocation_index: GcHeapAllocationIndex,
gc_heap: Box<dyn GcHeap>
) -> Self
pub fn new( allocation_index: GcHeapAllocationIndex, gc_heap: Box<dyn GcHeap> ) -> Self
Create a new GcStore
.
sourcepub fn gc(&mut self, roots: GcRootsIter<'_>)
pub fn gc(&mut self, roots: GcRootsIter<'_>)
Perform garbage collection within this heap.
sourcepub fn clone_gc_ref(&mut self, gc_ref: &VMGcRef) -> VMGcRef
pub fn clone_gc_ref(&mut self, gc_ref: &VMGcRef) -> VMGcRef
Clone a GC reference, calling GC write barriers as necessary.
sourcepub fn write_gc_ref(
&mut self,
destination: &mut Option<VMGcRef>,
source: Option<&VMGcRef>
)
pub fn write_gc_ref( &mut self, destination: &mut Option<VMGcRef>, source: Option<&VMGcRef> )
Write the source
GC reference into the destination
slot, performing
write barriers as necessary.
sourcepub fn drop_gc_ref(&mut self, gc_ref: VMGcRef)
pub fn drop_gc_ref(&mut self, gc_ref: VMGcRef)
Drop the given GC reference, performing drop barriers as necessary.
sourcepub fn expose_gc_ref_to_wasm(&mut self, gc_ref: VMGcRef)
pub fn expose_gc_ref_to_wasm(&mut self, gc_ref: VMGcRef)
Hook to call whenever a GC reference is about to be exposed to Wasm.
sourcepub fn alloc_externref(
&mut self,
value: Box<dyn Any + Send + Sync>
) -> Result<Result<VMExternRef, Box<dyn Any + Send + Sync>>>
pub fn alloc_externref( &mut self, value: Box<dyn Any + Send + Sync> ) -> Result<Result<VMExternRef, Box<dyn Any + Send + Sync>>>
Allocate a new externref
.
Returns:
-
Ok(Ok(_))
: Successfully allocated theexternref
. -
Ok(Err(value))
: Failed to allocate theexternref
, but doing a GC and then trying again may succeed. Returns the givenvalue
as the error payload. -
Err(_)
: Unrecoverable allocation failure.
sourcepub fn externref_host_data(
&self,
externref: &VMExternRef
) -> &(dyn Any + Send + Sync)
pub fn externref_host_data( &self, externref: &VMExternRef ) -> &(dyn Any + Send + Sync)
Get a shared borrow of the given externref
’s host data.
Passing invalid VMExternRef
s (eg garbage values or externref
s
associated with a different heap is memory safe but will lead to general
incorrectness such as panics and wrong results.
sourcepub fn externref_host_data_mut(
&mut self,
externref: &VMExternRef
) -> &mut (dyn Any + Send + Sync)
pub fn externref_host_data_mut( &mut self, externref: &VMExternRef ) -> &mut (dyn Any + Send + Sync)
Get a mutable borrow of the given externref
’s host data.
Passing invalid VMExternRef
s (eg garbage values or externref
s
associated with a different heap is memory safe but will lead to general
incorrectness such as panics and wrong results.