Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/wtf/Assertions.h

Issue 2130293003: Change OOMs to raise custom exception rather than breakpoint on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 30 matching lines...) Expand all
41 */ 41 */
42 42
43 #include "base/gtest_prod_util.h" 43 #include "base/gtest_prod_util.h"
44 #include "base/logging.h" 44 #include "base/logging.h"
45 #include "wtf/Compiler.h" 45 #include "wtf/Compiler.h"
46 #include "wtf/Noncopyable.h" 46 #include "wtf/Noncopyable.h"
47 #include "wtf/WTFExport.h" 47 #include "wtf/WTFExport.h"
48 #include "wtf/build_config.h" 48 #include "wtf/build_config.h"
49 #include <stdarg.h> 49 #include <stdarg.h>
50 50
51 #if OS(WIN)
52 #include <windows.h>
53 #endif
54
51 // Users must test "#if ENABLE(ASSERT)", which helps ensure that code 55 // Users must test "#if ENABLE(ASSERT)", which helps ensure that code
52 // testing this macro has included this header. 56 // testing this macro has included this header.
53 #ifndef ENABLE_ASSERT 57 #ifndef ENABLE_ASSERT
54 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 58 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
55 /* Disable ASSERT* macros in release mode by default. */ 59 /* Disable ASSERT* macros in release mode by default. */
56 #define ENABLE_ASSERT 0 60 #define ENABLE_ASSERT 0
57 #else 61 #else
58 #define ENABLE_ASSERT 1 62 #define ENABLE_ASSERT 1
59 #endif /* defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) */ 63 #endif /* defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) */
60 #endif 64 #endif
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 147
144 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p ossible way with no attempt at logging. */ 148 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p ossible way with no attempt at logging. */
145 #ifndef IMMEDIATE_CRASH 149 #ifndef IMMEDIATE_CRASH
146 #if COMPILER(GCC) || COMPILER(CLANG) 150 #if COMPILER(GCC) || COMPILER(CLANG)
147 #define IMMEDIATE_CRASH() __builtin_trap() 151 #define IMMEDIATE_CRASH() __builtin_trap()
148 #else 152 #else
149 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0)) 153 #define IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
150 #endif 154 #endif
151 #endif 155 #endif
152 156
157 /* OOM_CRASH() - Specialization of IMMEDIATE_CRASH which will raise a custom exc eption on Windows to signal this is OOM and not a normal assert. */
158 #ifndef OOM_CRASH
159 #if OS(WIN)
160 #define OOM_CRASH() do { \
161 ::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \
162 IMMEDIATE_CRASH(); \
163 } while (0)
164 #else
165 #define OOM_CRASH() IMMEDIATE_CRASH()
166 #endif
167 #endif
168
153 /* CRASH() - Raises a fatal error resulting in program termination and triggerin g either the debugger or the crash reporter. 169 /* CRASH() - Raises a fatal error resulting in program termination and triggerin g either the debugger or the crash reporter.
154 170
155 Use CRASH() in response to known, unrecoverable errors like out-of-memory. 171 Use CRASH() in response to known, unrecoverable errors like out-of-memory.
156 Macro is enabled in both debug and release mode. 172 Macro is enabled in both debug and release mode.
157 To test for unknown errors and verify assumptions, use ASSERT instead, to avo id impacting performance in release builds. 173 To test for unknown errors and verify assumptions, use ASSERT instead, to avo id impacting performance in release builds.
158 174
159 Signals are ignored by the crash reporter on OS X so we must do better. 175 Signals are ignored by the crash reporter on OS X so we must do better.
160 */ 176 */
161 #ifndef CRASH 177 #ifndef CRASH
162 #if COMPILER(MSVC) 178 #if COMPILER(MSVC)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } \ 336 } \
321 inline const thisType& to##thisType(const argumentType& argumentName) \ 337 inline const thisType& to##thisType(const argumentType& argumentName) \
322 { \ 338 { \
323 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ 339 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \
324 return static_cast<const thisType&>(argumentName); \ 340 return static_cast<const thisType&>(argumentName); \
325 } \ 341 } \
326 void to##thisType(const thisType*); \ 342 void to##thisType(const thisType*); \
327 void to##thisType(const thisType&) 343 void to##thisType(const thisType&)
328 344
329 #endif /* WTF_Assertions_h */ 345 #endif /* WTF_Assertions_h */
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PageMemory.cpp ('k') | third_party/WebKit/Source/wtf/allocator/PartitionAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698