ReviewOS

zig-utils/zig-js

VM: expose exact active legacy arguments for compiled ordinary functions

#802
Closed chris opened this 10 days ago ·
10 days ago

Parent: #465. Found while validating #801; coordinate activation ownership with #787.

Baseline e4f76af fails this positive paired VM witness even without GC:

function legacyRead(value) { return legacyRead.arguments[0]; }
assert.sameValue(legacyRead(37), 37);

The tree-walker passes; required bytecode throws TypeError: null is not an object. The ordinary function is admitted, but VM calls do not publish the legacy call-frame view used by Interpreter.getProperty. This is separate from relocation of an already published tree-walker legacy frame.

Acceptance:

  • Preserve the engine's legacy caller/arguments behavior in admitted ordinary compiled calls, including inline, nested-driver, recursive and tail transitions, without routing them to the tree-walker.
  • Keep argument mapping/identity, strict and newer-function poison restrictions, and cross-realm behavior exact.
  • Publish and retire introspection views under the existing activation ownership protocol, failure-atomically and with relocatable function/environment/argument slots; coordinate with #787 rather than racing that lifecycle work.
  • Add no-GC and actual moving-GC differential controls, OOM, no-GIL/TSan and relevant conformance.

The failing witness and transcript are retained locally under /Users/chris/.cache/zig-js-801.9pDs7h/legacy-arguments.js and before-legacy-arguments.log. This issue remains open independently of the scoped coercion/assignment root work.

10 days ago

Implemented and pushed to main in bcc3e757.

The VM now publishes activation-owned legacy caller/arguments views for compiled ordinary functions, lazily materializes exact mapped arguments, preserves recursive/nested/inline/tail ownership, and traces/relocates function, environment, and argument edges. Native direct calls reject potentially reentrant effects before execution and retain proven safe fast paths; common snapshots stay inline to avoid per-call allocator pressure.

Verification:

  • zig build test-parallel: 2,226 passed, 1 skipped, 0 failed, 0 leaked
  • optimizer unit gate: 71/71
  • tree-walker/required x GC-off/GC-on differential, wide-argument overflow, cross-realm, poison, recursion, tail, and actual moving-GC probes passed
  • activation OOM probes passed for normal and inline driver entry
  • focused no-GIL probe passed under TSan
  • test262 test/built-ins/Function/prototype: 309 -> 309; 0 flips, 0 regressions

Sign in to comment on this issue.