Commit 61343b09 authored by Chris Palmer's avatar Chris Palmer

Move IMMEDIATE_CRASH and OOM_CRASH from wtf to base.

Part of the WTF Headers Audit, and needed for moving PartitionAllocator to base.

BUG=632441
R=danakj@chromium.org, yutak@chromium.org

Review URL: https://codereview.chromium.org/2525723004 .

Cr-Commit-Position: refs/heads/master@{#435077}
parent 8df5e216
...@@ -445,6 +445,25 @@ class CheckOpResult { ...@@ -445,6 +445,25 @@ class CheckOpResult {
std::string* message_; std::string* message_;
}; };
// Crashes in the fastest, simplest possible way with no attempt at logging.
#if defined(COMPILER_GCC) || defined(__clang__)
#define IMMEDIATE_CRASH() __builtin_trap()
#else
#define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
#endif
// Specialization of IMMEDIATE_CRASH which will raise a custom exception on
// Windows to signal this is OOM and not a normal assert.
#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
// CHECK dies with a fatal error if condition is not true. It is *not* // 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 // controlled by NDEBUG, so the check will be executed regardless of
// compilation mode. // compilation mode.
...@@ -454,20 +473,14 @@ class CheckOpResult { ...@@ -454,20 +473,14 @@ class CheckOpResult {
#if defined(OFFICIAL_BUILD) && defined(NDEBUG) #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
// Make all CHECK functions discard their log strings to reduce code // Make all CHECK functions discard their log strings to reduce code bloat, and
// bloat, and improve performance, for official release builds. // 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 // This is not calling BreakDebugger since this is called frequently, and
// calling an out-of-line function instead of a noreturn inline macro prevents // calling an out-of-line function instead of a noreturn inline macro prevents
// compiler optimizations. // compiler optimizations.
#define CHECK(condition) \ #define CHECK(condition) \
!(condition) ? LOGGING_CRASH() : EAT_STREAM_PARAMETERS !(condition) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS
#define PCHECK(condition) CHECK(condition) #define PCHECK(condition) CHECK(condition)
......
...@@ -129,30 +129,6 @@ class WTF_EXPORT ScopedLogger { ...@@ -129,30 +129,6 @@ class WTF_EXPORT ScopedLogger {
} // namespace WTF } // namespace WTF
// IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest
// possible way with no attempt at logging.
#ifndef IMMEDIATE_CRASH
#if COMPILER(GCC) || COMPILER(CLANG)
#define IMMEDIATE_CRASH() __builtin_trap()
#else
#define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
#endif
#endif
// OOM_CRASH() - 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
#if OS(WIN)
#define OOM_CRASH() \
do { \
::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \
IMMEDIATE_CRASH(); \
} while (0)
#else
#define OOM_CRASH() IMMEDIATE_CRASH()
#endif
#endif
// CRASH() - Raises a fatal error resulting in program termination and // CRASH() - Raises a fatal error resulting in program termination and
// triggering either the debugger or the crash reporter. // triggering either the debugger or the crash reporter.
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment