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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // requirements of bytecode basic blocks. The only entry into a loop | 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 | 96 // must be the loop header. Surely breaks is okay? Not if nested |
97 // and misplaced between the headers. | 97 // and misplaced between the headers. |
98 DCHECK(break_sites_.empty() && continue_sites_.empty()); | 98 DCHECK(break_sites_.empty() && continue_sites_.empty()); |
99 builder()->Bind(&loop_header_); | 99 builder()->Bind(&loop_header_); |
100 for (auto& label : *additional_labels) { | 100 for (auto& label : *additional_labels) { |
101 builder()->Bind(loop_header_, &label); | 101 builder()->Bind(loop_header_, &label); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 | 105 void LoopBuilder::JumpToHeader() { |
106 void LoopBuilder::EndLoop() { | |
107 // Loop must have closed form, i.e. all loop elements are within the loop, | 106 // Loop must have closed form, i.e. all loop elements are within the loop, |
108 // the loop header precedes the body and next elements in the loop. | 107 // the loop header precedes the body and next elements in the loop. |
109 DCHECK(loop_header_.is_bound()); | 108 DCHECK(loop_header_.is_bound()); |
| 109 builder()->Jump(&loop_header_); |
| 110 } |
| 111 |
| 112 void LoopBuilder::JumpToHeaderIfTrue() { |
| 113 // Loop must have closed form, i.e. all loop elements are within the loop, |
| 114 // the loop header precedes the body and next elements in the loop. |
| 115 DCHECK(loop_header_.is_bound()); |
| 116 builder()->JumpIfTrue(&loop_header_); |
| 117 } |
| 118 |
| 119 void LoopBuilder::EndLoop() { |
110 builder()->Bind(&loop_end_); | 120 builder()->Bind(&loop_end_); |
111 SetBreakTarget(loop_end_); | 121 SetBreakTarget(loop_end_); |
112 } | 122 } |
113 | 123 |
114 void LoopBuilder::SetContinueTarget() { | 124 void LoopBuilder::SetContinueTarget() { |
115 BytecodeLabel target; | 125 BytecodeLabel target; |
116 builder()->Bind(&target); | 126 builder()->Bind(&target); |
117 BindLabels(target, &continue_sites_); | 127 BindLabels(target, &continue_sites_); |
118 } | 128 } |
119 | 129 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 189 } |
180 | 190 |
181 | 191 |
182 void TryFinallyBuilder::EndFinally() { | 192 void TryFinallyBuilder::EndFinally() { |
183 // Nothing to be done here. | 193 // Nothing to be done here. |
184 } | 194 } |
185 | 195 |
186 } // namespace interpreter | 196 } // namespace interpreter |
187 } // namespace internal | 197 } // namespace internal |
188 } // namespace v8 | 198 } // namespace v8 |
OLD | NEW |