Skip to content

[JSC] VariableEnvironment should avoid needless ref / deref of its keys - #79805

Open
sosukesuzuki wants to merge 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/JSC-VariableEnvironment-should-avoid-needless-ref-deref
Open

sosukesuzuki wants to merge 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/JSC-VariableEnvironment-should-avoid-needless-ref-deref

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

d30f2c6

[JSC] `VariableEnvironment` should avoid needless ref / deref of its keys
https://bugs.webkit.org/show_bug.cgi?id=330348

Reviewed by NOBODY (OOPS!).

The keys of VariableEnvironment's maps are PackedRefPtr, but their HashTraits is
the one for RefPtr. So every check for an empty or deleted key converts the key
to a temporary RefPtr, which costs an atomic ref and deref. Use the HashTraits
for PackedRefPtr instead.

Also, VariableEnvironment has no move assignment operator, so
`std::tie(lexicalEnvironment, functionStack) = popScope(...)` copies the whole
environment for each block. Add it.

* Source/JavaScriptCore/parser/VariableEnvironment.h:
* Source/JavaScriptCore/runtime/CachedTypes.cpp:

d30f2c6

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

…keys

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

Reviewed by NOBODY (OOPS!).

The keys of VariableEnvironment's maps are PackedRefPtr, but their HashTraits is
the one for RefPtr. So every check for an empty or deleted key converts the key
to a temporary RefPtr, which costs an atomic ref and deref. Use the HashTraits
for PackedRefPtr instead.

Also, VariableEnvironment has no move assignment operator, so
`std::tie(lexicalEnvironment, functionStack) = popScope(...)` copies the whole
environment for each block. Add it.

* Source/JavaScriptCore/parser/VariableEnvironment.h:
* Source/JavaScriptCore/runtime/CachedTypes.cpp:
@sosukesuzuki
sosukesuzuki requested a review from a team as a code owner November 5, 2026 18:08
@sosukesuzuki sosukesuzuki self-assigned this Nov 5, 2026
@sosukesuzuki sosukesuzuki added merge-queue Applied to send a pull request to merge-queue JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. and removed merge-queue Applied to send a pull request to merge-queue labels Nov 25, 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.

3 participants