Log Message
Implement __builtin_clzl for MSVC https://bugs.webkit.org/show_bug.cgi?id=174232
Patch by Daewoong Jang <[email protected]> on 2017-08-01 Reviewed by Geoffrey Garen. * bmalloc/Algorithm.h: (bmalloc::clzl): (bmalloc::clzl<1>): (bmalloc::__builtin_clzl): * bmalloc/BPlatform.h:
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (220096 => 220097)
--- trunk/Source/bmalloc/ChangeLog 2017-08-01 14:32:36 UTC (rev 220096)
+++ trunk/Source/bmalloc/ChangeLog 2017-08-01 15:56:20 UTC (rev 220097)
@@ -1,3 +1,16 @@
+2017-08-01 Daewoong Jang <[email protected]>
+
+ Implement __builtin_clzl for MSVC
+ https://bugs.webkit.org/show_bug.cgi?id=174232
+
+ Reviewed by Geoffrey Garen.
+
+ * bmalloc/Algorithm.h:
+ (bmalloc::clzl):
+ (bmalloc::clzl<1>):
+ (bmalloc::__builtin_clzl):
+ * bmalloc/BPlatform.h:
+
2017-07-31 Mark Lam <[email protected]>
Fixed some comment typos.
Modified: trunk/Source/bmalloc/bmalloc/Algorithm.h (220096 => 220097)
--- trunk/Source/bmalloc/bmalloc/Algorithm.h 2017-08-01 14:32:36 UTC (rev 220096)
+++ trunk/Source/bmalloc/bmalloc/Algorithm.h 2017-08-01 15:56:20 UTC (rev 220097)
@@ -26,7 +26,6 @@
#ifndef Algorithm_h
#define Algorithm_h
-#include "Algorithm.h"
#include "BAssert.h"
#include <algorithm>
#include <cstdint>
@@ -137,6 +136,23 @@
return sizeof(T) * 8;
}
+#if BOS(WINDOWS)
+template<int depth> __forceinline constexpr unsigned long clzl(unsigned long value)
+{
+ return value & (1UL << (bitCount<unsigned long>() - 1)) ? 0 : 1 + clzl<depth - 1>(value << 1);
+}
+
+template<> __forceinline constexpr unsigned long clzl<1>(unsigned long value)
+{
+ return 0;
+}
+
+__forceinline constexpr unsigned long __builtin_clzl(unsigned long value)
+{
+ return value == 0 ? 32 : clzl<bitCount<unsigned long>()>(value);
+}
+#endif
+
inline constexpr unsigned long log2(unsigned long value)
{
return bitCount<unsigned long>() - 1 - __builtin_clzl(value);
Modified: trunk/Source/bmalloc/bmalloc/BPlatform.h (220096 => 220097)
--- trunk/Source/bmalloc/bmalloc/BPlatform.h 2017-08-01 14:32:36 UTC (rev 220096)
+++ trunk/Source/bmalloc/bmalloc/BPlatform.h 2017-08-01 15:56:20 UTC (rev 220097)
@@ -42,6 +42,10 @@
#define BOS_UNIX 1
#endif
+#if defined(WIN32) || defined(_WIN32)
+#define BOS_WINDOWS 1
+#endif
+
#if BOS(DARWIN) && ((defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) \
|| (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) \
|| (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR))
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
