Title: [276502] trunk/Source
Revision
276502
Author
[email protected]
Date
2021-04-23 09:55:47 -0700 (Fri, 23 Apr 2021)

Log Message

Improve our constructDeletedValue() template specializations
https://bugs.webkit.org/show_bug.cgi?id=224889

Reviewed by Darin Adler.

Source/WebCore:

Improve our constructDeletedValue() template specializations and make them more consistent:
- Use placement-new instead of object assignment since we don't want/need to destroy the
  existing object (since it is uninitialized).
- Do as little initialization as possible for performance reasons.

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::deletedValue): Deleted.
* Modules/indexeddb/IDBKeyData.h:
(WebCore::IDBKeyDataHashTraits::constructDeletedValue):
(WebCore::IDBKeyDataHashTraits::isDeletedValue):
(WebCore::IDBKeyData::isDeletedValue const): Deleted.
* Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
(WebCore::IDBResourceIdentifier::deletedValue): Deleted.
(WebCore::IDBResourceIdentifier::isHashTableDeletedValue const): Deleted.
* Modules/indexeddb/shared/IDBResourceIdentifier.h:
(WebCore::IDBResourceIdentifierHashTraits::constructDeletedValue):
(WebCore::IDBResourceIdentifierHashTraits::isDeletedValue):
* dom/MessagePortIdentifier.h:
(WTF::HashTraits<WebCore::MessagePortIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::MessagePortIdentifier>::isDeletedValue):
* history/BackForwardItemIdentifier.h:
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::BackForwardItemIdentifier>::isDeletedValue):
* layout/LayoutUnits.h:
(WTF::HashTraits<WebCore::Layout::SlotPosition>::constructDeletedValue):
(WTF::HashTraits<WebCore::Layout::SlotPosition>::isDeletedValue):
* loader/PrivateClickMeasurement.h:
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::matches const):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::constructDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::isDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::constructDeletedValue):
(WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::isDeletedValue):
(WebCore::PrivateClickMeasurement::SourceSite::isHashTableDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::deletedValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::deleteValue): Deleted.
(WebCore::PrivateClickMeasurement::SourceSite::isDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::isHashTableDeletedValue const): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::deletedValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::deleteValue): Deleted.
(WebCore::PrivateClickMeasurement::AttributionDestinationSite::isDeletedValue const): Deleted.
* page/ClientOrigin.h:
(WTF::HashTraits<WebCore::ClientOrigin>::constructDeletedValue):
* page/GlobalWindowIdentifier.h:
(WTF::HashTraits<WebCore::GlobalWindowIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::GlobalWindowIdentifier>::isDeletedValue):
* platform/Cookie.h:
(WTF::HashTraits<WebCore::Cookie>::constructDeletedValue):
(WebCore::Cookie::Cookie): Deleted.
* platform/graphics/FontCache.cpp:
(WebCore::FontPlatformDataCacheKeyHashTraits::constructDeletedValue):
* platform/graphics/FontCache.h:
(WebCore::FontCascadeCacheKeyHashTraits::constructDeletedValue):
* platform/graphics/IntPointHash.h:
(WTF::HashTraits<WebCore::IntPoint>::constructDeletedValue):
(WTF::HashTraits<WebCore::IntPoint>::isDeletedValue):
* rendering/CSSValueKey.h:
(WTF::HashTraits<WebCore::CSSValueKey>::constructDeletedValue):
* workers/service/ServiceWorkerClientIdentifier.h:
(WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::constructDeletedValue):
(WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::isDeletedValue):

Source/WebCore/PAL:

* pal/SessionID.h:
(WTF::HashTraits<PAL::SessionID>::constructDeletedValue):

Source/WebKit:

Improve our constructDeletedValue() template specializations and make them more consistent:
- Use placement-new instead of object assignment since we don't want/need to destroy the
  existing object (since it is uninitialized).
- Do as little initialization as possible for performance reasons.

* NetworkProcess/cache/NetworkCache.h:
(WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::constructDeletedValue):
(WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::isDeletedValue):
* Platform/IPC/StringReference.h:
(WTF::HashTraits<IPC::StringReference>::constructDeletedValue):
* Shared/CallbackID.h:
(WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
(WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):

Source/WebKitLegacy/mac:

Improve our constructDeletedValue() template specializations and make them more consistent:
- Use placement-new instead of object assignment since we don't want/need to destroy the
  existing object (since it is uninitialized).
- Do as little initialization as possible for performance reasons.

* History/BinaryPropertyList.cpp:
(IntegerArray::integers const):
(IntegerArray::size const):
(IntegerArrayHashTraits::constructDeletedValue):
(IntegerArrayHashTraits::isDeletedValue):
(IntegerArray::markDeleted): Deleted.
(IntegerArray::isDeletedValue const): Deleted.
(IntegerArray::deletedValueSize): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276501 => 276502)


--- trunk/Source/WebCore/ChangeLog	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/ChangeLog	2021-04-23 16:55:47 UTC (rev 276502)
@@ -1,3 +1,73 @@
+2021-04-23  Chris Dumez  <[email protected]>
+
+        Improve our constructDeletedValue() template specializations
+        https://bugs.webkit.org/show_bug.cgi?id=224889
+
+        Reviewed by Darin Adler.
+
+        Improve our constructDeletedValue() template specializations and make them more consistent:
+        - Use placement-new instead of object assignment since we don't want/need to destroy the
+          existing object (since it is uninitialized).
+        - Do as little initialization as possible for performance reasons.
+
+        * Modules/indexeddb/IDBKeyData.cpp:
+        (WebCore::IDBKeyData::deletedValue): Deleted.
+        * Modules/indexeddb/IDBKeyData.h:
+        (WebCore::IDBKeyDataHashTraits::constructDeletedValue):
+        (WebCore::IDBKeyDataHashTraits::isDeletedValue):
+        (WebCore::IDBKeyData::isDeletedValue const): Deleted.
+        * Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
+        (WebCore::IDBResourceIdentifier::deletedValue): Deleted.
+        (WebCore::IDBResourceIdentifier::isHashTableDeletedValue const): Deleted.
+        * Modules/indexeddb/shared/IDBResourceIdentifier.h:
+        (WebCore::IDBResourceIdentifierHashTraits::constructDeletedValue):
+        (WebCore::IDBResourceIdentifierHashTraits::isDeletedValue):
+        * dom/MessagePortIdentifier.h:
+        (WTF::HashTraits<WebCore::MessagePortIdentifier>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::MessagePortIdentifier>::isDeletedValue):
+        * history/BackForwardItemIdentifier.h:
+        (WTF::HashTraits<WebCore::BackForwardItemIdentifier>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::BackForwardItemIdentifier>::isDeletedValue):
+        * layout/LayoutUnits.h:
+        (WTF::HashTraits<WebCore::Layout::SlotPosition>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::Layout::SlotPosition>::isDeletedValue):
+        * loader/PrivateClickMeasurement.h:
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::matches const):
+        (WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::PrivateClickMeasurement::SourceSite>::isDeletedValue):
+        (WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite>::isDeletedValue):
+        (WebCore::PrivateClickMeasurement::SourceSite::isHashTableDeletedValue const): Deleted.
+        (WebCore::PrivateClickMeasurement::SourceSite::deletedValue): Deleted.
+        (WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue): Deleted.
+        (WebCore::PrivateClickMeasurement::SourceSite::deleteValue): Deleted.
+        (WebCore::PrivateClickMeasurement::SourceSite::isDeletedValue const): Deleted.
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::isHashTableDeletedValue const): Deleted.
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::deletedValue): Deleted.
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue): Deleted.
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::deleteValue): Deleted.
+        (WebCore::PrivateClickMeasurement::AttributionDestinationSite::isDeletedValue const): Deleted.
+        * page/ClientOrigin.h:
+        (WTF::HashTraits<WebCore::ClientOrigin>::constructDeletedValue):
+        * page/GlobalWindowIdentifier.h:
+        (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::GlobalWindowIdentifier>::isDeletedValue):
+        * platform/Cookie.h:
+        (WTF::HashTraits<WebCore::Cookie>::constructDeletedValue):
+        (WebCore::Cookie::Cookie): Deleted.
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontPlatformDataCacheKeyHashTraits::constructDeletedValue):
+        * platform/graphics/FontCache.h:
+        (WebCore::FontCascadeCacheKeyHashTraits::constructDeletedValue):
+        * platform/graphics/IntPointHash.h:
+        (WTF::HashTraits<WebCore::IntPoint>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::IntPoint>::isDeletedValue):
+        * rendering/CSSValueKey.h:
+        (WTF::HashTraits<WebCore::CSSValueKey>::constructDeletedValue):
+        * workers/service/ServiceWorkerClientIdentifier.h:
+        (WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::constructDeletedValue):
+        (WTF::HashTraits<WebCore::ServiceWorkerClientIdentifier>::isDeletedValue):
+
 2021-04-23  Xabier Rodriguez Calvar  <[email protected]>
 
         [GStreamer][EME] cbcs fixes

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (276501 => 276502)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2021-04-23 16:55:47 UTC (rev 276502)
@@ -420,14 +420,6 @@
     m_isNull = false;
 }
 
-IDBKeyData IDBKeyData::deletedValue()
-{
-    IDBKeyData result;
-    result.m_isNull = false;
-    result.m_isDeletedValue = true;
-    return result;
-}
-
 bool IDBKeyData::isValid() const
 {
     if (m_type == IndexedDB::KeyType::Invalid)

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h (276501 => 276502)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -152,9 +152,6 @@
         return StringHasher::hashMemory(hashCodes.data(), hashCodes.size() * sizeof(unsigned));
     }
 
-    static IDBKeyData deletedValue();
-    bool isDeletedValue() const { return m_isDeletedValue; }
-
     String string() const
     {
         ASSERT(m_type == IndexedDB::KeyType::String);
@@ -188,6 +185,8 @@
     size_t size() const;
 
 private:
+    friend struct IDBKeyDataHashTraits;
+
     static void isolatedCopy(const IDBKeyData& source, IDBKeyData& destination);
 
     IndexedDB::KeyType m_type;
@@ -207,17 +206,9 @@
     static const bool emptyValueIsZero = false;
     static const bool hasIsEmptyValueFunction = true;
 
-    static void constructDeletedValue(IDBKeyData& key)
-    {
-        new (&key) IDBKeyData;
-        key = IDBKeyData::deletedValue();
-    }
+    static void constructDeletedValue(IDBKeyData& key) { key.m_isDeletedValue = true; }
+    static bool isDeletedValue(const IDBKeyData& key) { return key.m_isDeletedValue; }
 
-    static bool isDeletedValue(const IDBKeyData& key)
-    {
-        return key.isDeletedValue();
-    }
-
     static IDBKeyData emptyValue()
     {
         return IDBKeyData();

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp (276501 => 276502)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp	2021-04-23 16:55:47 UTC (rev 276502)
@@ -84,16 +84,6 @@
     return IDBResourceIdentifier({ }, 0);
 }
 
-IDBResourceIdentifier IDBResourceIdentifier::deletedValue()
-{
-    return IDBResourceIdentifier(IDBConnectionIdentifier { WTF::HashTableDeletedValue }, std::numeric_limits<uint64_t>::max());
-}
-
-bool IDBResourceIdentifier::isHashTableDeletedValue() const
-{
-    return m_idbConnectionIdentifier.isHashTableDeletedValue() && m_resourceNumber == std::numeric_limits<uint64_t>::max();
-}
-
 #if !LOG_DISABLED
 
 String IDBResourceIdentifier::loggingString() const

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h (276501 => 276502)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -49,9 +49,6 @@
     IDBResourceIdentifier(const IDBClient::IDBConnectionProxy&, const IDBRequest&);
     explicit IDBResourceIdentifier(const IDBServer::IDBConnectionToClient&);
 
-    static IDBResourceIdentifier deletedValue();
-    WEBCORE_EXPORT bool isHashTableDeletedValue() const;
-
     static IDBResourceIdentifier emptyValue();
     bool isEmpty() const
     {
@@ -84,6 +81,8 @@
     template<class Decoder> static WARN_UNUSED_RETURN bool decode(Decoder&, IDBResourceIdentifier&);
 
 private:
+    friend struct IDBResourceIdentifierHashTraits;
+
     IDBResourceIdentifier(IDBConnectionIdentifier, uint64_t resourceIdentifier);
     IDBConnectionIdentifier m_idbConnectionIdentifier;
     uint64_t m_resourceNumber { 0 };
@@ -111,12 +110,12 @@
 
     static void constructDeletedValue(IDBResourceIdentifier& identifier)
     {
-        identifier = IDBResourceIdentifier::deletedValue();
+        new (NotNull, &identifier.m_idbConnectionIdentifier) IDBConnectionIdentifier(WTF::HashTableDeletedValue);
     }
 
     static bool isDeletedValue(const IDBResourceIdentifier& identifier)
     {
-        return identifier.isHashTableDeletedValue();
+        return identifier.m_idbConnectionIdentifier.isHashTableDeletedValue();
     }
 };
 

Modified: trunk/Source/WebCore/PAL/ChangeLog (276501 => 276502)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-04-23 16:55:47 UTC (rev 276502)
@@ -1,3 +1,13 @@
+2021-04-23  Chris Dumez  <[email protected]>
+
+        Improve our constructDeletedValue() template specializations
+        https://bugs.webkit.org/show_bug.cgi?id=224889
+
+        Reviewed by Darin Adler.
+
+        * pal/SessionID.h:
+        (WTF::HashTraits<PAL::SessionID>::constructDeletedValue):
+
 2021-04-20  Brent Fulgham  <[email protected]>
 
         [Cocoa] Prevent GPU and WebContent processes from attempting to connect to the AppSSO service 

Modified: trunk/Source/WebCore/PAL/pal/SessionID.h (276501 => 276502)


--- trunk/Source/WebCore/PAL/pal/SessionID.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/PAL/pal/SessionID.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -115,7 +115,7 @@
 
 template<> struct HashTraits<PAL::SessionID> : GenericHashTraits<PAL::SessionID> {
     static PAL::SessionID emptyValue() { return PAL::SessionID(HashTableEmptyValue); }
-    static void constructDeletedValue(PAL::SessionID& slot) { slot = PAL::SessionID(HashTableDeletedValue); }
+    static void constructDeletedValue(PAL::SessionID& slot) { new (NotNull, &slot) PAL::SessionID(HashTableDeletedValue); }
     static bool isDeletedValue(const PAL::SessionID& slot) { return slot.isHashTableDeletedValue(); }
 };
 

Modified: trunk/Source/WebCore/dom/MessagePortIdentifier.h (276501 => 276502)


--- trunk/Source/WebCore/dom/MessagePortIdentifier.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/dom/MessagePortIdentifier.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -100,9 +100,9 @@
 template<> struct HashTraits<WebCore::MessagePortIdentifier> : GenericHashTraits<WebCore::MessagePortIdentifier> {
     static WebCore::MessagePortIdentifier emptyValue() { return { }; }
 
-    static void constructDeletedValue(WebCore::MessagePortIdentifier& slot) { slot.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(std::numeric_limits<uint64_t>::max()); }
+    static void constructDeletedValue(WebCore::MessagePortIdentifier& slot) { new (NotNull, &slot.processIdentifier) WebCore::ProcessIdentifier(WTF::HashTableDeletedValue); }
 
-    static bool isDeletedValue(const WebCore::MessagePortIdentifier& slot) { return slot.processIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
+    static bool isDeletedValue(const WebCore::MessagePortIdentifier& slot) { return slot.processIdentifier.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::MessagePortIdentifier> : MessagePortIdentifierHash { };

Modified: trunk/Source/WebCore/history/BackForwardItemIdentifier.h (276501 => 276502)


--- trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -114,9 +114,9 @@
 template<> struct HashTraits<WebCore::BackForwardItemIdentifier> : GenericHashTraits<WebCore::BackForwardItemIdentifier> {
     static WebCore::BackForwardItemIdentifier emptyValue() { return { }; }
 
-    static void constructDeletedValue(WebCore::BackForwardItemIdentifier& slot) { slot.processIdentifier = ObjectIdentifier<WebCore::ProcessIdentifierType>(HashTableDeletedValue); }
+    static void constructDeletedValue(WebCore::BackForwardItemIdentifier& slot) { new (NotNull, &slot.processIdentifier) WebCore::ProcessIdentifier(WTF::HashTableDeletedValue); }
 
-    static bool isDeletedValue(const WebCore::BackForwardItemIdentifier& slot) { return slot.processIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
+    static bool isDeletedValue(const WebCore::BackForwardItemIdentifier& slot) { return slot.processIdentifier.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::BackForwardItemIdentifier> : BackForwardItemIdentifierHash { };

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (276501 => 276502)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -244,8 +244,8 @@
 template<> struct HashTraits<WebCore::Layout::SlotPosition> : GenericHashTraits<WebCore::Layout::SlotPosition> {
     static WebCore::Layout::SlotPosition emptyValue() { return WebCore::Layout::SlotPosition(0, std::numeric_limits<size_t>::max()); }
 
-    static void constructDeletedValue(WebCore::Layout::SlotPosition& slot) { slot = WebCore::Layout::SlotPosition(std::numeric_limits<size_t>::max(), 0); }
-    static bool isDeletedValue(const WebCore::Layout::SlotPosition& slot) { return slot == WebCore::Layout::SlotPosition(std::numeric_limits<size_t>::max(), 0); }
+    static void constructDeletedValue(WebCore::Layout::SlotPosition& slot) { slot.column = std::numeric_limits<size_t>::max(); }
+    static bool isDeletedValue(const WebCore::Layout::SlotPosition& slot) { return slot.column == std::numeric_limits<size_t>::max(); }
 };
 template<> struct DefaultHash<WebCore::Layout::SlotPosition> : SlotPositionHash { };
 }

Modified: trunk/Source/WebCore/loader/PrivateClickMeasurement.h (276501 => 276502)


--- trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/loader/PrivateClickMeasurement.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -84,11 +84,6 @@
         {
         }
 
-        explicit SourceSite(WTF::HashTableDeletedValueType)
-            : registrableDomain(WTF::HashTableDeletedValue)
-        {
-        }
-
         bool operator==(const SourceSite& other) const
         {
             return registrableDomain == other.registrableDomain;
@@ -99,32 +94,6 @@
             return registrableDomain.matches(url);
         }
 
-        bool isHashTableDeletedValue() const
-        {
-            return registrableDomain.isHashTableDeletedValue();
-        }
-
-        static SourceSite deletedValue()
-        {
-            return SourceSite { WTF::HashTableDeletedValue };
-        }
-
-        static void constructDeletedValue(SourceSite& sourceSite)
-        {
-            new (&sourceSite) SourceSite;
-            sourceSite = SourceSite::deletedValue();
-        }
-
-        void deleteValue()
-        {
-            registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue };
-        }
-
-        bool isDeletedValue() const
-        {
-            return isHashTableDeletedValue();
-        }
-
         RegistrableDomain registrableDomain;
     };
 
@@ -149,11 +118,6 @@
         {
         }
 
-        explicit AttributionDestinationSite(WTF::HashTableDeletedValueType)
-            : registrableDomain { WTF::HashTableDeletedValue }
-        {
-        }
-
         explicit AttributionDestinationSite(RegistrableDomain&& domain)
             : registrableDomain { WTFMove(domain) }
         {
@@ -168,33 +132,7 @@
         {
             return registrableDomain == RegistrableDomain { url };
         }
-        
-        bool isHashTableDeletedValue() const
-        {
-            return registrableDomain.isHashTableDeletedValue();
-        }
 
-        static AttributionDestinationSite deletedValue()
-        {
-            return AttributionDestinationSite { WTF::HashTableDeletedValue };
-        }
-
-        static void constructDeletedValue(AttributionDestinationSite& destinationSite)
-        {
-            new (&destinationSite) AttributionDestinationSite;
-            destinationSite = AttributionDestinationSite::deletedValue();
-        }
-
-        void deleteValue()
-        {
-            registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue };
-        }
-
-        bool isDeletedValue() const
-        {
-            return isHashTableDeletedValue();
-        }
-
         RegistrableDomain registrableDomain;
     };
 
@@ -584,14 +522,14 @@
 template<> struct DefaultHash<WebCore::PrivateClickMeasurement::SourceSite> : WebCore::PrivateClickMeasurement::SourceSiteHash { };
 template<> struct HashTraits<WebCore::PrivateClickMeasurement::SourceSite> : GenericHashTraits<WebCore::PrivateClickMeasurement::SourceSite> {
     static WebCore::PrivateClickMeasurement::SourceSite emptyValue() { return { }; }
-    static void constructDeletedValue(WebCore::PrivateClickMeasurement::SourceSite& slot) { WebCore::PrivateClickMeasurement::SourceSite::constructDeletedValue(slot); }
-    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::SourceSite& slot) { return slot.isDeletedValue(); }
+    static void constructDeletedValue(WebCore::PrivateClickMeasurement::SourceSite& slot) { new (NotNull, &slot.registrableDomain) WebCore::RegistrableDomain(WTF::HashTableDeletedValue); }
+    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::SourceSite& slot) { return slot.registrableDomain.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::PrivateClickMeasurement::AttributionDestinationSite> : WebCore::PrivateClickMeasurement::AttributionDestinationSiteHash { };
 template<> struct HashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite> : GenericHashTraits<WebCore::PrivateClickMeasurement::AttributionDestinationSite> {
     static WebCore::PrivateClickMeasurement::AttributionDestinationSite emptyValue() { return { }; }
-    static void constructDeletedValue(WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { WebCore::PrivateClickMeasurement::AttributionDestinationSite::constructDeletedValue(slot); }
-    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { return slot.isDeletedValue(); }
+    static void constructDeletedValue(WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { new (NotNull, &slot.registrableDomain) WebCore::RegistrableDomain(WTF::HashTableDeletedValue); }
+    static bool isDeletedValue(const WebCore::PrivateClickMeasurement::AttributionDestinationSite& slot) { return slot.registrableDomain.isHashTableDeletedValue(); }
 };
 }

Modified: trunk/Source/WebCore/page/ClientOrigin.h (276501 => 276502)


--- trunk/Source/WebCore/page/ClientOrigin.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/page/ClientOrigin.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -102,7 +102,7 @@
 template<> struct HashTraits<WebCore::ClientOrigin> : GenericHashTraits<WebCore::ClientOrigin> {
     static WebCore::ClientOrigin emptyValue() { return WebCore::ClientOrigin::emptyKey(); }
 
-    static void constructDeletedValue(WebCore::ClientOrigin& slot) { slot.topOrigin = WebCore::SecurityOriginData(HashTableDeletedValue); }
+    static void constructDeletedValue(WebCore::ClientOrigin& slot) { new (NotNull, &slot.topOrigin) WebCore::SecurityOriginData(WTF::HashTableDeletedValue); }
     static bool isDeletedValue(const WebCore::ClientOrigin& slot) { return slot.topOrigin.isHashTableDeletedValue(); }
 };
 

Modified: trunk/Source/WebCore/page/GlobalWindowIdentifier.h (276501 => 276502)


--- trunk/Source/WebCore/page/GlobalWindowIdentifier.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/page/GlobalWindowIdentifier.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -94,8 +94,8 @@
 template<> struct HashTraits<WebCore::GlobalWindowIdentifier> : GenericHashTraits<WebCore::GlobalWindowIdentifier> {
     static WebCore::GlobalWindowIdentifier emptyValue() { return { }; }
 
-    static void constructDeletedValue(WebCore::GlobalWindowIdentifier& slot) { slot.windowIdentifier = makeObjectIdentifier<WebCore::WindowIdentifierType>(std::numeric_limits<uint64_t>::max()); }
-    static bool isDeletedValue(const WebCore::GlobalWindowIdentifier& slot) { return slot.windowIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
+    static void constructDeletedValue(WebCore::GlobalWindowIdentifier& slot) { new (NotNull, &slot.windowIdentifier) WebCore::WindowIdentifier(WTF::HashTableDeletedValue); }
+    static bool isDeletedValue(const WebCore::GlobalWindowIdentifier& slot) { return slot.windowIdentifier.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::GlobalWindowIdentifier> : GlobalWindowIdentifierHash { };

Modified: trunk/Source/WebCore/platform/Cookie.h (276501 => 276502)


--- trunk/Source/WebCore/platform/Cookie.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/platform/Cookie.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -43,10 +43,6 @@
 
 struct Cookie {
     Cookie() = default;
-    Cookie(WTF::HashTableDeletedValueType)
-        : name(WTF::HashTableDeletedValue)
-    {
-    }
 
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static Optional<Cookie> decode(Decoder&);
@@ -173,7 +169,7 @@
     template<> struct DefaultHash<WebCore::Cookie> : WebCore::CookieHash { };
     template<> struct HashTraits<WebCore::Cookie> : GenericHashTraits<WebCore::Cookie> {
         static WebCore::Cookie emptyValue() { return { }; }
-        static void constructDeletedValue(WebCore::Cookie& slot) { slot = WebCore::Cookie(WTF::HashTableDeletedValue); }
+        static void constructDeletedValue(WebCore::Cookie& slot) { new (NotNull, &slot.name) String(WTF::HashTableDeletedValue); }
         static bool isDeletedValue(const WebCore::Cookie& slot) { return slot.name.isHashTableDeletedValue(); }
 
         static const bool hasIsEmptyValueFunction = true;

Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (276501 => 276502)


--- trunk/Source/WebCore/platform/graphics/FontCache.cpp	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp	2021-04-23 16:55:47 UTC (rev 276502)
@@ -99,7 +99,7 @@
     static constexpr bool emptyValueIsZero = false;
     static void constructDeletedValue(FontPlatformDataCacheKey& slot)
     {
-        new (NotNull, &slot) FontPlatformDataCacheKey { FontDescriptionKey { WTF::HashTableDeletedValue }, { }, { }, { } };
+        new (NotNull, &slot.descriptionKey) FontDescriptionKey(WTF::HashTableDeletedValue);
     }
     static bool isDeletedValue(const FontPlatformDataCacheKey& key)
     {

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (276501 => 276502)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -207,7 +207,7 @@
 
 struct FontCascadeCacheKeyHashTraits : HashTraits<FontCascadeCacheKey> {
     static FontCascadeCacheKey emptyValue() { return { }; }
-    static void constructDeletedValue(FontCascadeCacheKey& slot) { new (NotNull, &slot) FontCascadeCacheKey { FontDescriptionKey { WTF::HashTableDeletedValue }, { }, { }, { } }; }
+    static void constructDeletedValue(FontCascadeCacheKey& slot) { new (NotNull, &slot.fontDescriptionKey) FontDescriptionKey(WTF::HashTableDeletedValue); }
     static bool isDeletedValue(const FontCascadeCacheKey& key) { return key.fontDescriptionKey.isHashTableDeletedValue(); }
 };
 

Modified: trunk/Source/WebCore/platform/graphics/IntPointHash.h (276501 => 276502)


--- trunk/Source/WebCore/platform/graphics/IntPointHash.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/platform/graphics/IntPointHash.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -35,8 +35,8 @@
 template<> struct HashTraits<WebCore::IntPoint> : GenericHashTraits<WebCore::IntPoint> {
     static WebCore::IntPoint emptyValue() { return WebCore::IntPoint(0, std::numeric_limits<int>::min()); }
     
-    static void constructDeletedValue(WebCore::IntPoint& slot) { slot = WebCore::IntPoint(std::numeric_limits<int>::min(), 0); }
-    static bool isDeletedValue(const WebCore::IntPoint& slot) { return slot == WebCore::IntPoint(std::numeric_limits<int>::min(), 0); }
+    static void constructDeletedValue(WebCore::IntPoint& slot) { slot.setX(std::numeric_limits<int>::min()); }
+    static bool isDeletedValue(const WebCore::IntPoint& slot) { return slot.x() == std::numeric_limits<int>::min(); }
 };
 template<> struct DefaultHash<WebCore::IntPoint> : IntPointHash { };
 

Modified: trunk/Source/WebCore/rendering/CSSValueKey.h (276501 => 276502)


--- trunk/Source/WebCore/rendering/CSSValueKey.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/rendering/CSSValueKey.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -89,7 +89,7 @@
 
 template<> struct HashTraits<WebCore::CSSValueKey> : GenericHashTraits<WebCore::CSSValueKey> {
     static WebCore::CSSValueKey emptyValue() { return WebCore::CSSValueKey { WebCore::CSSValueInvalid, false, false}; }
-    static void constructDeletedValue(WebCore::CSSValueKey& slot) { slot = WebCore::CSSValueKey { WebCore::CSSValueInvalid, true, true};}
+    static void constructDeletedValue(WebCore::CSSValueKey& slot) { new (NotNull, &slot) WebCore::CSSValueKey { WebCore::CSSValueInvalid, true, true}; }
     static bool isDeletedValue(const WebCore::CSSValueKey& slot) { return slot.cssValueID == WebCore::CSSValueInvalid && slot.useDarkAppearance && slot.useElevatedUserInterfaceLevel; }
 };
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h (276501 => 276502)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -109,9 +109,9 @@
 template<> struct HashTraits<WebCore::ServiceWorkerClientIdentifier> : GenericHashTraits<WebCore::ServiceWorkerClientIdentifier> {
     static WebCore::ServiceWorkerClientIdentifier emptyValue() { return { }; }
 
-    static void constructDeletedValue(WebCore::ServiceWorkerClientIdentifier& slot) { slot.serverConnectionIdentifier = makeObjectIdentifier<WebCore::SWServerConnectionIdentifierType>(std::numeric_limits<uint64_t>::max()); }
+    static void constructDeletedValue(WebCore::ServiceWorkerClientIdentifier& slot) { new (NotNull, &slot.serverConnectionIdentifier) WebCore::SWServerConnectionIdentifier(HashTableDeletedValue); }
 
-    static bool isDeletedValue(const WebCore::ServiceWorkerClientIdentifier& slot) { return slot.serverConnectionIdentifier.toUInt64() == std::numeric_limits<uint64_t>::max(); }
+    static bool isDeletedValue(const WebCore::ServiceWorkerClientIdentifier& slot) { return slot.serverConnectionIdentifier.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebCore::ServiceWorkerClientIdentifier> : ServiceWorkerClientIdentifierHash { };

Modified: trunk/Source/WebKit/ChangeLog (276501 => 276502)


--- trunk/Source/WebKit/ChangeLog	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKit/ChangeLog	2021-04-23 16:55:47 UTC (rev 276502)
@@ -1,3 +1,24 @@
+2021-04-23  Chris Dumez  <[email protected]>
+
+        Improve our constructDeletedValue() template specializations
+        https://bugs.webkit.org/show_bug.cgi?id=224889
+
+        Reviewed by Darin Adler.
+
+        Improve our constructDeletedValue() template specializations and make them more consistent:
+        - Use placement-new instead of object assignment since we don't want/need to destroy the
+          existing object (since it is uninitialized).
+        - Do as little initialization as possible for performance reasons.
+
+        * NetworkProcess/cache/NetworkCache.h:
+        (WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::constructDeletedValue):
+        (WTF::HashTraits<WebKit::NetworkCache::GlobalFrameID>::isDeletedValue):
+        * Platform/IPC/StringReference.h:
+        (WTF::HashTraits<IPC::StringReference>::constructDeletedValue):
+        * Shared/CallbackID.h:
+        (WTF::HashTraits<WebKit::CallbackID>::constructDeletedValue):
+        (WTF::HashTraits<WebKit::CallbackID>::isDeletedValue):
+
 2021-04-23  Youenn Fablet  <[email protected]>
 
         Handle rotation correctly in WebRTC GPUProcess rendering pipeline

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h (276501 => 276502)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -83,9 +83,9 @@
 template<> struct HashTraits<WebKit::NetworkCache::GlobalFrameID> : GenericHashTraits<WebKit::NetworkCache::GlobalFrameID> {
     static WebKit::NetworkCache::GlobalFrameID emptyValue() { return { }; }
 
-    static void constructDeletedValue(WebKit::NetworkCache::GlobalFrameID& slot) { slot.webPageID = makeObjectIdentifier<WebCore::PageIdentifierType>(std::numeric_limits<uint64_t>::max()); }
+    static void constructDeletedValue(WebKit::NetworkCache::GlobalFrameID& slot) { new (NotNull, &slot.webPageID) WebCore::PageIdentifier(WTF::HashTableDeletedValue); }
 
-    static bool isDeletedValue(const WebKit::NetworkCache::GlobalFrameID& slot) { return slot.webPageID.toUInt64() == std::numeric_limits<uint64_t>::max(); }
+    static bool isDeletedValue(const WebKit::NetworkCache::GlobalFrameID& slot) { return slot.webPageID.isHashTableDeletedValue(); }
 };
 
 template<> struct DefaultHash<WebKit::NetworkCache::GlobalFrameID> : GlobalFrameIDHash { };

Modified: trunk/Source/WebKit/Platform/IPC/StringReference.h (276501 => 276502)


--- trunk/Source/WebKit/Platform/IPC/StringReference.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKit/Platform/IPC/StringReference.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -73,6 +73,8 @@
     };
 
 private:
+    friend struct HashTraits<IPC::StringReference>;
+
     const char* m_data;
     size_t m_size;
 };
@@ -101,7 +103,7 @@
 
 template<> struct HashTraits<IPC::StringReference> : GenericHashTraits<IPC::StringReference> {
     static const bool emptyValueIsZero = 0;
-    static void constructDeletedValue(IPC::StringReference& stringReference) { stringReference = IPC::StringReference(0, std::numeric_limits<size_t>::max()); }
+    static void constructDeletedValue(IPC::StringReference& stringReference) { stringReference.m_size = std::numeric_limits<size_t>::max(); }
     static bool isDeletedValue(const IPC::StringReference& stringReference) { return stringReference.size() == std::numeric_limits<size_t>::max(); }
 };
 

Modified: trunk/Source/WebKit/Shared/CallbackID.h (276501 => 276502)


--- trunk/Source/WebKit/Shared/CallbackID.h	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKit/Shared/CallbackID.h	2021-04-23 16:55:47 UTC (rev 276502)
@@ -118,8 +118,8 @@
 };
 template<> struct HashTraits<WebKit::CallbackID> : GenericHashTraits<WebKit::CallbackID> {
     static WebKit::CallbackID emptyValue() { return WebKit::CallbackID(); }
-    static void constructDeletedValue(WebKit::CallbackID& slot) { slot = WebKit::CallbackID(std::numeric_limits<uint64_t>::max()); }
-    static bool isDeletedValue(const WebKit::CallbackID& slot) { return slot.m_id == std::numeric_limits<uint64_t>::max(); }
+    static void constructDeletedValue(WebKit::CallbackID& slot) { HashTraits<uint64_t>::constructDeletedValue(slot.m_id); }
+    static bool isDeletedValue(const WebKit::CallbackID& slot) { return HashTraits<uint64_t>::isDeletedValue(slot.m_id); }
 };
 template<> struct DefaultHash<WebKit::CallbackID> : CallbackIDHash { };
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (276501 => 276502)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-04-23 16:55:47 UTC (rev 276502)
@@ -1,3 +1,24 @@
+2021-04-23  Chris Dumez  <[email protected]>
+
+        Improve our constructDeletedValue() template specializations
+        https://bugs.webkit.org/show_bug.cgi?id=224889
+
+        Reviewed by Darin Adler.
+
+        Improve our constructDeletedValue() template specializations and make them more consistent:
+        - Use placement-new instead of object assignment since we don't want/need to destroy the
+          existing object (since it is uninitialized).
+        - Do as little initialization as possible for performance reasons.
+
+        * History/BinaryPropertyList.cpp:
+        (IntegerArray::integers const):
+        (IntegerArray::size const):
+        (IntegerArrayHashTraits::constructDeletedValue):
+        (IntegerArrayHashTraits::isDeletedValue):
+        (IntegerArray::markDeleted): Deleted.
+        (IntegerArray::isDeletedValue const): Deleted.
+        (IntegerArray::deletedValueSize): Deleted.
+
 2021-04-19  Kimmo Kinnunen  <[email protected]>
 
         Enable -Wthread-safety, add attributes to custom lock classes, and provide macros to declare guards

Modified: trunk/Source/WebKitLegacy/mac/History/BinaryPropertyList.cpp (276501 => 276502)


--- trunk/Source/WebKitLegacy/mac/History/BinaryPropertyList.cpp	2021-04-23 16:53:23 UTC (rev 276501)
+++ trunk/Source/WebKitLegacy/mac/History/BinaryPropertyList.cpp	2021-04-23 16:55:47 UTC (rev 276502)
@@ -55,15 +55,13 @@
     IntegerArray() : m_integers(0), m_size(0) { }
     IntegerArray(const int* integers, size_t size) : m_integers(integers), m_size(size) { ASSERT(integers); ASSERT(size); }
 
-    void markDeleted() { m_integers = 0; m_size = deletedValueSize(); }
-    bool isDeletedValue() const { return m_size == deletedValueSize(); }
+    bool isDeletedValue() const { return HashTraits<size_t>::isDeletedValue(m_size); }
 
     const int* integers() const { ASSERT(!isDeletedValue()); return m_integers; }
     size_t size() const { ASSERT(!isDeletedValue()); return m_size; }
 
 private:
-    static size_t deletedValueSize() { return std::numeric_limits<size_t>::max(); }
-
+    friend struct IntegerArrayHashTraits;
     friend bool operator==(const IntegerArray&, const IntegerArray&);
 
     const int* m_integers;
@@ -76,8 +74,8 @@
 }
 
 struct IntegerArrayHashTraits : HashTraits<IntegerArray> {
-    static void constructDeletedValue(IntegerArray& slot) { slot.markDeleted(); }
-    static bool isDeletedValue(const IntegerArray& array) { return array.isDeletedValue(); }
+    static void constructDeletedValue(IntegerArray& slot) { HashTraits<size_t>::constructDeletedValue(slot.m_size); }
+    static bool isDeletedValue(const IntegerArray& slot) { return HashTraits<size_t>::isDeletedValue(slot.m_size); }
 };
 
 struct IntegerArrayHash {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to