Title: [231035] trunk/Source/WTF
Revision
231035
Author
[email protected]
Date
2018-04-25 17:13:35 -0700 (Wed, 25 Apr 2018)

Log Message

Gardening: Speculative build fix for Windows 32-bit to compensate for MSVC's lack of smarts.
https://bugs.webkit.org/show_bug.cgi?id=184976
<rdar://problem/39723901>

Not reviewed.

According to https://stackoverflow.com/questions/37658794/integer-constant-overflow-warning-in-constexpr,
disabling the warning around the definition of the function will not disable it
for all clients of the function.

* wtf/PtrTag.h:
(WTF::makePtrTagHash):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (231034 => 231035)


--- trunk/Source/WTF/ChangeLog	2018-04-25 23:32:58 UTC (rev 231034)
+++ trunk/Source/WTF/ChangeLog	2018-04-26 00:13:35 UTC (rev 231035)
@@ -1,5 +1,20 @@
 2018-04-25  Mark Lam  <[email protected]>
 
+        Gardening: Speculative build fix for Windows 32-bit to compensate for MSVC's lack of smarts.
+        https://bugs.webkit.org/show_bug.cgi?id=184976
+        <rdar://problem/39723901>
+
+        Not reviewed.
+
+        According to https://stackoverflow.com/questions/37658794/integer-constant-overflow-warning-in-constexpr,
+        disabling the warning around the definition of the function will not disable it
+        for all clients of the function.
+
+        * wtf/PtrTag.h:
+        (WTF::makePtrTagHash):
+
+2018-04-25  Mark Lam  <[email protected]>
+
         Push the definition of PtrTag down to the WTF layer.
         https://bugs.webkit.org/show_bug.cgi?id=184976
         <rdar://problem/39723901>

Modified: trunk/Source/WTF/wtf/PtrTag.h (231034 => 231035)


--- trunk/Source/WTF/wtf/PtrTag.h	2018-04-25 23:32:58 UTC (rev 231034)
+++ trunk/Source/WTF/wtf/PtrTag.h	2018-04-26 00:13:35 UTC (rev 231035)
@@ -48,9 +48,16 @@
 template<size_t N>
 constexpr uintptr_t makePtrTagHash(const char (&str)[N])
 {
+    // The only reason for the following dance with casting to result64Bit and
+    // back is because, on 32-bit, MSVC will complain about "C4307: integral
+    // constant overflow" but not allow us to disable the warning for all clients
+    // of this function.
     uintptr_t result = 134775813;
-    for (size_t i = 0; i < N; ++i)
-        result += ((result * str[i]) ^ (result >> 16));
+    for (size_t i = 0; i < N; ++i) {
+        uint64_t result64Bit = static_cast<uint64_t>(result);
+        result64Bit += ((result64Bit * str[i]) ^ (result64Bit >> 16));
+        result = static_cast<uintptr_t>(result64Bit);
+    }
     return result & 0xffff;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to