OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \ | 258 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \ |
259 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) | 259 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) |
260 | 260 |
261 | 261 |
262 extern bool FLAG_enable_slow_asserts; | 262 extern bool FLAG_enable_slow_asserts; |
263 | 263 |
264 | 264 |
265 // The ASSERT macro is equivalent to CHECK except that it only | 265 // The ASSERT macro is equivalent to CHECK except that it only |
266 // generates code in debug builds. | 266 // generates code in debug builds. |
267 #ifdef DEBUG | 267 #ifdef DEBUG |
268 #define ASSERT_RESULT(expr) CHECK(expr) | 268 #define ASSERT_RESULT(expr) CHECK(expr) |
269 #define ASSERT(condition) CHECK(condition) | 269 #define ASSERT(condition) CHECK(condition) |
270 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) | 270 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) |
271 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) | 271 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) |
272 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) | 272 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) |
273 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) | 273 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) |
274 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) | 274 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) |
275 #define SLOW_ASSERT(condition) if (FLAG_enable_slow_asserts) CHECK(condition) | 275 #define SLOW_ASSERT(condition) CHECK(!FLAG_enable_slow_asserts || (condition)) |
276 #else | 276 #else |
277 #define ASSERT_RESULT(expr) (expr) | 277 #define ASSERT_RESULT(expr) (expr) |
278 #define ASSERT(condition) ((void) 0) | 278 #define ASSERT(condition) ((void) 0) |
279 #define ASSERT_EQ(v1, v2) ((void) 0) | 279 #define ASSERT_EQ(v1, v2) ((void) 0) |
280 #define ASSERT_NE(v1, v2) ((void) 0) | 280 #define ASSERT_NE(v1, v2) ((void) 0) |
281 #define ASSERT_GE(v1, v2) ((void) 0) | 281 #define ASSERT_GE(v1, v2) ((void) 0) |
282 #define ASSERT_LT(v1, v2) ((void) 0) | 282 #define ASSERT_LT(v1, v2) ((void) 0) |
283 #define ASSERT_LE(v1, v2) ((void) 0) | 283 #define ASSERT_LE(v1, v2) ((void) 0) |
284 #define SLOW_ASSERT(condition) ((void) 0) | 284 #define SLOW_ASSERT(condition) ((void) 0) |
285 #endif | 285 #endif |
286 // 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 |
287 // safely enabled in release mode. Moreover, the ((void) 0) expression | 287 // safely enabled in release mode. Moreover, the ((void) 0) expression |
288 // 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 |
289 // inside class declaration, this leads to inconsistency between debug | 289 // inside class declaration, this leads to inconsistency between debug |
290 // and release compilation modes behavior. | 290 // and release compilation modes behavior. |
291 #define STATIC_ASSERT(test) STATIC_CHECK(test) | 291 #define STATIC_ASSERT(test) STATIC_CHECK(test) |
292 | 292 |
293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) | 293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) |
294 | 294 |
295 #endif // V8_CHECKS_H_ | 295 #endif // V8_CHECKS_H_ |
OLD | NEW |