Parents: #473, #480
Related: #666, #777
Problem
The global String function always converts its result to canonical WTF-8 bytes and constructs a new StringCell. When the argument is already a String primitive, or object coercion produces one, ECMAScript ToString already has the exact immutable result Value. Re-encoding and rewrapping it adds avoidable allocation; with active flat Latin-1 storage it also adds an avoidable physical-to-canonical transcode.
new String(value) repeats the same string allocation before allocating the required wrapper object. The zero-argument path also allocates an empty StringCell despite the engine static empty-string value.
Scope
- Retain the exact StringData Value for primitive string inputs and object coercions that produce strings.
- Reuse the static empty string for the zero-argument call and construction paths.
- Preserve
String(symbol) descriptive-string behavior and the new String(symbol) TypeError.
- Preserve constructor prototype and wrapper String exotic semantics.
- Add allocation-exact witnesses for called and constructed flat Latin-1 paths.
No-workaround rules
- No storage forcing, hidden canonical copy, replacement characters, special input cache, or weakened WTF-8 validation.
- No stacks, queues, jobs, Promise, Worker, or Map/Set iterator changes.
Acceptance
Parents: #473, #480
Related: #666, #777
Problem
The global
Stringfunction always converts its result to canonical WTF-8 bytes and constructs a new StringCell. When the argument is already a String primitive, or object coercion produces one, ECMAScript ToString already has the exact immutable result Value. Re-encoding and rewrapping it adds avoidable allocation; with active flat Latin-1 storage it also adds an avoidable physical-to-canonical transcode.new String(value)repeats the same string allocation before allocating the required wrapper object. The zero-argument path also allocates an empty StringCell despite the engine static empty-string value.Scope
String(symbol)descriptive-string behavior and thenew String(symbol)TypeError.No-workaround rules
Acceptance
Stringreturns the existing StringData cell when ToString already yields one.Stringboxes that exact StringData cell and allocates only the required wrapper.