Repository navigation
Closed
Labels
enhancementNew feature or requestNew feature or requestperformanceMeasured runtime, memory, scaling, or build performanceMeasured runtime, memory, scaling, or build performanceruntimeJavaScript runtime and builtin implementationJavaScript runtime and builtin implementation
Description
Parent: #496
Related: #493, #460, #461
Problem
Lexer.lexString eagerly appends every byte of every quoted JavaScript string literal into arena-owned ArrayList storage, even when the literal has no escape and its exact value is already a stable slice of the Context-owned source. Wide JSON-like object literals, generated tables, bundles, and modules therefore pay avoidable allocation, copying, growth, and retained parse-arena bytes proportional to their unescaped string payload.
Scope
- Add parser-only growth rows for ordinary and escaped quoted-string programs with frozen source construction, checksums, warmup, and timed parse boundary.
- Return an exact zero-copy source slice for unescaped literals.
- Lazily materialize decoded storage at the first escape and copy raw spans in batches rather than appending every byte.
- Preserve quote removal, escape decoding, line continuations, JSON-superset U+2028/U+2029, legacy-octal flags, WTF-8 behavior, diagnostics, source locations, and source lifetime.
Security and correctness
- No borrowed slice may outlive the owned source backing used by the AST/compiled artifact.
- Malformed and unterminated literals must retain exact failure classification/location.
- Escaped decoding must remain OOM-propagating and failure-atomic.
- Do not special-case benchmark text, intern attacker-controlled literals globally, omit source ownership, or weaken validation.
Acceptance
- Benchmark source and structural checks land before the runtime change.
- Fail-on-first-allocation proves an unescaped literal tokenizes without allocation; escaped literals still allocate and decode exactly.
- 1K/2K/4K ordinary rows show bounded near-linear work and materially lower allocation/instruction cost versus the exact parent; escaped control remains semantically exact.
- Lexer/parser/frontend suites, forced execution paths, OOM diagnostics, full units, and affected test262 string/source parsing pass with no regressions.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestperformanceMeasured runtime, memory, scaling, or build performanceMeasured runtime, memory, scaling, or build performanceruntimeJavaScript runtime and builtin implementationJavaScript runtime and builtin implementation
Activity
bench(frontend): add quoted-string growth rows (#536)
chrisbbreuer commentedon Aug 12, 2026
Benchmark-first commit landed on
mainas 4b5a705b:bench(frontend): add quoted-string growth rows (#536).The parser-only runner now freezes 1,024/2,048/4,096 ordinary quoted-string programs plus a 4,096-literal escaped control. Source construction is outside warmup and timing. Each parse validates the top-level declaration, array-literal width, every StringLiteral node, and the sum of decoded bytes.
Frozen checksums:
50,090101,290203,690203,690No runtime change or performance claim is included in this commit. The next commit will implement the lexer ownership change and compare it against this exact parent.
perf(frontend): borrow unescaped string literals (#536)
chrisbbreuer commentedon Aug 12, 2026
Completed by 23df967d:
perf(frontend): borrow unescaped string literals (#536).The lexer now returns unescaped StringLiteral token text as an exact source-backed slice. The first escape switches to arena-owned decoded storage, copies ordinary text as contiguous spans, and preserves the existing validation and legacy-octal paths. The dedicated zero-byte FixedBufferAllocator test proves an ordinary literal performs no allocation; the same allocator returns
OutOfMemoryfor an escaped literal, and the allocation-backed control decodesraw\nspan\u0021tailexactly.Exact-parent diagnostic growth evidence used 7 order-balanced pairs, 100 parses per sample, identical frozen checksums, and source construction outside warmup/timing:
0.730x); 4,685,824 -> 3,768,320 bytes median peak RSS (0.804x).0.718x); 6,668,288 -> 4,505,600 bytes RSS (0.676x).0.720x); 9,289,728 -> 6,176,768 bytes RSS (0.665x).0.865x); median RSS remains 9,371,648 bytes; decoded checksum remains 20,369,000.These are non-public diagnostic measurements. The standardized attribution collector intentionally rejected this parser-only runner because it does not emit native counter rows; no metrics were fabricated or substituted.
Validation:
The benchmark-first requirement is satisfied by 4b5a705b. Source ownership is unchanged: tokens and AST nodes already borrow the Context-owned input backing, and decoded text remains arena-owned. All acceptance items are satisfied.