Chromium Code Reviews| 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..fcdc5be575206bda48ac485bbc5bb46e1ea2f081 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, ie all loop elements are within the |
|
rmcilroy
2015/12/15 17:35:44
nit - /ie/i.e./
oth
2015/12/15 22:42:17
Done.
|
| + // 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_); |
| } |