Unreviewed, speculative build fix on watchOS simulator
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2020 20:51:45 +0000 (20:51 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Feb 2020 20:51:45 +0000 (20:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=207183

* wtf/HashTable.h:
(WTF::HashTableCapacityForSize::capacityForSize):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/HashTable.h

index c2722d5..910f378 100644 (file)
@@ -1,5 +1,13 @@
 2020-02-10  Yusuke Suzuki  <ysuzuki@apple.com>
 
+        Unreviewed, speculative build fix on watchOS simulator
+        https://bugs.webkit.org/show_bug.cgi?id=207183
+
+        * wtf/HashTable.h:
+        (WTF::HashTableCapacityForSize::capacityForSize):
+
+2020-02-10  Yusuke Suzuki  <ysuzuki@apple.com>
+
         Unreviewed, fix build failure on watchOS simulator
         https://bugs.webkit.org/show_bug.cgi?id=207183
 
index eeed509..9074782 100644 (file)
@@ -327,9 +327,15 @@ DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HashTable);
         {
             if (!sizeArg)
                 return 0;
-            uint64_t capacity = roundUpToPowerOfTwo(sizeArg);
-            if (shouldExpand(sizeArg, capacity))
+            constexpr unsigned maxCapacity = 1U << 31;
+            UNUSED_PARAM(maxCapacity);
+            ASSERT_UNDER_CONSTEXPR_CONTEXT(sizeArg <= maxCapacity);
+            uint32_t capacity = roundUpToPowerOfTwo(sizeArg);
+            ASSERT_UNDER_CONSTEXPR_CONTEXT(capacity <= maxCapacity);
+            if (shouldExpand(sizeArg, capacity)) {
+                ASSERT_UNDER_CONSTEXPR_CONTEXT((static_cast<uint64_t>(capacity) * 2) <= maxCapacity);
                 return capacity * 2;
+            }
             return capacity;
         }