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

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

Issue 24282005: Move compile-time constant registrations to the backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status Created 7 years, 2 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 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 // property should not be mangled. 1708 // property should not be mangled.
1709 if (backend.isTypedArray( 1709 if (backend.isTypedArray(
1710 node.receiver.instructionType.computeMask(compiler))) { 1710 node.receiver.instructionType.computeMask(compiler))) {
1711 // TODO(12929): Remove this custom code for typed arrays once V8 1711 // TODO(12929): Remove this custom code for typed arrays once V8
1712 // optimizes their length access. 1712 // optimizes their length access.
1713 // Do a call to `fetchLength` instead of accessing `length` 1713 // Do a call to `fetchLength` instead of accessing `length`
1714 // directly. Because `fetchLength` is a constant we use its 1714 // directly. Because `fetchLength` is a constant we use its
1715 // constant value instead. 1715 // constant value instead.
1716 Element element = compiler.findRequiredElement( 1716 Element element = compiler.findRequiredElement(
1717 compiler.typedDataLibrary, const SourceString('fetchLength')); 1717 compiler.typedDataLibrary, const SourceString('fetchLength'));
1718 Constant constant = compiler.constantHandler.compileConstant(element); 1718 Constant constant =
1719 compiler.constantHandler.getConstantForVariable(element);
1720 assert(invariant(element, constant != null,
1721 message: 'No constant computed for $element'));
1719 var jsConstant = backend.emitter.constantReference(constant); 1722 var jsConstant = backend.emitter.constantReference(constant);
1720 push(new js.Call(jsConstant, [pop()]), node); 1723 push(new js.Call(jsConstant, [pop()]), node);
1721 } else { 1724 } else {
1722 push(new js.PropertyAccess.field(pop(), 'length'), node); 1725 push(new js.PropertyAccess.field(pop(), 'length'), node);
1723 } 1726 }
1724 } else { 1727 } else {
1725 String name = _fieldPropertyName(element); 1728 String name = _fieldPropertyName(element);
1726 push(new js.PropertyAccess.field(pop(), name), node); 1729 push(new js.PropertyAccess.field(pop(), name), node);
1727 world.registerFieldGetter(element); 1730 world.registerFieldGetter(element);
1728 } 1731 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 if (constant.isFunction()) { 1819 if (constant.isFunction()) {
1817 FunctionConstant function = constant; 1820 FunctionConstant function = constant;
1818 world.registerStaticUse(function.element); 1821 world.registerStaticUse(function.element);
1819 } 1822 }
1820 push(backend.emitter.constantReference(constant)); 1823 push(backend.emitter.constantReference(constant));
1821 } 1824 }
1822 1825
1823 visitConstant(HConstant node) { 1826 visitConstant(HConstant node) {
1824 assert(isGenerateAtUseSite(node)); 1827 assert(isGenerateAtUseSite(node));
1825 generateConstant(node.constant); 1828 generateConstant(node.constant);
1826 DartType type = node.constant.computeType(compiler); 1829
1827 if (node.constant is ConstructedConstant || 1830 backend.registerCompileTimeConstant(node.constant, work.resolutionTree);
1828 node.constant is InterceptorConstant) { 1831 compiler.constantHandler.addCompileTimeConstantForEmission(node.constant);
1829 ConstantHandler handler = compiler.constantHandler;
1830 handler.registerCompileTimeConstant(node.constant, work.resolutionTree);
1831 }
1832 if (node.constant is! InterceptorConstant) {
1833 world.registerInstantiatedClass(type.element, work.resolutionTree);
1834 }
1835 } 1832 }
1836 1833
1837 visitNot(HNot node) { 1834 visitNot(HNot node) {
1838 assert(node.inputs.length == 1); 1835 assert(node.inputs.length == 1);
1839 generateNot(node.inputs[0]); 1836 generateNot(node.inputs[0]);
1840 attachLocationToLast(node); 1837 attachLocationToLast(node);
1841 } 1838 }
1842 1839
1843 static String mapRelationalOperator(String op, bool inverse) { 1840 static String mapRelationalOperator(String op, bool inverse) {
1844 Map<String, String> inverseOperator = const <String, String>{ 1841 Map<String, String> inverseOperator = const <String, String>{
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 if (leftType.canBeNull() && rightType.canBeNull()) { 3041 if (leftType.canBeNull() && rightType.canBeNull()) {
3045 if (left.isConstantNull() || right.isConstantNull() || 3042 if (left.isConstantNull() || right.isConstantNull() ||
3046 (leftType.isPrimitive(compiler) && leftType == rightType)) { 3043 (leftType.isPrimitive(compiler) && leftType == rightType)) {
3047 return '=='; 3044 return '==';
3048 } 3045 }
3049 return null; 3046 return null;
3050 } else { 3047 } else {
3051 return '==='; 3048 return '===';
3052 } 3049 }
3053 } 3050 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698