Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: b945d56c49fadf2d353b34095e062236fa5ea119 https://github.com/WebKit/WebKit/commit/b945d56c49fadf2d353b34095e062236fa5ea119 Author: Keith Miller <keith_mil...@apple.com> Date: 2024-07-14 (Sun, 14 Jul 2024)
Changed paths: M Source/JavaScriptCore/b3/B3LowerToAir.cpp M Source/JavaScriptCore/b3/B3LowerToAir32_64.cpp M Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp M Source/WTF/wtf/FixedVector.h M Source/WTF/wtf/FunctionTraits.h M Source/WTF/wtf/HashMap.h M Source/WTF/wtf/HashSet.h M Source/WTF/wtf/HashTable.h M Source/WTF/wtf/ListHashSet.h M Source/WTF/wtf/LocklessBag.h M Source/WTF/wtf/PriorityQueue.h M Source/WTF/wtf/RobinHoodHashTable.h M Source/WTF/wtf/StdLibExtras.h M Source/WTF/wtf/TinyPtrSet.h M Source/WTF/wtf/Vector.h M Source/WTF/wtf/glib/SysprofAnnotator.h M Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp M Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp M Source/WebCore/platform/xr/openxr/OpenXRSwapchain.cpp M Source/WebCore/rendering/EventRegion.cpp M Source/WebCore/svg/SVGToOTFFontConversion.cpp M Source/WebCore/workers/service/background-fetch/BackgroundFetchEngine.cpp M Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp M Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp M Source/WebKit/Platform/IPC/ThreadSafeObjectHeap.h M Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp M Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp M Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp Log Message: ----------- [WTF] Add Invocable concept for callbacks and start adoption https://bugs.webkit.org/show_bug.cgi?id=275398 rdar://129668606 Reviewed by Yusuke Suzuki. Right now in WebKit if you want to have a callback the standard practice is to write your function as: `template<typename Functor> foo(const Functor& callback)` or `foo(const auto& callback)` this tends to make it unclear what the expected signature of the callback is. Now that we have concepts it would have been nice to do something like: `foo(const std::invocable<...> auto& callback)` however that doesn't provide a clean way to declare the return type, as far as I could tell. This patch adds a new concept to WTF, which should, make this a bit cleaner, `Invocable`. Invocable can be used like the following: `foo(const Invocable<T(U, const V&, ...)> auto& callback)` This allows us to use function declaration like syntax to tell folks what type of callback we're expecting. In the process of adding Invocable concepts to arguments there were two other notable changes: 1) HashTable/Map/Set took functions by r-value reference, which seemed weird so I tried changing it. I then noticed that a lot of users of `ensure` were passing lambdas that capture variables by copy rather than reference. Since `ensure`'s use of the lambda is scoped to the call there's no reason to copy data in. 2) the HashTranslator versions of add now take a callback rather than a arbitrary r-value reference type. This makes the logic of the code a bit easier to follow and allows adding invocable concepts. Since the new wrapper lambdas are marked ALWAYS_INLINE_LAMBDA there shouldn't be any performance overhead. * Source/JavaScriptCore/b3/B3LowerToAir.cpp: * Source/JavaScriptCore/b3/B3LowerToAir32_64.cpp: * Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp: (JSC::DFG::TierUpCheckInjectionPhase::run): * Source/WTF/wtf/FixedVector.h: * Source/WTF/wtf/FunctionTraits.h: * Source/WTF/wtf/HashMap.h: (WTF::HashMapTranslator::hash): (WTF::HashMapTranslator::equal): (WTF::HashMapTranslator::translate): (WTF::HashMapEnsureTranslator::hash): (WTF::HashMapEnsureTranslator::equal): (WTF::HashMapEnsureTranslator::translate): (WTF::HashMapTranslatorAdapter::hash): (WTF::HashMapTranslatorAdapter::equal): (WTF::HashMapTranslatorAdapter::translate): (WTF::HashMapEnsureTranslatorAdapter::hash): (WTF::HashMapEnsureTranslatorAdapter::equal): (WTF::HashMapEnsureTranslatorAdapter::translate): (WTF::TableTraitsArg>::inlineAdd): (WTF::TableTraitsArg>::inlineEnsure): (WTF::TableTraitsArg>::ensure): (WTF::TableTraitsArg>::add): (WTF::Y>::removeIf): * Source/WTF/wtf/HashSet.h: (WTF::HashSetTranslator::hash): (WTF::HashSetTranslator::equal): (WTF::HashSetTranslator::translate): (WTF::HashSetTranslatorAdapter::hash): (WTF::HashSetTranslatorAdapter::equal): (WTF::HashSetTranslatorAdapter::translate): (WTF::HashSetEnsureTranslatorAdaptor::hash): (WTF::HashSetEnsureTranslatorAdaptor::equal): (WTF::HashSetEnsureTranslatorAdaptor::translate): (WTF::TableTraits>::ensure): (WTF::TableTraits>::add): (WTF::W>::removeIf): * Source/WTF/wtf/HashTable.h: (WTF::IdentityHashTranslator::hash): (WTF::IdentityHashTranslator::equal): (WTF::IdentityHashTranslator::translate): (WTF::HashTable::add): (WTF::KeyTraits>::addUniqueForInitialization): (WTF::KeyTraits>::add): (WTF::KeyTraits>::addPassingHashCode): (WTF::KeyTraits>::HashTable): * Source/WTF/wtf/ListHashSet.h: (WTF::U>::add): (WTF::U>::appendOrMoveToLast): (WTF::U>::prependOrMoveToFirst): (WTF::U>::insertBefore): * Source/WTF/wtf/LocklessBag.h: * Source/WTF/wtf/PriorityQueue.h: * Source/WTF/wtf/RobinHoodHashTable.h: (WTF::RobinHoodHashTable::add): (WTF::SizePolicy>::add): (WTF::SizePolicy>::addPassingHashCode): * Source/WTF/wtf/StdLibExtras.h: (WTF::requires): * Source/WTF/wtf/TinyPtrSet.h: (WTF::TinyPtrSet::forEach const): (WTF::TinyPtrSet::genericFilter): * Source/WTF/wtf/Vector.h: (WTF::Vector::containsIf const): (WTF::Vector::removeLast): (WTF::Malloc>::contains const): (WTF::Malloc>::findIf const): (WTF::Malloc>::find const): (WTF::Malloc>::reverseFind const): (WTF::Malloc>::reverseFindIf const): (WTF::Malloc>::appendIfNotContains): (WTF::Malloc>::appendUsingFunctor): (WTF::Malloc>::removeFirst): (WTF::Malloc>::removeFirstMatching): (WTF::Malloc>::removeLast): (WTF::Malloc>::removeLastMatching): (WTF::Malloc>::removeAll): (WTF::Malloc>::removeAllMatching): (WTF::Malloc>::map const): (WTF:: const const): (WTF::Malloc>::map const const): Deleted. (WTF::Malloc>::map const const const): Deleted. * Source/WTF/wtf/glib/SysprofAnnotator.h: * Source/WebCore/Modules/mediastream/gstreamer/GStreamerMediaEndpoint.cpp: (WebCore::GStreamerMediaEndpoint::mediaStreamFromRTCStream): * Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::mediaStreamFromRTCStreamId): * Source/WebCore/platform/xr/openxr/OpenXRSwapchain.cpp: (PlatformXR::OpenXRSwapchain::create): * Source/WebCore/rendering/EventRegion.cpp: (WebCore::EventRegionContext::uniteInteractionRegions): (WebCore::EventRegionContext::convertGuardContainersToInterationIfNeeded): * Source/WebCore/svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter): * Source/WebCore/workers/service/background-fetch/BackgroundFetchEngine.cpp: (WebCore::BackgroundFetchEngine::startBackgroundFetch): * Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp: (WebCore::BackgroundFetchManager::backgroundFetchRegistrationInstance): * Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp: (WebKit::GPUConnectionToWebProcess::createRenderingBackend): (WebKit::GPUConnectionToWebProcess::createGraphicsContextGL): (WebKit::GPUConnectionToWebProcess::createGPU): * Source/WebKit/Platform/IPC/ThreadSafeObjectHeap.h: (IPC::HeldType>::add): * Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp: (WebKit::DeviceIdHashSaltStorage::loadStorageFromDisk): (WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): * Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::TEST(WTF_HashMap, Ref_Value)): * Tools/TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp: (TestWebKitAPI::TEST(WTF_RobinHoodHashMap, Ref_Value)): Canonical link: https://commits.webkit.org/280952@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes