Bug 197015

Summary: [JSC] Optimize cases of Array.prototype.join/toString on huge empty arrays which result into one-character repeats
Product: WebKit Reporter: Yacine Bandou <bandou.yacine>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bfulgham, ews-watchlist, fpizlo, guijemont, keith_miller, loic.yhuel, mark.lam, msaboff, olivier.blin, saam, ticaiolima, webkit-bug-importer, ysuzuki, zan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch bandou.yacine: review?, bandou.yacine: commit-queue?

Description Yacine Bandou 2019-04-17 09:30:22 PDT
Add a fast case in Array.prototype.join when the array is empty and it uses array_storage indexingType and the separator length is less than 2.
    
Use the same optimisation that is used in the case of UNDECIDED indexingType, in order allocate the final string in one step, instead of
appending in a loop which consumes additional temporary memory.
Comment 1 Yacine Bandou 2019-04-17 10:00:23 PDT
Created attachment 367638 [details]
Patch
Comment 2 Yacine Bandou 2019-04-17 10:23:02 PDT
Created attachment 367645 [details]
Patch
Comment 3 Olivier Blin 2019-04-18 00:20:26 PDT
For reference, this has been done to optimize the memory consumption of the "CPU Memory Allocation" YouTube test here:
https://ytlr-cert.appspot.com/2019/main.html?test_type=functional-test
Comment 4 Yusuke Suzuki 2019-04-18 00:49:58 PDT
Comment on attachment 367645 [details]
Patch

Can you add tests?, like

1. simple test
2. array storage with some element
3. array storage + accessors
4. and so on
Comment 5 Yacine Bandou 2019-05-10 09:33:43 PDT
Created attachment 369554 [details]
Patch
Comment 6 Radar WebKit Bug Importer 2022-07-01 15:39:09 PDT
<rdar://problem/96318246>