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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 use(node.receiver); | 1536 use(node.receiver); |
1537 List<js.Expression> arguments = <js.Expression>[pop()]; | 1537 List<js.Expression> arguments = <js.Expression>[pop()]; |
1538 push(new js.Call(interceptor, arguments), node); | 1538 push(new js.Call(interceptor, arguments), node); |
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; | 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 // Avoid adding the generative constructor name to the list of |
1550 // seen selectors. | 1550 // seen selectors. |
1551 if (target != null && target.isGenerativeConstructorBody()) { | 1551 if (target != null && target.isGenerativeConstructorBody()) { |
1552 methodName = name.slowToString(); | 1552 methodName = name.slowToString(); |
1553 arguments = visitArguments(node.inputs); | 1553 } else if (target == backend.jsArrayAdd) { |
| 1554 methodName = 'push'; |
| 1555 } else if (target == backend.jsArrayRemoveLast) { |
| 1556 methodName = 'pop'; |
| 1557 } else if (target == backend.jsStringSplit) { |
| 1558 methodName = 'split'; |
| 1559 // Split returns a List, so we make sure the backend knows the |
| 1560 // list class is instantiated. |
| 1561 world.registerInstantiatedClass(compiler.listClass); |
| 1562 } else if (target == backend.jsStringConcat) { |
| 1563 push(new js.Binary('+', object, arguments[0]), node); |
| 1564 return; |
1554 } else { | 1565 } else { |
1555 methodName = backend.namer.instanceMethodInvocationName( | 1566 methodName = backend.namer.instanceMethodInvocationName( |
1556 node.selector.library, name, node.selector); | 1567 node.selector.library, name, node.selector); |
1557 arguments = visitArguments(node.inputs); | |
1558 bool inLoop = node.block.enclosingLoopHeader != null; | 1568 bool inLoop = node.block.enclosingLoopHeader != null; |
1559 | 1569 |
1560 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1570 Selector selector = getOptimizedSelectorFor(node, node.selector); |
1561 if (node.isInterceptorCall) { | 1571 if (node.isInterceptorCall) { |
1562 backend.addInterceptedSelector(selector); | 1572 backend.addInterceptedSelector(selector); |
1563 } | 1573 } |
1564 // Register this invocation to collect the types used at all call sites. | 1574 // Register this invocation to collect the types used at all call sites. |
1565 backend.registerDynamicInvocation(node, selector, types); | 1575 backend.registerDynamicInvocation(node, selector, types); |
1566 | 1576 |
1567 // If we don't know what we're calling or if we are calling a getter, | 1577 // If we don't know what we're calling or if we are calling a getter, |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 if (leftType.canBeNull() && rightType.canBeNull()) { | 3030 if (leftType.canBeNull() && rightType.canBeNull()) { |
3021 if (left.isConstantNull() || right.isConstantNull() || | 3031 if (left.isConstantNull() || right.isConstantNull() || |
3022 (leftType.isPrimitive() && leftType == rightType)) { | 3032 (leftType.isPrimitive() && leftType == rightType)) { |
3023 return '=='; | 3033 return '=='; |
3024 } | 3034 } |
3025 return null; | 3035 return null; |
3026 } else { | 3036 } else { |
3027 return '==='; | 3037 return '==='; |
3028 } | 3038 } |
3029 } | 3039 } |
OLD | NEW |