Skip to content

Commit

Permalink
src: introduce DCHECK macro
Browse files Browse the repository at this point in the history
This commit adds a DCHECK macro for consistency with the
other DCHECK_* macros.

PR-URL: nodejs#25207
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
cjihrig committed Dec 26, 2018
1 parent c2b4269 commit 4e31a7f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/aliased_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ class AliasedBuffer {
void reserve(size_t new_capacity) {
DCHECK_GE(new_capacity, count_);
DCHECK_EQ(byte_offset_, 0);
#if defined(DEBUG) && DEBUG
CHECK(free_buffer_);
#endif
DCHECK(free_buffer_);
const v8::HandleScope handle_scope(isolate_);

const size_t old_size_in_bytes = sizeof(NativeT) * count_;
Expand Down
4 changes: 1 addition & 3 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ void BaseObject::ClearWeak() {
v8::Local<v8::FunctionTemplate>
BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
#ifdef DEBUG
CHECK(args.IsConstructCall());
#endif
DCHECK(args.IsConstructCall());
DCHECK_GT(args.This()->InternalFieldCount(), 0);
args.This()->SetAlignedPointerInInternalField(0, nullptr);
};
Expand Down
4 changes: 0 additions & 4 deletions src/inspector/node_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,4 @@ extern size_t kNotFound;
} // namespace inspector
} // namespace node

#ifndef DCHECK
#define DCHECK CHECK
#define DCHECK_LT CHECK_LT
#endif // DCHECK
#endif // SRC_INSPECTOR_NODE_STRING_H_
4 changes: 1 addition & 3 deletions src/string_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ MaybeLocal<String> MakeString(Isolate* isolate,
isolate->ThrowException(error);
}

#ifdef DEBUG
CHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
#endif
DCHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
return ret.FromMaybe(Local<Value>()).As<String>();
}

Expand Down
2 changes: 2 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void DumpBacktrace(FILE* fp);
#define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))

#ifdef DEBUG
#define DCHECK(expr) CHECK(expr)
#define DCHECK_EQ(a, b) CHECK((a) == (b))
#define DCHECK_GE(a, b) CHECK((a) >= (b))
#define DCHECK_GT(a, b) CHECK((a) > (b))
Expand All @@ -140,6 +141,7 @@ void DumpBacktrace(FILE* fp);
#define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
#define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
#else
#define DCHECK(expr)
#define DCHECK_EQ(a, b)
#define DCHECK_GE(a, b)
#define DCHECK_GT(a, b)
Expand Down

0 comments on commit 4e31a7f

Please sign in to comment.