Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add DCHECK macros #24359

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: added check statements for debugging
  • Loading branch information
kiyomizumia committed Nov 19, 2018
commit 22ef1c95c5f63ae7da8f9d152823bbbb5a4e4750
4 changes: 2 additions & 2 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

return handle;
}

Expand Down
5 changes: 2 additions & 3 deletions src/stream_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
23 changes: 23 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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.
Expand Down