[webkit-changes] [WebKit/WebKit] 5e5e74: [JSC] Handle Array with -1 in super common case
Yusuke Suzuki
noreply at github.com
Thu Feb 22 08:28:44 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5e5e7445e5ce0a8e5f9b846c57b2d65c64cd6f51
https://github.com/WebKit/WebKit/commit/5e5e7445e5ce0a8e5f9b846c57b2d65c64cd6f51
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2024-02-22 (Thu, 22 Feb 2024)
Changed paths:
A JSTests/microbenchmarks/array-negative-one.js
A JSTests/stress/array-negative-one-instance.js
A JSTests/stress/array-negative-one-prototype.js
A JSTests/stress/array-negative-one-prototype2.js
M Source/JavaScriptCore/dfg/DFGOperations.cpp
M Source/JavaScriptCore/jit/JITOperations.cpp
M Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
M Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
M Source/JavaScriptCore/runtime/CommonIdentifiers.h
M Source/JavaScriptCore/runtime/JSArray.h
M Source/JavaScriptCore/runtime/JSArrayInlines.h
M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
M Source/JavaScriptCore/runtime/JSGlobalObject.h
Log Message:
-----------
[JSC] Handle Array with -1 in super common case
https://bugs.webkit.org/show_bug.cgi?id=269901
rdar://123429794
Reviewed by Justin Michaud.
`array[-1]` access is actually common. For example,
while (item = array[--i]) {
...
}
code is written in the wild and using `array[-1]` => undefined access as a stop condition.
We should have enough fast access for that. In this patch, we set up `-1` property watchpoint for Array.prototype and Object.prototype,
and skip property lookup when we are just accessing normal Array's -1. We could improve this more generic way, but it looks like, most of cases
are just covered by this. Let's start with simple one.
ToT Patched
array-negative-one 29.5545+-0.6586 ^ 15.6126+-0.5059 ^ definitely 1.8930x faster
* JSTests/microbenchmarks/array-negative-one.js: Added.
(shouldBe):
(t):
* JSTests/stress/array-negative-one-instance.js: Added.
(shouldBe):
(t):
* JSTests/stress/array-negative-one-prototype.js: Added.
(shouldBe):
(t):
* JSTests/stress/array-negative-one-prototype2.js: Added.
(shouldBe):
(t):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::getByValCellInt):
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::getByVal):
(JSC::getByValWithThis):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* Source/JavaScriptCore/runtime/CommonIdentifiers.cpp:
(JSC::CommonIdentifiers::CommonIdentifiers):
* Source/JavaScriptCore/runtime/CommonIdentifiers.h:
* Source/JavaScriptCore/runtime/JSArray.h:
* Source/JavaScriptCore/runtime/JSArrayInlines.h:
(JSC::JSArray::definitelyNegativeOneMiss const):
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::setupAbsenceAdaptiveWatchpoint):
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::arrayNegativeOneWatchpointSet):
Canonical link: https://commits.webkit.org/275179@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list