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

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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1760
1761 visitLocalGet(HLocalGet node) { 1761 visitLocalGet(HLocalGet node) {
1762 use(node.receiver); 1762 use(node.receiver);
1763 } 1763 }
1764 1764
1765 visitLocalSet(HLocalSet node) { 1765 visitLocalSet(HLocalSet node) {
1766 use(node.value); 1766 use(node.value);
1767 assignVariable(variableNames.getName(node.receiver), pop()); 1767 assignVariable(variableNames.getName(node.receiver), pop());
1768 } 1768 }
1769 1769
1770 void registerForeignType(HType type) {
1771 DartType dartType = type.computeType(compiler);
1772 if (dartType == null) {
1773 assert(type == HType.UNKNOWN);
1774 return;
1775 }
1776 world.registerInstantiatedClass(dartType.element);
sra1 2013/01/28 20:12:20 This might be too broad - might be the least upper
1777 }
1778
1770 visitForeign(HForeign node) { 1779 visitForeign(HForeign node) {
1771 String code = node.code.slowToString(); 1780 String code = node.code.slowToString();
1772 List<HInstruction> inputs = node.inputs; 1781 List<HInstruction> inputs = node.inputs;
1773 if (node.isJsStatement()) { 1782 if (node.isJsStatement()) {
1774 if (!inputs.isEmpty) { 1783 if (!inputs.isEmpty) {
1775 compiler.internalError("foreign statement with inputs: $code", 1784 compiler.internalError("foreign statement with inputs: $code",
1776 instruction: node); 1785 instruction: node);
1777 } 1786 }
1778 pushStatement(new js.LiteralStatement(code), node); 1787 pushStatement(new js.LiteralStatement(code), node);
1779 } else { 1788 } else {
1780 List<js.Expression> data = <js.Expression>[]; 1789 List<js.Expression> data = <js.Expression>[];
1781 for (int i = 0; i < inputs.length; i++) { 1790 for (int i = 0; i < inputs.length; i++) {
1782 use(inputs[i]); 1791 use(inputs[i]);
1783 data.add(pop()); 1792 data.add(pop());
1784 } 1793 }
1785 push(new js.LiteralExpression.withData(code, data), node); 1794 push(new js.LiteralExpression.withData(code, data), node);
1786 } 1795 }
1787 DartType type = types[node].computeType(compiler); 1796 registerForeignType(types[node]);
1788 if (type != null) {
1789 world.registerInstantiatedClass(type.element);
1790 }
1791 // TODO(sra): Tell world.nativeEnqueuer about the types created here. 1797 // TODO(sra): Tell world.nativeEnqueuer about the types created here.
1792 } 1798 }
1793 1799
1794 visitForeignNew(HForeignNew node) { 1800 visitForeignNew(HForeignNew node) {
1795 String jsClassReference = backend.namer.isolateAccess(node.element); 1801 String jsClassReference = backend.namer.isolateAccess(node.element);
1796 List<HInstruction> inputs = node.inputs; 1802 List<HInstruction> inputs = node.inputs;
1797 // We can't use 'visitArguments', since our arguments start at input[0]. 1803 // We can't use 'visitArguments', since our arguments start at input[0].
1798 List<js.Expression> arguments = <js.Expression>[]; 1804 List<js.Expression> arguments = <js.Expression>[];
1799 for (int i = 0; i < inputs.length; i++) { 1805 for (int i = 0; i < inputs.length; i++) {
1800 use(inputs[i]); 1806 use(inputs[i]);
1801 arguments.add(pop()); 1807 arguments.add(pop());
1802 } 1808 }
1803 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it 1809 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it
1804 // as if it was a string. 1810 // as if it was a string.
1805 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); 1811 push(new js.New(new js.VariableUse(jsClassReference), arguments), node);
1812 registerForeignType(types[node]);
1806 } 1813 }
1807 1814
1808 js.Expression newLiteralBool(bool value) { 1815 js.Expression newLiteralBool(bool value) {
1809 if (compiler.enableMinification) { 1816 if (compiler.enableMinification) {
1810 // Use !0 for true, !1 for false. 1817 // Use !0 for true, !1 for false.
1811 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); 1818 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1"));
1812 } else { 1819 } else {
1813 return new js.LiteralBool(value); 1820 return new js.LiteralBool(value);
1814 } 1821 }
1815 } 1822 }
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 if (leftType.canBeNull() && rightType.canBeNull()) { 3035 if (leftType.canBeNull() && rightType.canBeNull()) {
3029 if (left.isConstantNull() || right.isConstantNull() || 3036 if (left.isConstantNull() || right.isConstantNull() ||
3030 (leftType.isPrimitive() && leftType == rightType)) { 3037 (leftType.isPrimitive() && leftType == rightType)) {
3031 return '=='; 3038 return '==';
3032 } 3039 }
3033 return null; 3040 return null;
3034 } else { 3041 } else {
3035 return '==='; 3042 return '===';
3036 } 3043 }
3037 } 3044 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698