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

Side by Side Diff: src/compiler/control-flow-optimizer.cc

Issue 971223002: [turbofan] Fix ControlFlowOptimizer to also handle non-control nodes in the control chain. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | test/unittests/compiler/control-flow-optimizer-unittest.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 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/compiler/control-flow-optimizer.h" 5 #include "src/compiler/control-flow-optimizer.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 void ControlFlowOptimizer::Enqueue(Node* node) { 40 void ControlFlowOptimizer::Enqueue(Node* node) {
41 DCHECK_NOT_NULL(node); 41 DCHECK_NOT_NULL(node);
42 if (node->IsDead() || queued_.Get(node)) return; 42 if (node->IsDead() || queued_.Get(node)) return;
43 queued_.Set(node, true); 43 queued_.Set(node, true);
44 queue_.push(node); 44 queue_.push(node);
45 } 45 }
46 46
47 47
48 void ControlFlowOptimizer::VisitNode(Node* node) { 48 void ControlFlowOptimizer::VisitNode(Node* node) {
49 for (Node* use : node->uses()) { 49 for (Edge edge : node->use_edges()) {
50 if (NodeProperties::IsControl(use)) Enqueue(use); 50 if (NodeProperties::IsControlEdge(edge)) {
51 Enqueue(edge.from());
52 }
51 } 53 }
52 } 54 }
53 55
54 56
55 void ControlFlowOptimizer::VisitBranch(Node* node) { 57 void ControlFlowOptimizer::VisitBranch(Node* node) {
56 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 58 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
57 if (TryBuildSwitch(node)) return; 59 if (TryBuildSwitch(node)) return;
58 if (TryCloneBranch(node)) return; 60 if (TryCloneBranch(node)) return;
59 VisitNode(node); 61 VisitNode(node);
60 } 62 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 value = value1; 253 value = value1;
252 values.insert(value); 254 values.insert(value);
253 } 255 }
254 256
255 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 257 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
256 DCHECK_EQ(IrOpcode::kBranch, branch->opcode()); 258 DCHECK_EQ(IrOpcode::kBranch, branch->opcode());
257 DCHECK_EQ(IrOpcode::kIfTrue, if_true->opcode()); 259 DCHECK_EQ(IrOpcode::kIfTrue, if_true->opcode());
258 DCHECK_EQ(IrOpcode::kIfFalse, if_false->opcode()); 260 DCHECK_EQ(IrOpcode::kIfFalse, if_false->opcode());
259 if (branch == node) { 261 if (branch == node) {
260 DCHECK_EQ(1u, values.size()); 262 DCHECK_EQ(1u, values.size());
261 Enqueue(if_true); 263 return false;
262 Enqueue(if_false);
263 } else {
264 DCHECK_LT(1u, values.size());
265 node->set_op(common()->Switch(values.size() + 1));
266 node->ReplaceInput(0, index);
267 if_true->set_op(common()->IfValue(value));
268 if_true->ReplaceInput(0, node);
269 Enqueue(if_true);
270 if_false->set_op(common()->IfDefault());
271 if_false->ReplaceInput(0, node);
272 Enqueue(if_false);
273 branch->RemoveAllInputs();
274 } 264 }
265 DCHECK_LT(1u, values.size());
266 node->set_op(common()->Switch(values.size() + 1));
267 node->ReplaceInput(0, index);
268 if_true->set_op(common()->IfValue(value));
269 if_true->ReplaceInput(0, node);
270 Enqueue(if_true);
271 if_false->set_op(common()->IfDefault());
272 if_false->ReplaceInput(0, node);
273 Enqueue(if_false);
274 branch->RemoveAllInputs();
275 return true; 275 return true;
276 } 276 }
277 277
278 278
279 CommonOperatorBuilder* ControlFlowOptimizer::common() const { 279 CommonOperatorBuilder* ControlFlowOptimizer::common() const {
280 return jsgraph()->common(); 280 return jsgraph()->common();
281 } 281 }
282 282
283 283
284 Graph* ControlFlowOptimizer::graph() const { return jsgraph()->graph(); } 284 Graph* ControlFlowOptimizer::graph() const { return jsgraph()->graph(); }
285 285
286 286
287 MachineOperatorBuilder* ControlFlowOptimizer::machine() const { 287 MachineOperatorBuilder* ControlFlowOptimizer::machine() const {
288 return jsgraph()->machine(); 288 return jsgraph()->machine();
289 } 289 }
290 290
291 } // namespace compiler 291 } // namespace compiler
292 } // namespace internal 292 } // namespace internal
293 } // namespace v8 293 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/control-flow-optimizer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698