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

Side by Side Diff: src/checks.h

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/builtins.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 int line, 56 int line,
57 const char* source, 57 const char* source,
58 bool condition) { 58 bool condition) {
59 if (!condition) 59 if (!condition)
60 V8_Fatal(file, line, "CHECK(%s) failed", source); 60 V8_Fatal(file, line, "CHECK(%s) failed", source);
61 } 61 }
62 62
63 63
64 // The CHECK macro checks that the given condition is true; if not, it 64 // The CHECK macro checks that the given condition is true; if not, it
65 // prints a message to stderr and aborts. 65 // prints a message to stderr and aborts.
66 #define CHECK(condition) CheckHelper(__FILE__, __LINE__, #condition, condition) 66 #define CHECK(condition) do { \
67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \
68 } while (0)
67 69
68 70
69 // Helper function used by the CHECK_EQ function when given int 71 // Helper function used by the CHECK_EQ function when given int
70 // arguments. Should not be called directly. 72 // arguments. Should not be called directly.
71 static inline void CheckEqualsHelper(const char* file, int line, 73 static inline void CheckEqualsHelper(const char* file, int line,
72 const char* expected_source, int expected, 74 const char* expected_source, int expected,
73 const char* value_source, int value) { 75 const char* value_source, int value) {
74 if (expected != value) { 76 if (expected != value) {
75 V8_Fatal(file, line, 77 V8_Fatal(file, line,
76 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", 78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i",
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // it can be used wherever a typedef can be used. Beware that this 252 // it can be used wherever a typedef can be used. Beware that this
251 // actually causes each use to introduce a new defined type with a 253 // actually causes each use to introduce a new defined type with a
252 // name depending on the source line. 254 // name depending on the source line.
253 template <int> class StaticAssertionHelper { }; 255 template <int> class StaticAssertionHelper { };
254 #define STATIC_CHECK(test) \ 256 #define STATIC_CHECK(test) \
255 typedef \ 257 typedef \
256 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \ 258 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
257 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) 259 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
258 260
259 261
260 namespace v8 { namespace internal { 262 extern bool FLAG_enable_slow_asserts;
261 263
262 bool EnableSlowAsserts();
263
264 } } // namespace v8::internal
265 264
266 // The ASSERT macro is equivalent to CHECK except that it only 265 // The ASSERT macro is equivalent to CHECK except that it only
267 // generates code in debug builds. 266 // generates code in debug builds.
268 #ifdef DEBUG 267 #ifdef DEBUG
269 #define ASSERT_RESULT(expr) CHECK(expr) 268 #define ASSERT_RESULT(expr) CHECK(expr)
270 #define ASSERT(condition) CHECK(condition) 269 #define ASSERT(condition) CHECK(condition)
271 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) 270 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2)
272 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) 271 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2)
273 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) 272 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2)
274 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) 273 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2)
275 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) 274 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2)
276 #define SLOW_ASSERT(condition) if (EnableSlowAsserts()) CHECK(condition) 275 #define SLOW_ASSERT(condition) if (FLAG_enable_slow_asserts) CHECK(condition)
277 #else 276 #else
278 #define ASSERT_RESULT(expr) (expr) 277 #define ASSERT_RESULT(expr) (expr)
279 #define ASSERT(condition) ((void) 0) 278 #define ASSERT(condition) ((void) 0)
280 #define ASSERT_EQ(v1, v2) ((void) 0) 279 #define ASSERT_EQ(v1, v2) ((void) 0)
281 #define ASSERT_NE(v1, v2) ((void) 0) 280 #define ASSERT_NE(v1, v2) ((void) 0)
282 #define ASSERT_GE(v1, v2) ((void) 0) 281 #define ASSERT_GE(v1, v2) ((void) 0)
283 #define ASSERT_LT(v1, v2) ((void) 0) 282 #define ASSERT_LT(v1, v2) ((void) 0)
284 #define ASSERT_LE(v1, v2) ((void) 0) 283 #define ASSERT_LE(v1, v2) ((void) 0)
285 #define SLOW_ASSERT(condition) ((void) 0) 284 #define SLOW_ASSERT(condition) ((void) 0)
286 #endif 285 #endif
287 // Static asserts has no impact on runtime performance, so they can be 286 // Static asserts has no impact on runtime performance, so they can be
288 // safely enabled in release mode. Moreover, the ((void) 0) expression 287 // safely enabled in release mode. Moreover, the ((void) 0) expression
289 // obeys different syntax rules than typedef's, e.g. it can't appear 288 // obeys different syntax rules than typedef's, e.g. it can't appear
290 // inside class declaration, this leads to inconsistency between debug 289 // inside class declaration, this leads to inconsistency between debug
291 // and release compilation modes behavior. 290 // and release compilation modes behavior.
292 #define STATIC_ASSERT(test) STATIC_CHECK(test) 291 #define STATIC_ASSERT(test) STATIC_CHECK(test)
293 292
294 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) 293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p)
295 294
296 #endif // V8_CHECKS_H_ 295 #endif // V8_CHECKS_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698