Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/compiler/graph-builder.cc

Issue 656123005: Implement loop variable assignment analysis. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 UpdateEffectDependency(effect); 144 UpdateEffectDependency(effect);
145 145
146 // Introduce Phi nodes for values that have differing input at merge points, 146 // Introduce Phi nodes for values that have differing input at merge points,
147 // potentially extending an existing Phi node if possible. 147 // potentially extending an existing Phi node if possible.
148 for (int i = 0; i < static_cast<int>(values_.size()); ++i) { 148 for (int i = 0; i < static_cast<int>(values_.size()); ++i) {
149 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control); 149 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control);
150 } 150 }
151 } 151 }
152 152
153 153
154 void StructuredGraphBuilder::Environment::PrepareForLoop() { 154 void StructuredGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) {
155 Node* control = GetControlDependency(); 155 Node* control = GetControlDependency();
156 for (int i = 0; i < static_cast<int>(values()->size()); ++i) { 156 int size = static_cast<int>(values()->size());
157 Node* phi = builder_->NewPhi(1, values()->at(i), control); 157 if (assigned == NULL) {
158 values()->at(i) = phi; 158 // Assume that everything is updated in the loop.
159 for (int i = 0; i < size; ++i) {
160 Node* phi = builder_->NewPhi(1, values()->at(i), control);
161 values()->at(i) = phi;
162 }
163 } else {
164 // Only build phis for those locals assigned in this loop.
165 for (int i = 0; i < size; ++i) {
166 if (i < assigned->length() && !assigned->Contains(i)) continue;
167 Node* phi = builder_->NewPhi(1, values()->at(i), control);
168 values()->at(i) = phi;
169 }
159 } 170 }
160 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); 171 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control);
161 UpdateEffectDependency(effect); 172 UpdateEffectDependency(effect);
162 } 173 }
163 174
164 175
165 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { 176 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
166 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); 177 const Operator* phi_op = common()->Phi(kMachAnyTagged, count);
167 Node** buffer = local_zone()->NewArray<Node*>(count + 1); 178 Node** buffer = local_zone()->NewArray<Node*>(count + 1);
168 MemsetPointer(buffer, input, count); 179 MemsetPointer(buffer, input, count);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (!dead_control_.is_set()) { 252 if (!dead_control_.is_set()) {
242 Node* dead_node = graph()->NewNode(common_->Dead()); 253 Node* dead_node = graph()->NewNode(common_->Dead());
243 dead_control_.set(dead_node); 254 dead_control_.set(dead_node);
244 return dead_node; 255 return dead_node;
245 } 256 }
246 return dead_control_.get(); 257 return dead_control_.get();
247 } 258 }
248 } 259 }
249 } 260 }
250 } // namespace v8::internal::compiler 261 } // namespace v8::internal::compiler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698