ReviewOS

zig-utils/zig-js

JIT: execute guarded dense-index effects in loop regions

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

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

The optimizer IR already models get_index/set_index and deterministic AArch64 paths can call their canonical runtime operations, but reducible loop-region lowering previously rejected both. This issue adds a guarded isolated packed-dense path so numeric array loops remain native while every observable or shared case exits or calls canonical VM semantics.

Acceptance

  • Lower get_index and set_index through loop-region SSA with exact two/three-input staging and precise stack maps.
  • Direct AArch64 reads guard isolated mode, object/Array brand, ordinary dense storage, absent cold/hole/accessor/attribute state, exact uint32 array index, bounds, and numeric result when required.
  • Direct existing-index writes preserve assignment result and call the non-allocating GC barrier before mutation; growth and every guard miss use canonical fallback.
  • Shared realms, arguments/typed/sparse arrays, proxies, restricted receivers, prototype/indexed hooks, holes, invalid keys, OOB, and concurrent mutation never use the unlocked direct path.
  • Native-on/off differentials cover reads, writes, bounds, holes, observable fallback, GC relocation/checkpoints, invalidation, and exact bytecode steps.
  • Focused normal and TSan gates pass; update #133/#146 docs without claiming append/growth completion.

Landed

  • a1307097 — loop SSA lowering, AArch64 packed-index guards, write barrier, canonical fallback, direct/callback counters, hot-loop, invalidation, and moving-GC differential witnesses.
  • 7b706ea2 — concise README and optimizing-tier documentation.
  • zig build test -Dtest-filter='optimizer packed index': 5/5 passed.
  • zig build test -Dtsan=true -Dtest-filter='optimizer packed index': 5/5 passed, zero leaks.

Append, growth/reallocation specialization, profiling, and broad release gates remain in #133.

9 days ago

Completed on main in a130709 and documented in 7b706ea. The focused normal and TSan packed-index gates both pass 5/5; broader packed-array specialization remains tracked by #133.

Sign in to comment on this issue.