| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface OptimizationPhase { | 5 interface OptimizationPhase { |
| 6 String get name(); | 6 String get name(); |
| 7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 Constant folded = operation.fold(receiver.constant); | 147 Constant folded = operation.fold(receiver.constant); |
| 148 if (folded !== null) return graph.addConstant(folded); | 148 if (folded !== null) return graph.addConstant(folded); |
| 149 } | 149 } |
| 150 return node; | 150 return node; |
| 151 } | 151 } |
| 152 | 152 |
| 153 HInstruction visitInvokeInterceptor(HInvokeInterceptor node) { | 153 HInstruction visitInvokeInterceptor(HInvokeInterceptor node) { |
| 154 if (node.isLengthGetter()) { | 154 if (node.isLengthGetter()) { |
| 155 HInstruction input = node.inputs[1]; | 155 HInstruction input = node.inputs[1]; |
| 156 if (input.isConstantString()) { | 156 if (input.isConstantString()) { |
| 157 StringConstant constant = input.constant; | 157 HConstant constantInput = input; |
| 158 StringConstant constant = constantInput.constant; |
| 158 return graph.addConstantInt(constant.length); | 159 return graph.addConstantInt(constant.length); |
| 159 } else if (input.isConstantList()) { | 160 } else if (input.isConstantList()) { |
| 160 ListConstant constant = input.constant; | 161 HConstant constantInput = input; |
| 162 ListConstant constant = constantInput.constant; |
| 161 return graph.addConstantInt(constant.length); | 163 return graph.addConstantInt(constant.length); |
| 162 } else if (input.isConstantMap()) { | 164 } else if (input.isConstantMap()) { |
| 163 MapConstant constant = input.constant; | 165 HConstant constantInput = input; |
| 166 MapConstant constant = constantInput.constant; |
| 164 return graph.addConstantInt(constant.length); | 167 return graph.addConstantInt(constant.length); |
| 165 } | 168 } |
| 166 } | 169 } |
| 167 return node; | 170 return node; |
| 168 } | 171 } |
| 169 | 172 |
| 170 HInstruction visitInvokeDynamic(HInvokeDynamic node) { | 173 HInstruction visitInvokeDynamic(HInvokeDynamic node) { |
| 171 HType receiverType = node.receiver.propagatedType; | 174 HType receiverType = node.receiver.propagatedType; |
| 172 if (receiverType.isNonPrimitive()) { | 175 if (receiverType.isNonPrimitive()) { |
| 173 HNonPrimitiveType type = receiverType; | 176 HNonPrimitiveType type = receiverType; |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 815 } |
| 813 } | 816 } |
| 814 if (!canBeMoved) continue; | 817 if (!canBeMoved) continue; |
| 815 | 818 |
| 816 // This is safe because we are running after GVN. | 819 // This is safe because we are running after GVN. |
| 817 // TODO(ngeoffray): ensure GVN has been run. | 820 // TODO(ngeoffray): ensure GVN has been run. |
| 818 set_.add(current); | 821 set_.add(current); |
| 819 } | 822 } |
| 820 } | 823 } |
| 821 } | 824 } |
| OLD | NEW |