Parents: #475, #460 Depends on: #577
Problem
Intl.Segmenter.prototype.segment stores one coerced input string on the %Segments% object, but every containing() result and iterator result calls Value.strAlloc on the complete input again. For an attacker-controlled input with many short segments, retained/cumulative string-cell work grows with input length multiplied by segment count even though ECMA-402 segment records all expose the same immutable input string. Iterator construction also allocates another closed granularity string cell.
The representative benchmark matrix has no dedicated Segmenter consumer rows, so changing ownership without symmetric controls would be unauditable.
Scope
- Add dependency-free word-segmentation rows for full iteration and indexed
containing()probes, with Segmenter/input fixture construction outside the timed boundary. - Consume complete
segment,index,input, andisWordLikeresults through stable checksums using identical source and inputs in zig-js and system JSC. - Attribute exact-parent allocations, bytes, GC cells/collections, locks, timing, and retained memory before changing the engine.
- Preserve the single ToString coercion result as one GC-owned immutable string value across
%Segments%, iterators, and every segment-data record instead of rebuilding the full input cell per result. - Represent closed Segmenter granularity metadata without per-iterator dynamic string allocation when exact attribution justifies it.
- Keep each returned
segmentsubstring independently owned and preserve ordinary result-object mutation, UTF-16 indices, iterator progress,containing()boundaries, abrupt completion, and observable coercion order.
Security and no-workaround rules
Input length and segment count are attacker-controlled. The implementation must make full-input ownership linear and bounded without an unbounded cache, global interning, input truncation, skipped records, precomputed benchmark output, or recognition of benchmark source/names. It must not weaken precise roots, moving relocation, no-GIL synchronization, OOM atomicity, watchdog accounting, or Unicode boundary semantics.
Acceptance
- Committed iterate and containing rows have stable non-zero checksums, identical zig-js/JSC work, and meet the harness timing protocol.
- Exact-parent attribution proves the full input string is allocated once per
segment()result rather than once per returned record; cumulative allocation scales linearly in input plus output. - Checksums and Segmenter semantics remain exact, with no increased property locks or collections.
- Focused OOM, bounded-heap adversarial input, moving nursery, shared-realm no-GIL, and suppression-free TSan coverage pass.
- The complete
test/intl402/Segmentersubtree and full sharded units have no regressions.
Exclusions
No Promise, microtask, Worker, queue, job-lifecycle, stack, or user-owned documentation changes.