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

Side by Side Diff: src/checks.h

Issue 8256011: Provide fast-path for CHECK macro. (Closed) Base URL: https://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 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // Static asserts has no impact on runtime performance, so they can be 289 // Static asserts has no impact on runtime performance, so they can be
288 // safely enabled in release mode. Moreover, the ((void) 0) expression 290 // safely enabled in release mode. Moreover, the ((void) 0) expression
289 // obeys different syntax rules than typedef's, e.g. it can't appear 291 // obeys different syntax rules than typedef's, e.g. it can't appear
290 // inside class declaration, this leads to inconsistency between debug 292 // inside class declaration, this leads to inconsistency between debug
291 // and release compilation modes behavior. 293 // and release compilation modes behavior.
292 #define STATIC_ASSERT(test) STATIC_CHECK(test) 294 #define STATIC_ASSERT(test) STATIC_CHECK(test)
293 295
294 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) 296 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p)
295 297
296 #endif // V8_CHECKS_H_ 298 #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