Parent: #144\nDepends on: #333\nRoadmap: #134\n\nImplement the first real moving collector as a stop-the-world, same-heap compaction path with deterministic forwarding and rollback-safe planning.\n\n## Scope\n\n- Select compactable GC cell classes and explicitly pin all non-movable classes.\n- Plan evacuation destinations without mutating observable state; fail allocation before movement begins.\n- Copy/move live cells, publish forwarding metadata, repair backing metadata, and release fully evacuated storage.\n- Preserve cell kind, generation, age, mark state, finalizer ownership, allocation accounting, and stable identity.\n- Keep the existing non-moving collector as an explicit policy/fallback, not an accidental partial move.\n- Integrate with zig-gc only through separately committed generic collector changes when necessary.\n\n## Acceptance\n\n- [ ] Fragmented heaps compact into fewer backing chunks with exact before/after accounting.\n- [ ] Injected planning OOM leaves the original heap and every reference unchanged.\n- [ ] Mixed movable/pinned cells and every size class behave deterministically.\n- [ ] Object/string/environment/function/promise representative graphs survive repeated compaction with identity preserved.\n- [ ] Focused normal, ReleaseSafe, leak, and TSan tests pass.\n- [ ] The policy is disabled on any host/configuration lacking its declared relocation guarantees.\n
GC relocation: implement failure-atomic stop-the-world compaction
#334Dependency/core progress is on main:
- zig-gc
e6ea569: failure-atomic generic collect+compact plan, pinned/moved live-graph rewriting, exact rollback, and live commit without finalization; full local normal/ReleaseSafe/TSan green. - zig-js
346c57b5: ownedGcCellBackingunpublished reserve/release/commit trio with exact publication/live-slot accounting and no mutator-pressure charge. - zig-js
585b97be: the engine contract now consumes zig-gc's authoritative stable IDs/forwarding records and provides typed pointer, atomic, tagged-Value, and interior slot operations.
Focused zig-js backing and relocation-contract tests are green with zero leaks. Production movement is still intentionally disabled: the next slice is complete engine root/edge rewriting before any CellKind can opt in.
First engine compaction is executable in c5727715 via the checked explicit Context.compactGarbage() policy. It moves the complete live heap repeatedly with exact accounting and has an engine-level planning OOM witness that leaves roots/edges/storage unchanged. Full local unit suite is 1,196/1,196 green; focused Debug/ReleaseSafe/TSan are green with zero leaks. Remaining #334 work is fragmentation/chunk-reduction and mixed policy evidence plus descendant CI.
#352's fragmentation-aware placement is implemented on main in 5243acf. Explicit compaction now evacuates fragmented tail chunks into the minimal dense leading prefix without growing backing, trims the evacuated tails, and deterministically reaches no_candidates on the second pass. Its integration test also preserves failure-atomic backing/accounting state under forced scratch OOM.
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.