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

Unified Diff: src/compiler/bytecode-loop-analysis.cc

Issue 2254493002: [interpreter] Use VisitForTest for loop conditions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo Created 4 years, 4 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
Index: src/compiler/bytecode-loop-analysis.cc
diff --git a/src/compiler/bytecode-loop-analysis.cc b/src/compiler/bytecode-loop-analysis.cc
index 76b90f882ef44543cec21bd16f39de62f8dca6a8..0a353ac443f18eb9d8988d455be17943838ec0a2 100644
--- a/src/compiler/bytecode-loop-analysis.cc
+++ b/src/compiler/bytecode-loop-analysis.cc
@@ -37,18 +37,32 @@ void BytecodeLoopAnalysis::Analyze() {
}
void BytecodeLoopAnalysis::AddLoopEntry(int entry_offset) {
+ if (found_current_backedge_) {
+ // We assume that all backedges of a loop must occur together and before
+ // another loop entry or an outer loop backedge.
Jarin 2016/08/18 12:49:50 Could you explain how you guard against the assump
klaasb 2016/08/18 13:38:01 The combination of the DCHECKs on 58, 60 and 63 do
+ // Thus here, the current loop actually ended before.
+ current_loop_offset_ = loop_header_to_parent_[current_loop_offset_];
+ }
loop_header_to_parent_[entry_offset] = current_loop_offset_;
current_loop_offset_ = entry_offset;
+ found_current_backedge_ = false;
}
void BytecodeLoopAnalysis::AddBranch(int origin_offset, int target_offset) {
- // If this is a backedge, record it and update the current loop to the parent.
+ // If this is a backedge, record it.
if (target_offset < origin_offset) {
backedge_to_header_[origin_offset] = target_offset;
- // Check that we are finishing the current loop. This assumes that
- // there is one backedge for each loop.
- DCHECK_EQ(target_offset, current_loop_offset_);
- current_loop_offset_ = loop_header_to_parent_[target_offset];
+ // Check whether this is actually a backedge of the outer loop and we have
+ // already finished the current loop.
+ if (target_offset < current_loop_offset_) {
+ DCHECK(found_current_backedge_);
+ int parent_offset = loop_header_to_parent_[current_loop_offset_];
+ DCHECK_EQ(target_offset, parent_offset);
+ current_loop_offset_ = parent_offset;
+ } else {
+ DCHECK_EQ(target_offset, current_loop_offset_);
+ found_current_backedge_ = true;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698