#[repr(u32)]pub enum VMGcKind {
ExternRef = 1_073_741_824,
AnyRef = 2_147_483_648,
EqRef = 2_684_354_560,
ArrayRef = 2_818_572_288,
StructRef = 2_952_790_016,
}
Expand description
The kind of an object in a GC heap.
Note that this type is accessed from Wasm JIT code.
VMGcKind
is a bitset where to test if a
is a subtype of an
“abstract-ish” type b
, we can simply use a single bitwise-and operation:
a <: b iff a & b == b
For example, because VMGcKind::AnyRef
has the high bit set, every kind
representing some subtype of anyref
also has its high bit set.
We say “abstract-ish” type because in addition to the abstract heap types
(other than i31
) we also have variants for externref
s that have been
converted into an anyref
via extern.convert_any
and externref
s that
have been converted into an anyref
via any.convert_extern
. Note that in
the latter case, because any.convert_extern $foo
produces a value that is
not an instance of eqref
, VMGcKind::AnyOfExternRef & VMGcKind::EqRef != VMGcKind::EqRef
.
Furthermore, this type only uses the highest 6 bits of its u32
representation, allowing the lower 27 bytes to be bitpacked with other stuff
as users see fit.
Variants§
ExternRef = 1_073_741_824
AnyRef = 2_147_483_648
EqRef = 2_684_354_560
ArrayRef = 2_818_572_288
StructRef = 2_952_790_016
Implementations§
Source§impl VMGcKind
impl VMGcKind
Sourcepub const MASK: u32 = 4_160_749_568u32
pub const MASK: u32 = 4_160_749_568u32
Mask this value with a u32
to get just the bits that VMGcKind
uses.
Sourcepub const UNUSED_MASK: u32 = 134_217_727u32
pub const UNUSED_MASK: u32 = 134_217_727u32
Mask this value with a u32
that potentially contains a VMGcKind
to
get the bits that VMGcKind
doesn’t use.
Sourcepub fn value_fits_in_unused_bits(value: u32) -> bool
pub fn value_fits_in_unused_bits(value: u32) -> bool
Does the given value fit in the unused bits of a VMGcKind
?
Sourcepub fn from_high_bits_of_u32(val: u32) -> VMGcKind
pub fn from_high_bits_of_u32(val: u32) -> VMGcKind
Convert the given value into a VMGcKind
by masking off the unused
bottom bits.
Trait Implementations§
impl Copy for VMGcKind
impl Eq for VMGcKind
impl StructuralPartialEq for VMGcKind
Auto Trait Implementations§
impl Freeze for VMGcKind
impl RefUnwindSafe for VMGcKind
impl Send for VMGcKind
impl Sync for VMGcKind
impl Unpin for VMGcKind
impl UnwindSafe for VMGcKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.