Skip to main content

HeapHeader

Struct HeapHeader 

Source
#[repr(C)]
pub struct HeapHeader { pub refcount: AtomicU32, pub kind: u16, pub flags: u8, pub _pad: u8, }
Expand description

8-byte header for all v2 heap-allocated objects. Refcount at offset 0 for fastest access.

Fields§

§refcount: AtomicU32

Atomic reference count (offset 0, 4 bytes).

§kind: u16

Object kind for GC/debug/serialization (offset 4, 2 bytes). Never used for hot-path type dispatch — compiled code knows the concrete type.

§flags: u8

Bitfield flags: FLAG_MARKED, FLAG_PINNED, FLAG_READONLY (offset 6, 1 byte).

§_pad: u8

Padding to 8 bytes (offset 7, 1 byte).

Implementations§

Source§

impl HeapHeader

Source

pub const OFFSET_REFCOUNT: usize = 0

Byte offset constants for JIT codegen.

Source

pub const OFFSET_KIND: usize = 4

Source

pub const OFFSET_FLAGS: usize = 6

Source

pub fn new(kind: u16) -> Self

Create a new HeapHeader with the given kind, refcount initialized to 1.

Source

pub fn kind(&self) -> u16

Get the kind field.

Source

pub fn flags(&self) -> u8

Get the flags field.

Source

pub fn has_flag(&self, flag: u8) -> bool

Check if a flag is set.

Source

pub fn set_flag(&mut self, flag: u8)

Set a flag.

Source

pub fn clear_flag(&mut self, flag: u8)

Clear a flag.

Source

pub fn retain(&self)

Increment the reference count.

Source

pub fn release(&self) -> bool

Decrement the reference count. Returns true if the count reached zero (caller must deallocate).

Source

pub fn get_refcount(&self) -> u32

Get the current reference count (for debugging/testing).

Trait Implementations§

Source§

impl Debug for HeapHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,