Index: src/interpreter/control-flow-builders.cc |
diff --git a/src/interpreter/control-flow-builders.cc b/src/interpreter/control-flow-builders.cc |
index 3ecabe4351cb9ddbac13618b1b85e52d29ca0cd3..8e287aaea44881570d87ad8e6f7907e28c17c67f 100644 |
--- a/src/interpreter/control-flow-builders.cc |
+++ b/src/interpreter/control-flow-builders.cc |
@@ -32,6 +32,13 @@ void BreakableControlFlowBuilder::EmitJumpIfTrue( |
} |
+void BreakableControlFlowBuilder::EmitJumpIfFalse( |
+ ZoneVector<BytecodeLabel>* sites) { |
+ sites->push_back(BytecodeLabel()); |
+ builder()->JumpIfFalse(&sites->back()); |
+} |
+ |
+ |
void BreakableControlFlowBuilder::EmitJumpIfUndefined( |
ZoneVector<BytecodeLabel>* sites) { |
sites->push_back(BytecodeLabel()); |
@@ -58,6 +65,12 @@ void BreakableControlFlowBuilder::EmitJumpIfTrue( |
} |
+void BreakableControlFlowBuilder::EmitJumpIfFalse( |
+ ZoneVector<BytecodeLabel>* sites, int index) { |
+ builder()->JumpIfFalse(&sites->at(index)); |
+} |
+ |
+ |
void BreakableControlFlowBuilder::BindLabels(const BytecodeLabel& target, |
ZoneVector<BytecodeLabel>* sites) { |
for (size_t i = 0; i < sites->size(); i++) { |
@@ -71,6 +84,24 @@ void BreakableControlFlowBuilder::BindLabels(const BytecodeLabel& target, |
LoopBuilder::~LoopBuilder() { DCHECK(continue_sites_.empty()); } |
+void LoopBuilder::LoopEnd() { |
+ // Loop must have closed form, i.e. all loop elements are within the loop, |
+ // the loop header precedes the body and next elements in the loop. |
+ DCHECK(loop_header_.is_bound()); |
+ builder()->Bind(&loop_end_); |
+ SetBreakTarget(loop_end_); |
+ if (next_.is_bound()) { |
+ DCHECK(!condition_.is_bound() || next_.offset() >= condition_.offset()); |
+ SetContinueTarget(next_); |
+ } else { |
+ DCHECK(condition_.is_bound()); |
+ DCHECK_GE(condition_.offset(), loop_header_.offset()); |
+ DCHECK_LE(condition_.offset(), loop_end_.offset()); |
+ SetContinueTarget(condition_); |
+ } |
+} |
+ |
+ |
void LoopBuilder::SetContinueTarget(const BytecodeLabel& target) { |
BindLabels(target, &continue_sites_); |
} |