ReviewOS

zig-utils/zig-js

VM: lower captured super writes across tiers

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

Parent: #465 Related: #491, #705, #707, #708

Problem

Plain, generator, async, and async-generator bytecode can read and call super properties, but rejects direct assignment, logical assignment, compound assignment, and prefix/postfix updates. Falling back makes otherwise supported methods tier-dependent and leaves resumable computed keys/RHS expressions outside the VM.

A SuperReference must be resolved once. The current home-object parent and computed property key cannot be recomputed after a getter, coercion, RHS, yield, or await mutates observable state.

Scope

  • Add receiver-aware bytecode primitives that capture the exact SuperReference base and property key once.
  • Lower named and computed direct writes, &&= / ||= / ??=, every compound operator, and prefix/postfix ++ / --.
  • Preserve GetThisBinding/GetSuperBase/key coercion/GetValue/RHS/PutValue order, strict failed-write TypeErrors, inherited setter receivers, BigInt updates, and expression results.
  • Preserve the captured base/key across generator, async, and async-generator suspension.
  • Cache exact unsupported native-tier plans and retain interpreter fallback for code shapes outside the native tiers.

No-workaround rules

  • No repeated base/key evaluation, widened runtime checks, source rewriting, broad method fallback, ignored failed writes, or benchmark-only paths.
  • No stacks, queues, jobs, Promise/microtask, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Plain, generator, async, and async-generator tier differentials cover named/computed direct, logical, compound, and update writes.
  • Abrupt-order witnesses cover uninitialized this, null super base, key coercion, getters/setters, prototype mutation, strict failed writes, BigInt, yield, and await.
  • Focused compiler/VM/frontend, full units, relevant Test262, and applicable TSan gates pass with exact accounting.
  • Commit and parent issues are cross-linked with quantified evidence.
9 days ago

Implementation is in the working tree and the first production relink completed. Three causal gates passed: compiler admission/opcode coverage, a direct VM uninitialized-this check, and generator/async/async-generator suspension plus GC/prototype-mutation coverage. The forced tree-walker/required-bytecode semantic result also passed; only its initial admission-counter assertion was invalid because class methods use a different bookkeeping category. That assertion is now replaced by direct tree-walker-entry and VM-entry deltas.

The corrected rerun is pending behind a separate user-owned Home parity suite. A host disk-full failure exposed 5.5 GB of stale reproducible zig-js object cache; only .zig-cache object/build-graph metadata was removed, preserving source, evidence, and shard logs. No implementation failure or semantic mismatch is currently known.

9 days ago

Landed on main as a5280fad (feat(compiler): lower captured super writes (#715)).

Implemented one-time SuperReference capture for named/computed direct, logical, compound, and prefix/postfix writes in plain, generator, async, and async-generator bytecode. The same commit fixes the tree-walker logical-assignment baseline, preserves receiver-aware strict writes across getter/RHS/prototype mutation and suspension, and caches unsupported native-tier plans without partial native execution.

Validation:

  • full units: 1,830 passed, 1 skipped, 0 failed, 0 leaked across 6 shards;
  • focused normal and TSan: 5/5 passed, 0 skipped/failed/leaked, with no TSan race report;
  • broad super units: 12/12 passed;
  • frontend: 12/12 passed;
  • exact-parent → candidate Test262 test/language/expressions/super: 94/94 → 94/94;
  • exact-parent → candidate Test262 test/language/expressions/assignment: 485/485 → 485/485;
  • Test262 flips 0, regressions 0; both focused transcripts are byte-identical.

No stacks, queues, jobs, Promise/microtask, Worker lifecycle, or Map/Set iterator implementation was changed.

9 days ago

Follow-up #720 was audited and closed as already completed by this landing: its named/computed super logical-assignment scope, including suspendable getter/RHS state, is covered by a5280fa and the evidence recorded above.

Sign in to comment on this issue.