ReviewOS

zig-utils/zig-js

GC relocation: rewrite surviving weak and finalization records

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

Parent: #345 Depends on: #344 Roadmap: #335, #144, #134

Implement the internal weak/finalization portion after zig-gc has completed ephemeron fixpoint, cleared dead weak slots, pruned entries, and swept dead cells.

Acceptance:

  • Clear a FinalizationRegistry target when its record becomes ready so no swept address remains stored.
  • Rewrite surviving WeakRef targets, weak collection keys, ephemeron values, finalization callback/held Values, and live unregister tokens.
  • Never resolve a dead target through the relocation plan.
  • Repair or invalidate pointer-keyed weak indexes.
  • Prove surviving/dead/ready ordering and preserve exactly-once cleanup state.
  • Focused normal and TSan runs report zero failures and leaks.
  • Production movement remains disabled and #345/#335 are updated.
9 days ago

Implemented and pushed in 88dae824.

Delivered:

  • FinalizationRegistry records null dead targets as soon as they become ready, before sweep can leave a stale address;
  • surviving WeakRef targets, weak keys, ephemeron values, finalization callback/held Values, live targets, and live unregister tokens rewrite after pruning;
  • ready/dead targets are never offered to the forwarding plan;
  • pointer-keyed weak_index is cleared after key relocation; linear lookup remains correct and later mutations repopulate it;
  • exact regression proves live/dead/ready ordering and zero forbidden resolutions.

Local gates:

  • filtered normal: 3/3 passed, 0 failed, 0 leaked;
  • filtered TSan: 3/3 passed, 0 failed, 0 leaked.

Production movement remains disabled. #345 still tracks native-private and Wasm boundaries.

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.