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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
6 | 6 |
7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
8 | 8 |
9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
10 : this.backend = backend, | 10 : this.backend = backend, |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1476 methodName = name.slowToString(); | 1476 methodName = name.slowToString(); |
1477 arguments = visitArguments(node.inputs); | 1477 arguments = visitArguments(node.inputs); |
1478 } else { | 1478 } else { |
1479 methodName = backend.namer.instanceMethodInvocationName( | 1479 methodName = backend.namer.instanceMethodInvocationName( |
1480 node.selector.library, name, node.selector); | 1480 node.selector.library, name, node.selector); |
1481 arguments = visitArguments(node.inputs); | 1481 arguments = visitArguments(node.inputs); |
1482 bool inLoop = node.block.enclosingLoopHeader != null; | 1482 bool inLoop = node.block.enclosingLoopHeader != null; |
1483 | 1483 |
1484 // Register this invocation to collect the types used at all call sites. | 1484 // Register this invocation to collect the types used at all call sites. |
1485 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1485 Selector selector = getOptimizedSelectorFor(node, node.selector); |
1486 if (node.selector.name.slowToString() == 'foo' || | |
ngeoffray
2012/10/26 08:34:55
Remove
Johnni Winther
2012/10/26 10:18:01
Done.
| |
1487 node.selector.name.slowToString() == 'bar') { | |
1488 print('getOptimizedSelectorFor($node)=$selector, target=${target}'); | |
1489 } | |
1486 backend.registerDynamicInvocation(node, selector, types); | 1490 backend.registerDynamicInvocation(node, selector, types); |
1487 | 1491 |
1488 // If we don't know what we're calling or if we are calling a getter, | 1492 // If we don't know what we're calling or if we are calling a getter, |
1489 // we need to register that fact that we may be calling a closure | 1493 // we need to register that fact that we may be calling a closure |
1490 // with the same arguments. | 1494 // with the same arguments. |
1491 if (target == null || target.isGetter()) { | 1495 if (target == null || target.isGetter()) { |
1492 // TODO(kasperl): If we have a typed selector for the call, we | 1496 // TODO(kasperl): If we have a typed selector for the call, we |
1493 // may know something about the types of closures that need | 1497 // may know something about the types of closures that need |
1494 // the specific closure call method. | 1498 // the specific closure call method. |
1495 Selector call = new Selector.callClosureFrom(selector); | 1499 Selector call = new Selector.callClosureFrom(selector); |
(...skipping 10 matching lines...) Expand all Loading... | |
1506 world.registerDynamicInvocation(name, selector); | 1510 world.registerDynamicInvocation(name, selector); |
1507 } | 1511 } |
1508 } | 1512 } |
1509 push(jsPropertyCall(object, methodName, arguments), node); | 1513 push(jsPropertyCall(object, methodName, arguments), node); |
1510 } | 1514 } |
1511 | 1515 |
1512 Selector getOptimizedSelectorFor(HInvokeDynamic node, | 1516 Selector getOptimizedSelectorFor(HInvokeDynamic node, |
1513 Selector defaultSelector) { | 1517 Selector defaultSelector) { |
1514 // TODO(4434): For private members we need to use the untyped selector. | 1518 // TODO(4434): For private members we need to use the untyped selector. |
1515 if (defaultSelector.name.isPrivate()) return defaultSelector; | 1519 if (defaultSelector.name.isPrivate()) return defaultSelector; |
1520 // If [noSuchMethod] has been overridden and [InvocationMirror.invokeOn] | |
1521 // has been called we must not create a typed selector based on the receiver | |
1522 // type. | |
1523 if (node.element == null && // Invocation is not exact. | |
1524 backend.compiler.enabledNoSuchMethod && | |
ngeoffray
2012/10/26 08:34:55
I think you can just check enabledInvokeOn.
Johnni Winther
2012/10/26 10:18:01
Done.
| |
1525 backend.compiler.enabledInvokeOn) { | |
1526 return defaultSelector; | |
1527 } | |
1516 HType receiverHType = types[node.inputs[0]]; | 1528 HType receiverHType = types[node.inputs[0]]; |
1517 DartType receiverType = receiverHType.computeType(compiler); | 1529 DartType receiverType = receiverHType.computeType(compiler); |
1518 if (receiverType != null) { | 1530 if (receiverType != null) { |
1519 return new TypedSelector(receiverType, defaultSelector); | 1531 return new TypedSelector(receiverType, defaultSelector); |
1520 } else { | 1532 } else { |
1521 return defaultSelector; | 1533 return defaultSelector; |
1522 } | 1534 } |
1523 } | 1535 } |
1524 | 1536 |
1525 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 1537 visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2990 if (leftType.canBeNull() && rightType.canBeNull()) { | 3002 if (leftType.canBeNull() && rightType.canBeNull()) { |
2991 if (left.isConstantNull() || right.isConstantNull() || | 3003 if (left.isConstantNull() || right.isConstantNull() || |
2992 (leftType.isPrimitive() && leftType == rightType)) { | 3004 (leftType.isPrimitive() && leftType == rightType)) { |
2993 return '=='; | 3005 return '=='; |
2994 } | 3006 } |
2995 return null; | 3007 return null; |
2996 } else { | 3008 } else { |
2997 return '==='; | 3009 return '==='; |
2998 } | 3010 } |
2999 } | 3011 } |
OLD | NEW |