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

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

Issue 809333002: [turbofan] Implement OSR for outer loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « src/compiler/graph-builder.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/graph-visualizer.h" 9 #include "src/compiler/graph-visualizer.h"
10 #include "src/compiler/node.h" 10 #include "src/compiler/node.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 UpdateEffectDependency(effect); 161 UpdateEffectDependency(effect);
162 162
163 // Introduce Phi nodes for values that have differing input at merge points, 163 // Introduce Phi nodes for values that have differing input at merge points,
164 // potentially extending an existing Phi node if possible. 164 // potentially extending an existing Phi node if possible.
165 for (int i = 0; i < static_cast<int>(values_.size()); ++i) { 165 for (int i = 0; i < static_cast<int>(values_.size()); ++i) {
166 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control); 166 values_[i] = builder_->MergeValue(values_[i], other->values_[i], control);
167 } 167 }
168 } 168 }
169 169
170 170
171 void StructuredGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) { 171 void StructuredGraphBuilder::Environment::PrepareForLoop(BitVector* assigned,
172 Node* control = GetControlDependency(); 172 bool is_osr) {
173 int size = static_cast<int>(values()->size()); 173 int size = static_cast<int>(values()->size());
174 if (assigned == NULL) { 174
175 Node* control = builder_->NewLoop();
176 if (assigned == nullptr) {
175 // Assume that everything is updated in the loop. 177 // Assume that everything is updated in the loop.
176 for (int i = 0; i < size; ++i) { 178 for (int i = 0; i < size; ++i) {
177 Node* phi = builder_->NewPhi(1, values()->at(i), control); 179 Node* phi = builder_->NewPhi(1, values()->at(i), control);
178 values()->at(i) = phi; 180 values()->at(i) = phi;
179 } 181 }
180 } else { 182 } else {
181 // Only build phis for those locals assigned in this loop. 183 // Only build phis for those locals assigned in this loop.
182 for (int i = 0; i < size; ++i) { 184 for (int i = 0; i < size; ++i) {
183 if (i < assigned->length() && !assigned->Contains(i)) continue; 185 if (i < assigned->length() && !assigned->Contains(i)) continue;
184 Node* phi = builder_->NewPhi(1, values()->at(i), control); 186 Node* phi = builder_->NewPhi(1, values()->at(i), control);
185 values()->at(i) = phi; 187 values()->at(i) = phi;
186 } 188 }
187 } 189 }
188 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); 190 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control);
189 UpdateEffectDependency(effect); 191 UpdateEffectDependency(effect);
192
193 if (is_osr) {
194 // Merge OSR values as inputs to the phis of the loop.
195 Graph* graph = builder_->graph();
196 Node* osr_loop_entry = builder_->graph()->NewNode(
197 builder_->common()->OsrLoopEntry(), graph->start(), graph->start());
198
199 builder_->MergeControl(control, osr_loop_entry);
200 builder_->MergeEffect(effect, osr_loop_entry, control);
201
202 for (int i = 0; i < size; ++i) {
203 Node* val = values()->at(i);
204 // TODO(titzer): use IrOpcode::IsConstant() or similar.
205 if (val->opcode() == IrOpcode::kNumberConstant ||
206 val->opcode() == IrOpcode::kInt32Constant ||
207 val->opcode() == IrOpcode::kInt64Constant ||
208 val->opcode() == IrOpcode::kFloat64Constant ||
209 val->opcode() == IrOpcode::kHeapConstant)
210 continue;
211 Node* osr_value =
212 graph->NewNode(builder_->common()->OsrValue(i), osr_loop_entry);
213 values()->at(i) = builder_->MergeValue(val, osr_value, control);
214 }
215 }
190 } 216 }
191 217
192 218
193 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { 219 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) {
194 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); 220 const Operator* phi_op = common()->Phi(kMachAnyTagged, count);
195 Node** buffer = EnsureInputBufferSize(count + 1); 221 Node** buffer = EnsureInputBufferSize(count + 1);
196 MemsetPointer(buffer, input, count); 222 MemsetPointer(buffer, input, count);
197 buffer[count] = control; 223 buffer[count] = control;
198 return graph()->NewNode(phi_op, count + 1, buffer, true); 224 return graph()->NewNode(phi_op, count + 1, buffer, true);
199 } 225 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (!dead_control_.is_set()) { 296 if (!dead_control_.is_set()) {
271 Node* dead_node = graph()->NewNode(common_->Dead()); 297 Node* dead_node = graph()->NewNode(common_->Dead());
272 dead_control_.set(dead_node); 298 dead_control_.set(dead_node);
273 return dead_node; 299 return dead_node;
274 } 300 }
275 return dead_control_.get(); 301 return dead_control_.get();
276 } 302 }
277 } 303 }
278 } 304 }
279 } // namespace v8::internal::compiler 305 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/graph-builder.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698