Title: [248930] trunk/Source/WTF
Revision
248930
Author
mark....@apple.com
Date
2019-08-20 18:36:41 -0700 (Tue, 20 Aug 2019)

Log Message

Make it easier to pass pointers to WTFCrashWithInfo.
https://bugs.webkit.org/show_bug.cgi?id=200960

Reviewed by Saam Barati and Yusuke Suzuki.

Now, we don't have to explicitly cast them to uint64_ts first.  The template
wrappers will take care of it for us.

* wtf/Assertions.h:
(wtfCrashArg):
(WTFCrashWithInfo):
(WTF::isIntegralOrPointerType):
(WTF::isIntegralType): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (248929 => 248930)


--- trunk/Source/WTF/ChangeLog	2019-08-21 01:13:02 UTC (rev 248929)
+++ trunk/Source/WTF/ChangeLog	2019-08-21 01:36:41 UTC (rev 248930)
@@ -1,3 +1,19 @@
+2019-08-20  Mark Lam  <mark....@apple.com>
+
+        Make it easier to pass pointers to WTFCrashWithInfo.
+        https://bugs.webkit.org/show_bug.cgi?id=200960
+
+        Reviewed by Saam Barati and Yusuke Suzuki.
+
+        Now, we don't have to explicitly cast them to uint64_ts first.  The template
+        wrappers will take care of it for us.
+
+        * wtf/Assertions.h:
+        (wtfCrashArg):
+        (WTFCrashWithInfo):
+        (WTF::isIntegralOrPointerType):
+        (WTF::isIntegralType): Deleted.
+
 2019-08-20  Saam Barati  <sbar...@apple.com>
 
         Unreviewed. Followup to r248903. It's not valid to remove

Modified: trunk/Source/WTF/wtf/Assertions.h (248929 => 248930)


--- trunk/Source/WTF/wtf/Assertions.h	2019-08-21 01:13:02 UTC (rev 248929)
+++ trunk/Source/WTF/wtf/Assertions.h	2019-08-21 01:36:41 UTC (rev 248930)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2017 Apple Inc.  All rights reserved.
+ * Copyright (C) 2003-2019 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -549,6 +549,54 @@
 
 #ifdef __cplusplus
 
+template<typename T>
+ALWAYS_INLINE uint64_t wtfCrashArg(T* arg) { return reinterpret_cast<uintptr_t>(arg); }
+
+template<typename T>
+ALWAYS_INLINE uint64_t wtfCrashArg(T arg) { return arg; }
+
+template<typename T>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason));
+}
+
+template<typename T, typename U>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1));
+}
+
+template<typename T, typename U, typename V>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1, V misc2)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2));
+}
+
+template<typename T, typename U, typename V, typename W>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1, V misc2, W misc3)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3));
+}
+
+template<typename T, typename U, typename V, typename W, typename X>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1, V misc2, W misc3, X misc4)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4));
+}
+
+template<typename T, typename U, typename V, typename W, typename X, typename Y>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1, V misc2, W misc3, X misc4, Y misc5)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4), wtfCrashArg(misc5));
+}
+
+template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z>
+NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1, V misc2, W misc3, X misc4, Y misc5, Z misc6)
+{
+    WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4), wtfCrashArg(misc5), wtfCrashArg(misc6));
+}
+
 // The combination of line, file, function, and counter should be a unique number per call to this crash. This tricks the compiler into not coalescing calls to WTFCrashWithInfo.
 // The easiest way to fill these values per translation unit is to pass __LINE__, __FILE__, WTF_PRETTY_FUNCTION, and __COUNTER__.
 WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6);
@@ -569,13 +617,13 @@
 }
 
 namespace WTF {
-inline void isIntegralType() { }
+inline void isIntegralOrPointerType() { }
 
 template<typename T, typename... Types>
-void isIntegralType(T, Types... types)
+void isIntegralOrPointerType(T, Types... types)
 {
-    static_assert(std::is_integral<T>::value || std::is_enum<T>::value, "All types need to be integral bitwise_cast to integral type for logging");
-    isIntegralType(types...);
+    static_assert(std::is_integral<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value, "All types need to be bitwise_cast-able to integral type for logging");
+    isIntegralOrPointerType(types...);
 }
 }
 
@@ -593,7 +641,7 @@
 // crashWithInfo functions below.
 #if COMPILER(CLANG) || COMPILER(MSVC)
 #define CRASH_WITH_INFO(...) do { \
-        WTF::isIntegralType(__VA_ARGS__); \
+        WTF::isIntegralOrPointerType(__VA_ARGS__); \
         compilerFenceForCrash(); \
         WTFCrashWithInfo(__LINE__, __FILE__, WTF_PRETTY_FUNCTION, __COUNTER__, ##__VA_ARGS__); \
     } while (false)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to