ReviewOS

zig-utils/zig-js

JIT: specialize packed array growth and append paths

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

Parent: #133 Roadmap: #146, #134 Predecessor: #448 Related: #132, #433

#448 keeps guarded existing-index reads and writes native. #450 keeps general allocating calls and literal array effects inside reducible optimizer loops. #451 specializes spare-capacity exact-end assignment, literal append, and one-argument intrinsic push; #452 completes zero/variadic direct push and rooted reallocation.

Acceptance

  • Inventory bytecodes/runtime kernels for packed index growth, literal append, push-like growth, reserve, and length publication; identify benchmark-relevant paths.
  • Add direct specialization for the measured in-capacity append/growth paths without routing through general operation dispatch.
  • Guard isolated/shared mutation, Array brand, extensibility/restrictions, holes/sparse tails, indexed/prototype hooks, exact index==length, capacity, and concurrent mutation before direct specialization.
  • Preserve assignment/container results, failure atomicity, GC barriers, allocation safepoints, and canonical fallback for reallocation or any observable case.
  • Add native-on/off differentials for in-capacity append, reallocating append, holes, non-extensible arrays, inherited setters/proxies, OOM, invalidation, moving GC, shared realms, and exact steps.
  • Resolve optimizer-vs-VM-kernel tier arbitration for the published packed-push/sum workload using measurements, not forced ownership.
  • Publish an exact-parent array profile showing where residual runChunk/runtime leaves moved; update #133, optimizer docs, README, and benchmark artifacts only for measured behavior.
  • Pass focused normal and TSan gates; batch broad unit/no-GIL gates with the next #133 completion checkpoint.

Children

  • #450 — exact allocating call/construction/literal effects in reducible loop regions.
  • #451 — guarded in-capacity exact-end assignment, literal append, and one-argument intrinsic push.
  • #452 — reallocating/variadic packed push and measured tier arbitration.
  • #453 — final #133 targeted attribution and broad unit/no-GIL evidence.

Result

#450 (96d54ac2, 59063a77, d372d0ae) stages exact variable-arity frame inputs and executes calls, construction, allocation, and literal effects in general optimizer loops. #451 (a2010acc, 90de5f08) adds isolated direct spare-capacity publication after the GC barrier.

#452 (f4916c3c, c4436ade) adds zero/variadic direct publication and one precisely rooted narrow callback for wider or reallocating push. Reserve completes before barriers, length, elements, or indexed-witness publication, making OOM failure-atomic. Direct/narrow/growth/canonical counters, object barriers, moving GC, native-off parity, overrides/throws, invalidation, exact steps, shared contention, and focused normal/TSan batches pass.

The exact-parent db91caba→f4916c3c profile keeps the published arrays workload in the existing VM packed-push/sum kernels: both profiles record 40 tryFastArrayPush leaves and neither records nativeArrayPushGrow. Tier priority and accepted README scores therefore remain unchanged. #453 owns the once-per-checkpoint broad gates and final #133 attribution.

9 days ago

Completed by #450–#452. Implementation and exact-parent tier arbitration are pushed through c4436ad; focused normal/TSan and shared-contention gates pass. #453 owns the single broad #133 completion checkpoint.

Sign in to comment on this issue.