[JSC] Use fastJoin in Array#toString
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2017 11:50:21 +0000 (11:50 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Oct 2017 11:50:21 +0000 (11:50 +0000)
commit95b3ff28653274aa2e7c0882edc2a19b47460fd5
treed137e5bb6b20f4474d177d519cff905cad742c00
parent3f65074755ce17460021c069b5c41a39dd162d60
[JSC] Use fastJoin in Array#toString
https://bugs.webkit.org/show_bug.cgi?id=178062

Reviewed by Darin Adler.

JSTests:

* microbenchmarks/contiguous-array-to-string.js: Added.
(target):
* microbenchmarks/double-array-to-string.js: Added.
(target):
* microbenchmarks/int32-array-to-string.js: Added.
(target):

Source/JavaScriptCore:

Array#toString()'s fast path uses original join operation.
But this should use fastJoin if possible.
This patch adds a fast path using fastJoin in Array#toString.
And we also extend fastJoin to perform fast joining for int32
arrays.

                                     baseline                  patched

double-array-to-string          126.6157+-5.8625     ^    103.7343+-4.4968        ^ definitely 1.2206x faster
int32-array-to-string            64.7792+-2.6524           61.2390+-2.1749          might be 1.0578x faster
contiguous-array-to-string       62.6224+-2.6388     ^     56.9899+-2.0852        ^ definitely 1.0988x faster

* runtime/ArrayPrototype.cpp:
(JSC::fastJoin):
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
* runtime/JSStringJoiner.h:
(JSC::JSStringJoiner::appendWithoutSideEffects):
(JSC::JSStringJoiner::appendInt32):
(JSC::JSStringJoiner::appendDouble):

Source/WTF:

A bit cleaning up to use StringImpl::copyChars instead of
using for-loop directly.

* wtf/text/StringView.h:
(WTF::StringView::getCharactersWithUpconvert const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223834 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/microbenchmarks/contiguous-array-to-string.js [new file with mode: 0644]
JSTests/microbenchmarks/double-array-to-string.js [new file with mode: 0644]
JSTests/microbenchmarks/int32-array-to-string.js [new file with mode: 0644]
JSTests/stress/array-to-locale-string.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Source/JavaScriptCore/runtime/JSStringJoiner.h
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringView.h