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

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

Issue 10539156: Track fields which are known to be always set to integer constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comment and addressed initializers 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 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 visitFieldSet(HFieldSet node) { 1731 visitFieldSet(HFieldSet node) {
1732 String name; 1732 String name;
1733 if (!node.isFromActivation()) { 1733 if (!node.isFromActivation()) {
1734 name = compiler.namer.getName(node.element); 1734 name = compiler.namer.getName(node.element);
1735 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1735 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1736 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1736 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1737 buffer.add('.'); 1737 buffer.add('.');
1738 buffer.add(name); 1738 buffer.add(name);
1739 Type type = node.receiver.propagatedType.computeType(compiler); 1739 Type type = node.receiver.propagatedType.computeType(compiler);
1740 if (type != null) { 1740 if (type != null) {
1741 world.registerFieldSetter(node.element.name, type); 1741 world.registerFieldSetter(node.element.name,
1742 type,
1743 node.value.isInteger());
1742 } 1744 }
1743 } else { 1745 } else {
1744 declareInstruction(node.receiver); 1746 declareInstruction(node.receiver);
1745 } 1747 }
1746 buffer.add(' = '); 1748 buffer.add(' = ');
1747 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); 1749 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1748 if (node.receiver !== null) { 1750 if (node.receiver !== null) {
1749 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1751 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1750 } 1752 }
1751 } 1753 }
1752 1754
1753 visitForeign(HForeign node) { 1755 visitForeign(HForeign node) {
1754 String code = node.code.slowToString(); 1756 String code = node.code.slowToString();
1755 List<HInstruction> inputs = node.inputs; 1757 List<HInstruction> inputs = node.inputs;
1756 List<String> parts = code.split('#'); 1758 List<String> parts = code.split('#');
1757 if (parts.length != inputs.length + 1) { 1759 if (parts.length != inputs.length + 1) {
1758 compiler.internalError( 1760 compiler.internalError(
1759 'Wrong number of arguments for JS', instruction: node); 1761 'Wrong number of arguments for JS', instruction: node);
1760 } 1762 }
1761 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); 1763 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE);
1762 buffer.add(parts[0]); 1764 buffer.add(parts[0]);
1763 for (int i = 0; i < inputs.length; i++) { 1765 for (int i = 0; i < inputs.length; i++) {
1764 use(inputs[i], JSPrecedence.EXPRESSION_PRECEDENCE); 1766 use(inputs[i], JSPrecedence.EXPRESSION_PRECEDENCE);
1765 buffer.add(parts[i + 1]); 1767 buffer.add(parts[i + 1]);
1766 } 1768 }
1767 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); 1769 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE);
1768 } 1770 }
1769 1771
1770 visitForeignNew(HForeignNew node) { 1772 visitForeignNew(HForeignNew node) {
1773 var i = 0;
1774 node.element.forEachInstanceField(
1775 includeBackendMembers: true,
1776 includeSuperMembers: true,
1777 f: (ClassElement enclosingClass, Element member) {
1778 world.registerFieldInitializer(member.name,
1779 enclosingClass.computeType(compiler),
1780 node.inputs[i].isInteger());
1781
1782 i++;
1783 });
1771 String jsClassReference = compiler.namer.isolateAccess(node.element); 1784 String jsClassReference = compiler.namer.isolateAccess(node.element);
1772 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1785 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1773 buffer.add('new $jsClassReference('); 1786 buffer.add('new $jsClassReference(');
1774 // We can't use 'visitArguments', since our arguments start at input[0]. 1787 // We can't use 'visitArguments', since our arguments start at input[0].
1775 List<HInstruction> inputs = node.inputs; 1788 List<HInstruction> inputs = node.inputs;
1776 for (int i = 0; i < inputs.length; i++) { 1789 for (int i = 0; i < inputs.length; i++) {
1777 if (i != 0) buffer.add(', '); 1790 if (i != 0) buffer.add(', ');
1778 use(inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE); 1791 use(inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE);
1779 } 1792 }
1780 buffer.add(')'); 1793 buffer.add(')');
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 startBailoutSwitch(); 2922 startBailoutSwitch();
2910 } 2923 }
2911 } 2924 }
2912 2925
2913 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2926 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2914 if (labeledBlockInfo.body.start.hasGuards()) { 2927 if (labeledBlockInfo.body.start.hasGuards()) {
2915 endBailoutSwitch(); 2928 endBailoutSwitch();
2916 } 2929 }
2917 } 2930 }
2918 } 2931 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698