Parent: #496 Related: #537, #548
Problem
Plain cooked template quasis borrow source after #537, but any escape still switches parseTemplate / parseTaggedTemplate to arena-backed ArrayListUnmanaged growth. Allocation requests and retained capacity therefore depend on escape and quasi layout. Tagged templates also perform allocation work before discovering that an invalid escape makes the cooked quasi undefined.
Scope
- Add 1K/2K/4K escaped untagged-template target rows and keep plain/tagged controls with exact cooked/raw validation.
- Reuse the lexer fixed escape decoder to size and fill valid cooked quasis with one exact allocation.
- Preserve substitution boundaries and contexts, TRV line normalization, line continuations, UTF-16/WTF-8 behavior, raw quasis, tagged invalid-escape
undefined, and untagged early errors. - Make invalid and OOM paths failure-atomic; do not allocate cooked bytes for a tagged invalid quasi.
No-workaround rules
- No worst-case over-allocation, hidden scratch copy, source transformation, delayed syntax error, dropped raw bytes, benchmark-only path, or special casing one template shape.
Acceptance
- Each valid escaped cooked quasi uses one exact decoded-byte allocation with no growth/transfer; plain quasis remain source-backed.
- Tagged invalid quasis allocate no cooked byte buffer and retain exact raw text plus
undefinedcooked value. - Unit tests cover every escape family, multiple quasis/substitutions, raw/cooked divergence, invalid tagged/untagged escapes, line normalization/continuation, WTF-8, and deterministic OOM.
- Focused frontend, parser/lexer, TSan, full units, and exact template test262 comparisons pass.
- Exact-parent evidence records wall, hardware counters, allocation requests/bytes, RSS, checksums, and 1K/2K/4K growth without moving parsing/decoding outside the timed boundary.