ReviewOS

zig-utils/zig-js

Compiler: lower parameter-local construction in VM frames

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

Parents: #465, #498 Depends on: #744 Related: #739, #740, #741, #742, #743, #746

Problem

#744 permits exact value and receiver-preserving calls rooted in invocation context or strictly earlier formals, but construction through a proven earlier constructor still rejects the enclosing plain function. The VM already owns canonical [[Construct]], callee/argument order, new.target, Proxy construct traps, base initialization, explicit object-return override, abrupt completion, activation nesting, and GC roots through new_call.

Scope

  • Admit non-spread new expressions when the constructor and every argument recursively satisfy the parameter-safe grammar.
  • Preserve constructor evaluation before left-to-right arguments, one [[Construct]], exact new.target, Proxy construct behavior, base initialization, primitive-vs-object return rules, non-constructable errors, provided-value bypass, recursion/reentrancy, moving GC, and OOM propagation.
  • Permit nested safe construction and composition through existing value/property/call nodes while retaining immutable metadata, debugger/step/watchdog accounting, shared-chunk no-GIL execution, and exact activation restoration.

Spread construction, optional/private/super construction, direct eval/import, writes/assignment/update/delete, unresolved outer/body bindings, suspension, literal allocation, nested-pattern expressions, and rest mixtures remain barriers. Derived and field-initializing constructor callees retain their independent plain_policy_class_constructor_semantics barrier tracked in #746; this issue does not route them through the tree walker.

No-workaround rules

  • No eager construction, cached instance, duplicated constructor/getter/argument effect, skipped constructability check, substituted new.target, source rewriting, permissive new arm, tree-walker callback (including for #746 constructor shapes), hidden native tier, or benchmark-only path.
  • No stacks, queues, jobs, Promise, microtask, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Exhaustive admission tests accept only recursively safe non-spread construction and reject spread/private/super/outer/unsafe-argument forms.
  • Forced tree-walker and required bytecode agree on value and named/computed bytecode-eligible constructors, callee-before-arguments order, Proxy construct, new.target, base initialization, object return override, non-constructable/throwing constructors, provided bypass, methods/arrows, and recursion/reentrancy.
  • Moving-GC, allocation-failure restoration, shared no-GIL, and TSan witnesses preserve one-shot effects and activation state.
  • Full units, focused compiler/frontend/VM, threadfuzz, and exact nonzero relevant Test262 accounting pass with zero regressions.
  • A conventional commit lands directly on main and cross-links #465, #498, #744, #743, #742, #739, #740, #741, and #746.

Landed

feat(compiler): lower parameter construction defaults (#745)

9 days ago

Landed feat(compiler): lower parameter construction defaults (#745) directly on main.

The compiler now admits recursively safe, non-spread parameter-local new expressions and lowers them through the existing canonical new_call operation. The witnesses cover direct/named/computed/nested construction, callee-before-argument order, exact new.target, Proxy construct traps, base initialization and return rules, non-constructable and throwing constructors, provided-value bypass, reentry/recursion, moving GC, shared no-GIL execution, TSan, and OOM caller-activation restoration.

Private/super access, spread, later-formal/outer dependencies, and all unlisted forms remain causal admission barriers. Derived and field-initializing constructor activations are deliberately fail-closed—not routed through the interpreter—and are tracked by #746.

Validation:

  • exact relevant Test262 subtrees: 10,296 -> 10,296 across seven function/class boundaries; byte-identical results, 0 flips
  • full units: 1,890 passed, 1 skipped, 0 failed, 0 leaked
  • focused compiler, semantic, VM OOM, shared no-GIL, and frontend: pass in normal builds; targeted engine witnesses also pass under TSan
  • frontend: 24/24
  • deterministic threadfuzz: 400/0 in normal and TSan builds

All acceptance criteria are complete, so I am closing this issue.

9 days ago

The constructor-activation barrier identified here has advanced: base constructors with instance fields are now bytecode-owned via #747 and d9d480d0. Exact evidence covers 8,426 relevant Test262 class cases with 0 failures/0 flips, full units, no-GIL/TSan, OOM, moving GC, and threadfuzz. Derived super() activation semantics remain isolated in #746.

Sign in to comment on this issue.