| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (live > 1 && live == node->InputCount()) return node; // nothing to do. | 449 if (live > 1 && live == node->InputCount()) return node; // nothing to do. |
| 450 | 450 |
| 451 TRACE(("ReduceMerge: #%d:%s (%d live)\n", node->id(), | 451 TRACE(("ReduceMerge: #%d:%s (%d live)\n", node->id(), |
| 452 node->op()->mnemonic(), live)); | 452 node->op()->mnemonic(), live)); |
| 453 | 453 |
| 454 if (live == 0) return dead(); // no remaining inputs. | 454 if (live == 0) return dead(); // no remaining inputs. |
| 455 | 455 |
| 456 // Gather phis and effect phis to be edited. | 456 // Gather phis and effect phis to be edited. |
| 457 ZoneVector<Node*> phis(zone_); | 457 ZoneVector<Node*> phis(zone_); |
| 458 for (Node* const use : node->uses()) { | 458 for (Node* const use : node->uses()) { |
| 459 if (use->opcode() == IrOpcode::kPhi || | 459 if (IrOpcode::IsPhiOpcode(use->opcode())) phis.push_back(use); |
| 460 use->opcode() == IrOpcode::kEffectPhi) { | |
| 461 phis.push_back(use); | |
| 462 } | |
| 463 } | 460 } |
| 464 | 461 |
| 465 if (live == 1) { | 462 if (live == 1) { |
| 466 // All phis are redundant. Replace them with their live input. | 463 // All phis are redundant. Replace them with their live input. |
| 467 for (Node* const phi : phis) ReplaceNode(phi, phi->InputAt(live_index)); | 464 for (Node* const phi : phis) ReplaceNode(phi, phi->InputAt(live_index)); |
| 468 // The merge itself is redundant. | 465 // The merge itself is redundant. |
| 469 return node->InputAt(live_index); | 466 return node->InputAt(live_index); |
| 470 } | 467 } |
| 471 | 468 |
| 472 // Edit phis in place, removing dead inputs and revisiting them. | 469 // Edit phis in place, removing dead inputs and revisiting them. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 Node* ControlReducer::ReduceBranchForTesting(JSGraph* jsgraph, | 584 Node* ControlReducer::ReduceBranchForTesting(JSGraph* jsgraph, |
| 588 CommonOperatorBuilder* common, | 585 CommonOperatorBuilder* common, |
| 589 Node* node) { | 586 Node* node) { |
| 590 Zone zone(jsgraph->graph()->zone()->isolate()); | 587 Zone zone(jsgraph->graph()->zone()->isolate()); |
| 591 ControlReducerImpl impl(&zone, jsgraph, common); | 588 ControlReducerImpl impl(&zone, jsgraph, common); |
| 592 return impl.ReduceBranch(node); | 589 return impl.ReduceBranch(node); |
| 593 } | 590 } |
| 594 } | 591 } |
| 595 } | 592 } |
| 596 } // namespace v8::internal::compiler | 593 } // namespace v8::internal::compiler |
| OLD | NEW |