Parent: #475 Related: #460, #461, #480, #493
Problem
CanonicalizeLocaleList currently linearly scans every previously accepted locale for each candidate and formats each array index into realm-owned arena storage before HasProperty and Get. A large valid locale list therefore has quadratic duplicate-check cost and retains avoidable decimal-key backing even though each key is used only synchronously. Every Intl service constructor and supportedLocalesOf shares this path.
Scope
- Preserve ECMA-402
CanonicalizeLocaleListordering exactly:length, then per-indexHasProperty,Get, element conversion/canonicalization, and first-occurrence output. - Replace quadratic duplicate membership with an invocation-local, securely seeded native content index whose exact byte equality remains authoritative on collisions.
- Format decimal property keys into bounded native storage; no borrowed key may escape the synchronous property operation.
- Release all index scratch at invocation exit and keep output strings/array under normal realm/GC ownership.
- Cover unique, duplicate-heavy, canonical-equivalent, sparse, Proxy-observable, invalid, and adversarial inputs.
No-workaround rules
- No locale-count cap, skipped validation, sorting/reordering, deterministic attacker-known hash placement, Object/Map-visible cache, unbounded process/realm cache, or bypass of Proxy traps and conversion hooks.
- Index allocation failure must produce the engine's normal OOM outcome without a partial observable result or leak.
Acceptance
- Deterministic 1K/2K/4K unique and duplicate-heavy rows plus a small-list control preserve frozen checksums.
- Exact-parent wall/instruction/allocation/RSS evidence attributes the retained change and rejects regressions on the control.
- Getter/Proxy order, first-occurrence ordering, canonical-equivalent deduplication, and invalid-tag exceptions are unchanged.
- OOM at index growth and output publication is rollback-safe and leak-free.
- Moving GC, bounded-heap reclamation, no-GIL, focused TSan, full units, and
test/intl402pass with a nonzero denominator.
Security boundary
Hash placement must be unpredictable per interpreter/invocation from the existing secure engine entropy stream, while exact canonical-locale byte equality decides membership. This is an algorithmic-complexity boundary, not a best-effort micro-optimization.