| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.cps_ir.shrinking_reductions; | 5 library dart2js.cps_ir.shrinking_reductions; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart'; | 8 import 'optimizers.dart'; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (trueBody is! InvokeContinuation) return false; | 538 if (trueBody is! InvokeContinuation) return false; |
| 539 Continuation falseCont = branch.falseContinuation.definition; | 539 Continuation falseCont = branch.falseContinuation.definition; |
| 540 Expression falseBody = _unfoldDeadRefinements(falseCont.body); | 540 Expression falseBody = _unfoldDeadRefinements(falseCont.body); |
| 541 if (falseBody is! InvokeContinuation) return false; | 541 if (falseBody is! InvokeContinuation) return false; |
| 542 InvokeContinuation trueInvoke = trueBody; | 542 InvokeContinuation trueInvoke = trueBody; |
| 543 InvokeContinuation falseInvoke = falseBody; | 543 InvokeContinuation falseInvoke = falseBody; |
| 544 if (trueInvoke.continuation.definition != | 544 if (trueInvoke.continuation.definition != |
| 545 falseInvoke.continuation.definition) { | 545 falseInvoke.continuation.definition) { |
| 546 return false; | 546 return false; |
| 547 } | 547 } |
| 548 assert(trueInvoke.arguments.length == falseInvoke.arguments.length); | |
| 549 // Matching zero arguments should be adequate, since isomorphic true and false | 548 // Matching zero arguments should be adequate, since isomorphic true and false |
| 550 // invocations should result in redundant phis which are removed elsewhere. | 549 // invocations should result in redundant phis which are removed elsewhere. |
| 551 if (trueInvoke.arguments.isNotEmpty) return false; | 550 // |
| 552 return true; | 551 // Note that the argument lists are not necessarily the same length here, |
| 552 // because we could be looking for new redexes in the middle of performing a |
| 553 // dead parameter reduction, where some but not all of the invocations have |
| 554 // been rewritten. In that case, we will find the redex (once) after both |
| 555 // of these invocations have been rewritten. |
| 556 return trueInvoke.arguments.isEmpty && falseInvoke.arguments.isEmpty; |
| 553 } | 557 } |
| 554 | 558 |
| 555 bool _isDeadParameter(Parameter parameter) { | 559 bool _isDeadParameter(Parameter parameter) { |
| 556 if (_isParameterRemoved(parameter)) return false; | 560 if (_isParameterRemoved(parameter)) return false; |
| 557 | 561 |
| 558 // We cannot remove function parameters as an intraprocedural optimization. | 562 // We cannot remove function parameters as an intraprocedural optimization. |
| 559 if (parameter.parent is! Continuation || parameter.hasAtLeastOneUse) { | 563 if (parameter.parent is! Continuation || parameter.hasAtLeastOneUse) { |
| 560 return false; | 564 return false; |
| 561 } | 565 } |
| 562 | 566 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 assert(node is Continuation || node is LetPrim || node is Parameter || | 706 assert(node is Continuation || node is LetPrim || node is Parameter || |
| 703 node is Branch); | 707 node is Branch); |
| 704 } | 708 } |
| 705 | 709 |
| 706 bool operator==(_ReductionTask that) { | 710 bool operator==(_ReductionTask that) { |
| 707 return (that.kind == this.kind && that.node == this.node); | 711 return (that.kind == this.kind && that.node == this.node); |
| 708 } | 712 } |
| 709 | 713 |
| 710 String toString() => "$kind: $node"; | 714 String toString() => "$kind: $node"; |
| 711 } | 715 } |
| OLD | NEW |