Skip to main content

Crate shape_gc

Crate shape_gc 

Source
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.
GcHeapStats
Collection statistics.
SweepStats
Statistics from a sweep phase.

Enums§

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