Problem
Interpreter.regexpSearchInput appends the complete input to an arena before it knows whether any astral code point requires conversion to WTF-8 surrogate code units. When no conversion is needed it returns the original slice, leaving the full constructed copy unused but retained by the arena.
The hottest matching callers avoid this for ASCII, but compileRegex invokes it for every non-Unicode pattern, and BMP-only non-ASCII match inputs still take the allocate-then-discard path.
Required behavior
- return the original slice without allocating when the input contains no astral code point;
- when conversion is required, allocate/fill exact output or otherwise prove a lower-cost bounded construction;
- preserve non-
uUTF-16 code-unit matching, lone-surrogate behavior, byte↔code-unit span mapping, captures,lastIndex, and/u/vbehavior exactly; - propagate OOM without publishing partial state or retaining abandoned conversion buffers.
No-workaround rules
- no ASCII-only semantic shortcut at the public boundary;
- no skipped conversion for astral input;
- no changed RegExp indices/captures or invalid Unicode normalization;
- no cache with unbounded, realm-unsafe, or unsynchronized lifetime.
Acceptance
- allocation tests prove the no-op path performs zero conversion allocations and the changed path is failure-atomic;
- exact-parent rows cover ASCII, BMP non-ASCII, astral, lone-surrogate/WTF-8, match/no-match, and global/sticky index progression with exact checksums;
- focused RegExp tests, test262 RegExp/literal subtrees, OOM, TSan, and full units pass.