ReviewOS

zig-utils/zig-js

IteratorClose: preserve VM protocol order with seeded tier differential

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

Parent: #491 Related: #752, #753

Problem

Strict iterator-record conformance had adversarial fixed examples for each execution tier, but no owned seeded matrix proving that the tree walker and required-bytecode VM preserve the same lookup, capture, receiver, result-object, accessor-order, and IteratorClose observables. The new matrix exposed two VM defects: IteratorValue failures incorrectly closed the iterator, and a failed explicit break-close could invoke return a second time while unwinding.

Scope

  • Generate a bounded deterministic inventory of synchronous iterator protocol cases from an owned fixed seed.
  • Force every counted plain-function case through both tree-walker and required-bytecode modes with JIT disabled.
  • Compare exact returned value bits plus an observable transcript containing getter/call/receiver/close ordering and exception name/message.
  • Assert required bytecode admission and zero template fallback for every counted case.
  • Cover GetIterator failures, captured next methods, step-result object validation, done-before-value ordering, abrupt accessors, and IteratorClose on abrupt loop completion.

Promise jobs, async iteration, Worker lifecycle, and Map/Set iterator implementation are intentionally outside this bounded child and remain owned by their existing tracks.

No-workaround rules

  • No unsupported or tree-only case is counted as VM coverage.
  • No result-only comparison, retry, skipped seed, duck-typed iterator acceptance, or dynamic next re-read.
  • The seed and generated source inventory make a failure locally reproducible.

Acceptance

  • Fixed seed deterministically emits a bounded, named case inventory.
  • Every case matches result bits, exact protocol transcript, and exception outcome across forced tree-walker and required VM.
  • Required VM records compiled admissions with zero plain-function fallback.
  • Focused normal and TSan witnesses pass without leaks or races.

Evidence

  • Iterator units: 31 passed, 0 failed, 0 leaked.
  • Captured destructuring units: 2 passed; lexical binding identity: 1 passed.
  • Focused TSan: 1 passed, 0 failed, 0 leaked.
  • Exact-parent Test262: for-of 751 to 751 passed and for-await-of 1234 to 1234 passed, with zero failures in both revisions.
9 days ago

Landed in fix(iterator): preserve VM close ordering (#754).

The fixed-seed 17-case matrix found and now guards both VM ordering defects. Exact-parent corpus comparisons remained 751 to 751 for for-of and 1234 to 1234 for for-await-of, with zero failures and zero regressions.

Sign in to comment on this issue.