ReviewOS

zig-utils/zig-js

JIT: compile general resumable baseline regions with precise stack maps

#466
Open chris opened this 9 days ago ·
9 days ago

Parent: #459 Depends on: #465, #461

Goal

Turn the baseline JIT into a general resumable native region tier with precise stack maps, rather than rejecting whole chunks or relying on VM quick kernels for most nonnumeric work.

Current boundary

#52 completed the safe numeric/control baseline. Arithmetic profiles at 93.3% generated leaves, but the saved baseline profile attributes properties and arrays largely to VM kernels/residual dispatch. docs/baseline-jit.md still identifies resumable side exits and precise native stack maps as future work.

Scope

  • Compile maximal supported bytecode regions and emit exact side exits at unsupported/effectful boundaries instead of rejecting an otherwise profitable chunk.
  • Extend NativeFrame recovery state for operand stack, accumulator, locals/environments, handler stack, call/construct state, and precise source IP.
  • Generate precise stack maps at calls, backedges, allocation points, traps, and debugger/termination checkpoints so managed values may safely remain in registers between safepoints.
  • Cover ordinary calls, property/index access, allocations, typed operations, exceptions, and structured control through direct code or narrow rooted runtime stubs.
  • Add per-opcode/region admission and side-exit counters plus symbolized attribution.
  • Preserve immutable publication, W^X, cached rejection, context teardown, epoch retirement, and shared-realm safety.

No-workaround rules

  • No benchmark-shaped quick kernel, source recognition, unsafe register root, restart-after-observable-effect exit, or silent step/watchdog undercount.
  • A runtime stub must be a narrow semantic operation, not the entire bytecode interpreter hidden behind one native call.

Acceptance

  • Forced baseline-off/on differentials cover result, exception, effects, steps, OOM, debugger, termination, recursion, host callbacks, and deoptimization boundaries.
  • Moving GC rewrites every mapped live native value; malformed/unpublished maps fail closed.
  • No-GIL publication/invalidation/teardown passes normal and TSan races.
  • A machine-readable coverage inventory names supported opcodes, region exits, and rejection reasons.
  • #461 profiles show dispatch transfer on expanded #460 workloads; retained changes have exact-parent timing and code-size evidence.
  • The original #44 matrix has no noise-qualified regression.

Foundation

#52; baseline design; numeric register work began at 79e6ba92.

9 days ago

Child #719 landed in 2388fd77 — feat(compiler): lower proper tail spread calls (#719). Strict ordinary spread calls now retain terminal activation replacement across direct, member, optional, parenthesized-optional, and super forms with precise native roots. Full units were 1,844 passed / 1 skipped / 0 failed or leaked; focused TSan was 4/4; exact-parent call/optional/super/return Test262 stayed byte-identical at 240/240 with 0 regressions.

Sign in to comment on this issue.