summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/base_object-inl.h8
-rw-r--r--src/env-inl.h12
-rw-r--r--src/env.cc4
-rw-r--r--src/inspector/node_string.h7
-rw-r--r--src/stream_base-inl.h5
-rw-r--r--src/stream_base.cc13
-rw-r--r--src/util.h23
7 files changed, 44 insertions, 28 deletions
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index 0b8fbb8520..cce8727393 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -67,10 +67,10 @@ v8::Local<v8::Object> BaseObject::object() const {
v8::Local<v8::Object> BaseObject::object(v8::Isolate* isolate) const {
v8::Local<v8::Object> handle = object();
-#ifdef DEBUG
- CHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
- CHECK_EQ(env_->isolate(), isolate);
-#endif
+
+ DCHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
+ DCHECK_EQ(env_->isolate(), isolate);
+
return handle;
}
diff --git a/src/env-inl.h b/src/env-inl.h
index ea257a1d60..e323d8707e 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -559,20 +559,16 @@ inline void Environment::set_http2_state(
}
bool Environment::debug_enabled(DebugCategory category) const {
-#ifdef DEBUG
- CHECK_GE(static_cast<int>(category), 0);
- CHECK_LT(static_cast<int>(category),
+ DCHECK_GE(static_cast<int>(category), 0);
+ DCHECK_LT(static_cast<int>(category),
static_cast<int>(DebugCategory::CATEGORY_COUNT));
-#endif
return debug_enabled_[static_cast<int>(category)];
}
void Environment::set_debug_enabled(DebugCategory category, bool enabled) {
-#ifdef DEBUG
- CHECK_GE(static_cast<int>(category), 0);
- CHECK_LT(static_cast<int>(category),
+ DCHECK_GE(static_cast<int>(category), 0);
+ DCHECK_LT(static_cast<int>(category),
static_cast<int>(DebugCategory::CATEGORY_COUNT));
-#endif
debug_enabled_[static_cast<int>(category)] = enabled;
}
diff --git a/src/env.cc b/src/env.cc
index afdebc304f..d8c4dce205 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -622,9 +622,7 @@ void Environment::RunAndClearNativeImmediates() {
};
while (drain_list()) {}
-#ifdef DEBUG
- CHECK_GE(immediate_info()->count(), count);
-#endif
+ DCHECK_GE(immediate_info()->count(), count);
immediate_info()->count_dec(count);
immediate_info()->ref_count_dec(ref_count);
}
diff --git a/src/inspector/node_string.h b/src/inspector/node_string.h
index 468aec96b5..4588364ab1 100644
--- a/src/inspector/node_string.h
+++ b/src/inspector/node_string.h
@@ -73,7 +73,8 @@ extern size_t kNotFound;
} // namespace inspector
} // namespace node
-#define DCHECK CHECK
-#define DCHECK_LT CHECK_LT
-
+#ifndef DCHECK
+ #define DCHECK CHECK
+ #define DCHECK_LT CHECK_LT
+#endif // DCHECK
#endif // SRC_INSPECTOR_NODE_STRING_H_
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h
index 1d6ec17b80..7e2bbaa173 100644
--- a/src/stream_base-inl.h
+++ b/src/stream_base-inl.h
@@ -448,9 +448,8 @@ inline void StreamReq::Done(int status, const char* error_str) {
}
inline void StreamReq::ResetObject(v8::Local<v8::Object> obj) {
-#ifdef DEBUG
- CHECK_GT(obj->InternalFieldCount(), StreamReq::kStreamReqField);
-#endif
+ DCHECK_GT(obj->InternalFieldCount(), StreamReq::kStreamReqField);
+
obj->SetAlignedPointerInInternalField(0, nullptr); // BaseObject field.
obj->SetAlignedPointerInInternalField(StreamReq::kStreamReqField, nullptr);
}
diff --git a/src/stream_base.cc b/src/stream_base.cc
index 26efa46ba0..739964eb85 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -292,17 +292,16 @@ void StreamBase::CallJSOnreadMethod(ssize_t nread,
size_t offset) {
Environment* env = env_;
-#ifdef DEBUG
- CHECK_EQ(static_cast<int32_t>(nread), nread);
- CHECK_LE(offset, INT32_MAX);
+ DCHECK_EQ(static_cast<int32_t>(nread), nread);
+ DCHECK_LE(offset, INT32_MAX);
if (ab.IsEmpty()) {
- CHECK_EQ(offset, 0);
- CHECK_LE(nread, 0);
+ DCHECK_EQ(offset, 0);
+ DCHECK_LE(nread, 0);
} else {
- CHECK_GE(nread, 0);
+ DCHECK_GE(nread, 0);
}
-#endif
+
env->stream_base_state()[kReadBytesOrError] = nread;
env->stream_base_state()[kArrayBufferOffset] = offset;
diff --git a/src/util.h b/src/util.h
index 9bf8bb0582..9a10904394 100644
--- a/src/util.h
+++ b/src/util.h
@@ -129,6 +129,29 @@ void DumpBacktrace(FILE* fp);
#define CHECK_NOT_NULL(val) CHECK((val) != nullptr)
#define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))
+#ifdef DEBUG
+ #define DCHECK_EQ(a, b) CHECK((a) == (b))
+ #define DCHECK_GE(a, b) CHECK((a) >= (b))
+ #define DCHECK_GT(a, b) CHECK((a) > (b))
+ #define DCHECK_LE(a, b) CHECK((a) <= (b))
+ #define DCHECK_LT(a, b) CHECK((a) < (b))
+ #define DCHECK_NE(a, b) CHECK((a) != (b))
+ #define DCHECK_NULL(val) CHECK((val) == nullptr)
+ #define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
+ #define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
+#else
+ #define DCHECK_EQ(a, b)
+ #define DCHECK_GE(a, b)
+ #define DCHECK_GT(a, b)
+ #define DCHECK_LE(a, b)
+ #define DCHECK_LT(a, b)
+ #define DCHECK_NE(a, b)
+ #define DCHECK_NULL(val)
+ #define DCHECK_NOT_NULL(val)
+ #define DCHECK_IMPLIES(a, b)
+#endif
+
+
#define UNREACHABLE() ABORT()
// TAILQ-style intrusive list node.