ReviewOS

zig-utils/zig-gc

Expose stable cell identity across relocation

#39
Closed chris opened this 9 days ago ·
9 days ago

Consumer: zig-utils/zig-js#403

Heap snapshots need a process-unique cell identifier that survives moving compaction. zig-gc already memcpy-copies the complete header during relocation, so identity belongs in collector metadata rather than an embedder pointer map that would go stale.

Scope

  • Add a process-unique nonzero StableCellId to every published cell header.
  • Preserve the ID automatically across relocation and never recycle it during the process lifetime.
  • Expose a read-only quiescent cellMetadata/stable-ID query without exposing mutable headers.
  • Cover single and batch allocation, independent heaps, unknown pointers, reclamation/address reuse, and compaction.
  • Keep allocation publication race-free and document the quiescent query contract.
  • Run focused Debug/ReleaseSafe collector evidence.
  • Close on green CI.
9 days ago

Implemented and pushed to main in c17c01a.

Evidence:

  • process-global nonzero atomic identity assigned before publication
  • identity stored in the cell header and preserved by the existing failure-atomic relocation copy
  • quiescent cellMetadata exposes only ID, kind, and shallow payload size
  • focused Debug and ReleaseSafe tests pass for single/batch allocations, independent heaps, unknown/null/stale pointers, reclaim/reallocate, and moving compaction

Leaving this open only for the exact CI run at c17c01a.

9 days ago

Implemented on main in c17c01a. Both required GitHub Actions jobs are green: test and tsan in https://github.com/zig-utils/zig-gc/actions/runs/29773868754. The stable non-recycled cell identity prerequisite is ready for zig-js #403.

Sign in to comment on this issue.