Struct wasmtime_runtime::VMGcHeader

source ·
pub struct VMGcHeader(/* private fields */);
Expand description

The common header for all objects allocated in a GC heap.

This header is shared across all collectors, although particular collectors may always add their own trailing fields to this header for all of their own GC objects.

This is a bit-packed structure that logically has the following fields:

struct VMGcHeader {
    // Highest 2 bits.
    kind: VMGcKind,

    // 30 bits available for the `GcRuntime` to make use of however it sees fit.
    reserved: u30,

    // The `VMSharedTypeIndex` for this GC object, if it isn't an
    // `externref` (or an `externref` re-wrapped as an `anyref`). `None` is
    // represented with `VMSharedTypeIndex::default()`.
    ty: Option<VMSharedTypeIndex>,
}

Implementations§

source§

impl VMGcHeader

source

pub fn externref() -> Self

Create the header for an externref.

source

pub fn kind(&self) -> VMGcKind

Get the kind of GC object that this is.

source

pub fn reserved_u30(&self) -> u32

Get the reserved 30 bits in this header.

These are bits are reserved for GcRuntime implementations to make use of however they see fit.

source

pub fn set_reserved_u30(&mut self, value: u32)

Set the 30-bit reserved value.

§Panics

Panics if the given value has any of the upper 2 bits set.

source

pub unsafe fn unchecked_set_reserved_u30(&mut self, value: u32)

Set the 30-bit reserved value.

§Safety

The given value must only use the lower 30 bits; its upper 2 bits must be unset.

source

pub fn ty(&self) -> Option<VMSharedTypeIndex>

Get this object’s specific concrete type.

Trait Implementations§

source§

impl GcHeapObject for VMGcHeader

source§

fn is(_: &VMGcHeader) -> bool

Check whether the GC object with the given header is an instance of Self.

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>,

§

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>,

§

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.