| 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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 compiler.namer.setterName(currentLibrary, superMethod.name); | 1708 compiler.namer.setterName(currentLibrary, superMethod.name); |
| 1709 } | 1709 } |
| 1710 buffer.add('$className.prototype.$methodName.call'); | 1710 buffer.add('$className.prototype.$methodName.call'); |
| 1711 visitArguments(node.inputs); | 1711 visitArguments(node.inputs); |
| 1712 } | 1712 } |
| 1713 endExpression(JSPrecedence.CALL_PRECEDENCE); | 1713 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 1714 world.registerStaticUse(superMethod); | 1714 world.registerStaticUse(superMethod); |
| 1715 } | 1715 } |
| 1716 | 1716 |
| 1717 visitFieldGet(HFieldGet node) { | 1717 visitFieldGet(HFieldGet node) { |
| 1718 if (!node.isFromActivation()) { | 1718 String name = compiler.namer.getName(node.element); |
| 1719 String name = compiler.namer.getName(node.element); | 1719 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| 1720 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1720 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1721 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1721 buffer.add('.'); |
| 1722 buffer.add('.'); | 1722 buffer.add(name); |
| 1723 buffer.add(name); | 1723 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| 1724 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1724 Type type = node.receiver.propagatedType.computeType(compiler); |
| 1725 Type type = node.receiver.propagatedType.computeType(compiler); | 1725 if (type != null) { |
| 1726 if (type != null) { | 1726 world.registerFieldGetter(node.element.name, type); |
| 1727 world.registerFieldGetter(node.element.name, type); | |
| 1728 } | |
| 1729 } else { | |
| 1730 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); | |
| 1731 } | 1727 } |
| 1732 } | 1728 } |
| 1733 | 1729 |
| 1734 visitFieldSet(HFieldSet node) { | 1730 visitFieldSet(HFieldSet node) { |
| 1735 String name; | 1731 String name = compiler.namer.getName(node.element); |
| 1736 if (!node.isFromActivation()) { | 1732 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1737 name = compiler.namer.getName(node.element); | 1733 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1738 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1734 buffer.add('.'); |
| 1739 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1735 buffer.add(name); |
| 1740 buffer.add('.'); | 1736 Type type = node.receiver.propagatedType.computeType(compiler); |
| 1741 buffer.add(name); | 1737 if (type != null) { |
| 1742 Type type = node.receiver.propagatedType.computeType(compiler); | 1738 world.registerFieldSetter(node.element.name, type); |
| 1743 if (type != null) { | |
| 1744 world.registerFieldSetter(node.element.name, type); | |
| 1745 } | |
| 1746 } else { | |
| 1747 declareInstruction(node.receiver); | |
| 1748 } | 1739 } |
| 1749 buffer.add(' = '); | 1740 buffer.add(' = '); |
| 1750 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1741 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1751 if (node.receiver !== null) { | 1742 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1752 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1743 } |
| 1753 } | 1744 |
| 1745 visitLocalGet(HLocalGet node) { |
| 1746 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); |
| 1747 } |
| 1748 |
| 1749 visitLocalSet(HLocalSet node) { |
| 1750 declareInstruction(node.receiver); |
| 1751 buffer.add(' = '); |
| 1752 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1754 } | 1753 } |
| 1755 | 1754 |
| 1756 visitForeign(HForeign node) { | 1755 visitForeign(HForeign node) { |
| 1757 String code = node.code.slowToString(); | 1756 String code = node.code.slowToString(); |
| 1758 List<HInstruction> inputs = node.inputs; | 1757 List<HInstruction> inputs = node.inputs; |
| 1759 List<String> parts = code.split('#'); | 1758 List<String> parts = code.split('#'); |
| 1760 if (parts.length != inputs.length + 1) { | 1759 if (parts.length != inputs.length + 1) { |
| 1761 compiler.internalError( | 1760 compiler.internalError( |
| 1762 'Wrong number of arguments for JS', instruction: node); | 1761 'Wrong number of arguments for JS', instruction: node); |
| 1763 } | 1762 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 visitInvokeBinary(input, | 1890 visitInvokeBinary(input, |
| 1892 inverseOperator[relational.operation.name.stringValue]); | 1891 inverseOperator[relational.operation.name.stringValue]); |
| 1893 } else { | 1892 } else { |
| 1894 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1893 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1895 buffer.add('!'); | 1894 buffer.add('!'); |
| 1896 use(input, JSPrecedence.PREFIX_PRECEDENCE); | 1895 use(input, JSPrecedence.PREFIX_PRECEDENCE); |
| 1897 endExpression(JSPrecedence.PREFIX_PRECEDENCE); | 1896 endExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| 1898 } | 1897 } |
| 1899 } | 1898 } |
| 1900 | 1899 |
| 1901 visitParameterValue(HParameterValue node) { | 1900 visitParameterValue(HParameterValue node) => visitLocalValue(node); |
| 1901 |
| 1902 visitLocalValue(HLocalValue node) { |
| 1902 assert(isGenerateAtUseSite(node)); | 1903 assert(isGenerateAtUseSite(node)); |
| 1903 buffer.add(variableNames.getName(node)); | 1904 buffer.add(variableNames.getName(node)); |
| 1904 } | 1905 } |
| 1905 | 1906 |
| 1906 visitPhi(HPhi node) { | 1907 visitPhi(HPhi node) { |
| 1907 // This method is only called for phis that are generated at use | 1908 // This method is only called for phis that are generated at use |
| 1908 // site. A phi can be generated at use site only if it is the | 1909 // site. A phi can be generated at use site only if it is the |
| 1909 // result of a control flow operation. | 1910 // result of a control flow operation. |
| 1910 HBasicBlock ifBlock = node.block.dominator; | 1911 HBasicBlock ifBlock = node.block.dominator; |
| 1911 assert(controlFlowOperators.contains(ifBlock.last)); | 1912 assert(controlFlowOperators.contains(ifBlock.last)); |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 startBailoutSwitch(); | 2896 startBailoutSwitch(); |
| 2896 } | 2897 } |
| 2897 } | 2898 } |
| 2898 | 2899 |
| 2899 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2900 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2900 if (labeledBlockInfo.body.start.hasGuards()) { | 2901 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2901 endBailoutSwitch(); | 2902 endBailoutSwitch(); |
| 2902 } | 2903 } |
| 2903 } | 2904 } |
| 2904 } | 2905 } |
| OLD | NEW |