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

Unified Diff: src/base/logging.h

Issue 843513002: make check failures unlikely (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/logging.h
diff --git a/src/base/logging.h b/src/base/logging.h
index 83c1bb60136c1ec9d626c0230db452f3dbb2bf96..323ff50c5bc70c9f550b7dc25b4d468406d4063c 100644
--- a/src/base/logging.h
+++ b/src/base/logging.h
@@ -33,8 +33,9 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...);
// The CHECK macro checks that the given condition is true; if not, it
// prints a message to stderr and aborts.
-#define CHECK(condition) do { \
- if (!(condition)) { \
+#define CHECK(condition) \
+ do { \
+ if (V8_UNLIKELY(!(condition))) { \
V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \
} \
} while (0)
@@ -45,7 +46,7 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...);
inline void CheckEqualsHelper(const char* file, int line,
const char* expected_source, int expected,
const char* value_source, int value) {
- if (expected != value) {
+ if (V8_UNLIKELY(expected != value)) {
V8_Fatal(file, line,
"CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i",
expected_source, value_source, expected, value);
@@ -60,7 +61,7 @@ inline void CheckEqualsHelper(const char* file, int line,
int64_t expected,
const char* value_source,
int64_t value) {
- if (expected != value) {
+ if (V8_UNLIKELY(expected != value)) {
// Print int64_t values in hex, as two int32s,
// to avoid platform-dependencies.
V8_Fatal(file, line,
@@ -83,7 +84,7 @@ inline void CheckNonEqualsHelper(const char* file,
int unexpected,
const char* value_source,
int value) {
- if (unexpected == value) {
+ if (V8_UNLIKELY(unexpected == value)) {
V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i",
unexpected_source, value_source, value);
}
@@ -98,9 +99,10 @@ inline void CheckEqualsHelper(const char* file,
const char* expected,
const char* value_source,
const char* value) {
- if ((expected == NULL && value != NULL) ||
- (expected != NULL && value == NULL) ||
- (expected != NULL && value != NULL && strcmp(expected, value) != 0)) {
+ if (V8_UNLIKELY((expected == NULL && value != NULL) ||
+ (expected != NULL && value == NULL) ||
+ (expected != NULL && value != NULL &&
+ strcmp(expected, value) != 0))) {
V8_Fatal(file, line,
"CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s",
expected_source, value_source, expected, value);
@@ -114,8 +116,8 @@ inline void CheckNonEqualsHelper(const char* file,
const char* expected,
const char* value_source,
const char* value) {
- if (expected == value ||
- (expected != NULL && value != NULL && strcmp(expected, value) == 0)) {
+ if (V8_UNLIKELY(expected == value || (expected != NULL && value != NULL &&
+ strcmp(expected, value) == 0))) {
V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
expected_source, value_source, value);
}
@@ -130,7 +132,7 @@ inline void CheckEqualsHelper(const char* file,
const void* expected,
const char* value_source,
const void* value) {
- if (expected != value) {
+ if (V8_UNLIKELY(expected != value)) {
V8_Fatal(file, line,
"CHECK_EQ(%s, %s) failed\n# Expected: %p\n# Found: %p",
expected_source, value_source,
@@ -145,7 +147,7 @@ inline void CheckNonEqualsHelper(const char* file,
const void* expected,
const char* value_source,
const void* value) {
- if (expected == value) {
+ if (V8_UNLIKELY(expected == value)) {
V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p",
expected_source, value_source, value);
}
@@ -158,7 +160,7 @@ inline void CheckNonEqualsHelper(const char* file,
int64_t expected,
const char* value_source,
int64_t value) {
- if (expected == value) {
+ if (V8_UNLIKELY(expected == value)) {
V8_Fatal(file, line,
"CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f",
expected_source, value_source, expected, value);
« 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