Add IC support for arguments.length
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 19:37:04 +0000 (19:37 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2016 19:37:04 +0000 (19:37 +0000)
commit6b30759b49844e3d9c8223e5d07b3a43352e3101
treeaa9c1c3acd1480f8d7dd247f9d19f0b5493ed3b9
parentd781bb2ed558eb0b29494f6a2d4b1eb48e89ca2d
Add IC support for arguments.length
https://bugs.webkit.org/show_bug.cgi?id=156389

Reviewed by Geoffrey Garen.
Source/JavaScriptCore:

This adds support for caching accesses to arguments.length for both DirectArguments and
ScopedArguments. In strict mode, we already cached these accesses since they were just
normal properties.

Amazingly, we also already supported caching of overridden arguments.length in both
DirectArguments and ScopedArguments. This is because when you override, the property gets
materialized as a normal JS property and the structure is changed.

This patch painstakingly preserves our previous caching of overridden length while
introducing caching of non-overridden length (i.e. the common case). In fact, we even cache
the case where it could either be overridden or not, since we just end up with an AccessCase
for each and they cascade to each other.

This is a >3x speed-up on microbenchmarks that do arguments.length in a polymorphic context.
Entirely monomorphic accesses were already handled by the DFG.

* bytecode/PolymorphicAccess.cpp:
(JSC::AccessGenerationState::calculateLiveRegistersForCallAndExceptionHandling):
(JSC::AccessCase::guardedByStructureCheck):
(JSC::AccessCase::generateWithGuard):
(JSC::AccessCase::generate):
(WTF::printInternal):
* bytecode/PolymorphicAccess.h:
* jit/ICStats.h:
* jit/JITOperations.cpp:
* jit/Repatch.cpp:
(JSC::tryCacheGetByID):
(JSC::tryCachePutByID):
(JSC::tryRepatchIn):
* tests/stress/direct-arguments-override-length-then-access-normal-length.js: Added.
(args):
(foo):
(result.foo):

LayoutTests:

* js/regress/direct-arguments-length-expected.txt: Added.
* js/regress/direct-arguments-length.html: Added.
* js/regress/direct-arguments-overridden-length-expected.txt: Added.
* js/regress/direct-arguments-overridden-length.html: Added.
* js/regress/direct-arguments-possibly-overridden-length-expected.txt: Added.
* js/regress/direct-arguments-possibly-overridden-length.html: Added.
* js/regress/scoped-arguments-length-expected.txt: Added.
* js/regress/scoped-arguments-length.html: Added.
* js/regress/scoped-arguments-overridden-length-expected.txt: Added.
* js/regress/scoped-arguments-overridden-length.html: Added.
* js/regress/scoped-arguments-possibly-overridden-length-expected.txt: Added.
* js/regress/scoped-arguments-possibly-overridden-length.html: Added.
* js/regress/script-tests/direct-arguments-length.js: Added.
(args):
* js/regress/script-tests/direct-arguments-overridden-length.js: Added.
(args):
* js/regress/script-tests/direct-arguments-possibly-overridden-length.js: Added.
(args1):
(args2):
* js/regress/script-tests/scoped-arguments-length.js: Added.
(args):
* js/regress/script-tests/scoped-arguments-overridden-length.js: Added.
(args):
* js/regress/script-tests/scoped-arguments-possibly-overridden-length.js: Added.
(args1):
(args2):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/js/regress/direct-arguments-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/direct-arguments-length.html [new file with mode: 0644]
LayoutTests/js/regress/direct-arguments-overridden-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/direct-arguments-overridden-length.html [new file with mode: 0644]
LayoutTests/js/regress/direct-arguments-possibly-overridden-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/direct-arguments-possibly-overridden-length.html [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-length.html [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-overridden-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-overridden-length.html [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-possibly-overridden-length-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/scoped-arguments-possibly-overridden-length.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/direct-arguments-length.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/direct-arguments-overridden-length.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/direct-arguments-possibly-overridden-length.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/put-by-id-transition-with-indexing-header.js
LayoutTests/js/regress/script-tests/scoped-arguments-length.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/scoped-arguments-overridden-length.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/scoped-arguments-possibly-overridden-length.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp
Source/JavaScriptCore/bytecode/PolymorphicAccess.h
Source/JavaScriptCore/jit/ICStats.h
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/jit/Repatch.cpp
Source/JavaScriptCore/tests/stress/direct-arguments-override-length-then-access-normal-length.js [new file with mode: 0644]