ReviewOS

zig-utils/zig-js

VM: use canonical lowering for parameter expressions and patterns

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

Parent: #465. Related: #798, #799, #803, #771, #493.

At f83c419, the parameter-only supportedPlainParameterDefault/supportedPlainParameterPattern whitelist still rejects array/object/RegExp/class literals, optional chains, spread, delete and destructuring assignment even where canonical expression/pattern lowering already exists. The exact-parent 13-subtree paired matrix has 672 explicit parameter-prologue rejections, 124 TypeError results requiring causal diagnosis, and five other mismatches (801 failures / 9,643 scored files). Rejection is not evidence of an unsupported VM opcode.

For example ([[x,y,z]=[4,5,6]])=>x+y+z is rejected in required mode before its existing array/pattern lowering can run. Nested defaults and aggregate parameter defaults reproduce this across arrow/function/method/class forms.

Scope:

  • Make canonical expression/pattern compilation the admission authority for parameter evaluation, retaining stable parameter-prologue rejection for genuinely unsupported lowering and never swallowing OOM.
  • Preserve left-to-right binding initialization, exact undefined default selection, later/self TDZ, separate parameter/body records, live closures/eval, private and super context, inferred names, optional/spread evaluation order, iterator close and abrupt completion.
  • Audit newly reachable existing lowering for real semantic/ownership defects instead of treating removal of a rejection as completion.
  • Add structural/OOM, paired semantic, actual moving-GC and shared no-GIL/TSan checks, with nonzero exact-parent corpus accounting.

No parallel syntax whitelist, blanket acceptance of unsupported nodes, AST fallback counted as bytecode, detached binding snapshots, source rewrite, suppressed failures, disabled GC, or native stack/queue/job/Promise/Worker/Map/Set lifecycle redesign.

Acceptance:

  • Parameter admission follows canonical lowering and reports unsupported/OOM causally.
  • All newly admitted expression families and nested patterns pass exact paired controls without fallback.
  • TDZ/scope/context/iterator/GC/OOM/no-GIL invariants pass targeted and full integration checks.
  • Exact-parent corpus gains/regressions and structural/allocation effects are reported; conventional commit and pushed CI linked separately.

Completed integration (2026-08-28 UTC)

Implementation: f2340f27. The measured local evidence above and in the linked implementation comments remains unchanged.

  • Complete pushed integration: CI 33144524467 at descendant 81978f7b completed successfully: 53 jobs passed, one scheduled-only job skipped, zero failures. This supersedes earlier pending, cancelled, or failed integration reports; those earlier runs are not counted as successful gates.

Closing this implemented issue as completed. Parent-roadmap work and independently tracked follow-ups remain open; this closure does not claim those broader scopes are finished.

9 days ago

Initial canonical-lowering candidate passes 37/38 broad paired controls (baseline 2/38); its only failure is a separately reproduced parser defect in valid new this.#Ctor(), now tracked as #807. The old parameter whitelist is removed and unsupported/OOM classification is retained at actual parameter compilation. A same-inventory 13-subtree corpus comparison is running. Combined tests additionally cover private construction, 20 actual-moving cases, compiler allocation replay and concurrent shared no-GIL calls. No native activation/job lifecycle changes.

9 days ago

Initial compiler-only exact-parent measurement is complete: identical 9,643 eligible positive upstream files, 8,842 -> 9,633 required-bytecode passes, 791 gains and zero regressions. Gains by subtree: expressions/arrow-function 78, expressions/class 278, expressions/function 78, expressions/object/method-definition 1, statements/class 278, statements/function 78. All 13 default-tier reports remain byte-identical (11,494 passes). Stronger validation exposed prerequisite parser #807 and aggregate ownership #808; combined Debug now passes 47 paired controls, 28 actual-moving cases, shared no-GIL calls and compiler/parser allocation replay. Final combined corpus and full/sanitized checks remain pending; no closure or performance claim yet.

9 days ago

Landed on origin/main as f2340f27, with prerequisite parser d3170836 (#807) and aggregate ownership #808. Chris is author/committer; no trailers.

Final same 9,643 eligible positive upstream files: required-bytecode passes 8,842 -> 9,633, failures 801 -> 10, 791 gains / zero regressions. Per-subtree pass counts: expressions/arrow-function 172 -> 250, expressions/class 3,165 -> 3,443, expressions/function 147 -> 225, expressions/object/method-definition 197 -> 198, statements/class 3,424 -> 3,702, statements/function 313 -> 391. The other seven required-tier subtrees are unchanged.

All 13 default-tier reports remain byte-identical (11,494 passes). Additional object 1,170, array 52, new 59 and optional-chaining 38 controls are unchanged too; the object run overlaps the method-definition subtree and is not added twice to a claimed denominator.

Retained paired controls improve 2/47 -> 47/47; Node independently agrees with every expected result. Debug, ReleaseSafe and unsuppressed TSan pass 47 semantic cases in both tiers, 28 actual-moving cases, shared four-worker no-GIL calls, compiler/parser allocation replay and existing reentrant runtime OOM restoration. Full Debug: 2,042 passed, one platform skip, zero failures/leaks, 604.5 seconds / four shards. Seed-one fuzz: 400 default + 300 verify, zero failures.

No whitelist, fallback coverage substitution, source rewrite, disabled GC or native lifecycle redesign. The separate Proxy metadata operand audit is #810; these tests do not claim to resolve it. Ten remaining required-tier files remain visible under parent #465.

All task build caches and intermediate binaries are retired after retaining exact baseline/final binaries, source hashes, witness files and logs in /Users/chris/.cache/zig-js-parameter.jIiaXW. Full pushed integration is still pending; this issue remains open until that gate completes. No performance claim is made.

Sign in to comment on this issue.