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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 // Depending on how the then/else branches terminate | 1466 // Depending on how the then/else branches terminate |
1467 // (e.g., return/throw/break) there can be any number of these. | 1467 // (e.g., return/throw/break) there can be any number of these. |
1468 List<HBasicBlock> dominated = node.block.dominatedBlocks; | 1468 List<HBasicBlock> dominated = node.block.dominatedBlocks; |
1469 for (int i = 2; i < dominated.length; i++) { | 1469 for (int i = 2; i < dominated.length; i++) { |
1470 visitBasicBlock(dominated[i]); | 1470 visitBasicBlock(dominated[i]); |
1471 } | 1471 } |
1472 } | 1472 } |
1473 | 1473 |
1474 void visitInterceptor(HInterceptor node) { | 1474 void visitInterceptor(HInterceptor node) { |
1475 registry.registerSpecializedGetInterceptor(node.interceptedClasses); | 1475 registry.registerSpecializedGetInterceptor(node.interceptedClasses); |
1476 String name = backend.namer.getInterceptorName( | 1476 String name = backend.namer.nameForGetInterceptor(node.interceptedClasses); |
1477 backend.getInterceptorMethod, node.interceptedClasses); | |
1478 var isolate = new js.VariableUse( | 1477 var isolate = new js.VariableUse( |
1479 backend.namer.globalObjectFor(backend.interceptorsLibrary)); | 1478 backend.namer.globalObjectFor(backend.interceptorsLibrary)); |
1480 use(node.receiver); | 1479 use(node.receiver); |
1481 List<js.Expression> arguments = <js.Expression>[pop()]; | 1480 List<js.Expression> arguments = <js.Expression>[pop()]; |
1482 push(js.propertyCall(isolate, name, arguments), node); | 1481 push(js.propertyCall(isolate, name, arguments), node); |
1483 registry.registerUseInterceptor(); | 1482 registry.registerUseInterceptor(); |
1484 } | 1483 } |
1485 | 1484 |
1486 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { | 1485 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { |
1487 use(node.receiver); | 1486 use(node.receiver); |
(...skipping 25 matching lines...) Expand all Loading... |
1513 if (methodName == null) { | 1512 if (methodName == null) { |
1514 methodName = backend.namer.invocationName(node.selector); | 1513 methodName = backend.namer.invocationName(node.selector); |
1515 registerMethodInvoke(node); | 1514 registerMethodInvoke(node); |
1516 } | 1515 } |
1517 push(js.propertyCall(object, methodName, arguments), node); | 1516 push(js.propertyCall(object, methodName, arguments), node); |
1518 } | 1517 } |
1519 | 1518 |
1520 void visitInvokeConstructorBody(HInvokeConstructorBody node) { | 1519 void visitInvokeConstructorBody(HInvokeConstructorBody node) { |
1521 use(node.inputs[0]); | 1520 use(node.inputs[0]); |
1522 js.Expression object = pop(); | 1521 js.Expression object = pop(); |
1523 String methodName = backend.namer.getNameOfInstanceMember(node.element); | 1522 String methodName = backend.namer.instanceMethodName(node.element); |
1524 List<js.Expression> arguments = visitArguments(node.inputs); | 1523 List<js.Expression> arguments = visitArguments(node.inputs); |
1525 push(js.propertyCall(object, methodName, arguments), node); | 1524 push(js.propertyCall(object, methodName, arguments), node); |
1526 registry.registerStaticUse(node.element); | 1525 registry.registerStaticUse(node.element); |
1527 } | 1526 } |
1528 | 1527 |
1529 void visitOneShotInterceptor(HOneShotInterceptor node) { | 1528 void visitOneShotInterceptor(HOneShotInterceptor node) { |
1530 List<js.Expression> arguments = visitArguments(node.inputs); | 1529 List<js.Expression> arguments = visitArguments(node.inputs); |
1531 var isolate = new js.VariableUse( | 1530 var isolate = new js.VariableUse( |
1532 backend.namer.globalObjectFor(backend.interceptorsLibrary)); | 1531 backend.namer.globalObjectFor(backend.interceptorsLibrary)); |
1533 Selector selector = getOptimizedSelectorFor(node, node.selector); | 1532 Selector selector = getOptimizedSelectorFor(node, node.selector); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 TypeMask receiverType = | 1652 TypeMask receiverType = |
1654 new TypeMask.nonNullExact(superClass, compiler.world); | 1653 new TypeMask.nonNullExact(superClass, compiler.world); |
1655 selector = new TypedSelector(receiverType, selector, compiler.world); | 1654 selector = new TypedSelector(receiverType, selector, compiler.world); |
1656 // TODO(floitsch): we know the target. We shouldn't register a | 1655 // TODO(floitsch): we know the target. We shouldn't register a |
1657 // dynamic getter. | 1656 // dynamic getter. |
1658 registry.registerDynamicGetter(selector); | 1657 registry.registerDynamicGetter(selector); |
1659 registry.registerGetterForSuperMethod(node.element); | 1658 registry.registerGetterForSuperMethod(node.element); |
1660 methodName = backend.namer.invocationName(selector); | 1659 methodName = backend.namer.invocationName(selector); |
1661 } else { | 1660 } else { |
1662 assert(invariant(node, compiler.hasIncrementalSupport)); | 1661 assert(invariant(node, compiler.hasIncrementalSupport)); |
1663 methodName = backend.namer.getNameOfInstanceMember(superMethod); | 1662 methodName = backend.namer.instanceMethodName(superMethod); |
1664 } | 1663 } |
1665 push(js.js('#.#.call(#)', | 1664 push(js.js('#.#.call(#)', |
1666 [backend.emitter.prototypeAccess(superClass, | 1665 [backend.emitter.prototypeAccess(superClass, |
1667 hasBeenInstantiated: true), | 1666 hasBeenInstantiated: true), |
1668 methodName, visitArguments(node.inputs, start: 0)]), | 1667 methodName, visitArguments(node.inputs, start: 0)]), |
1669 node); | 1668 node); |
1670 } else { | 1669 } else { |
1671 use(node.receiver); | 1670 use(node.receiver); |
1672 push( | 1671 push( |
1673 js.js('#.#(#)', [ | 1672 js.js('#.#(#)', [ |
1674 pop(), backend.namer.getNameOfAliasedSuperMember(superMethod), | 1673 pop(), backend.namer.aliasedSuperMemberPropertyName(superMethod), |
1675 visitArguments(node.inputs, start: 1)]), // Skip receiver argument. | 1674 visitArguments(node.inputs, start: 1)]), // Skip receiver argument. |
1676 node); | 1675 node); |
1677 } | 1676 } |
1678 } | 1677 } |
1679 } | 1678 } |
1680 | 1679 |
1681 visitFieldGet(HFieldGet node) { | 1680 visitFieldGet(HFieldGet node) { |
1682 use(node.receiver); | 1681 use(node.receiver); |
1683 Element element = node.element; | 1682 Element element = node.element; |
1684 if (node.isNullCheck) { | 1683 if (node.isNullCheck) { |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2625 if (backend.isInterceptorClass(element.enclosingClass)) { | 2624 if (backend.isInterceptorClass(element.enclosingClass)) { |
2626 int index = RuntimeTypes.getTypeVariableIndex(element); | 2625 int index = RuntimeTypes.getTypeVariableIndex(element); |
2627 js.Expression receiver = pop(); | 2626 js.Expression receiver = pop(); |
2628 js.Expression helper = backend.emitter | 2627 js.Expression helper = backend.emitter |
2629 .staticFunctionAccess(helperElement); | 2628 .staticFunctionAccess(helperElement); |
2630 push(js.js(r'#(#.$builtinTypeInfo && #.$builtinTypeInfo[#])', | 2629 push(js.js(r'#(#.$builtinTypeInfo && #.$builtinTypeInfo[#])', |
2631 [helper, receiver, receiver, js.js.number(index)])); | 2630 [helper, receiver, receiver, js.js.number(index)])); |
2632 } else { | 2631 } else { |
2633 backend.emitter.registerReadTypeVariable(element); | 2632 backend.emitter.registerReadTypeVariable(element); |
2634 push(js.js('#.#()', | 2633 push(js.js('#.#()', |
2635 [pop(), backend.namer.readTypeVariableName(element)])); | 2634 [pop(), backend.namer.nameForReadTypeVariable(element)])); |
2636 } | 2635 } |
2637 } else { | 2636 } else { |
2638 push(js.js('#(#)', [ | 2637 push(js.js('#(#)', [ |
2639 backend.emitter.staticFunctionAccess( | 2638 backend.emitter.staticFunctionAccess( |
2640 backend.findHelper('convertRtiToRuntimeType')), | 2639 backend.findHelper('convertRtiToRuntimeType')), |
2641 pop()])); | 2640 pop()])); |
2642 } | 2641 } |
2643 } | 2642 } |
2644 | 2643 |
2645 void visitInterfaceType(HInterfaceType node) { | 2644 void visitInterfaceType(HInterfaceType node) { |
(...skipping 22 matching lines...) Expand all Loading... |
2668 js.PropertyAccess accessHelper(String name) { | 2667 js.PropertyAccess accessHelper(String name) { |
2669 Element helper = backend.findHelper(name); | 2668 Element helper = backend.findHelper(name); |
2670 if (helper == null) { | 2669 if (helper == null) { |
2671 // For mocked-up tests. | 2670 // For mocked-up tests. |
2672 return js.js('(void 0).$name'); | 2671 return js.js('(void 0).$name'); |
2673 } | 2672 } |
2674 registry.registerStaticUse(helper); | 2673 registry.registerStaticUse(helper); |
2675 return backend.emitter.staticFunctionAccess(helper); | 2674 return backend.emitter.staticFunctionAccess(helper); |
2676 } | 2675 } |
2677 } | 2676 } |
OLD | NEW |