OLD | NEW |
1 // Copyright 2012 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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 V8_Fatal(__FILE__, __LINE__, "unreachable code") | 44 V8_Fatal(__FILE__, __LINE__, "unreachable code") |
45 #else | 45 #else |
46 #define FATAL(msg) \ | 46 #define FATAL(msg) \ |
47 V8_Fatal("", 0, "%s", (msg)) | 47 V8_Fatal("", 0, "%s", (msg)) |
48 #define UNIMPLEMENTED() \ | 48 #define UNIMPLEMENTED() \ |
49 V8_Fatal("", 0, "unimplemented code") | 49 V8_Fatal("", 0, "unimplemented code") |
50 #define UNREACHABLE() ((void) 0) | 50 #define UNREACHABLE() ((void) 0) |
51 #endif | 51 #endif |
52 | 52 |
53 | 53 |
54 // Used by the CHECK macro -- should not be called directly. | |
55 inline void CheckHelper(const char* file, | |
56 int line, | |
57 const char* source, | |
58 bool condition) { | |
59 if (!condition) | |
60 V8_Fatal(file, line, "CHECK(%s) failed", source); | |
61 } | |
62 | |
63 | |
64 // The CHECK macro checks that the given condition is true; if not, it | 54 // The CHECK macro checks that the given condition is true; if not, it |
65 // prints a message to stderr and aborts. | 55 // prints a message to stderr and aborts. |
66 #define CHECK(condition) do { \ | 56 #define CHECK(condition) do { \ |
67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \ | 57 if (!(condition)) { \ |
| 58 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ |
| 59 } \ |
68 } while (0) | 60 } while (0) |
69 | 61 |
70 | 62 |
71 // Helper function used by the CHECK_EQ function when given int | 63 // Helper function used by the CHECK_EQ function when given int |
72 // arguments. Should not be called directly. | 64 // arguments. Should not be called directly. |
73 inline void CheckEqualsHelper(const char* file, int line, | 65 inline void CheckEqualsHelper(const char* file, int line, |
74 const char* expected_source, int expected, | 66 const char* expected_source, int expected, |
75 const char* value_source, int value) { | 67 const char* value_source, int value) { |
76 if (expected != value) { | 68 if (expected != value) { |
77 V8_Fatal(file, line, | 69 V8_Fatal(file, line, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // Static asserts has no impact on runtime performance, so they can be | 278 // Static asserts has no impact on runtime performance, so they can be |
287 // safely enabled in release mode. Moreover, the ((void) 0) expression | 279 // safely enabled in release mode. Moreover, the ((void) 0) expression |
288 // obeys different syntax rules than typedef's, e.g. it can't appear | 280 // obeys different syntax rules than typedef's, e.g. it can't appear |
289 // inside class declaration, this leads to inconsistency between debug | 281 // inside class declaration, this leads to inconsistency between debug |
290 // and release compilation modes behavior. | 282 // and release compilation modes behavior. |
291 #define STATIC_ASSERT(test) STATIC_CHECK(test) | 283 #define STATIC_ASSERT(test) STATIC_CHECK(test) |
292 | 284 |
293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) | 285 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) |
294 | 286 |
295 #endif // V8_CHECKS_H_ | 287 #endif // V8_CHECKS_H_ |
OLD | NEW |