OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/graph-builder.h" | 5 #include "src/compiler/graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/generic-graph.h" | 8 #include "src/compiler/generic-graph.h" |
9 #include "src/compiler/generic-node.h" | 9 #include "src/compiler/generic-node.h" |
10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 UpdateEffectDependency(effect); | 159 UpdateEffectDependency(effect); |
160 | 160 |
161 // Introduce Phi nodes for values that have differing input at merge points, | 161 // Introduce Phi nodes for values that have differing input at merge points, |
162 // potentially extending an existing Phi node if possible. | 162 // potentially extending an existing Phi node if possible. |
163 for (int i = 0; i < static_cast<int>(values_.size()); ++i) { | 163 for (int i = 0; i < static_cast<int>(values_.size()); ++i) { |
164 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control); | 164 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 void StructuredGraphBuilder::Environment::PrepareForLoop() { | 169 void StructuredGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) { |
170 Node* control = GetControlDependency(); | 170 Node* control = GetControlDependency(); |
171 for (int i = 0; i < static_cast<int>(values()->size()); ++i) { | 171 int size = static_cast<int>(values()->size()); |
172 Node* phi = builder_->NewPhi(1, values()->at(i), control); | 172 if (assigned == NULL) { |
173 values()->at(i) = phi; | 173 // Assume that everything is updated in the loop. |
| 174 for (int i = 0; i < size; ++i) { |
| 175 Node* phi = builder_->NewPhi(1, values()->at(i), control); |
| 176 values()->at(i) = phi; |
| 177 } |
| 178 } else { |
| 179 // Only build phis for those locals assigned in this loop. |
| 180 for (int i = 0; i < size; ++i) { |
| 181 if (i < assigned->length() && !assigned->Contains(i)) continue; |
| 182 Node* phi = builder_->NewPhi(1, values()->at(i), control); |
| 183 values()->at(i) = phi; |
| 184 } |
174 } | 185 } |
175 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); | 186 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); |
176 UpdateEffectDependency(effect); | 187 UpdateEffectDependency(effect); |
177 } | 188 } |
178 | 189 |
179 | 190 |
180 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { | 191 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { |
181 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); | 192 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); |
182 Node** buffer = EnsureInputBufferSize(count + 1); | 193 Node** buffer = EnsureInputBufferSize(count + 1); |
183 MemsetPointer(buffer, input, count); | 194 MemsetPointer(buffer, input, count); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (!dead_control_.is_set()) { | 268 if (!dead_control_.is_set()) { |
258 Node* dead_node = graph()->NewNode(common_->Dead()); | 269 Node* dead_node = graph()->NewNode(common_->Dead()); |
259 dead_control_.set(dead_node); | 270 dead_control_.set(dead_node); |
260 return dead_node; | 271 return dead_node; |
261 } | 272 } |
262 return dead_control_.get(); | 273 return dead_control_.get(); |
263 } | 274 } |
264 } | 275 } |
265 } | 276 } |
266 } // namespace v8::internal::compiler | 277 } // namespace v8::internal::compiler |
OLD | NEW |