[JSC] Repeat string created from Array.prototype.join() take too much memory
authorguijemont@igalia.com <guijemont@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 08:50:48 +0000 (08:50 +0000)
committerguijemont@igalia.com <guijemont@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 08:50:48 +0000 (08:50 +0000)
commit4cd2a26f9c28a243e682516c13d27dc9d8b202a6
treefce2f1dcb302d4da52428c8c4b172b3b95f33e1c
parent3f14898e0a7a4351f20d29c467f0c474f5e71c84
[JSC] Repeat string created from Array.prototype.join() take too much memory
https://bugs.webkit.org/show_bug.cgi?id=193912

Reviewed by Saam Barati.

JSTests:

Added a test and a microbenchmark for corner cases of
Array.prototype.join() with an uninitialized array.

* microbenchmarks/array-prototype-join-uninitialized.js: Added.
* stress/array-prototype-join-uninitialized.js: Added.
(testArray):
(testABC):
(B):
(C):

Source/JavaScriptCore:

Added a fast case in Array.prototype.join when the array is
uninitialized.

* runtime/ArrayPrototype.cpp:
(JSC::canUseFastJoin):
(JSC::fastJoin):
* runtime/JSStringInlines.h:
(JSC::repeatCharacter): moved from StringPrototype.cpp
* runtime/StringPrototype.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242081 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/microbenchmarks/array-prototype-join-uninitialized.js [new file with mode: 0644]
JSTests/stress/array-prototype-join-uninitialized.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Source/JavaScriptCore/runtime/JSStringInlines.h
Source/JavaScriptCore/runtime/StringPrototype.cpp