| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // If a node has only one control input and it is dead, replace with dead. | 393 // If a node has only one control input and it is dead, replace with dead. |
| 394 Node* control = NodeProperties::GetControlInput(node); | 394 Node* control = NodeProperties::GetControlInput(node); |
| 395 if (control->opcode() == IrOpcode::kDead) { | 395 if (control->opcode() == IrOpcode::kDead) { |
| 396 TRACE(("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic())); | 396 TRACE(("ControlDead: #%d:%s\n", node->id(), node->op()->mnemonic())); |
| 397 return control; | 397 return control; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 // Reduce branches, phis, and merges. | 401 // Reduce branches, phis, and merges. |
| 402 switch (node->opcode()) { | 402 switch (node->opcode()) { |
| 403 case IrOpcode::kBranch: |
| 404 return ReduceBranch(node); |
| 403 case IrOpcode::kIfTrue: | 405 case IrOpcode::kIfTrue: |
| 404 return ReduceIfTrue(node); | 406 return ReduceIfTrue(node); |
| 405 case IrOpcode::kIfFalse: | 407 case IrOpcode::kIfFalse: |
| 406 return ReduceIfFalse(node); | 408 return ReduceIfFalse(node); |
| 407 case IrOpcode::kLoop: | 409 case IrOpcode::kLoop: |
| 408 case IrOpcode::kMerge: | 410 case IrOpcode::kMerge: |
| 409 return ReduceMerge(node); | 411 return ReduceMerge(node); |
| 410 case IrOpcode::kSelect: | 412 case IrOpcode::kSelect: |
| 411 return ReduceSelect(node); | 413 return ReduceSelect(node); |
| 412 case IrOpcode::kPhi: | 414 case IrOpcode::kPhi: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 Node* input = *it; | 473 Node* input = *it; |
| 472 if (input->opcode() == IrOpcode::kDead) continue; // ignore dead inputs. | 474 if (input->opcode() == IrOpcode::kDead) continue; // ignore dead inputs. |
| 473 if (input != node && input != replacement) { // non-redundant input. | 475 if (input != node && input != replacement) { // non-redundant input. |
| 474 if (replacement != NULL) return node; | 476 if (replacement != NULL) return node; |
| 475 replacement = input; | 477 replacement = input; |
| 476 } | 478 } |
| 477 } | 479 } |
| 478 return replacement == NULL ? dead() : replacement; | 480 return replacement == NULL ? dead() : replacement; |
| 479 } | 481 } |
| 480 | 482 |
| 483 // Reduce branches. |
| 484 Node* ReduceBranch(Node* branch) { |
| 485 if (DecideCondition(branch->InputAt(0)) != kUnknown) { |
| 486 for (Node* use : branch->uses()) Revisit(use); |
| 487 } |
| 488 return branch; |
| 489 } |
| 490 |
| 481 // Reduce merges by trimming away dead inputs from the merge and phis. | 491 // Reduce merges by trimming away dead inputs from the merge and phis. |
| 482 Node* ReduceMerge(Node* node) { | 492 Node* ReduceMerge(Node* node) { |
| 483 // Count the number of live inputs. | 493 // Count the number of live inputs. |
| 484 int live = 0; | 494 int live = 0; |
| 485 int index = 0; | 495 int index = 0; |
| 486 int live_index = 0; | 496 int live_index = 0; |
| 487 for (Node* const input : node->inputs()) { | 497 for (Node* const input : node->inputs()) { |
| 488 if (input->opcode() != IrOpcode::kDead) { | 498 if (input->opcode() != IrOpcode::kDead) { |
| 489 live++; | 499 live++; |
| 490 live_index = index; | 500 live_index = index; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 return impl.ReduceIfTrue(node); | 644 return impl.ReduceIfTrue(node); |
| 635 case IrOpcode::kIfFalse: | 645 case IrOpcode::kIfFalse: |
| 636 return impl.ReduceIfFalse(node); | 646 return impl.ReduceIfFalse(node); |
| 637 default: | 647 default: |
| 638 return node; | 648 return node; |
| 639 } | 649 } |
| 640 } | 650 } |
| 641 } | 651 } |
| 642 } | 652 } |
| 643 } // namespace v8::internal::compiler | 653 } // namespace v8::internal::compiler |
| OLD | NEW |