Changeset 248930 in webkit
- Timestamp:
- Aug 20, 2019, 6:36:41 PM (6 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r248913 r248930 1 2019-08-20 Mark Lam <mark.lam@apple.com> 2 3 Make it easier to pass pointers to WTFCrashWithInfo. 4 https://bugs.webkit.org/show_bug.cgi?id=200960 5 6 Reviewed by Saam Barati and Yusuke Suzuki. 7 8 Now, we don't have to explicitly cast them to uint64_ts first. The template 9 wrappers will take care of it for us. 10 11 * wtf/Assertions.h: 12 (wtfCrashArg): 13 (WTFCrashWithInfo): 14 (WTF::isIntegralOrPointerType): 15 (WTF::isIntegralType): Deleted. 16 1 17 2019-08-20 Saam Barati <sbarati@apple.com> 2 18 -
trunk/Source/WTF/wtf/Assertions.h
r248008 r248930 1 1 /* 2 * Copyright (C) 2003-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2003-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 550 550 #ifdef __cplusplus 551 551 552 template<typename T> 553 ALWAYS_INLINE uint64_t wtfCrashArg(T* arg) { return reinterpret_cast<uintptr_t>(arg); } 554 555 template<typename T> 556 ALWAYS_INLINE uint64_t wtfCrashArg(T arg) { return arg; } 557 558 template<typename T> 559 NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason) 560 { 561 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason)); 562 } 563 564 template<typename T, typename U> 565 NO_RETURN_DUE_TO_CRASH ALWAYS_INLINE void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason, U misc1) 566 { 567 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1)); 568 } 569 570 template<typename T, typename U, typename V> 571 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) 572 { 573 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2)); 574 } 575 576 template<typename T, typename U, typename V, typename W> 577 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) 578 { 579 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3)); 580 } 581 582 template<typename T, typename U, typename V, typename W, typename X> 583 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) 584 { 585 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4)); 586 } 587 588 template<typename T, typename U, typename V, typename W, typename X, typename Y> 589 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) 590 { 591 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4), wtfCrashArg(misc5)); 592 } 593 594 template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z> 595 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) 596 { 597 WTFCrashWithInfo(line, file, function, counter, wtfCrashArg(reason), wtfCrashArg(misc1), wtfCrashArg(misc2), wtfCrashArg(misc3), wtfCrashArg(misc4), wtfCrashArg(misc5), wtfCrashArg(misc6)); 598 } 599 552 600 // 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. 553 601 // The easiest way to fill these values per translation unit is to pass __LINE__, __FILE__, WTF_PRETTY_FUNCTION, and __COUNTER__. … … 570 618 571 619 namespace WTF { 572 inline void isIntegral Type() { }620 inline void isIntegralOrPointerType() { } 573 621 574 622 template<typename T, typename... Types> 575 void isIntegral Type(T, Types... types)576 { 577 static_assert(std::is_integral<T>::value || std::is_enum<T>::value , "All types need to be integral bitwise_castto integral type for logging");578 isIntegral Type(types...);623 void isIntegralOrPointerType(T, Types... types) 624 { 625 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"); 626 isIntegralOrPointerType(types...); 579 627 } 580 628 } … … 594 642 #if COMPILER(CLANG) || COMPILER(MSVC) 595 643 #define CRASH_WITH_INFO(...) do { \ 596 WTF::isIntegral Type(__VA_ARGS__); \644 WTF::isIntegralOrPointerType(__VA_ARGS__); \ 597 645 compilerFenceForCrash(); \ 598 646 WTFCrashWithInfo(__LINE__, __FILE__, WTF_PRETTY_FUNCTION, __COUNTER__, ##__VA_ARGS__); \
Note:
See TracChangeset
for help on using the changeset viewer.