[WTF] Add ThreadSafeLazyUniquePtr#64619
Merged
webkit-commit-queue merged 1 commit intoMay 11, 2026
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash f31a772) Details
|
f31a772 to
a0282ad
Compare
Collaborator
|
EWS run on previous version of this PR (hash a0282ad) Details
|
a0282ad to
1c1a141
Compare
Collaborator
|
EWS run on previous version of this PR (hash 1c1a141) Details |
kmiller68
reviewed
May 11, 2026
Comment on lines
+52
to
+53
| template<typename Func> | ||
| T& ensure(NOESCAPE const Func& func) const |
Contributor
There was a problem hiding this comment.
Nit: Might be worth a comment along the lines of "In general there is no need to fence in func the compareExchangeStrong will ensure any stores to initialize the value will happen before the new pointer becomes visible."
1c1a141 to
bf3fa09
Compare
Collaborator
|
EWS run on current version of this PR (hash bf3fa09) Details
|
https://bugs.webkit.org/show_bug.cgi?id=314487 rdar://176696158 Reviewed by Keith Miller. Point of this class is adding handy class which uses the pattern, if (oldValue) return oldValue; newValue = factory(); if (oldValue = Strong-CAS-with-release(oldValue, nullptr, newValue)) { destroy newValue; return oldValue; } return newValue; This removes necessity of locking to publish a new value to the other thread. We speculatively create a new value and attempt to publish it, if it failed, we use the already published one. But otherwise, we install a newly created one. This is ownership wrapped version of Atomics.h's ensurePointer. This is something similar to standard C++'s `std::atomic<std::shared_ptr<T>>`. But it does not offer `std::atomic<std::unique_ptr<T>>`, so this is why this class exists. We use this class for IPIntSharedBytecode in RTT. We also remove storeStoreFence() since now we use "release" to publish a value via strong-CAS. * Source/JavaScriptCore/wasm/WasmTypeDefinition.cpp: (JSC::Wasm::RTT::ensureArgumINTBytecode const): (JSC::Wasm::RTT::ensureUINTBytecode const): (JSC::Wasm::RTT::ensureCallBytecode const): (JSC::Wasm::RTT::ensureTailCallBytecode const): * Source/JavaScriptCore/wasm/WasmTypeDefinition.h: * Source/WTF/WTF.xcodeproj/project.pbxproj: * Source/WTF/wtf/CMakeLists.txt: * Source/WTF/wtf/ThreadSafeLazyUniquePtr.h: Added. Canonical link: https://commits.webkit.org/313019@main
bf3fa09 to
1661ae2
Compare
Collaborator
|
Committed 313019@main (1661ae2): https://commits.webkit.org/313019@main Reviewed commits have been landed. Closing PR #64619 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 🧪 jsc
1661ae2
bf3fa09
🛠 mac🧪 wpe-wk2🧪 ios-wk2🧪 api-mac🧪 api-wpe🛠 gtk3-libwebrtc🧪 mac-wk1🛠 ios-safer-cpp🧪 mac-wk2🧪 gtk-wk2🧪 api-gtk🧪 mac-wk2-stress🧪 vision-wk2🧪 mac-intel-wk2🛠 mac-safer-cpp🧪 jsc-armv7-tests🛠 watch-sim