| 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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 795 |
| 796 bool isDeadCode(HInstruction instruction) { | 796 bool isDeadCode(HInstruction instruction) { |
| 797 return !instruction.hasSideEffects() | 797 return !instruction.hasSideEffects() |
| 798 && instruction.usedBy.isEmpty | 798 && instruction.usedBy.isEmpty |
| 799 // A dynamic getter that has no side effect can still throw | 799 // A dynamic getter that has no side effect can still throw |
| 800 // a NoSuchMethodError. | 800 // a NoSuchMethodError. |
| 801 && instruction is !HInvokeDynamicGetter | 801 && instruction is !HInvokeDynamicGetter |
| 802 && instruction is !HCheck | 802 && instruction is !HCheck |
| 803 && instruction is !HTypeGuard | 803 && instruction is !HTypeGuard |
| 804 && instruction is !HParameterValue | 804 && instruction is !HParameterValue |
| 805 && instruction is !HLocalSet |
| 805 && !instruction.isControlFlow(); | 806 && !instruction.isControlFlow(); |
| 806 } | 807 } |
| 807 | 808 |
| 808 void visitGraph(HGraph graph) { | 809 void visitGraph(HGraph graph) { |
| 809 visitPostDominatorTree(graph); | 810 visitPostDominatorTree(graph); |
| 810 } | 811 } |
| 811 | 812 |
| 812 void visitBasicBlock(HBasicBlock block) { | 813 void visitBasicBlock(HBasicBlock block) { |
| 813 HInstruction instruction = block.last; | 814 HInstruction instruction = block.last; |
| 814 while (instruction != null) { | 815 while (instruction != null) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 // Run through all the basic blocks in the graph and fill in the | 1056 // Run through all the basic blocks in the graph and fill in the |
| 1056 // changes flags lists. | 1057 // changes flags lists. |
| 1057 for (int i = length - 1; i >= 0; i--) { | 1058 for (int i = length - 1; i >= 0; i--) { |
| 1058 final HBasicBlock block = graph.blocks[i]; | 1059 final HBasicBlock block = graph.blocks[i]; |
| 1059 final int id = block.id; | 1060 final int id = block.id; |
| 1060 | 1061 |
| 1061 // Compute block changes flags for the block. | 1062 // Compute block changes flags for the block. |
| 1062 int changesFlags = 0; | 1063 int changesFlags = 0; |
| 1063 HInstruction instruction = block.first; | 1064 HInstruction instruction = block.first; |
| 1064 while (instruction != null) { | 1065 while (instruction != null) { |
| 1065 instruction.prepareGvn(types); | |
| 1066 changesFlags |= instruction.getChangesFlags(); | 1066 changesFlags |= instruction.getChangesFlags(); |
| 1067 instruction = instruction.next; | 1067 instruction = instruction.next; |
| 1068 } | 1068 } |
| 1069 assert(blockChangesFlags[id] == null); | 1069 assert(blockChangesFlags[id] == null); |
| 1070 blockChangesFlags[id] = changesFlags; | 1070 blockChangesFlags[id] = changesFlags; |
| 1071 | 1071 |
| 1072 // Loop headers are part of their loop, so update the loop | 1072 // Loop headers are part of their loop, so update the loop |
| 1073 // changes flags accordingly. | 1073 // changes flags accordingly. |
| 1074 if (block.isLoopHeader()) { | 1074 if (block.isLoopHeader()) { |
| 1075 loopChangesFlags[id] |= changesFlags; | 1075 loopChangesFlags[id] |= changesFlags; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 || otherIntercepted.contains(backend.jsDoubleClass)) { | 1441 || otherIntercepted.contains(backend.jsDoubleClass)) { |
| 1442 interceptor.interceptedClasses.addAll(user.interceptedClasses); | 1442 interceptor.interceptedClasses.addAll(user.interceptedClasses); |
| 1443 } | 1443 } |
| 1444 user.interceptedClasses = interceptor.interceptedClasses; | 1444 user.interceptedClasses = interceptor.interceptedClasses; |
| 1445 } | 1445 } |
| 1446 } | 1446 } |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 // TODO(ngeoffray): Also implement it for non-intercepted calls. | 1449 // TODO(ngeoffray): Also implement it for non-intercepted calls. |
| 1450 } | 1450 } |
| OLD | NEW |