Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10562041: Introduce HLocalValue and HLocalGet/Set. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
kasperl 2012/06/19 11:19:45 String name =
floitsch 2012/06/19 11:31:33 Done.
1736 if (!node.isFromActivation()) { 1732 name = compiler.namer.getName(node.element);
1737 name = compiler.namer.getName(node.element); 1733 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1738 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1734 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1739 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1735 buffer.add('.');
1740 buffer.add('.'); 1736 buffer.add(name);
1741 buffer.add(name); 1737 Type type = node.receiver.propagatedType.computeType(compiler);
1742 Type type = node.receiver.propagatedType.computeType(compiler); 1738 if (type != null) {
1743 if (type != null) { 1739 world.registerFieldSetter(node.element.name, type);
1744 world.registerFieldSetter(node.element.name, type);
1745 }
1746 } else {
1747 declareInstruction(node.receiver);
1748 } 1740 }
1749 buffer.add(' = '); 1741 buffer.add(' = ');
1750 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); 1742 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1751 if (node.receiver !== null) { 1743 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1752 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1744 }
1753 } 1745
1746 visitLocalGet(HLocalGet node) {
1747 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE);
1748 }
1749
1750 visitLocalSet(HLocalSet node) {
1751 String name;
kasperl 2012/06/19 11:19:45 Unused name?
floitsch 2012/06/19 11:31:33 Done.
1752 declareInstruction(node.receiver);
1753 buffer.add(' = ');
1754 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1754 } 1755 }
1755 1756
1756 visitForeign(HForeign node) { 1757 visitForeign(HForeign node) {
1757 String code = node.code.slowToString(); 1758 String code = node.code.slowToString();
1758 List<HInstruction> inputs = node.inputs; 1759 List<HInstruction> inputs = node.inputs;
1759 List<String> parts = code.split('#'); 1760 List<String> parts = code.split('#');
1760 if (parts.length != inputs.length + 1) { 1761 if (parts.length != inputs.length + 1) {
1761 compiler.internalError( 1762 compiler.internalError(
1762 'Wrong number of arguments for JS', instruction: node); 1763 'Wrong number of arguments for JS', instruction: node);
1763 } 1764 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 visitInvokeBinary(input, 1892 visitInvokeBinary(input,
1892 inverseOperator[relational.operation.name.stringValue]); 1893 inverseOperator[relational.operation.name.stringValue]);
1893 } else { 1894 } else {
1894 beginExpression(JSPrecedence.PREFIX_PRECEDENCE); 1895 beginExpression(JSPrecedence.PREFIX_PRECEDENCE);
1895 buffer.add('!'); 1896 buffer.add('!');
1896 use(input, JSPrecedence.PREFIX_PRECEDENCE); 1897 use(input, JSPrecedence.PREFIX_PRECEDENCE);
1897 endExpression(JSPrecedence.PREFIX_PRECEDENCE); 1898 endExpression(JSPrecedence.PREFIX_PRECEDENCE);
1898 } 1899 }
1899 } 1900 }
1900 1901
1901 visitParameterValue(HParameterValue node) { 1902 visitParameterValue(HParameterValue node) {
kasperl 2012/06/19 11:19:45 Remove this method entirely? By default it should
floitsch 2012/06/19 11:31:33 This visitor does not extend the base-visitor. We
1902 assert(isGenerateAtUseSite(node)); 1903 assert(isGenerateAtUseSite(node));
1903 buffer.add(variableNames.getName(node)); 1904 buffer.add(variableNames.getName(node));
1904 } 1905 }
1905 1906
1907 visitLocalValue(HLocalValue node) {
1908 assert(isGenerateAtUseSite(node));
1909 buffer.add(variableNames.getName(node));
1910 }
1911
1906 visitPhi(HPhi node) { 1912 visitPhi(HPhi node) {
1907 // This method is only called for phis that are generated at use 1913 // 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 1914 // site. A phi can be generated at use site only if it is the
1909 // result of a control flow operation. 1915 // result of a control flow operation.
1910 HBasicBlock ifBlock = node.block.dominator; 1916 HBasicBlock ifBlock = node.block.dominator;
1911 assert(controlFlowOperators.contains(ifBlock.last)); 1917 assert(controlFlowOperators.contains(ifBlock.last));
1912 HInstruction input = ifBlock.last.inputs[0]; 1918 HInstruction input = ifBlock.last.inputs[0];
1913 if (input.isConstantFalse()) { 1919 if (input.isConstantFalse()) {
1914 use(node.inputs[1], expectedPrecedence); 1920 use(node.inputs[1], expectedPrecedence);
1915 } else if (input.isConstantTrue()) { 1921 } else if (input.isConstantTrue()) {
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 startBailoutSwitch(); 2901 startBailoutSwitch();
2896 } 2902 }
2897 } 2903 }
2898 2904
2899 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2905 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2900 if (labeledBlockInfo.body.start.hasGuards()) { 2906 if (labeledBlockInfo.body.start.hasGuards()) {
2901 endBailoutSwitch(); 2907 endBailoutSwitch();
2902 } 2908 }
2903 } 2909 }
2904 } 2910 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698