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

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

Issue 11415168: Revert "Emit constants using ASTs" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/namer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 js.Expression newLiteralBool(bool value) { 1805 js.Expression newLiteralBool(bool value) {
1806 if (compiler.enableMinification) { 1806 if (compiler.enableMinification) {
1807 // Use !0 for true, !1 for false. 1807 // Use !0 for true, !1 for false.
1808 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); 1808 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1"));
1809 } else { 1809 } else {
1810 return new js.LiteralBool(value); 1810 return new js.LiteralBool(value);
1811 } 1811 }
1812 } 1812 }
1813 1813
1814 void generateConstant(Constant constant) { 1814 void generateConstant(Constant constant) {
1815 if (constant.isFunction()) { 1815 Namer namer = backend.namer;
1816 FunctionConstant function = constant; 1816 // TODO(floitsch): should we use the ConstantVisitor here?
1817 world.registerStaticUse(function.element); 1817 if (!constant.isObject()) {
1818 if (constant.isBool()) {
1819 BoolConstant boolConstant = constant;
1820 push(newLiteralBool(boolConstant.value));
1821 } else if (constant.isNum()) {
1822 // TODO(floitsch): get rid of the code buffer.
1823 CodeBuffer buffer = new CodeBuffer();
1824 backend.emitter.writeConstantToBuffer(constant, buffer);
1825 push(new js.LiteralNumber(buffer.toString()));
1826 } else if (constant.isNull()) {
1827 push(new js.LiteralNull());
1828 } else if (constant.isString()) {
1829 // TODO(floitsch): get rid of the code buffer.
1830 CodeBuffer buffer = new CodeBuffer();
1831 backend.emitter.writeConstantToBuffer(constant, buffer);
1832 push(new js.LiteralString(buffer.toString()));
1833 } else if (constant.isFunction()) {
1834 FunctionConstant function = constant;
1835 world.registerStaticUse(function.element);
1836 push(new js.VariableUse(namer.isolateAccess(function.element)));
1837 } else if (constant.isSentinel()) {
1838 // TODO(floitsch): get rid of the code buffer.
1839 CodeBuffer buffer = new CodeBuffer();
1840 backend.emitter.writeConstantToBuffer(constant, buffer);
1841 push(new js.VariableUse(buffer.toString()));
1842 } else {
1843 compiler.internalError(
1844 "The compiler does not know how generate code for "
1845 "constant $constant");
1846 }
1847 } else {
1848 String name = namer.constantName(constant);
1849 js.VariableUse currentIsolateUse =
1850 new js.VariableUse(backend.namer.CURRENT_ISOLATE);
1851 push(new js.PropertyAccess.field(currentIsolateUse, name));
1818 } 1852 }
1819 push(backend.emitter.constantReference(constant));
1820 } 1853 }
1821 1854
1822 visitConstant(HConstant node) { 1855 visitConstant(HConstant node) {
1823 assert(isGenerateAtUseSite(node)); 1856 assert(isGenerateAtUseSite(node));
1824 generateConstant(node.constant); 1857 generateConstant(node.constant);
1825 DartType type = node.constant.computeType(compiler); 1858 DartType type = node.constant.computeType(compiler);
1826 world.registerInstantiatedClass(type.element); 1859 world.registerInstantiatedClass(type.element);
1827 } 1860 }
1828 1861
1829 visitLoopBranch(HLoopBranch node) { 1862 visitLoopBranch(HLoopBranch node) {
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 if (leftType.canBeNull() && rightType.canBeNull()) { 3049 if (leftType.canBeNull() && rightType.canBeNull()) {
3017 if (left.isConstantNull() || right.isConstantNull() || 3050 if (left.isConstantNull() || right.isConstantNull() ||
3018 (leftType.isPrimitive() && leftType == rightType)) { 3051 (leftType.isPrimitive() && leftType == rightType)) {
3019 return '=='; 3052 return '==';
3020 } 3053 }
3021 return null; 3054 return null;
3022 } else { 3055 } else {
3023 return '==='; 3056 return '===';
3024 } 3057 }
3025 } 3058 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698