| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/control-reducer.h" | 6 #include "src/compiler/control-reducer.h" |
| 7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/node-marker.h" | 9 #include "src/compiler/node-marker.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 EnsureStateSize(id); | 377 EnsureStateSize(id); |
| 378 state_[id] = kVisited; | 378 state_[id] = kVisited; |
| 379 } | 379 } |
| 380 | 380 |
| 381 Node* dead() { return jsgraph_->DeadControl(); } | 381 Node* dead() { return jsgraph_->DeadControl(); } |
| 382 | 382 |
| 383 //=========================================================================== | 383 //=========================================================================== |
| 384 // Reducer implementation: perform reductions on a node. | 384 // Reducer implementation: perform reductions on a node. |
| 385 //=========================================================================== | 385 //=========================================================================== |
| 386 Node* ReduceNode(Node* node) { | 386 Node* ReduceNode(Node* node) { |
| 387 if (node->op()->ControlInputCount() == 1) { | 387 if (node->op()->ControlInputCount() == 1 || |
| 388 node->opcode() == IrOpcode::kLoop) { |
| 388 // If a node has only one control input and it is dead, replace with dead. | 389 // If a node has only one control input and it is dead, replace with dead. |
| 389 Node* control = NodeProperties::GetControlInput(node); | 390 Node* control = NodeProperties::GetControlInput(node); |
| 390 if (control->opcode() == IrOpcode::kDead) { | 391 if (control->opcode() == IrOpcode::kDead) { |
| 391 TRACE(("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic())); | 392 TRACE(("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic())); |
| 392 return control; | 393 return control; |
| 393 } | 394 } |
| 394 } | 395 } |
| 395 | 396 |
| 396 // Reduce branches, phis, and merges. | 397 // Reduce branches, phis, and merges. |
| 397 switch (node->opcode()) { | 398 switch (node->opcode()) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 impl.Reduce(); | 605 impl.Reduce(); |
| 605 } | 606 } |
| 606 | 607 |
| 607 | 608 |
| 608 void ControlReducer::TrimGraph(Zone* zone, JSGraph* jsgraph) { | 609 void ControlReducer::TrimGraph(Zone* zone, JSGraph* jsgraph) { |
| 609 ControlReducerImpl impl(zone, jsgraph, NULL); | 610 ControlReducerImpl impl(zone, jsgraph, NULL); |
| 610 impl.Trim(); | 611 impl.Trim(); |
| 611 } | 612 } |
| 612 | 613 |
| 613 | 614 |
| 615 Node* ControlReducer::ReduceMerge(JSGraph* jsgraph, |
| 616 CommonOperatorBuilder* common, Node* node) { |
| 617 Zone zone; |
| 618 ControlReducerImpl impl(&zone, jsgraph, common); |
| 619 return impl.ReduceMerge(node); |
| 620 } |
| 621 |
| 622 |
| 614 Node* ControlReducer::ReducePhiForTesting(JSGraph* jsgraph, | 623 Node* ControlReducer::ReducePhiForTesting(JSGraph* jsgraph, |
| 615 CommonOperatorBuilder* common, | 624 CommonOperatorBuilder* common, |
| 616 Node* node) { | 625 Node* node) { |
| 617 Zone zone; | 626 Zone zone; |
| 618 ControlReducerImpl impl(&zone, jsgraph, common); | 627 ControlReducerImpl impl(&zone, jsgraph, common); |
| 619 return impl.ReducePhi(node); | 628 return impl.ReducePhi(node); |
| 620 } | 629 } |
| 621 | 630 |
| 622 | 631 |
| 623 Node* ControlReducer::ReduceMergeForTesting(JSGraph* jsgraph, | |
| 624 CommonOperatorBuilder* common, | |
| 625 Node* node) { | |
| 626 Zone zone; | |
| 627 ControlReducerImpl impl(&zone, jsgraph, common); | |
| 628 return impl.ReduceMerge(node); | |
| 629 } | |
| 630 | |
| 631 | |
| 632 Node* ControlReducer::ReduceIfNodeForTesting(JSGraph* jsgraph, | 632 Node* ControlReducer::ReduceIfNodeForTesting(JSGraph* jsgraph, |
| 633 CommonOperatorBuilder* common, | 633 CommonOperatorBuilder* common, |
| 634 Node* node) { | 634 Node* node) { |
| 635 Zone zone; | 635 Zone zone; |
| 636 ControlReducerImpl impl(&zone, jsgraph, common); | 636 ControlReducerImpl impl(&zone, jsgraph, common); |
| 637 switch (node->opcode()) { | 637 switch (node->opcode()) { |
| 638 case IrOpcode::kIfTrue: | 638 case IrOpcode::kIfTrue: |
| 639 return impl.ReduceIfTrue(node); | 639 return impl.ReduceIfTrue(node); |
| 640 case IrOpcode::kIfFalse: | 640 case IrOpcode::kIfFalse: |
| 641 return impl.ReduceIfFalse(node); | 641 return impl.ReduceIfFalse(node); |
| 642 default: | 642 default: |
| 643 return node; | 643 return node; |
| 644 } | 644 } |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 } // namespace v8::internal::compiler | 648 } // namespace v8::internal::compiler |
| OLD | NEW |