Chromium Code Reviews| Index: base/logging.h |
| diff --git a/base/logging.h b/base/logging.h |
| index a100bb45ec6a1afdc09abf14e24e08bcb22101e8..5cb88f5d39147cdbfcbe12236ba0fd24d1a50822 100644 |
| --- a/base/logging.h |
| +++ b/base/logging.h |
| @@ -445,6 +445,29 @@ class CheckOpResult { |
| std::string* message_; |
| }; |
| +// Crashes in the fastest, simplest possible way with no attempt at logging. |
| +#ifndef IMMEDIATE_CRASH |
|
danakj
2016/11/28 22:28:08
Why the #ifndef?
palmer
2016/11/28 22:44:47
It's only there because it was in the original Bli
|
| +#if defined(COMPILER_GCC) || defined(__clang__) |
| +#define IMMEDIATE_CRASH() __builtin_trap() |
| +#else |
| +#define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) |
| +#endif |
| +#endif |
| + |
| +// Specialization of IMMEDIATE_CRASH which will raise a custom exception on |
| +// Windows to signal this is OOM and not a normal assert. |
| +#ifndef OOM_CRASH |
|
danakj
2016/11/28 22:28:08
same. is there some collision that this is worryin
|
| +#if defined(OS_WIN) |
| +#define OOM_CRASH() \ |
| + do { \ |
| + ::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \ |
| + IMMEDIATE_CRASH(); \ |
| + } while (0) |
| +#else |
| +#define OOM_CRASH() IMMEDIATE_CRASH() |
| +#endif |
| +#endif |
| + |
| // CHECK dies with a fatal error if condition is not true. It is *not* |
| // controlled by NDEBUG, so the check will be executed regardless of |
| // compilation mode. |
| @@ -454,20 +477,11 @@ class CheckOpResult { |
| #if defined(OFFICIAL_BUILD) && defined(NDEBUG) |
| -// Make all CHECK functions discard their log strings to reduce code |
| -// bloat, and improve performance, for official release builds. |
| - |
| -#if defined(COMPILER_GCC) || __clang__ |
| -#define LOGGING_CRASH() __builtin_trap() |
| -#else |
| -#define LOGGING_CRASH() ((void)(*(volatile char*)0 = 0)) |
| -#endif |
| - |
| // This is not calling BreakDebugger since this is called frequently, and |
| // calling an out-of-line function instead of a noreturn inline macro prevents |
| // compiler optimizations. |
| -#define CHECK(condition) \ |
| - !(condition) ? LOGGING_CRASH() : EAT_STREAM_PARAMETERS |
| +#define CHECK(condition) \ |
| + !(condition) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS |
| #define PCHECK(condition) CHECK(condition) |