| OLD | NEW |
| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 static inline void CheckEqualsHelper(const char* file, int line, | 73 static inline void CheckEqualsHelper(const char* file, int line, |
| 74 const char* expected_source, int expected, | 74 const char* expected_source, int expected, |
| 75 const char* value_source, int value) { | 75 const char* value_source, int value) { |
| 76 if (expected != value) { | 76 if (expected != value) { |
| 77 V8_Fatal(file, line, | 77 V8_Fatal(file, line, |
| 78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", | 78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", |
| 79 expected_source, value_source, expected, value); | 79 expected_source, value_source, expected, value); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 #if !V8_HOST_ARCH_64_BIT | 83 // Helper function used by the CHECK_INT64_EQ function when given int64_t |
| 84 // Helper function used by the CHECK_EQ function when given int64_t | 84 // arguments. Should not be called directly. We do not overload CHECK_EQ |
| 85 // arguments. Should not be called directly. | 85 // with both 32-bit and 64-bit integers, because it causes ambiguity |
| 86 static inline void CheckEqualsHelper(const char* file, int line, | 86 // with operands of mixed sizes. |
| 87 const char* expected_source, | 87 static inline void CheckInt64EqualsHelper(const char* file, int line, |
| 88 int64_t expected, | 88 const char* expected_source, |
| 89 const char* value_source, | 89 int64_t expected, |
| 90 int64_t value) { | 90 const char* value_source, |
| 91 int64_t value) { |
| 91 if (expected != value) { | 92 if (expected != value) { |
| 92 // Sorry, printing int64_t in a fanky hex way, | 93 // Print int64_t values in hex, as two int32s, |
| 93 // that's our mother tongue after all :) | 94 // to avoid platform-dependencies. |
| 94 V8_Fatal(file, line, | 95 V8_Fatal(file, line, |
| 95 "CHECK_EQ(%s, %s) failed\n#" | 96 "CHECK_EQ(%s, %s) failed\n#" |
| 96 " Expected: 0x%08x%08x\n# Found: 0x%08x%08x", | 97 " Expected: 0x%08x%08x\n# Found: 0x%08x%08x", |
| 97 expected_source, value_source, | 98 expected_source, value_source, |
| 98 uint32_t(expected >> 32), uint32_t(expected), | 99 uint32_t(expected >> 32), uint32_t(expected), |
| 99 uint32_t(value >> 32), uint32_t(value)); | 100 uint32_t(value >> 32), uint32_t(value)); |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 #endif | |
| 103 | 103 |
| 104 | 104 |
| 105 // Helper function used by the CHECK_NE function when given int | 105 // Helper function used by the CHECK_NE function when given int |
| 106 // arguments. Should not be called directly. | 106 // arguments. Should not be called directly. |
| 107 static inline void CheckNonEqualsHelper(const char* file, | 107 static inline void CheckNonEqualsHelper(const char* file, |
| 108 int line, | 108 int line, |
| 109 const char* unexpected_source, | 109 const char* unexpected_source, |
| 110 int unexpected, | 110 int unexpected, |
| 111 const char* value_source, | 111 const char* value_source, |
| 112 int value) { | 112 int value) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 #expected, expected, #value, value) | 226 #expected, expected, #value, value) |
| 227 | 227 |
| 228 | 228 |
| 229 #define CHECK_NE(unexpected, value) CheckNonEqualsHelper(__FILE__, __LINE__, \ | 229 #define CHECK_NE(unexpected, value) CheckNonEqualsHelper(__FILE__, __LINE__, \ |
| 230 #unexpected, unexpected, #value, value) | 230 #unexpected, unexpected, #value, value) |
| 231 | 231 |
| 232 | 232 |
| 233 #define CHECK_GT(a, b) CHECK((a) > (b)) | 233 #define CHECK_GT(a, b) CHECK((a) > (b)) |
| 234 #define CHECK_GE(a, b) CHECK((a) >= (b)) | 234 #define CHECK_GE(a, b) CHECK((a) >= (b)) |
| 235 | 235 |
| 236 #define CHECK_INT64_EQ(expected, value) CheckInt64EqualsHelper(__FILE__, \ |
| 237 __LINE__, #expected, expected, #value, value) |
| 238 |
| 236 | 239 |
| 237 // This is inspired by the static assertion facility in boost. This | 240 // This is inspired by the static assertion facility in boost. This |
| 238 // is pretty magical. If it causes you trouble on a platform you may | 241 // is pretty magical. If it causes you trouble on a platform you may |
| 239 // find a fix in the boost code. | 242 // find a fix in the boost code. |
| 240 template <bool> class StaticAssertion; | 243 template <bool> class StaticAssertion; |
| 241 template <> class StaticAssertion<true> { }; | 244 template <> class StaticAssertion<true> { }; |
| 242 // This macro joins two tokens. If one of the tokens is a macro the | 245 // This macro joins two tokens. If one of the tokens is a macro the |
| 243 // helper call causes it to be resolved before joining. | 246 // helper call causes it to be resolved before joining. |
| 244 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b) | 247 #define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b) |
| 245 #define SEMI_STATIC_JOIN_HELPER(a, b) a##b | 248 #define SEMI_STATIC_JOIN_HELPER(a, b) a##b |
| (...skipping 29 matching lines...) Expand all Loading... |
| 275 | 278 |
| 276 | 279 |
| 277 #define ASSERT_TAG_ALIGNED(address) \ | 280 #define ASSERT_TAG_ALIGNED(address) \ |
| 278 ASSERT((reinterpret_cast<intptr_t>(address) & kHeapObjectTagMask) == 0) | 281 ASSERT((reinterpret_cast<intptr_t>(address) & kHeapObjectTagMask) == 0) |
| 279 | 282 |
| 280 #define ASSERT_SIZE_TAG_ALIGNED(size) ASSERT((size & kHeapObjectTagMask) == 0) | 283 #define ASSERT_SIZE_TAG_ALIGNED(size) ASSERT((size & kHeapObjectTagMask) == 0) |
| 281 | 284 |
| 282 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) | 285 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) |
| 283 | 286 |
| 284 #endif // V8_CHECKS_H_ | 287 #endif // V8_CHECKS_H_ |
| OLD | NEW |