Skip to main content

Module heap_header

Module heap_header 

Source
Expand description

Fixed-layout heap object header for JIT-friendly type dispatch.

HeapHeader is a #[repr(C, align(16))] struct that prefixes heap-allocated objects, giving the JIT a stable memory layout to read the object’s kind, length, and capacity without depending on Rust’s enum discriminant layout.

§Memory layout (32 bytes, 16-byte aligned)

Offset  Size  Field
------  ----  -----
  0       2   kind (HeapKind as u16)
  2       1   elem_type (element type hint for arrays/typed objects)
  3       1   flags (bitfield: MARKED, PINNED, READONLY, etc.)
  4       4   len (element count / field count)
  8       4   cap (allocated capacity, 0 if not applicable)
 12       4   (padding)
 16       8   aux (auxiliary data: schema_id, function_id, etc.)
 24       8   (reserved / future use)

Modules§

elem_types
Element type hints for the elem_type field.

Structs§

HeapHeader
Fixed-layout header for heap-allocated objects.

Constants§

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).