Skip to content

Strings: bound variadic concat construction #783

Description

@chrisbbreuer

Parents: #473, #493
Related: #480, #777, #781, #782

Problem

String.prototype.concat with two or more arguments still converts each argument to canonical WTF-8 and appends through ArrayListUnmanaged. The growable buffer can copy an expanding prefix repeatedly, flat Latin-1 arguments require whole-input snapshots, and the path does not enforce the engine string-size ceiling before growth.

#782 deliberately fixed binary + and the zero/one-argument concat cases. This child owns the remaining variadic construction path.

Scope

  • Preserve receiver coercion and left-to-right ToString ordering for every argument.
  • Retain exact StringData identity when all other pieces are empty.
  • Compute checked canonical output length, including high/low surrogate pairs spanning any adjacent non-empty pieces.
  • Enforce the engine string-size ceiling before output allocation.
  • Stream every flat Latin-1 and canonical WTF-8 piece into one exact owned output buffer.
  • Reuse one shared construction implementation with the two-value path without changing binary + semantics.

No-workaround rules

  • No rope placeholder, repeated pairwise rebuilding, arbitrary argument cap, lossy surrogate handling, source recognition, cached result, weaker RangeError/OOM behavior, or growable output buffer.
  • No stacks, queues, jobs, Promise/microtask, Worker lifecycle, or Map/Set iterator changes.

Acceptance

  • Multi-argument empty pieces retain the exact sole non-empty StringData cell without output allocation.
  • Non-empty results use checked exact sizing and one canonical output buffer.
  • Flat Latin-1 and surrogate pairs spanning empty/non-empty argument boundaries remain exact.
  • Coercions occur once each in left-to-right order and abrupt completion stops later coercions.
  • Focused normal/TSan/OOM units, exact-parent Test262 concat accounting, threadfuzz, and the full unit gate pass without regressions.

Completed integration

CI run 33113309062 completed successfully on main commit 8a1398ffc04e9e30987f968693667c7271ca3ce1, a descendant containing this implementation. All 53 executed jobs succeeded (unit and TSan-unit shards, Linux no-GIL TSan, functional/no-GIL corpus gates, fuzz profiles, ABI, Wasm, Test262 parallel, and docs); the scheduled-only nightly job was skipped. Together with the measured local evidence in the comments, this completes this issue's acceptance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions