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