Consumer: zig-utils/zig-js#62
Evidence
A symbolized ReleaseFast object_churn profile after zig-js entered the 512-byte Object slab attributes 135 exclusive samples to Heap.writeBarrierFromManaged. The guarded object-allocation loop stores only freshly allocated managed children into one prevalidated array, but currently repeats the full child-young, parent-young, remembered-owner CAS, and marking checks for every replacement.
Invariant
For a checkpoint-bounded batch of fresh allocations:
- every child is allocated by the same heap immediately before its first store;
- a child allocated during incremental/full marking is born marked and queued/deferred for tracing;
- no collection can promote the owner inside the batch;
- an old owner therefore needs to enter the nursery remembered-owner set once before the batch, while a young owner needs no remembered entry;
- the consumer must re-prepare after every GC checkpoint.
Scope
- expose a strict exact-managed-owner API that prepares an owner for a batch of stores of newly allocated cells;
- remember an old owner once when nursery collection is enabled;
- avoid a redundant incremental child barrier because future children are born grey whenever marking is active;
- keep the tolerant and ordinary per-child barriers unchanged;
- document caller obligations and add a focused old-owner/young-child survival test.
Acceptance criteria
- Old-owner to fresh-young-child edges survive minor collection after one preparation call.
- Young owners and nursery-disabled heaps remain correct.
- Existing exact/tolerant barrier tests remain green.
- zig-gc full tests pass.
- The consuming zig-js optimization shows repeatable exact-parent improvement.
- Retained commits reference this issue.