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

Unified Diff: src/frames.cc

Issue 1862753003: Refactoring: Avoid redundant checks in SingletonFor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/frames.cc
diff --git a/src/frames.cc b/src/frames.cc
index 8e5b530a93b095f5b42160320f9be007124adab1..679ae11b4c6d07aa49690e697e2921dab38018f1 100644
--- a/src/frames.cc
+++ b/src/frames.cc
@@ -104,17 +104,15 @@ void StackFrameIterator::Reset(ThreadLocalTop* top) {
StackFrame::Type type = ExitFrame::GetStateForFramePointer(
Isolate::c_entry_fp(top), &state);
handler_ = StackHandler::FromAddress(Isolate::handler(top));
- if (SingletonFor(type) == NULL) return;
frame_ = SingletonFor(type, &state);
}
StackFrame* StackFrameIteratorBase::SingletonFor(StackFrame::Type type,
StackFrame::State* state) {
- if (type == StackFrame::NONE) return NULL;
StackFrame* result = SingletonFor(type);
- DCHECK(result != NULL);
- result->state_ = *state;
+ DCHECK((!result) == (type == StackFrame::NONE));
+ if (result) result->state_ = *state;
return result;
}
@@ -230,10 +228,8 @@ SafeStackFrameIterator::SafeStackFrameIterator(
} else {
return;
}
- if (SingletonFor(type) == NULL) return;
frame_ = SingletonFor(type, &state);
- DCHECK(frame_);
- Advance();
+ if (frame_) Advance();
}
@@ -261,12 +257,8 @@ void SafeStackFrameIterator::AdvanceOneFrame() {
// Advance to the previous frame.
StackFrame::State state;
StackFrame::Type type = frame_->GetCallerState(&state);
- if (SingletonFor(type) == NULL) {
- frame_ = NULL;
- return;
- }
frame_ = SingletonFor(type, &state);
- DCHECK(frame_);
+ if (!frame_) return;
// Check that we have actually moved to the previous frame in the stack.
if (frame_->sp() < last_sp || frame_->fp() < last_fp) {
« 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