Skip to content

[JSC] Skip the generic lookup in get_by_val slow paths when the base has no prototype - #79733

Open
sosukesuzuki wants to merge 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/skip-the-generic-lookup-in-get-by-val-slow-paths-when-the-base-has-no-prototype
Open

sosukesuzuki wants to merge 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/skip-the-generic-lookup-in-get-by-val-slow-paths-when-the-base-has-no-prototype

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

3cf0fe9

[JSC] Skip the generic lookup in `get_by_val` slow paths when the base has no prototype
https://bugs.webkit.org/show_bug.cgi?id=330274

Reviewed by NOBODY (OOPS!).

The get_by_val slow paths try fastGetOwnProperty() first. When it misses,
they call the generic get(), which sets up a PropertySlot, looks the name up
in the same Structure again, finds no prototype to walk, and finally calls
parseIndex() on the name.

If the base is a JSFinalObject whose prototype is null, the result is already
known after the miss: an index-like name can only be an indexed property of the
base, and any other name is undefined. This patch returns that directly.

LLInt, Baseline and DFG each had their own copy of this lookup. This patch
moves DFG's getByValObject() to CommonSlowPaths and uses it from all of them.

This helps objects created with Object.create(null) and used as maps. A lookup
reaches these slow paths when the IC gave up, when the key is not an atom
string yet, when the key is an index-like string such as "123", and always in
LLInt.

                                                   Baseline                  Patched

get-by-val-null-prototype-index-string        197.0297+-5.9499     ^    168.7088+-6.4240        ^ definitely 1.1679x faster
get-by-val-null-prototype-dictionary-miss     245.5512+-9.7113     ^    156.2362+-5.4247        ^ definitely 1.5717x faster

Tests: JSTests/microbenchmarks/get-by-val-null-prototype-dictionary-miss.js
       JSTests/microbenchmarks/get-by-val-null-prototype-index-string.js
       JSTests/stress/get-by-val-null-prototype-miss.js

* JSTests/microbenchmarks/get-by-val-null-prototype-dictionary-miss.js: Added.
(get map):
(get countHits):
* JSTests/microbenchmarks/get-by-val-null-prototype-index-string.js: Added.
(sum):
* JSTests/stress/get-by-val-null-prototype-miss.js: Added.
(shouldBe):
(getString):
(getFreshString):
(getSymbol):
(getAny):
(fill):
(small):
(empty):
(dictionary):
(uncacheableDictionary):
(ordinary):
(inheriting):
(inheritingFromNullPrototype):
(inheritingFromProxy):
(get inheritingGetter):
(get inheritingFromProxyReturningReceiver):
(get polyProto.create.Constructor):
(get polyProto.create):
(get polyProto):
(frozen):
(array):
(func):
(withIndexedGetter.get return):
(withIndexedGetter):
(withGetter.get return):
(withGetter):
(check):
(let.throwing.fill.Object.create.get inherited):
(let.throwing.fill.Object.create.get missingSymbol):
(get catch):
(let.get of):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
(JSC::DFG::getByValObject): Deleted.
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::getByVal):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* Source/JavaScriptCore/runtime/CommonSlowPathsInlines.h:
(JSC::CommonSlowPaths::getByValObject):

3cf0fe9

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-cmake-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-cmake-debug ✅ 🧪 jsc-wpe
✅ 🧪 jsc-x86-64 ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp ✅ 🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

…e has no prototype

https://bugs.webkit.org/show_bug.cgi?id=330274

Reviewed by NOBODY (OOPS!).

The get_by_val slow paths try fastGetOwnProperty() first. When it misses,
they call the generic get(), which sets up a PropertySlot, looks the name up
in the same Structure again, finds no prototype to walk, and finally calls
parseIndex() on the name.

If the base is a JSFinalObject whose prototype is null, the result is already
known after the miss: an index-like name can only be an indexed property of the
base, and any other name is undefined. This patch returns that directly.

LLInt, Baseline and DFG each had their own copy of this lookup. This patch
moves DFG's getByValObject() to CommonSlowPaths and uses it from all of them.

This helps objects created with Object.create(null) and used as maps. A lookup
reaches these slow paths when the IC gave up, when the key is not an atom
string yet, when the key is an index-like string such as "123", and always in
LLInt.

                                                   Baseline                  Patched

get-by-val-null-prototype-index-string        197.0297+-5.9499     ^    168.7088+-6.4240        ^ definitely 1.1679x faster
get-by-val-null-prototype-dictionary-miss     245.5512+-9.7113     ^    156.2362+-5.4247        ^ definitely 1.5717x faster

Tests: JSTests/microbenchmarks/get-by-val-null-prototype-dictionary-miss.js
       JSTests/microbenchmarks/get-by-val-null-prototype-index-string.js
       JSTests/stress/get-by-val-null-prototype-miss.js

* JSTests/microbenchmarks/get-by-val-null-prototype-dictionary-miss.js: Added.
(get map):
(get countHits):
* JSTests/microbenchmarks/get-by-val-null-prototype-index-string.js: Added.
(sum):
* JSTests/stress/get-by-val-null-prototype-miss.js: Added.
(shouldBe):
(getString):
(getFreshString):
(getSymbol):
(getAny):
(fill):
(small):
(empty):
(dictionary):
(uncacheableDictionary):
(ordinary):
(inheriting):
(inheritingFromNullPrototype):
(inheritingFromProxy):
(get inheritingGetter):
(get inheritingFromProxyReturningReceiver):
(get polyProto.create.Constructor):
(get polyProto.create):
(get polyProto):
(frozen):
(array):
(func):
(withIndexedGetter.get return):
(withIndexedGetter):
(withGetter.get return):
(withGetter):
(check):
(let.throwing.fill.Object.create.get inherited):
(let.throwing.fill.Object.create.get missingSymbol):
(get catch):
(let.get of):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
(JSC::DFG::getByValObject): Deleted.
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::getByVal):
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
* Source/JavaScriptCore/runtime/CommonSlowPathsInlines.h:
(JSC::CommonSlowPaths::getByValObject):
@sosukesuzuki
sosukesuzuki requested a review from a team as a code owner November 5, 2026 05:50
@sosukesuzuki sosukesuzuki self-assigned this Nov 5, 2026
@sosukesuzuki sosukesuzuki added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants