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

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

Issue 12095011: Properly register types on the JS foreign instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 1758
1759 visitLocalGet(HLocalGet node) { 1759 visitLocalGet(HLocalGet node) {
1760 use(node.receiver); 1760 use(node.receiver);
1761 } 1761 }
1762 1762
1763 visitLocalSet(HLocalSet node) { 1763 visitLocalSet(HLocalSet node) {
1764 use(node.value); 1764 use(node.value);
1765 assignVariable(variableNames.getName(node.receiver), pop()); 1765 assignVariable(variableNames.getName(node.receiver), pop());
1766 } 1766 }
1767 1767
1768 void registerForeignType(HType type) {
1769 DartType dartType = type.computeType(compiler);
1770 if (dartType == null) {
1771 assert(type == HType.UNKNOWN);
1772 return;
1773 }
1774 world.registerInstantiatedClass(dartType.element);
1775 }
1776
1768 visitForeign(HForeign node) { 1777 visitForeign(HForeign node) {
1769 String code = node.code.slowToString(); 1778 String code = node.code.slowToString();
1770 List<HInstruction> inputs = node.inputs; 1779 List<HInstruction> inputs = node.inputs;
1771 if (node.isJsStatement()) { 1780 if (node.isJsStatement()) {
1772 if (!inputs.isEmpty) { 1781 if (!inputs.isEmpty) {
1773 compiler.internalError("foreign statement with inputs: $code", 1782 compiler.internalError("foreign statement with inputs: $code",
1774 instruction: node); 1783 instruction: node);
1775 } 1784 }
1776 pushStatement(new js.LiteralStatement(code), node); 1785 pushStatement(new js.LiteralStatement(code), node);
1777 } else { 1786 } else {
1778 List<js.Expression> data = <js.Expression>[]; 1787 List<js.Expression> data = <js.Expression>[];
1779 for (int i = 0; i < inputs.length; i++) { 1788 for (int i = 0; i < inputs.length; i++) {
1780 use(inputs[i]); 1789 use(inputs[i]);
1781 data.add(pop()); 1790 data.add(pop());
1782 } 1791 }
1783 push(new js.LiteralExpression.withData(code, data), node); 1792 push(new js.LiteralExpression.withData(code, data), node);
1784 } 1793 }
1785 DartType type = types[node].computeType(compiler); 1794 registerForeignType(types[node]);
1786 if (type != null) {
1787 world.registerInstantiatedClass(type.element);
1788 }
1789 // TODO(sra): Tell world.nativeEnqueuer about the types created here. 1795 // TODO(sra): Tell world.nativeEnqueuer about the types created here.
1790 } 1796 }
1791 1797
1792 visitForeignNew(HForeignNew node) { 1798 visitForeignNew(HForeignNew node) {
1793 String jsClassReference = backend.namer.isolateAccess(node.element); 1799 String jsClassReference = backend.namer.isolateAccess(node.element);
1794 List<HInstruction> inputs = node.inputs; 1800 List<HInstruction> inputs = node.inputs;
1795 // We can't use 'visitArguments', since our arguments start at input[0]. 1801 // We can't use 'visitArguments', since our arguments start at input[0].
1796 List<js.Expression> arguments = <js.Expression>[]; 1802 List<js.Expression> arguments = <js.Expression>[];
1797 for (int i = 0; i < inputs.length; i++) { 1803 for (int i = 0; i < inputs.length; i++) {
1798 use(inputs[i]); 1804 use(inputs[i]);
1799 arguments.add(pop()); 1805 arguments.add(pop());
1800 } 1806 }
1801 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1807 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it
1802 // as if it was a string. 1808 // as if it was a string.
1803 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); 1809 push(new js.New(new js.VariableUse(jsClassReference), arguments), node);
1810 registerForeignType(types[node]);
1804 } 1811 }
1805 1812
1806 js.Expression newLiteralBool(bool value) { 1813 js.Expression newLiteralBool(bool value) {
1807 if (compiler.enableMinification) { 1814 if (compiler.enableMinification) {
1808 // Use !0 for true, !1 for false. 1815 // Use !0 for true, !1 for false.
1809 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); 1816 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1"));
1810 } else { 1817 } else {
1811 return new js.LiteralBool(value); 1818 return new js.LiteralBool(value);
1812 } 1819 }
1813 } 1820 }
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 if (leftType.canBeNull() && rightType.canBeNull()) { 3002 if (leftType.canBeNull() && rightType.canBeNull()) {
2996 if (left.isConstantNull() || right.isConstantNull() || 3003 if (left.isConstantNull() || right.isConstantNull() ||
2997 (leftType.isPrimitive() && leftType == rightType)) { 3004 (leftType.isPrimitive() && leftType == rightType)) {
2998 return '=='; 3005 return '==';
2999 } 3006 }
3000 return null; 3007 return null;
3001 } else { 3008 } else {
3002 return '==='; 3009 return '===';
3003 } 3010 }
3004 } 3011 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698