ReviewOS

zig-utils/zig-js

Compiler: lower computed and super tagged-template references

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

Parents: #465, #498 Related: #491

Problem

The bytecode compiler lowers plain and named-member tagged templates but rejects computed member tags and every super tag. Generator/async bodies and required no-JIT execution therefore fall back even though the existing get_index, super_get*, template_object, and receiver-aware call/tail-call operations already express the full reference contract.

Scope

  • Lower ordinary computed member tags and named/computed super tags in expression and tail position across plain, generator, and async bytecode.
  • Evaluate the base, computed key/ToPropertyKey, and tag GetValue exactly once before GetTemplateObject and substitutions.
  • Preserve the exact receiver: the captured base for ordinary member tags and the current this for super tags.
  • Preserve abrupt completion and suspension order for computed keys and substitutions, direct-eval distinctions, template-object caching/freeze identity, and proper-tail-call behavior.
  • Keep syntactically forbidden optional-chain template tags rejected by the parser.

No-workaround rules

  • No repeated base/key/tag lookup, AST rewrite, tree-walker callback, shared/global scratch, receiver loss, eager substitution, new runtime opcode, or syntax broadening.
  • No stacks, queues, jobs, Promise/microtask, Worker, or Map/Set iterator changes.

Acceptance

  • Computed member and named/computed super tags compile in ordinary and tail positions across applicable plain/generator/async admission.
  • Exact witnesses cover base/key/get/template/substitution/call order, receiver identity, abrupt completion, recursion, suspension, and tail-call behavior.
  • Forced tree-walker and required-bytecode differentials match; unsupported optional-chain syntax remains a parser error.
  • Focused compiler/frontend, full units, applicable TSan, and exact relevant Test262 before → after accounting pass with zero regressions.
  • Parent issues and landing commit are cross-linked with quantified evidence.

Result

Landed in feat(compiler): lower computed and super template tags (#709).

  • Computed ordinary and named/computed super tags now use the existing receiver-aware call/tail-call path across plain, generator, and async bytecode; no runtime opcode or shared scratch was added.
  • Tag Reference/GetValue completes before GetTemplateObject and substitutions. The tree-walker baseline now follows the same ordering and preserves the current this receiver for super tags.
  • Witnesses cover exact base -> key -> getter -> substitution -> call ordering, abrupt completion at each stage, one-shot receiver capture, recursion, template-object identity/freeze, generator/async suspension, super receiver identity, and emitted proper-tail-call operations.
  • Test262 tagged-template expressions: 27/27 → 27/27, byte-identical transcripts, flips 0, regressions 0.
  • Validation: tagged-template units 7/7; admission inventory 2/2; TSan tagged-template units 7/7; focused frontend 12/12; full units 1,812 passed, 1 skipped, 0 failed, 0 leaked.
8 days ago

Implementation is drafted locally using only existing receiver-aware call/tail-call and super_get* operations. Review also exposed a tree-walker baseline defect within this exact scope: it resolved member tags after GetTemplateObject/substitutions and treated super tags as receiver-less calls. The candidate now captures the tag Reference/GetValue first and preserves the ordinary/super receiver. Focused admission, differential, abrupt-order, recursion, suspension, and super runtime witnesses are added; validation is waiting behind the active user-owned Home corpus job.

8 days ago

Completed by ee0e0520 with the quantified evidence recorded in the issue body.

8 days ago

Follow-on #710 landed in e818a068, reusing the same receiver-aware super-reference discipline for normal calls, proper tail calls, and generator spread. It preserves GetThisBinding/key/getter/argument/call order and suspension without a new runtime primitive.

Sign in to comment on this issue.