[JSC] Make StringRecursionChecker faster in the simple cases without any recursion
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2015 06:23:31 +0000 (06:23 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2015 06:23:31 +0000 (06:23 +0000)
commit3024e1b25aec4cc7b3e4cf1baadb0031fada5a15
treef109eb76985eba3d05f910a5f1be49a623a646e8
parent6ba832807be532703e752d6e5598e0147772d804
[JSC] Make StringRecursionChecker faster in the simple cases without any recursion
https://bugs.webkit.org/show_bug.cgi?id=145102

Reviewed by Darin Adler.

Source/JavaScriptCore:

In general, the array targeted by Array.toString() or Array.join() are pretty
simple. In those simple cases, we spend as much time in StringRecursionChecker
as we do on the actual operation.

The reason for this is the HashSet stringRecursionCheckVisitedObjects used
to detect recursion. We are constantly adding and removing objects which
dirty buckets and force constant rehash.

This patch adds a simple shortcut for those simple case: in addition to the HashSet,
we keep a pointer to the root object of the recursion.
In the vast majority of cases, we no longer touch the HashSet at all.

This patch is a 12% progression on the overall score of ArrayWeighted.

* runtime/StringRecursionChecker.h:
(JSC::StringRecursionChecker::performCheck):
(JSC::StringRecursionChecker::~StringRecursionChecker):
* runtime/VM.h:

LayoutTests:

Improve the coverage a tiny bit.

* js/array-string-recursion-expected.txt: Added.
* js/array-string-recursion.html: Added.
* js/script-tests/array-string-recursion.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184447 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/js/array-string-recursion-expected.txt [new file with mode: 0644]
LayoutTests/js/array-string-recursion.html [new file with mode: 0644]
LayoutTests/js/script-tests/array-string-recursion.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/StringRecursionChecker.h
Source/JavaScriptCore/runtime/VM.h