ReviewOS

zig-utils/zig-js

Compiler: lower property and value delete expressions

#713
Closed chris opened this 8 days ago ·
8 days ago

Parents: #465, #498 Related: #491, #712

Problem

The compiler inventories delete_expr for yield/capture analysis but has no expression lowering arm and bytecode has no delete operation. Any otherwise eligible program, plain function, generator, or async function containing delete therefore falls back, including property deletes whose exact Reference already fits the operand stack.

Scope

  • Lower named/computed member deletion through owned bytecode operations that preserve [[Delete]], attributes, arrays/strings, Proxies, Symbols/private-name rules, and strict-mode failure behavior.
  • Preserve one-shot base and computed-key evaluation, suspension across yield/await, RequireObjectCoercible/ToPropertyKey ordering, and exceptions.
  • Lower optional member deletion so a nullish short circuit yields true, while parentheses retain the exact chain boundary.
  • Lower non-Reference operands by evaluating their side effects once and yielding true without inventing runtime work.
  • Cover program, plain-function, generator, and async admission; keep bare identifier deletion and super deletion as explicit causal barriers until their environment/super contracts have dedicated operations.
  • Preserve exact interpreter/VM agreement and native-tier fallback without adding a runtime stack container.

No-workaround rules

  • No repeated observable evaluation, hidden global/environment bindings, heap wrapper per Reference, source/AST rewriting, tree-walker callback presented as bytecode, weakened Proxy invariants, or global lock serialization.
  • No stacks/queues/jobs-runtime, Promise, Worker, or Map/Set iterator changes.

Acceptance

  • Named/computed/optional property delete and non-Reference delete compile across program/plain/generator/async tiers.
  • Witnesses cover strict/sloppy configurable failures, arrays/strings/primitives, Proxies and revoked/invariant traps, Symbols, key coercion order, suspension, GC relocation, and abrupt completion.
  • Bare identifier and super delete remain audited causal rejections with stable admission reasons.
  • Forced tree-walker/required bytecode agree; focused compiler/frontend, full units, applicable TSan, and exact delete/optional-chaining Test262 before → after accounting pass with zero regressions.
  • Parent/related issues and landing commit carry quantified evidence links.
8 days ago

Implementation is underway in an isolated exact-parent worktree. The lowering now uses two owned bytecodes (delete_prop and delete_index) over the ordinary operand stack; optional short exits are compiler-patched cleanup blocks that synthesize true, and non-Reference operands evaluate once then synthesize true. Bare identifiers and super remain causal unsupported_lowering barriers.

The shared runtime path preserves strict/sloppy descriptors, String/index exotics, Proxy revocation/invariants, Symbols, and the required split between computed-key evaluation and ToPropertyKey (including delete 1[objectKey] coercing while delete null[objectKey] does not). Program/generator/async strictness is encoded into the instruction. No stack/queue/job, Promise/Worker, or Map/Set iterator implementation was changed.

Current focused evidence: 3/3 matching unit tests passed (forced tree-walker vs required bytecode differential, compiler admissions, and the existing property-deletion transition test). Suspension/relocation, frontend, TSan, full units, and exact Test262 before/after evidence remain pending; the next focused run is fail-closed behind the repository quiet-host gate.

8 days ago

A first full-unit integration attempt exposed a real compiler completion bug after delete became program-bytecode eligible: an expression statement inside a normally completing finally overwrote the preserved try/catch program completion. The compiler now discards normal finally-body statement values while retaining the incoming completion, matching TryStatement evaluation; an explicit tree-walker/required-bytecode witness preserves "preserved" across finally { delete holder.value; }.

Post-fix evidence is green so far:

  • existing array/prototype regression: 1/1 passed;
  • full property-deletion focus: 3/3 passed;
  • required-bytecode generator/async suspension across an actual moving nursery compaction: 1/1 passed, with moved cells confirmed;
  • git diff --check: clean across the five intended engine files.

The fresh TSan/frontend/full-unit and exact 69-case delete + 38-case optional-chaining comparisons remain fail-closed behind the quiet-host gate because unrelated parity jobs are active. No implementation surface owned by the stacks/queues/jobs work was touched.

8 days ago

Landed on main in 7a1932cf (feat(compiler): lower delete expressions across tiers (#713)).

Final evidence:

  • full unit suite: 1,822 passed, 1 established skip, 0 failed, 0 leaked across 1,823 tests / 6 shards;
  • frontend matrix: 12/12 passed;
  • focused deletion TSan: 3/3 passed, zero sanitizer warnings;
  • generator/async suspension across confirmed moving nursery compaction: 1/1 passed;
  • exact frozen-parent Test262: delete 69/69 → 69/69 and optional-chaining 38/38 → 38/38; flips 0, regressions 0;
  • git diff --check clean; five explicit engine files only; no stack/queue/job, Promise/Worker, Map/Set iterator, docs/threads, or reference corpus changes.

The integration run also found and fixed the program-completion regression for normally completing finally bodies before landing.

8 days ago

The SuperReference barrier intentionally left by #713 is now resolved by #716 in e051fc45. Bare identifier deletion remains the separate Environment Record barrier; ordinary/member deletion behavior is unchanged. Exact delete Test262 is 69/69 before and after.

8 days ago

The bare-IdentifierReference barrier intentionally left by #713 is resolved in #717 by c8e1b0c0. Together with #716, property, value, SuperReference, and identifier deletion now have owned bytecode semantics. Exact delete Test262 remains 69/69 with byte-identical parent/candidate transcripts.

Sign in to comment on this issue.