Expand description
shape-gc: Zero-pause hardware-assisted garbage collector for the Shape VM.
Replaces Arc refcounting with a concurrent mark-relocate GC using hardware pointer masking (ARM TBI / x86-64 LAM) for zero-pause collection.
§Architecture
- Bump allocation with thread-local allocation buffers (TLABs) for ~1 cycle alloc
- Tri-color marking (white/gray/black) with incremental mark steps
- Hardware pointer masking to store GC metadata in upper pointer bits
- Concurrent relocation with forwarding table + SIGSEGV trap handler
- Generational collection with card table write barriers
Modules§
- allocator
- Bump allocator with thread-local allocation buffers (TLABs).
- barrier
- SATB (Snapshot At The Beginning) write barrier for incremental marking.
- fixup
- Pointer fixup after relocation.
- generations
- Generational collection with card table write barriers.
- header
- GC object header — 8 bytes prepended to every GC-managed allocation.
- marker
- Tri-color mark phase for the GC.
- platform
- Hardware pointer masking platform detection and operations.
- ptr
- GcPtr
— typed pointer to a GC-managed object. - region
- Memory regions — 2MB mmap’d chunks for GC allocation.
- relocator
- Concurrent relocation with forwarding table.
- roots
- Root scanning infrastructure for the GC.
- safepoint
- Safepoint coordination between mutator threads and GC.
- scheduler
- Adaptive GC scheduling — decides WHEN and WHAT to collect.
- trap_
handler - SIGSEGV trap handler for concurrent relocation.
Structs§
- GcHeap
- Main GC heap — owns all regions, allocator, marker, and relocation state.
- GcHeap
Stats - Collection statistics.
- Sweep
Stats - Statistics from a sweep phase.
Enums§
- Collect
Result - Result of an incremental collection step.
Functions§
- set_
thread_ ⚠gc_ heap - Set the thread-local GC heap pointer. Called by VM before execution.
- thread_
gc_ heap - Get the thread-local GC heap, panicking if not set.