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 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
8 | 8 |
9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
10 | 10 |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 } | 1539 } |
1540 | 1540 |
1541 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 1541 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
1542 use(node.receiver); | 1542 use(node.receiver); |
1543 js.Expression object = pop(); | 1543 js.Expression object = pop(); |
1544 SourceString name = node.selector.name; | 1544 SourceString name = node.selector.name; |
1545 String methodName; | 1545 String methodName; |
1546 List<js.Expression> arguments = visitArguments(node.inputs); | 1546 List<js.Expression> arguments = visitArguments(node.inputs); |
1547 Element target = node.element; | 1547 Element target = node.element; |
1548 | 1548 |
1549 // Avoid adding the generative constructor name to the list of | 1549 if (target != null) { |
1550 // seen selectors. | 1550 // Avoid adding the generative constructor name to the list of |
1551 if (target != null && target.isGenerativeConstructorBody()) { | 1551 // seen selectors. |
1552 methodName = name.slowToString(); | 1552 if (target.isGenerativeConstructorBody()) { |
1553 } else if (target == backend.jsArrayAdd) { | 1553 methodName = name.slowToString(); |
1554 methodName = 'push'; | 1554 } else if (target == backend.jsArrayAdd) { |
1555 } else if (target == backend.jsArrayRemoveLast) { | 1555 methodName = 'push'; |
1556 methodName = 'pop'; | 1556 } else if (target == backend.jsArrayRemoveLast) { |
1557 } else if (target == backend.jsStringSplit) { | 1557 methodName = 'pop'; |
1558 methodName = 'split'; | 1558 } else if (target == backend.jsStringSplit) { |
1559 // Split returns a List, so we make sure the backend knows the | 1559 methodName = 'split'; |
1560 // list class is instantiated. | 1560 // Split returns a List, so we make sure the backend knows the |
1561 world.registerInstantiatedClass(compiler.listClass); | 1561 // list class is instantiated. |
1562 } else if (target == backend.jsStringConcat) { | 1562 world.registerInstantiatedClass(compiler.listClass); |
1563 push(new js.Binary('+', object, arguments[0]), node); | 1563 } else if (target == backend.jsStringConcat) { |
1564 return; | 1564 push(new js.Binary('+', object, arguments[0]), node); |
1565 } else { | 1565 return; |
| 1566 } |
| 1567 } |
| 1568 |
| 1569 if (methodName == null) { |
1566 methodName = backend.namer.instanceMethodInvocationName( | 1570 methodName = backend.namer.instanceMethodInvocationName( |
1567 node.selector.library, name, node.selector); | 1571 node.selector.library, name, node.selector); |
1568 bool inLoop = node.block.enclosingLoopHeader != null; | 1572 bool inLoop = node.block.enclosingLoopHeader != null; |
1569 | 1573 |
1570 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1574 Selector selector = getOptimizedSelectorFor(node, node.selector); |
1571 if (node.isInterceptorCall) { | 1575 if (node.isInterceptorCall) { |
1572 backend.addInterceptedSelector(selector); | 1576 backend.addInterceptedSelector(selector); |
1573 } | 1577 } |
1574 // Register this invocation to collect the types used at all call sites. | 1578 // Register this invocation to collect the types used at all call sites. |
1575 backend.registerDynamicInvocation(node, selector, types); | 1579 backend.registerDynamicInvocation(node, selector, types); |
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 if (leftType.canBeNull() && rightType.canBeNull()) { | 3034 if (leftType.canBeNull() && rightType.canBeNull()) { |
3031 if (left.isConstantNull() || right.isConstantNull() || | 3035 if (left.isConstantNull() || right.isConstantNull() || |
3032 (leftType.isPrimitive() && leftType == rightType)) { | 3036 (leftType.isPrimitive() && leftType == rightType)) { |
3033 return '=='; | 3037 return '=='; |
3034 } | 3038 } |
3035 return null; | 3039 return null; |
3036 } else { | 3040 } else { |
3037 return '==='; | 3041 return '==='; |
3038 } | 3042 } |
3039 } | 3043 } |
OLD | NEW |