Skip to main content

Module heap_header

Module heap_header 

Source
Expand description

Unified heap object header (v2 runtime spec).

HeapHeader is a #[repr(C)] 8-byte struct that prefixes every heap-allocated object, giving the JIT a stable memory layout to read kind/flags and perform atomic reference counting without depending on Rust’s enum discriminant layout.

§Memory layout (8 bytes)

Offset  Size  Field
------  ----  -----
  0       4   refcount (AtomicU32)
  4       2   kind (HeapKind as u16)
  6       1   flags (bitfield: MARKED, PINNED, READONLY, etc.)
  7       1   _pad (reserved, always 0)

Data starts at offset 8 (DATA_OFFSET).

Clone = atomic_fetch_add([ptr+0], 1, Relaxed). Drop = atomic_fetch_sub([ptr+0], 1, Release).

Structs§

HeapHeader
Fixed-layout header for heap-allocated objects (v2 runtime spec).

Constants§

DATA_OFFSET
Byte offset from the start of a heap allocation where payload data begins (immediately after the 8-byte HeapHeader).
FLAG_MARKED
Flag: object has been marked by the GC during a collection cycle.
FLAG_PINNED
Flag: object is pinned and must not be relocated by the GC.
FLAG_READONLY
Flag: object is read-only (immutable after construction).