Skip to main content

Module heap_header

Module heap_header 

Source
Expand description

8-byte heap header for all v2 heap-allocated objects.

§Memory layout (8 bytes)

Offset  Size  Field
------  ----  -----
  0       4   refcount (AtomicU32)
  4       2   kind (u16 — GC/debug/serialization, never hot-path dispatch)
  6       1   flags (bitfield)
  7       1   _pad

Refcount is at offset 0 for fastest access — single-cycle load from base pointer. Compiled code never reads kind; it knows the concrete type at compile time.

Structs§

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

Constants§

FLAG_MARKED
FLAG_PINNED
FLAG_READONLY
HEAP_KIND_V2_CLOSURE
Closure-spec Phase F: escape-fallback TypedClosureHeader allocation kind. A MakeClosureHeap opcode allocates a TypedClosureHeader-shaped block with this kind; Drop glue walks the closure’s heap_capture_mask and releases each pointer capture. See docs/v2-closure-specialization.md §1.3 and §5.3 for the full ABI.
HEAP_KIND_V2_DECIMAL
R20 S2-prime-production: v2-raw DecimalObj carrier kind. The 24-byte #[repr(C)] struct (HeapHeader at offset 0 + inline rust_decimal::Decimal at offset 8) lives in decimal_obj.rs. Per ADR-006 §2.7.24 Q25.A SUPERSEDED
HEAP_KIND_V2_STRING
HEAP_KIND_V2_STRUCT
HEAP_KIND_V2_TRAIT_OBJECT
Wave 2 Agent E (2026-05-14): v2-raw TraitObjectStorage carrier kind. TraitObjectStorage grows a HeapHeader at offset 0 (per ADR-006 §Q25.C.5 amendment and audit §4.3 Obstacle O-3.a resolution). The struct is #[repr(C)]; allocation goes through TraitObjectStorage::_new which returns *mut TraitObjectStorage with the header initialized via HeapHeader::new(HEAP_KIND_V2_TRAIT_OBJECT). Refcount discipline on the raw-pointer path goes through v2_retain / v2_release per the HeapElement trait. The NativeKind::Ptr(HeapKind::TraitObject) label is unchanged at the slot ABI. The struct continues to carry an inner Arc<TypedObjectStorage> value half + Arc<VTable> vtable half during Wave 2 Round 2 transition; D2’s parallel close evaporates the inner Arc<TypedObjectStorage> wrapping. Next free post-HEAP_KIND_V2_TYPED_OBJECT=86.
HEAP_KIND_V2_TYPED_ARRAY
HEAP_KIND_V2_TYPED_MAP
HEAP_KIND_V2_TYPED_OBJECT
Wave 2 Agent D1 (2026-05-14): v2-raw TypedObjectStorage carrier kind. TypedObjectStorage grows a HeapHeader at offset 0 (per ADR-006 §2.3 amendment and audit §4.3 Obstacle O-3.a resolution). The struct is #[repr(C)]; allocation goes through TypedObjectStorage::_new which returns *mut TypedObjectStorage with the header initialized via HeapHeader::new(HEAP_KIND_V2_TYPED_OBJECT). Refcount discipline on the raw-pointer path goes through v2_retain / v2_release per the HeapElement trait. The NativeKind::Ptr(HeapKind::TypedObject) label is unchanged at the slot ABI. Next free post-HEAP_KIND_V2_DECIMAL=85.