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

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 second round of comments 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 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 visitFieldSet(HFieldSet node) { 1734 visitFieldSet(HFieldSet node) {
1735 String name; 1735 String name;
1736 if (!node.isFromActivation()) { 1736 if (!node.isFromActivation()) {
1737 name = compiler.namer.getName(node.element); 1737 name = compiler.namer.getName(node.element);
1738 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1738 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1739 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1739 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1740 buffer.add('.'); 1740 buffer.add('.');
1741 buffer.add(name); 1741 buffer.add(name);
1742 Type type = node.receiver.propagatedType.computeType(compiler); 1742 Type type = node.receiver.propagatedType.computeType(compiler);
1743 if (type != null) { 1743 if (type != null) {
1744 world.registerFieldSetter(node.element.name, type); 1744 world.registerFieldSetter(node.element.name,
1745 type,
1746 node.value.isInteger());
1745 } 1747 }
1746 } else { 1748 } else {
1747 declareInstruction(node.receiver); 1749 declareInstruction(node.receiver);
1748 } 1750 }
1749 buffer.add(' = '); 1751 buffer.add(' = ');
1750 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); 1752 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1751 if (node.receiver !== null) { 1753 if (node.receiver !== null) {
1752 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1754 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1753 } 1755 }
1754 } 1756 }
1755 1757
1756 visitForeign(HForeign node) { 1758 visitForeign(HForeign node) {
1757 String code = node.code.slowToString(); 1759 String code = node.code.slowToString();
1758 List<HInstruction> inputs = node.inputs; 1760 List<HInstruction> inputs = node.inputs;
1759 List<String> parts = code.split('#'); 1761 List<String> parts = code.split('#');
1760 if (parts.length != inputs.length + 1) { 1762 if (parts.length != inputs.length + 1) {
1761 compiler.internalError( 1763 compiler.internalError(
1762 'Wrong number of arguments for JS', instruction: node); 1764 'Wrong number of arguments for JS', instruction: node);
1763 } 1765 }
1764 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); 1766 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE);
1765 buffer.add(parts[0]); 1767 buffer.add(parts[0]);
1766 for (int i = 0; i < inputs.length; i++) { 1768 for (int i = 0; i < inputs.length; i++) {
1767 use(inputs[i], JSPrecedence.EXPRESSION_PRECEDENCE); 1769 use(inputs[i], JSPrecedence.EXPRESSION_PRECEDENCE);
1768 buffer.add(parts[i + 1]); 1770 buffer.add(parts[i + 1]);
1769 } 1771 }
1770 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); 1772 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE);
1771 } 1773 }
1772 1774
1773 visitForeignNew(HForeignNew node) { 1775 visitForeignNew(HForeignNew node) {
1776 var i = 0;
1777 node.element.forEachInstanceField(
1778 includeBackendMembers: true,
1779 includeSuperMembers: true,
1780 f: (ClassElement enclosingClass, Element member) {
1781 world.registerFieldInitializer(member.name,
1782 enclosingClass.computeType(compiler),
1783 node.inputs[i].isInteger());
1784
1785 i++;
1786 });
1774 String jsClassReference = compiler.namer.isolateAccess(node.element); 1787 String jsClassReference = compiler.namer.isolateAccess(node.element);
1775 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1788 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1776 buffer.add('new $jsClassReference('); 1789 buffer.add('new $jsClassReference(');
1777 // We can't use 'visitArguments', since our arguments start at input[0]. 1790 // We can't use 'visitArguments', since our arguments start at input[0].
1778 List<HInstruction> inputs = node.inputs; 1791 List<HInstruction> inputs = node.inputs;
1779 for (int i = 0; i < inputs.length; i++) { 1792 for (int i = 0; i < inputs.length; i++) {
1780 if (i != 0) buffer.add(', '); 1793 if (i != 0) buffer.add(', ');
1781 use(inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE); 1794 use(inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE);
1782 } 1795 }
1783 buffer.add(')'); 1796 buffer.add(')');
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 startBailoutSwitch(); 2925 startBailoutSwitch();
2913 } 2926 }
2914 } 2927 }
2915 2928
2916 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2929 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2917 if (labeledBlockInfo.body.start.hasGuards()) { 2930 if (labeledBlockInfo.body.start.hasGuards()) {
2918 endBailoutSwitch(); 2931 endBailoutSwitch();
2919 } 2932 }
2920 } 2933 }
2921 } 2934 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/bailout.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698