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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // requirements of bytecode basic blocks. The only entry into a loop | 53 // requirements of bytecode basic blocks. The only entry into a loop |
54 // must be the loop header. Surely breaks is okay? Not if nested | 54 // must be the loop header. Surely breaks is okay? Not if nested |
55 // and misplaced between the headers. | 55 // and misplaced between the headers. |
56 DCHECK(break_labels_.empty() && continue_labels_.empty()); | 56 DCHECK(break_labels_.empty() && continue_labels_.empty()); |
57 builder()->Bind(&loop_header_); | 57 builder()->Bind(&loop_header_); |
58 for (auto& label : *additional_labels) { | 58 for (auto& label : *additional_labels) { |
59 builder()->Bind(&label); | 59 builder()->Bind(&label); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void LoopBuilder::JumpToHeader() { | 63 void LoopBuilder::JumpToHeader(int loop_depth) { |
| 64 // Pass the proper loop nesting level to the backwards branch, to trigger |
| 65 // on-stack replacement when armed for the given loop nesting depth. |
| 66 int level = Min(loop_depth, AbstractCode::kMaxLoopNestingMarker - 1); |
64 // Loop must have closed form, i.e. all loop elements are within the loop, | 67 // Loop must have closed form, i.e. all loop elements are within the loop, |
65 // the loop header precedes the body and next elements in the loop. | 68 // the loop header precedes the body and next elements in the loop. |
66 DCHECK(loop_header_.is_bound()); | 69 DCHECK(loop_header_.is_bound()); |
67 builder()->Jump(&loop_header_); | 70 builder()->JumpLoop(&loop_header_, level); |
68 } | |
69 | |
70 void LoopBuilder::JumpToHeaderIfTrue() { | |
71 // Loop must have closed form, i.e. all loop elements are within the loop, | |
72 // the loop header precedes the body and next elements in the loop. | |
73 DCHECK(loop_header_.is_bound()); | |
74 builder()->JumpIfTrue(&loop_header_); | |
75 } | 71 } |
76 | 72 |
77 void LoopBuilder::EndLoop() { | 73 void LoopBuilder::EndLoop() { |
78 BindBreakTarget(); | 74 BindBreakTarget(); |
79 header_labels_.BindToLabel(builder(), loop_header_); | 75 header_labels_.BindToLabel(builder(), loop_header_); |
80 } | 76 } |
81 | 77 |
82 void LoopBuilder::BindContinueTarget() { continue_labels_.Bind(builder()); } | 78 void LoopBuilder::BindContinueTarget() { continue_labels_.Bind(builder()); } |
83 | 79 |
84 SwitchBuilder::~SwitchBuilder() { | 80 SwitchBuilder::~SwitchBuilder() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 130 |
135 void TryFinallyBuilder::BeginFinally() { finalization_sites_.Bind(builder()); } | 131 void TryFinallyBuilder::BeginFinally() { finalization_sites_.Bind(builder()); } |
136 | 132 |
137 void TryFinallyBuilder::EndFinally() { | 133 void TryFinallyBuilder::EndFinally() { |
138 // Nothing to be done here. | 134 // Nothing to be done here. |
139 } | 135 } |
140 | 136 |
141 } // namespace interpreter | 137 } // namespace interpreter |
142 } // namespace internal | 138 } // namespace internal |
143 } // namespace v8 | 139 } // namespace v8 |
OLD | NEW |