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

Side by Side Diff: src/checks.h

Issue 8267004: Faster slow asserts. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // it can be used wherever a typedef can be used. Beware that this 250 // 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 251 // actually causes each use to introduce a new defined type with a
252 // name depending on the source line. 252 // name depending on the source line.
253 template <int> class StaticAssertionHelper { }; 253 template <int> class StaticAssertionHelper { };
254 #define STATIC_CHECK(test) \ 254 #define STATIC_CHECK(test) \
255 typedef \ 255 typedef \
256 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \ 256 StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
257 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) 257 SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
258 258
259 259
260 namespace v8 { namespace internal { 260 extern bool FLAG_enable_slow_asserts;
261 261
262 bool EnableSlowAsserts();
263
264 } } // namespace v8::internal
265 262
266 // The ASSERT macro is equivalent to CHECK except that it only 263 // The ASSERT macro is equivalent to CHECK except that it only
267 // generates code in debug builds. 264 // generates code in debug builds.
268 #ifdef DEBUG 265 #ifdef DEBUG
269 #define ASSERT_RESULT(expr) CHECK(expr) 266 #define ASSERT_RESULT(expr) CHECK(expr)
270 #define ASSERT(condition) CHECK(condition) 267 #define ASSERT(condition) CHECK(condition)
271 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) 268 #define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2)
272 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) 269 #define ASSERT_NE(v1, v2) CHECK_NE(v1, v2)
273 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) 270 #define ASSERT_GE(v1, v2) CHECK_GE(v1, v2)
274 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) 271 #define ASSERT_LT(v1, v2) CHECK_LT(v1, v2)
275 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) 272 #define ASSERT_LE(v1, v2) CHECK_LE(v1, v2)
276 #define SLOW_ASSERT(condition) if (EnableSlowAsserts()) CHECK(condition) 273 #define SLOW_ASSERT(condition) if (FLAG_enable_slow_asserts) CHECK(condition)
Sven Panne 2011/10/13 13:07:00 Although it's a bit late for a comment: Using the
Kevin Millikin (Chromium) 2011/10/13 13:21:19 Yes, we need that, or else the ugly if (FLAG_enab
277 #else 274 #else
278 #define ASSERT_RESULT(expr) (expr) 275 #define ASSERT_RESULT(expr) (expr)
279 #define ASSERT(condition) ((void) 0) 276 #define ASSERT(condition) ((void) 0)
280 #define ASSERT_EQ(v1, v2) ((void) 0) 277 #define ASSERT_EQ(v1, v2) ((void) 0)
281 #define ASSERT_NE(v1, v2) ((void) 0) 278 #define ASSERT_NE(v1, v2) ((void) 0)
282 #define ASSERT_GE(v1, v2) ((void) 0) 279 #define ASSERT_GE(v1, v2) ((void) 0)
283 #define ASSERT_LT(v1, v2) ((void) 0) 280 #define ASSERT_LT(v1, v2) ((void) 0)
284 #define ASSERT_LE(v1, v2) ((void) 0) 281 #define ASSERT_LE(v1, v2) ((void) 0)
285 #define SLOW_ASSERT(condition) ((void) 0) 282 #define SLOW_ASSERT(condition) ((void) 0)
286 #endif 283 #endif
287 // Static asserts has no impact on runtime performance, so they can be 284 // Static asserts has no impact on runtime performance, so they can be
288 // safely enabled in release mode. Moreover, the ((void) 0) expression 285 // safely enabled in release mode. Moreover, the ((void) 0) expression
289 // obeys different syntax rules than typedef's, e.g. it can't appear 286 // obeys different syntax rules than typedef's, e.g. it can't appear
290 // inside class declaration, this leads to inconsistency between debug 287 // inside class declaration, this leads to inconsistency between debug
291 // and release compilation modes behavior. 288 // and release compilation modes behavior.
292 #define STATIC_ASSERT(test) STATIC_CHECK(test) 289 #define STATIC_ASSERT(test) STATIC_CHECK(test)
293 290
294 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) 291 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p)
295 292
296 #endif // V8_CHECKS_H_ 293 #endif // V8_CHECKS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698