Problem
Heap.createBatch amortizes zig-gc metadata publication, but it still invokes the backing allocator once per cell. Embedders with size-class locks therefore pay and contend on the same lock for every slab in the batch.
A post-zig-js #104 8-lane shared object-churn sample attributes 10,150 samples to GcCellBacking.allocFn and 6,955 to gc.allocObjectBatch; the remaining generic Heap.create fallback is only 1,055 samples.
Direction
Add an optional binding hook that fills a same-size raw cell-slab prefix in one operation. Heap.createBatch should use the hook when present, then retain ownership of header initialization, all-list/index publication, nursery counters, and born-grey concurrent-mark handling. Bindings without the hook remain unchanged.
Correctness requirements
- A zero or short prefix must preserve current allocation-recovery and OOM ordering.
- Returned slabs remain private until zig-gc publishes the complete prefix under its metadata lock.
- Concurrent marking must use one marking-state snapshot for the publication batch.
- Tests cover full batches, short prefixes, first-allocation recovery, and existing parallel publication invariants.
- README documents the optional hook and exact contract.
Validation
Run zig-gc unit tests once after the implementation is retained, then validate the zig-js consumer under focused regular and TSan tests plus exact shared object-churn A/B.