Title: [272095] trunk/Source/WTF
Revision
272095
Author
[email protected]
Date
2021-01-29 18:16:56 -0800 (Fri, 29 Jan 2021)

Log Message

Make check for full HashTables opt-in
https://bugs.webkit.org/show_bug.cgi?id=221166
<rdar://problem/70902458>

Reviewed by Saam Barati and Yusuke Suzuki.

Having the check always on was a regression on Speedometer2, so we only keep it for
the HashMaps in the MetaAllocator.

* wtf/HashTable.h:
(WTF::KeyTraits>::inlineLookup):
(WTF::KeyTraits>::lookupForWriting):
(WTF::KeyTraits>::fullLookupForWriting):
(WTF::KeyTraits>::addUniqueForInitialization):
(WTF::KeyTraits>::add):
* wtf/HashTraits.h:
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::addFreeSpace):
* wtf/MetaAllocator.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (272094 => 272095)


--- trunk/Source/WTF/ChangeLog	2021-01-30 02:13:44 UTC (rev 272094)
+++ trunk/Source/WTF/ChangeLog	2021-01-30 02:16:56 UTC (rev 272095)
@@ -1,3 +1,25 @@
+2021-01-29  Tadeu Zagallo  <[email protected]>
+
+        Make check for full HashTables opt-in
+        https://bugs.webkit.org/show_bug.cgi?id=221166
+        <rdar://problem/70902458>
+
+        Reviewed by Saam Barati and Yusuke Suzuki.
+
+        Having the check always on was a regression on Speedometer2, so we only keep it for
+        the HashMaps in the MetaAllocator.
+
+        * wtf/HashTable.h:
+        (WTF::KeyTraits>::inlineLookup):
+        (WTF::KeyTraits>::lookupForWriting):
+        (WTF::KeyTraits>::fullLookupForWriting):
+        (WTF::KeyTraits>::addUniqueForInitialization):
+        (WTF::KeyTraits>::add):
+        * wtf/HashTraits.h:
+        * wtf/MetaAllocator.cpp:
+        (WTF::MetaAllocator::addFreeSpace):
+        * wtf/MetaAllocator.h:
+
 2021-01-29  Myles C. Maxfield  <[email protected]>
 
         WebKit doesn't automatically right-align Adlam

Modified: trunk/Source/WTF/wtf/HashTable.h (272094 => 272095)


--- trunk/Source/WTF/wtf/HashTable.h	2021-01-30 02:13:44 UTC (rev 272094)
+++ trunk/Source/WTF/wtf/HashTable.h	2021-01-30 02:16:56 UTC (rev 272095)
@@ -717,7 +717,8 @@
             if (k == 0)
                 k = 1 | doubleHash(h);
             i = (i + k) & sizeMask;
-            HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
+            if constexpr (KeyTraits::assertNotFull)
+                HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
         }
     }
 
@@ -780,7 +781,8 @@
             if (k == 0)
                 k = 1 | doubleHash(h);
             i = (i + k) & sizeMask;
-            HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
+            if constexpr (KeyTraits::assertNotFull)
+                HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
         }
     }
 
@@ -843,7 +845,8 @@
             if (k == 0)
                 k = 1 | doubleHash(h);
             i = (i + k) & sizeMask;
-            HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
+            if constexpr (KeyTraits::assertNotFull)
+                HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
         }
     }
 
@@ -894,7 +897,8 @@
             if (k == 0)
                 k = 1 | doubleHash(h);
             i = (i + k) & sizeMask;
-            HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
+            if constexpr (KeyTraits::assertNotFull)
+                HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
         }
 
         HashTranslator::translate(*entry, std::forward<T>(key), std::forward<Extra>(extra));
@@ -994,7 +998,8 @@
             if (k == 0)
                 k = 1 | doubleHash(h);
             i = (i + k) & sizeMask;
-            HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
+            if constexpr (KeyTraits::assertNotFull)
+                HASH_TABLE_RELEASE_ASSERT(i != initialIndex);
         }
 
         if (deletedEntry) {

Modified: trunk/Source/WTF/wtf/HashTraits.h (272094 => 272095)


--- trunk/Source/WTF/wtf/HashTraits.h	2021-01-30 02:13:44 UTC (rev 272094)
+++ trunk/Source/WTF/wtf/HashTraits.h	2021-01-30 02:16:56 UTC (rev 272095)
@@ -51,6 +51,9 @@
     // The starting table size. Can be overridden when we know beforehand that
     // a hash table will have at least N entries.
     static constexpr unsigned minimumTableSize = 8;
+
+    // Whenever traversing the hash table, assert it is not full
+    static constexpr bool assertNotFull = false;
 };
 
 // Default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned).
@@ -380,6 +383,11 @@
     static bool isDeletedValue(const Vector<T, inlineCapacity>& value) { return value.isHashTableDeletedValue(); }
 };
 
+template<typename Traits>
+struct HardenedHashTraits : public Traits {
+    static constexpr bool assertNotFull = true;
+};
+
 // Useful for classes that want complete control over what is empty and what is deleted,
 // and how to construct both.
 template<typename T>

Modified: trunk/Source/WTF/wtf/MetaAllocator.cpp (272094 => 272095)


--- trunk/Source/WTF/wtf/MetaAllocator.cpp	2021-01-30 02:13:44 UTC (rev 272094)
+++ trunk/Source/WTF/wtf/MetaAllocator.cpp	2021-01-30 02:16:56 UTC (rev 272095)
@@ -307,8 +307,8 @@
 {
     FreeSpacePtr end = start + sizeInBytes;
 
-    HashMap<FreeSpacePtr, FreeSpaceNode*>::iterator leftNeighbor = m_freeSpaceEndAddressMap.find(start);
-    HashMap<FreeSpacePtr, FreeSpaceNode*>::iterator rightNeighbor = m_freeSpaceStartAddressMap.find(end);
+    auto leftNeighbor = m_freeSpaceEndAddressMap.find(start);
+    auto rightNeighbor = m_freeSpaceStartAddressMap.find(end);
 
     if (leftNeighbor != m_freeSpaceEndAddressMap.end()) {
         // We have something we can coalesce with on the left. Remove it from the tree, and

Modified: trunk/Source/WTF/wtf/MetaAllocator.h (272094 => 272095)


--- trunk/Source/WTF/wtf/MetaAllocator.h	2021-01-30 02:13:44 UTC (rev 272094)
+++ trunk/Source/WTF/wtf/MetaAllocator.h	2021-01-30 02:16:56 UTC (rev 272095)
@@ -193,8 +193,8 @@
     unsigned m_logPageSize;
     
     Tree m_freeSpaceSizeMap;
-    HashMap<FreeSpacePtr, FreeSpaceNode*> m_freeSpaceStartAddressMap;
-    HashMap<FreeSpacePtr, FreeSpaceNode*> m_freeSpaceEndAddressMap;
+    HashMap<FreeSpacePtr, FreeSpaceNode*, DefaultHash<FreeSpacePtr>, HardenedHashTraits<HashTraits<FreeSpacePtr>>> m_freeSpaceStartAddressMap;
+    HashMap<FreeSpacePtr, FreeSpaceNode*, DefaultHash<FreeSpacePtr>, HardenedHashTraits<HashTraits<FreeSpacePtr>>> m_freeSpaceEndAddressMap;
     HashMap<uintptr_t, size_t> m_pageOccupancyMap;
     
     size_t m_bytesAllocated;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to