| 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/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/common-operator.h" |
| 8 #include "src/compiler/graph.h" |
| 8 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 namespace compiler { | 14 namespace compiler { |
| 14 | 15 |
| 15 ControlFlowOptimizer::ControlFlowOptimizer(JSGraph* jsgraph, Zone* zone) | 16 ControlFlowOptimizer::ControlFlowOptimizer(Graph* graph, |
| 16 : jsgraph_(jsgraph), | 17 CommonOperatorBuilder* common, |
| 18 MachineOperatorBuilder* machine, |
| 19 Zone* zone) |
| 20 : graph_(graph), |
| 21 common_(common), |
| 22 machine_(machine), |
| 17 queue_(zone), | 23 queue_(zone), |
| 18 queued_(jsgraph->graph(), 2), | 24 queued_(graph, 2), |
| 19 zone_(zone) {} | 25 zone_(zone) {} |
| 20 | 26 |
| 21 | 27 |
| 22 void ControlFlowOptimizer::Optimize() { | 28 void ControlFlowOptimizer::Optimize() { |
| 23 Enqueue(graph()->start()); | 29 Enqueue(graph()->start()); |
| 24 while (!queue_.empty()) { | 30 while (!queue_.empty()) { |
| 25 Node* node = queue_.front(); | 31 Node* node = queue_.front(); |
| 26 queue_.pop(); | 32 queue_.pop(); |
| 27 if (node->IsDead()) continue; | 33 if (node->IsDead()) continue; |
| 28 switch (node->opcode()) { | 34 switch (node->opcode()) { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 if_true->set_op(common()->IfValue(value)); | 266 if_true->set_op(common()->IfValue(value)); |
| 261 if_true->ReplaceInput(0, node); | 267 if_true->ReplaceInput(0, node); |
| 262 Enqueue(if_true); | 268 Enqueue(if_true); |
| 263 if_false->set_op(common()->IfDefault()); | 269 if_false->set_op(common()->IfDefault()); |
| 264 if_false->ReplaceInput(0, node); | 270 if_false->ReplaceInput(0, node); |
| 265 Enqueue(if_false); | 271 Enqueue(if_false); |
| 266 branch->NullAllInputs(); | 272 branch->NullAllInputs(); |
| 267 return true; | 273 return true; |
| 268 } | 274 } |
| 269 | 275 |
| 270 | |
| 271 CommonOperatorBuilder* ControlFlowOptimizer::common() const { | |
| 272 return jsgraph()->common(); | |
| 273 } | |
| 274 | |
| 275 | |
| 276 Graph* ControlFlowOptimizer::graph() const { return jsgraph()->graph(); } | |
| 277 | |
| 278 | |
| 279 MachineOperatorBuilder* ControlFlowOptimizer::machine() const { | |
| 280 return jsgraph()->machine(); | |
| 281 } | |
| 282 | |
| 283 } // namespace compiler | 276 } // namespace compiler |
| 284 } // namespace internal | 277 } // namespace internal |
| 285 } // namespace v8 | 278 } // namespace v8 |
| OLD | NEW |