Struct 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

Source

pub fn new( allocation_index: GcHeapAllocationIndex, gc_heap: Box<dyn GcHeap>, ) -> Self

Create a new GcStore.

Source

pub fn gc(&mut self, roots: GcRootsIter<'_>)

Perform garbage collection within this heap.

Source

pub fn clone_gc_ref(&mut self, gc_ref: &VMGcRef) -> VMGcRef

Clone a GC reference, calling GC write barriers as necessary.

Source

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.

Source

pub fn drop_gc_ref(&mut self, gc_ref: VMGcRef)

Drop the given GC reference, performing drop barriers as necessary.

Source

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.

Source

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 the externref.

  • Ok(Err(value)): Failed to allocate the externref, but doing a GC and then trying again may succeed. Returns the given value as the error payload.

  • Err(_): Unrecoverable allocation failure.

Source

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 VMExternRefs (eg garbage values or externrefs associated with a different heap is memory safe but will lead to general incorrectness such as panics and wrong results.

Source

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 VMExternRefs (eg garbage values or externrefs associated with a different heap is memory safe but will lead to general incorrectness such as panics and wrong results.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.