Skip to content
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
Prev Previous commit
Next Next commit
src: refactored and removed some ifdef debug statements
test: fixed order of actual and expected arguments

src: ifdef changes

src: refactored and removed some ifdef debug statements
  • Loading branch information
kiyomizumia committed Nov 19, 2018
commit 4f6fdbd31a840356d3f1f9a36396fadd97f1909c
4 changes: 2 additions & 2 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ v8::Local<v8::Object> BaseObject::object() const {
v8::Local<v8::Object> BaseObject::object(v8::Isolate* isolate) const {
v8::Local<v8::Object> handle = object();

CHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
CHECK_EQ(env_->isolate(), isolate);
DCHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
DCHECK_EQ(env_->isolate(), isolate);

return handle;
}
Expand Down
12 changes: 4 additions & 8 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,20 +549,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;
}

Expand Down
4 changes: 1 addition & 3 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,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);
}
Expand Down
13 changes: 6 additions & 7 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Comment thread
joyeecheung marked this conversation as resolved.
Outdated
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;

Expand Down
36 changes: 18 additions & 18 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,25 @@ void DumpBacktrace(FILE* fp);
#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))
#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)
#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


Expand Down