Cache toString results for CoW arrays
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2018 03:07:28 +0000 (03:07 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2018 03:07:28 +0000 (03:07 +0000)
commitf7d2d4f8983165933de079e49df76de775372107
tree6c9108d90210d97b6791e1ea26541625d94a9d79
parent22b3adb34d8795ebd712f15eec9025a089a59d56
Cache toString results for CoW arrays
https://bugs.webkit.org/show_bug.cgi?id=186160

Reviewed by Keith Miller.

JSTests:

* microbenchmarks/to-string-on-cow-array.js: Added.
(foo):

Source/JavaScriptCore:

This patch makes it so that we cache the result of toString on
arrays with a CoW butterfly. This cache lives on Heap and is
cleared after every GC. We only cache the toString result when
the CoW butterfly doesn't have a hole (currently, all CoW arrays
have a hole, but this isn't an invariant we want to rely on). The
reason for this is that if there is a hole, the value may be loaded
from the prototype, and the cache may produce a stale result.

This is a ~4% speedup on the ML subtest in ARES. And is a ~1% overall
progression on ARES.

* heap/Heap.cpp:
(JSC::Heap::finalize):
(JSC::Heap::addCoreConstraints):
* heap/Heap.h:
* runtime/ArrayPrototype.cpp:
(JSC::canUseFastJoin):
(JSC::holesMustForwardToPrototype):
(JSC::isHole):
(JSC::containsHole):
(JSC::fastJoin):
(JSC::arrayProtoFuncToString):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232385 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/microbenchmarks/to-string-on-cow-array.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/runtime/ArrayPrototype.cpp