ReviewOS

zig-utils/zig-js

GC relocation: wire binding dispatch and safe compaction policy

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

Parent: #335 Depends on: #338, #339, #340, #341, #342, #343, #344, #345, #349 Roadmap: #134

Connect the completed typed cell/root rewriters to zig-gc and expose only a fail-closed stop-the-world compaction entrypoint.

Scope

  • Add exact CellKind relocation dispatch and the complete Context-root hook to GcBinding.
  • Define a checked eligibility policy for quiescent heaps; refuse movement across conservative native-stack, active native/JIT, running-thread, concurrent-marker, or unregistered raw-pointer boundaries.
  • Keep mixed pinned/movable behavior explicit and deterministic.
  • Add end-to-end cyclic/representative graph, stable-handle, identity, accounting, repeated-compaction, and planning-OOM tests.
  • Update the relocation inventory/docs only when the executable policy matches them.

Acceptance

  • All nine cell kinds dispatch to an exact mutating companion.
  • Unsupported/unsafe runtime states fail closed without mutation.
  • Successful compaction leaves no stale old-space address in audited roots/edges.
  • Focused normal, ReleaseSafe, leak, and TSan checks pass.
  • Full GitHub Actions matrix passes before parent closure.
9 days ago

Activation landed on main in c5727715.

Context.compactGarbage() now opens an atomic relocation token only for a JIT-disabled, fully quiescent realm. It fails closed for active interpreters, running JS threads, conservative/parked stack scans, in-flight parallel/concurrent collection, reentrancy, and GC-disabled contexts. Direct heap compaction remains pinned without that token.

End-to-end evidence moves every live cell twice through a protected stable handle and verifies: cyclic/aliased Objects; pre-move Function + captured Environment, Promise, suspended Generator, and managed String execution; exact live-cell/live-byte accounting; and deterministic planning-scratch OOM with unchanged roots, graph, and accounting.

Validation:

  • full zig build test: 1,196/1,196 passed, 0 skipped/failed/leaked
  • focused Debug, ReleaseSafe, and TSan compaction: 3/3 in each mode, 0 leaked
  • relocation inventory: 9 cell kinds, 26 pointer surfaces, 21 tags; explicit STW movement enabled

The README now accurately distinguishes this explicit quiescent path from the still-missing automatic/concurrent/multi-age compactor. Keeping #350 open until the descendant GitHub Actions matrix is green.

9 days ago

Completed and accepted. The implementation-specific local evidence is recorded above, and descendant full CI at https://github.com/zig-utils/zig-js/actions/runs/29716788619 completed with 42 successful jobs, one intentional nightly skip, zero failures, and zero cancellations.

Sign in to comment on this issue.