#[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: AtomicU32Atomic reference count (offset 0, 4 bytes).
kind: u16Object kind for GC/debug/serialization (offset 4, 2 bytes). Never used for hot-path type dispatch — compiled code knows the concrete type.
flags: u8Bitfield flags: FLAG_MARKED, FLAG_PINNED, FLAG_READONLY (offset 6, 1 byte).
_pad: u8Padding to 8 bytes (offset 7, 1 byte).
Implementations§
Source§impl HeapHeader
impl HeapHeader
Sourcepub const OFFSET_REFCOUNT: usize = 0
pub const OFFSET_REFCOUNT: usize = 0
Byte offset constants for JIT codegen.
pub const OFFSET_KIND: usize = 4
pub const OFFSET_FLAGS: usize = 6
Sourcepub fn new(kind: u16) -> Self
pub fn new(kind: u16) -> Self
Create a new HeapHeader with the given kind, refcount initialized to 1.
Sourcepub fn clear_flag(&mut self, flag: u8)
pub fn clear_flag(&mut self, flag: u8)
Clear a flag.
Sourcepub fn release(&self) -> bool
pub fn release(&self) -> bool
Decrement the reference count. Returns true if the count reached zero
(caller must deallocate).
Sourcepub fn get_refcount(&self) -> u32
pub fn get_refcount(&self) -> u32
Get the current reference count (for debugging/testing).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HeapHeader
impl RefUnwindSafe for HeapHeader
impl Send for HeapHeader
impl Sync for HeapHeader
impl Unpin for HeapHeader
impl UnsafeUnpin for HeapHeader
impl UnwindSafe for HeapHeader
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
Mutably borrows from an owned value. Read more