ReviewOS

zig-utils/zig-js

Compiler: lower invocation-context default leaves into VM frames

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

Parents: #465, #498 Depends on: #739 Related: #729, #737

Implemented by: bc805037

Problem

#739 admits recursively closed primitive default expressions, but direct invocation-context leaves remain rejected even though the VM installs their exact values before executing the ordered parameter prologue. A bare this, bare new.target, or an ordinary function's own unmapped arguments object needs no body-variable lookup, closure capture, or expression folding.

Scope

  • Admit a default Initializer only when its complete expression is bare this, bare new.target, or bare arguments resolving to the ordinary function's own arguments exotic.
  • Preserve sloppy receiver substitution, strict undefined this, method receiver identity, lexical arrow this/new.target, ordinary call versus construct new.target, alternate Reflect.construct targets, and unmapped non-simple arguments identity/content.
  • Evaluate only for raw undefined and preserve provided-value bypass, recursion/reentrancy, debugger checkpoints, moving GC, OOM restoration, and shared-chunk no-GIL behavior.
  • Reuse #738/#739's immutable default-index metadata, ordered bytecode prologue, activation guards, and native-tier fail-closed policy.

An arguments parameter/pattern binding, arrow's inherited arguments, embedded unary/binary/logical/conditional/sequence/member/call/new forms, source identifiers other than the exact own arguments binding, functions/classes/allocating literals, assignments/updates, nested pattern expressions, rest mixtures, and class constructors requiring derived/field initialization remain barriers.

No-workaround rules

  • No source-text recognizer, constant folding, host evaluation, tree-walker callback, guessed arguments ownership, receiver snapshot, derived-constructor placeholder, permissive recursive admission, or alternate metadata path.
  • No stacks, queues, jobs, Promise, microtask, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Compiler admission proves the three exact leaf families and stable rejection for shadowed/inherited/embedded/excluded forms.
  • Forced tree-walker and required bytecode agree across sloppy/strict calls, methods, arrows, base constructors, ordinary and alternate construction, own arguments, provided bypass, recursion/reentrancy, and moving GC.
  • Derived/field constructor policy, malformed metadata, OOM restoration, shared no-GIL/TSan, debugger, and native activation guards remain exact.
  • Full units, focused compiler/frontend/VM, threadfuzz, and exact nonzero Test262 accounting pass with zero regressions.
  • A conventional commit lands directly on main and cross-links #465, #498, #739, #729, and #737.
9 days ago

Landed on main as feat(compiler): lower invocation defaults (#740).

The compiler admits only complete bare this, new.target, and exact own-arguments default leaves after the VM installs invocation context. Inherited or shadowed arguments, embedded/coercing expressions, mixed rest prologues, and derived/field constructor semantics remain explicit barriers. The implementation reuses the ordered default-index prologue and adds no alternate evaluator or metadata path.

Verification on the landed tree: full units 1,881 passed / 1 skipped / 0 failed / 0 leaked; focused frontend 19/19; compiler admission, 3-way tree-walker/VM parity, arguments OOM restoration, and four-lane shared no-GIL witnesses pass normally and under TSan; deterministic threadfuzz is 400/0 in default and TSan builds. Exact nonzero Test262 accounting is byte-identical at 10,296 → 10,296 across function expressions/statements, arrows, object methods, class expressions/statements, and the Function constructor.

9 days ago

All acceptance criteria are complete on main; closing as implemented.

9 days ago

Follow-up #741 landed in feat(compiler): lower earlier parameter defaults (#741), adding exact earlier-formal leaves alongside #740’s invocation-context leaves while keeping inherited arguments rejected.

9 days ago

The follow-on composition issue #742 has landed on main in 54c54afe, reusing this issue's proven leaf semantics inside a fail-closed recursive expression grammar. Test262 remained byte-identical at 10296 -> 10296; full units, TSan, shared no-GIL, allocation-failure restoration, and 400-iteration default/TSan threadfuzz all passed.

9 days ago

The follow-on public property-read slice #743 has landed on main in 1b7e8e58, composing this issue's proven parameter-default semantics through canonical named/computed [[Get]]. Test262 remained byte-identical at 10296 -> 10296; full units, TSan, shared no-GIL, getter-OOM restoration, and default/TSan threadfuzz all passed.

9 days ago

The follow-on parameter-local call slice #744 has landed on main in 402e805a, composing this issue's proven defaults through canonical value and receiver-preserving call opcodes. Test262 remained byte-identical at 10296 -> 10296; full units, TSan, shared no-GIL, nested-call OOM restoration, and default/TSan threadfuzz all passed.

9 days ago

Follow-up #745 landed on main as feat(compiler): lower parameter construction defaults (#745). It composes the parameter-safe value/property/call grammar into canonical non-spread new_call lowering, remains fail-closed for unsupported forms, and records 10,296 -> 10,296 exact relevant Test262 cases with 0 flips. Derived and field-initializing constructor activations are separated into #746.

Sign in to comment on this issue.