Defect
The JSON string parser correctly borrows unescaped source slices, but an escaped string value still decodes into an owned arena buffer and then calls Value.strAlloc, allocating and copying the complete decoded bytes a second time into its string cell. Wide escaped-string inputs therefore retain both the temporary decode storage and the runtime copy for the life of the arena.
Property names have a different ownership boundary because shapes establish key storage; this issue targets value strings only and must not make shape keys alias parser scratch.
Implementation
- Return explicit borrowed-versus-owned string parse results.
- Copy borrowed source text once into the runtime string cell.
- Transfer owned escaped decode buffers through
Value.strOwnedwith no second byte copy. - Preserve JSON source-text slices, WTF-8/lone-surrogate decoding, malformed escape rejection, and OOM propagation.
Acceptance
- Allocator witnesses distinguish the borrowed and owned paths and prove the escaped value avoids the redundant byte allocation.
- Escaped keys and values, surrogate pairs/lone surrogates, controls, reviver context.source, OOM, and malformed syntax remain covered.
- Focused normal + TSan, full unit, and JSON.parse test262 pass with zero regressions.
- Exact-parent escaped-string evidence records CPU and memory impact without unsupported claims.