| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 if (isFixedSizeListConstructor(node)) { | 379 if (isFixedSizeListConstructor(node)) { |
| 380 node.guaranteedType = HType.FIXED_ARRAY; | 380 node.guaranteedType = HType.FIXED_ARRAY; |
| 381 } | 381 } |
| 382 return node; | 382 return node; |
| 383 } | 383 } |
| 384 | 384 |
| 385 HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 385 HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
| 386 if (node.isInterceptorCall) return handleInterceptorCall(node); | 386 if (node.isInterceptorCall) return handleInterceptorCall(node); |
| 387 HType receiverType = types[node.receiver]; | 387 HType receiverType = types[node.receiver]; |
| 388 if (receiverType.isExact()) { | 388 if (receiverType.isExact()) { |
| 389 HBoundedType type = receiverType; | 389 Element element = receiverType.lookupMember(node.selector.name, compiler); |
| 390 Element element = type.lookupMember(node.selector.name); | |
| 391 // TODO(ngeoffray): Also fold if it's a getter or variable. | 390 // TODO(ngeoffray): Also fold if it's a getter or variable. |
| 392 if (element != null && element.isFunction()) { | 391 if (element != null && element.isFunction()) { |
| 393 if (node.selector.applies(element, compiler)) { | 392 if (node.selector.applies(element, compiler)) { |
| 394 FunctionElement method = element; | 393 FunctionElement method = element; |
| 395 FunctionSignature parameters = method.computeSignature(compiler); | 394 FunctionSignature parameters = method.computeSignature(compiler); |
| 396 if (parameters.optionalParameterCount == 0) { | 395 if (parameters.optionalParameterCount == 0) { |
| 397 node.element = element; | 396 node.element = element; |
| 398 } | 397 } |
| 399 // TODO(ngeoffray): If the method has optional parameters, | 398 // TODO(ngeoffray): If the method has optional parameters, |
| 400 // we should pass the default values here. | 399 // we should pass the default values here. |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 | 1268 |
| 1270 HTypeConversion newInput = new HTypeConversion(convertedType, input); | 1269 HTypeConversion newInput = new HTypeConversion(convertedType, input); |
| 1271 dominator.addBefore(dominator.first, newInput); | 1270 dominator.addBefore(dominator.first, newInput); |
| 1272 dominatedUsers.forEach((HInstruction user) { | 1271 dominatedUsers.forEach((HInstruction user) { |
| 1273 user.changeUse(input, newInput); | 1272 user.changeUse(input, newInput); |
| 1274 }); | 1273 }); |
| 1275 } | 1274 } |
| 1276 | 1275 |
| 1277 void visitIs(HIs instruction) { | 1276 void visitIs(HIs instruction) { |
| 1278 HInstruction input = instruction.expression; | 1277 HInstruction input = instruction.expression; |
| 1279 HType convertedType = | 1278 HType convertedType = new HType.fromBoundedType( |
| 1280 new HType.fromBoundedType(instruction.typeExpression, compiler); | 1279 instruction.typeExpression, |
| 1280 compiler, |
| 1281 canBeNull: false, |
| 1282 isExact: false, |
| 1283 isInterfaceType: true); |
| 1281 | 1284 |
| 1282 List<HInstruction> ifUsers = <HInstruction>[]; | 1285 List<HInstruction> ifUsers = <HInstruction>[]; |
| 1283 List<HInstruction> notIfUsers = <HInstruction>[]; | 1286 List<HInstruction> notIfUsers = <HInstruction>[]; |
| 1284 | 1287 |
| 1285 for (HInstruction user in instruction.usedBy) { | 1288 for (HInstruction user in instruction.usedBy) { |
| 1286 if (user is HIf) { | 1289 if (user is HIf) { |
| 1287 ifUsers.add(user); | 1290 ifUsers.add(user); |
| 1288 } else if (user is HNot) { | 1291 } else if (user is HNot) { |
| 1289 for (HInstruction notUser in user.usedBy) { | 1292 for (HInstruction notUser in user.usedBy) { |
| 1290 if (notUser is HIf) notIfUsers.add(notUser); | 1293 if (notUser is HIf) notIfUsers.add(notUser); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 HBasicBlock block = user.block; | 1539 HBasicBlock block = user.block; |
| 1537 block.addAfter(user, interceptor); | 1540 block.addAfter(user, interceptor); |
| 1538 block.rewrite(user, interceptor); | 1541 block.rewrite(user, interceptor); |
| 1539 block.remove(user); | 1542 block.remove(user); |
| 1540 | 1543 |
| 1541 // The interceptor will be removed in the dead code elimination | 1544 // The interceptor will be removed in the dead code elimination |
| 1542 // phase. Note that removing it here would not work because of how | 1545 // phase. Note that removing it here would not work because of how |
| 1543 // the [visitBasicBlock] is implemented. | 1546 // the [visitBasicBlock] is implemented. |
| 1544 } | 1547 } |
| 1545 } | 1548 } |
| OLD | NEW |