ReviewOS

zig-utils/zig-js

Compiler: compose parameter-safe default expressions in VM frames

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

Parents: #465, #498 Depends on: #741 Related: #739, #740

Problem

#739 recursively lowers primitive-only default expressions, while #740/#741 add exact invocation-context and earlier-formal leaves only as complete expressions. Composing those proven leaves through the same unary, binary, logical, conditional, and sequence nodes still falls back even though the VM already owns canonical runtime evaluation, coercion, short-circuiting, abrupt completion, and GC roots for every operation.

Scope

  • Admit recursively parameter-safe expression trees whose leaves are primitive literals, exact this/new.target/own-arguments, or bindings established by strictly earlier formals.
  • Retain the existing explicit unary, binary, logical, conditional, and sequence node grammar; every child must recursively satisfy the same rule.
  • Evaluate normally on every raw-undefined call with exact coercion effects, short-circuiting, BigInt behavior, exception ordering, provided-value bypass, reentrancy, moving GC, and OOM propagation.
  • Preserve self/later/outer TDZ and environment boundaries, derived/field constructor policy, immutable metadata, debugger/step accounting, shared-chunk no-GIL execution, and native activation guards.

Member/call/new expressions, functions/classes, object/array/regex/template literals, assignment/update/delete, direct eval, imports, yield/await, nested pattern expressions, and rest mixtures remain barriers even when a subexpression appears unreachable.

No-workaround rules

  • No constant folding, host evaluation, source rewriting, cached result, skipped coercion, effect replay, permissive default switch arm, guessed identifier resolution, tree-walker callback, or alternate metadata path.
  • No stacks, queues, jobs, Promise, microtask, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Exhaustive compiler tests prove every recursive node/leaf family and reject every excluded or unsafe composition.
  • Forced tree-walker and required bytecode agree on primitive/object coercion, short-circuiting, throws, signed zero/NaN/infinity, BigInt, values, bypass, recursion/reentrancy, methods/arrows/base constructors, and moving GC.
  • Shared no-GIL/TSan and allocation-failure restoration remain exact without effect replay.
  • 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, #741, #739, and #740.

Landed

54c54afe — feat(compiler): compose parameter defaults (#742)

9 days ago

Landed on main in 54c54afe.

The compiler now accepts the exhaustive recursive grammar over proven primitive, invocation-context, and strictly-earlier-parameter leaves. Runtime evaluation remains in the canonical VM expression stream, so coercion, short-circuiting, exceptions, allocation, reentry, and GC occur once in source order. Every unlisted or stateful AST kind remains fail-closed.

Validation on the landed tree:

  • Test262: 10296 -> 10296, byte-identical diagnostics across function declaration/expression, arrow, object method, class declaration/expression, and Function constructor boundaries; 0 gains, 0 regressions.
  • Full units: 1,884 passed, 1 skipped, 0 failed, 0 leaked across 1,885 tests.
  • Focused compiler, semantic, shared no-GIL, and allocation-failure tests passed normally and under TSan; frontend 21/21.
  • Seeded threadfuzz: 400/0 in default and TSan builds.

The body acceptance checklist is complete. Crosslinks: #465, #498, #739, #740, #741.

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.