| 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 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
| 7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 8 : this.backend = backend, | 8 : this.backend = backend, |
| 9 super(backend.compiler); | 9 super(backend.compiler); |
| 10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 assert(superMethod.kind == ElementKind.GETTER); | 1561 assert(superMethod.kind == ElementKind.GETTER); |
| 1562 String methodName = | 1562 String methodName = |
| 1563 compiler.namer.getterName(currentLibrary, superMethod.name); | 1563 compiler.namer.getterName(currentLibrary, superMethod.name); |
| 1564 buffer.add('$className.prototype.$methodName.call()'); | 1564 buffer.add('$className.prototype.$methodName.call()'); |
| 1565 } | 1565 } |
| 1566 endExpression(JSPrecedence.CALL_PRECEDENCE); | 1566 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 1567 world.registerStaticUse(superMethod); | 1567 world.registerStaticUse(superMethod); |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 visitFieldGet(HFieldGet node) { | 1570 visitFieldGet(HFieldGet node) { |
| 1571 if (node.receiver !== null) { | 1571 if (!node.isFromActivation()) { |
| 1572 String name = | 1572 String name = |
| 1573 compiler.namer.instanceFieldName(currentLibrary, node.name); | 1573 compiler.namer.instanceFieldName(currentLibrary, node.name); |
| 1574 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1574 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| 1575 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1575 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1576 buffer.add('.'); | 1576 buffer.add('.'); |
| 1577 buffer.add(name); | 1577 buffer.add(name); |
| 1578 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1578 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| 1579 } else { | 1579 } else { |
| 1580 buffer.add(JsNames.getValid(node.name.slowToString())); | 1580 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1581 } | 1581 } |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 visitFieldSet(HFieldSet node) { | 1584 visitFieldSet(HFieldSet node) { |
| 1585 String name; | 1585 String name; |
| 1586 if (node.receiver !== null) { | 1586 if (!node.isFromActivation()) { |
| 1587 name = | 1587 name = |
| 1588 compiler.namer.instanceFieldName(currentLibrary, node.name); | 1588 compiler.namer.instanceFieldName(currentLibrary, node.name); |
| 1589 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1589 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1590 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1590 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1591 buffer.add('.'); | 1591 buffer.add('.'); |
| 1592 buffer.add(name); | 1592 buffer.add(name); |
| 1593 } else { | 1593 } else { |
| 1594 // TODO(ngeoffray): Remove the 'var' once we don't globally box | 1594 // TODO(ngeoffray): Remove the 'var' once we don't globally box |
| 1595 // variables used in a try/catch. | 1595 // variables used in a try/catch. |
| 1596 name = JsNames.getValid(node.name.slowToString()); | 1596 if (!isGeneratingExpression()) { |
| 1597 declareVariable(name); | 1597 buffer.add('var '); |
| 1598 } |
| 1599 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1598 } | 1600 } |
| 1599 buffer.add(' = '); | 1601 buffer.add(' = '); |
| 1600 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1602 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1601 if (node.receiver !== null) { | 1603 if (node.receiver !== null) { |
| 1602 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1604 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1603 } | 1605 } |
| 1604 } | 1606 } |
| 1605 | 1607 |
| 1606 visitForeign(HForeign node) { | 1608 visitForeign(HForeign node) { |
| 1607 String code = node.code.slowToString(); | 1609 String code = node.code.slowToString(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 } else { | 1737 } else { |
| 1736 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1738 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1737 buffer.add('!'); | 1739 buffer.add('!'); |
| 1738 use(input, JSPrecedence.PREFIX_PRECEDENCE); | 1740 use(input, JSPrecedence.PREFIX_PRECEDENCE); |
| 1739 endExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1741 endExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1740 } | 1742 } |
| 1741 } | 1743 } |
| 1742 | 1744 |
| 1743 visitParameterValue(HParameterValue node) { | 1745 visitParameterValue(HParameterValue node) { |
| 1744 assert(isGenerateAtUseSite(node)); | 1746 assert(isGenerateAtUseSite(node)); |
| 1745 buffer.add(parameterNames[node.element]); | 1747 if (parameterNames[node.element] == null) { |
| 1748 buffer.add(temporary(node)); |
| 1749 } else { |
| 1750 buffer.add(parameterNames[node.element]); |
| 1751 } |
| 1746 } | 1752 } |
| 1747 | 1753 |
| 1748 visitPhi(HPhi node) { | 1754 visitPhi(HPhi node) { |
| 1749 String operation = logicalOperations[node]; | 1755 String operation = logicalOperations[node]; |
| 1750 if (operation !== null) { | 1756 if (operation !== null) { |
| 1751 emitLogicalOperation(node, operation); | 1757 emitLogicalOperation(node, operation); |
| 1752 } else { | 1758 } else { |
| 1753 HPhi canonicalPhi = phiEquivalence.getRepresentative(node); | 1759 HPhi canonicalPhi = phiEquivalence.getRepresentative(node); |
| 1754 buffer.add('${temporary(canonicalPhi)}'); | 1760 buffer.add('${temporary(canonicalPhi)}'); |
| 1755 } | 1761 } |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 startBailoutSwitch(); | 2632 startBailoutSwitch(); |
| 2627 } | 2633 } |
| 2628 } | 2634 } |
| 2629 | 2635 |
| 2630 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2636 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2631 if (labeledBlockInfo.body.start.hasGuards()) { | 2637 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2632 endBailoutSwitch(); | 2638 endBailoutSwitch(); |
| 2633 } | 2639 } |
| 2634 } | 2640 } |
| 2635 } | 2641 } |
| OLD | NEW |