| 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 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 return node; | 224 return node; |
| 225 } | 225 } |
| 226 | 226 |
| 227 HInstruction visitInvokeDynamic(HInvokeDynamic node) { | 227 HInstruction visitInvokeDynamic(HInvokeDynamic node) { |
| 228 HType receiverType = types[node.receiver]; | 228 HType receiverType = types[node.receiver]; |
| 229 if (receiverType.isExact()) { | 229 if (receiverType.isExact()) { |
| 230 HBoundedType type = receiverType; | 230 HBoundedType type = receiverType; |
| 231 Element element = type.lookupMember(node.name); | 231 Element element = type.lookupMember(node.selector.name); |
| 232 // TODO(ngeoffray): Also fold if it's a getter or variable. | 232 // TODO(ngeoffray): Also fold if it's a getter or variable. |
| 233 if (element != null && element.isFunction()) { | 233 if (element != null && element.isFunction()) { |
| 234 if (node.selector.applies(element, compiler)) { | 234 if (node.selector.applies(element, compiler)) { |
| 235 FunctionElement method = element; | 235 FunctionElement method = element; |
| 236 FunctionSignature parameters = method.computeSignature(compiler); | 236 FunctionSignature parameters = method.computeSignature(compiler); |
| 237 if (parameters.optionalParameterCount == 0) { | 237 if (parameters.optionalParameterCount == 0) { |
| 238 node.element = element; | 238 node.element = element; |
| 239 } | 239 } |
| 240 // TODO(ngeoffray): If the method has optional parameters, | 240 // TODO(ngeoffray): If the method has optional parameters, |
| 241 // we should pass the default values here. | 241 // we should pass the default values here. |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 return node; | 245 return node; |
| 246 } | 246 } |
| 247 | 247 |
| 248 HInstruction fromInterceptorToDynamicInvocation(HInvokeStatic node, | 248 HInstruction fromInterceptorToDynamicInvocation(HInvokeStatic node, |
| 249 Selector selector) { | 249 Selector selector) { |
| 250 HBoundedType type = types[node.inputs[1]]; | 250 HBoundedType type = types[node.inputs[1]]; |
| 251 HInvokeDynamicMethod result = new HInvokeDynamicMethod( | 251 HInvokeDynamicMethod result = new HInvokeDynamicMethod( |
| 252 selector, | 252 selector, |
| 253 selector.name, | |
| 254 node.inputs.getRange(1, node.inputs.length - 1)); | 253 node.inputs.getRange(1, node.inputs.length - 1)); |
| 255 if (type.isExact()) { | 254 if (type.isExact()) { |
| 256 HBoundedType concrete = type; | 255 HBoundedType concrete = type; |
| 257 result.element = concrete.lookupMember(selector.name); | 256 result.element = concrete.lookupMember(selector.name); |
| 258 } | 257 } |
| 259 return result; | 258 return result; |
| 260 } | 259 } |
| 261 | 260 |
| 262 HInstruction visitBoundsCheck(HBoundsCheck node) { | 261 HInstruction visitBoundsCheck(HBoundsCheck node) { |
| 263 int tryGetIntConstantValue(HInstruction instruction, String errorMessage) { | 262 int tryGetIntConstantValue(HInstruction instruction, String errorMessage) { |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 // this type for the field is still a strong signal | 1328 // this type for the field is still a strong signal |
| 1330 // indicating the expected type of the field. | 1329 // indicating the expected type of the field. |
| 1331 types[field] = type; | 1330 types[field] = type; |
| 1332 } else { | 1331 } else { |
| 1333 // If there are no invoked setters we know the type of | 1332 // If there are no invoked setters we know the type of |
| 1334 // this field for sure. | 1333 // this field for sure. |
| 1335 field.guaranteedType = type; | 1334 field.guaranteedType = type; |
| 1336 } | 1335 } |
| 1337 } | 1336 } |
| 1338 } | 1337 } |
| OLD | NEW |