| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 788 } |
| 789 | 789 |
| 790 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { | 790 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { |
| 791 final HTypeMap types; | 791 final HTypeMap types; |
| 792 final String name = "SsaDeadCodeEliminator"; | 792 final String name = "SsaDeadCodeEliminator"; |
| 793 | 793 |
| 794 SsaDeadCodeEliminator(this.types); | 794 SsaDeadCodeEliminator(this.types); |
| 795 | 795 |
| 796 bool isDeadCode(HInstruction instruction) { | 796 bool isDeadCode(HInstruction instruction) { |
| 797 return !instruction.hasSideEffects() | 797 return !instruction.hasSideEffects() |
| 798 && !instruction.canThrow() |
| 798 && instruction.usedBy.isEmpty | 799 && instruction.usedBy.isEmpty |
| 799 // A dynamic getter that has no side effect can still throw | |
| 800 // a NoSuchMethodError. | |
| 801 && instruction is !HInvokeDynamicGetter | |
| 802 && instruction is !HCheck | |
| 803 && instruction is !HTypeGuard | 800 && instruction is !HTypeGuard |
| 804 && instruction is !HParameterValue | 801 && instruction is !HParameterValue |
| 805 && instruction is !HLocalSet | 802 && instruction is !HLocalSet |
| 806 && !instruction.isControlFlow(); | 803 && !instruction.isControlFlow(); |
| 807 } | 804 } |
| 808 | 805 |
| 809 void visitGraph(HGraph graph) { | 806 void visitGraph(HGraph graph) { |
| 810 visitPostDominatorTree(graph); | 807 visitPostDominatorTree(graph); |
| 811 } | 808 } |
| 812 | 809 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 || otherIntercepted.contains(backend.jsDoubleClass)) { | 1438 || otherIntercepted.contains(backend.jsDoubleClass)) { |
| 1442 interceptor.interceptedClasses.addAll(user.interceptedClasses); | 1439 interceptor.interceptedClasses.addAll(user.interceptedClasses); |
| 1443 } | 1440 } |
| 1444 user.interceptedClasses = interceptor.interceptedClasses; | 1441 user.interceptedClasses = interceptor.interceptedClasses; |
| 1445 } | 1442 } |
| 1446 } | 1443 } |
| 1447 } | 1444 } |
| 1448 | 1445 |
| 1449 // TODO(ngeoffray): Also implement it for non-intercepted calls. | 1446 // TODO(ngeoffray): Also implement it for non-intercepted calls. |
| 1450 } | 1447 } |
| OLD | NEW |