ReviewOS

zig-utils/zig-js

JIT: lower verified packed-array regions into the native tier

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

Parent: #44 Successor to: #52 Related: #47, #49, #132, #146

The baseline array profile attributed 65.3% of collapsed leaves to runChunk, followed by dense storage movement, bound calculation, Value conversion, append, and prototype validation.

Evidence: https://github.com/zig-utils/zig-js/blob/main/docs/.data/baseline-jit-profile-2026-07-16.md

Goal

Lower verified packed-array regions or enter exact runtime kernels from native code while preserving observable Array/prototype semantics.

Acceptance

  • Complete existing-index, growth, append/reallocation, length, hole, extensibility, prototype, and concurrent-mutation guards.
  • Preserve canonical accessors, proxy/prototype hooks, sparse arrays, restrictions, OOM, GC barriers, exceptions, termination, and exact checkpoints.
  • Differential-test append, indexed read/write, growth/reallocation, invalidation, shared mutation, and moving GC.
  • Resolve optimizer-vs-VM-kernel tier arbitration from exact-parent measurements.
  • Publish a material residual-dispatch reduction without moving work into repeated guards/callbacks.
  • Pass focused JIT, full unit, no-GIL, and suppression-free TSan gates.

Children

  • #448 — guarded packed existing-index reads/writes in deterministic and loop regions.
  • #449 — packed growth, append/reallocation, and measured tier arbitration.
    • #450 — allocating calls, construction, and literal effects in reducible loops.
    • #451 — guarded in-capacity exact-end assignment, literal append, and one-argument intrinsic push.
    • #452 — reallocating/variadic packed push and measured tier arbitration.
  • #453 — targeted residual-dispatch attribution and broad completion evidence.

Result

Packed existing-index reads/writes, exact-end assignment, literal append, zero/variadic spare-capacity push, and rooted reallocating push now execute through guarded optimizer paths. Canonical callbacks remain for observable/shared/special cases. Reserve-before-publication makes growth OOM failure-atomic; precise scratch roots survive moving GC.

The exact-parent focused A/B keeps 19,564 spare-capacity appends direct and moves all 14 measured reallocations from general dispatch to the narrow rooted callback. The separate published-workload profile confirms VM packed kernels still win before optimizer OSR, so accepted README scores remain unchanged.

Final evidence in #453 passes 1,409/1,409 unit tests across four shards, 3/3 relevant no-GIL corpus cases normally and under suppression-free TSan, all benchmark publication harnesses, and the 6/12 release matrix with private ABI pending 0. The remaining release gates are unrelated #146/#134 work.

9 days ago

Baseline-tier GC integration advanced in ca92af0 / #359: the AArch64 numeric checkpoint island now declares a movement-safe interval only after canonical local publication, operand spilling, and exact state publication. A requested compaction can relocate the active graph and resume the same immutable entry with exact output; generic/side-exit/host/exception paths never set the movement token.

9 days ago

Completed by #448–#453 through 8ec5529. Packed access/growth is guarded and failure-atomic, exact-parent dispatch evidence is material, published tier priority remains measured, and combined broad gates pass.

Sign in to comment on this issue.