| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/interpreter/control-flow-builders.h" | 5 #include "src/interpreter/control-flow-builders.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 void BlockBuilder::EndBlock() { | 84 void BlockBuilder::EndBlock() { |
| 85 builder()->Bind(&block_end_); | 85 builder()->Bind(&block_end_); |
| 86 SetBreakTarget(block_end_); | 86 SetBreakTarget(block_end_); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 LoopBuilder::~LoopBuilder() { DCHECK(continue_sites_.empty()); } | 90 LoopBuilder::~LoopBuilder() { DCHECK(continue_sites_.empty()); } |
| 91 | 91 |
| 92 | 92 |
| 93 void LoopBuilder::LoopHeader() { |
| 94 // Jumps from before the loop header into the loop violate ordering |
| 95 // requirements of bytecode basic blocks. The only entry into a loop |
| 96 // must be the loop header. Surely breaks is okay? Not if nested |
| 97 // and misplaced between the headers. |
| 98 DCHECK(break_sites_.empty() && continue_sites_.empty()); |
| 99 builder()->Bind(&loop_header_); |
| 100 } |
| 101 |
| 102 |
| 93 void LoopBuilder::EndLoop() { | 103 void LoopBuilder::EndLoop() { |
| 94 // Loop must have closed form, i.e. all loop elements are within the loop, | 104 // Loop must have closed form, i.e. all loop elements are within the loop, |
| 95 // the loop header precedes the body and next elements in the loop. | 105 // the loop header precedes the body and next elements in the loop. |
| 96 DCHECK(loop_header_.is_bound()); | 106 DCHECK(loop_header_.is_bound()); |
| 97 builder()->Bind(&loop_end_); | 107 builder()->Bind(&loop_end_); |
| 98 SetBreakTarget(loop_end_); | 108 SetBreakTarget(loop_end_); |
| 99 if (next_.is_bound()) { | 109 if (next_.is_bound()) { |
| 100 DCHECK(!condition_.is_bound() || next_.offset() >= condition_.offset()); | 110 DCHECK(!condition_.is_bound() || next_.offset() >= condition_.offset()); |
| 101 SetContinueTarget(next_); | 111 SetContinueTarget(next_); |
| 102 } else { | 112 } else { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 123 | 133 |
| 124 | 134 |
| 125 void SwitchBuilder::SetCaseTarget(int index) { | 135 void SwitchBuilder::SetCaseTarget(int index) { |
| 126 BytecodeLabel& site = case_sites_.at(index); | 136 BytecodeLabel& site = case_sites_.at(index); |
| 127 builder()->Bind(&site); | 137 builder()->Bind(&site); |
| 128 } | 138 } |
| 129 | 139 |
| 130 } // namespace interpreter | 140 } // namespace interpreter |
| 131 } // namespace internal | 141 } // namespace internal |
| 132 } // namespace v8 | 142 } // namespace v8 |
| OLD | NEW |