Parent: #496 Related: #461, #479
Problem
Parser.initWithScratchDiagnostic always tokenized source with Script HTML-comment handling enabled. Parser.parseModule then discarded that complete token stream and tokenized the same source again with HTML-like comments disabled. Every production module parse therefore paid for and retained an unnecessary Script-goal token list before performing the required Module-goal scan.
Scope
- Freeze parser-only 1K/2K/4K static-module declaration/import/export rows with exact AST, source-range, cardinality, and checksum validation.
- Freeze Script-vs-Module HTML-like-comment rejection controls and malformed-module diagnostic offsets.
- Let production module entry points retain exactly one token stream while preserving Module lexical-goal rejection.
- Preserve the existing
Parser.init(...).parseModule()public path. - Keep source construction outside warmup/scored boundaries and lexing, parsing, AST construction, early errors, and validation inside.
No-workaround rules
- No source pre-scan, cached/precompiled benchmark input, hidden warmup tokenization, omitted tokens/source locations, weakened Annex B behavior, delayed errors, or duplicate Script/Module parsers.
- Do not accept HTML-like comments in modules or reject their Annex B Script forms.
- Do not touch stacks, queues, jobs, Promise/microtask, or Worker lifecycle code.
Acceptance
- Benchmark source, 1K/2K/4K identities, jobs, checksums, warmup, timed boundary, and existing Script/Module controls were committed before the runtime change.
- Production module parsing creates one lexer and one retained token stream while preserving Module lexical-goal rules.
- Exact AST/module-request/export/source-range checks and diagnostic offsets remain unchanged.
- Failure paths are allocation-failure atomic and bounded; no discarded Script token arena remains.
- Focused frontend Debug/TSan, full units, module/Annex B/source-location test262, and forced module execution pass without regressions.
- Seven-pair exact-parent evidence reports wall, CPU, allocation requests/bytes, peak RSS, instructions/cycles/energy availability, thermal state, and dispersion without discarded samples.
Security boundary
Module source and comment forms are attacker-controlled. The fix removes redundant work without allowing lexical-goal confusion, hiding malformed input, changing diagnostic boundaries, or retaining attacker-proportional discarded storage.
Landed
- Benchmark:
1240045a - Implementation:
78dbd220 - Evidence:
080f2302 - Report:
docs/.data/exact-parent-frontend-modules-2026-08-13.md