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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1411783005: Remove [addForEmission] parameter from [registerCompileTimeConstant] (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
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 js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 jsAst.Name name = namer.nameForGetInterceptor(classes); 972 jsAst.Name name = namer.nameForGetInterceptor(classes);
973 if (classes.contains(jsInterceptorClass)) { 973 if (classes.contains(jsInterceptorClass)) {
974 // We can't use a specialized [getInterceptorMethod], so we make 974 // We can't use a specialized [getInterceptorMethod], so we make
975 // sure we emit the one with all checks. 975 // sure we emit the one with all checks.
976 specializedGetInterceptors[name] = interceptedClasses; 976 specializedGetInterceptors[name] = interceptedClasses;
977 } else { 977 } else {
978 specializedGetInterceptors[name] = classes; 978 specializedGetInterceptors[name] = classes;
979 } 979 }
980 } 980 }
981 981
982 void registerCompileTimeConstant(ConstantValue constant, Registry registry, 982 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {
983 {bool addForEmission: true}) {
984 registerCompileTimeConstantInternal(constant, registry); 983 registerCompileTimeConstantInternal(constant, registry);
985 984
986 if (!registry.isForResolution && 985 if (!registry.isForResolution &&
987 lookupMapAnalysis.isLookupMap(constant)) { 986 lookupMapAnalysis.isLookupMap(constant)) {
988 // Note: internally, this registration will temporarily remove the 987 // Note: internally, this registration will temporarily remove the
989 // constant dependencies and add them later on-demand. 988 // constant dependencies and add them later on-demand.
990 lookupMapAnalysis.registerLookupMapReference(constant); 989 lookupMapAnalysis.registerLookupMapReference(constant);
991 } 990 }
992 991
993 for (ConstantValue dependency in constant.getDependencies()) { 992 for (ConstantValue dependency in constant.getDependencies()) {
994 registerCompileTimeConstant(dependency, registry, 993 registerCompileTimeConstant(dependency, registry);
995 addForEmission: false);
996 } 994 }
995 }
997 996
998 if (addForEmission) constants.addCompileTimeConstantForEmission(constant); 997 void addCompileTimeConstantForEmission(ConstantValue constant) {
998 constants.addCompileTimeConstantForEmission(constant);
999 } 999 }
1000 1000
1001 void registerCompileTimeConstantInternal(ConstantValue constant, 1001 void registerCompileTimeConstantInternal(ConstantValue constant,
1002 Registry registry) { 1002 Registry registry) {
1003 DartType type = constant.getType(compiler.coreTypes); 1003 DartType type = constant.getType(compiler.coreTypes);
1004 registerInstantiatedConstantType(type, registry); 1004 registerInstantiatedConstantType(type, registry);
1005 1005
1006 if (constant.isFunction) { 1006 if (constant.isFunction) {
1007 FunctionConstantValue function = constant; 1007 FunctionConstantValue function = constant;
1008 registry.registerGetOfStaticFunction(function.element); 1008 registry.registerGetOfStaticFunction(function.element);
(...skipping 23 matching lines...) Expand all
1032 registry.registerStaticInvocation(helpers.createRuntimeType); 1032 registry.registerStaticInvocation(helpers.createRuntimeType);
1033 } 1033 }
1034 } 1034 }
1035 } 1035 }
1036 1036
1037 void registerMetadataConstant(MetadataAnnotation metadata, 1037 void registerMetadataConstant(MetadataAnnotation metadata,
1038 Element annotatedElement, 1038 Element annotatedElement,
1039 Registry registry) { 1039 Registry registry) {
1040 assert(registry.isForResolution); 1040 assert(registry.isForResolution);
1041 ConstantValue constant = constants.getConstantValueForMetadata(metadata); 1041 ConstantValue constant = constants.getConstantValueForMetadata(metadata);
1042 registerCompileTimeConstant(constant, registry, addForEmission: false); 1042 registerCompileTimeConstant(constant, registry);
1043 metadataConstants.add(new Dependency(constant, annotatedElement)); 1043 metadataConstants.add(new Dependency(constant, annotatedElement));
1044 } 1044 }
1045 1045
1046 void registerInstantiatedClass(ClassElement cls, 1046 void registerInstantiatedClass(ClassElement cls,
1047 Enqueuer enqueuer, 1047 Enqueuer enqueuer,
1048 Registry registry) { 1048 Registry registry) {
1049 _processClass(cls, enqueuer, registry); 1049 _processClass(cls, enqueuer, registry);
1050 } 1050 }
1051 1051
1052 void registerImplementedClass(ClassElement cls, 1052 void registerImplementedClass(ClassElement cls,
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 } 1567 }
1568 if (element.isConstructor && element.enclosingClass == jsNullClass) { 1568 if (element.isConstructor && element.enclosingClass == jsNullClass) {
1569 // Work around a problem compiling JSNull's constructor. 1569 // Work around a problem compiling JSNull's constructor.
1570 return const WorldImpact(); 1570 return const WorldImpact();
1571 } 1571 }
1572 if (kind.category == ElementCategory.VARIABLE) { 1572 if (kind.category == ElementCategory.VARIABLE) {
1573 ConstantValue initialValue = 1573 ConstantValue initialValue =
1574 constants.getConstantValueForVariable(element); 1574 constants.getConstantValueForVariable(element);
1575 if (initialValue != null) { 1575 if (initialValue != null) {
1576 registerCompileTimeConstant(initialValue, work.registry); 1576 registerCompileTimeConstant(initialValue, work.registry);
1577 addCompileTimeConstantForEmission(initialValue);
1577 // We don't need to generate code for static or top-level 1578 // We don't need to generate code for static or top-level
1578 // variables. For instance variables, we may need to generate 1579 // variables. For instance variables, we may need to generate
1579 // the checked setter. 1580 // the checked setter.
1580 if (Elements.isStaticOrTopLevel(element)) { 1581 if (Elements.isStaticOrTopLevel(element)) {
1581 return const WorldImpact(); 1582 return const WorldImpact();
1582 } 1583 }
1583 } else { 1584 } else {
1584 // If the constant-handler was not able to produce a result we have to 1585 // If the constant-handler was not able to produce a result we have to
1585 // go through the builder (below) to generate the lazy initializer for 1586 // go through the builder (below) to generate the lazy initializer for
1586 // the static variable. 1587 // the static variable.
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 2495
2495 if (mustRetainMetadata) { 2496 if (mustRetainMetadata) {
2496 reporter.log('Retaining metadata.'); 2497 reporter.log('Retaining metadata.');
2497 2498
2498 compiler.libraryLoader.libraries.forEach(retainMetadataOf); 2499 compiler.libraryLoader.libraries.forEach(retainMetadataOf);
2499 if (enqueuer.isResolutionQueue) { 2500 if (enqueuer.isResolutionQueue) {
2500 for (Dependency dependency in metadataConstants) { 2501 for (Dependency dependency in metadataConstants) {
2501 registerCompileTimeConstant( 2502 registerCompileTimeConstant(
2502 dependency.constant, 2503 dependency.constant,
2503 new EagerRegistry(compiler, 2504 new EagerRegistry(compiler,
2504 dependency.annotatedElement.analyzableElement.treeElements), 2505 dependency.annotatedElement.analyzableElement.treeElements));
2505 addForEmission: false);
2506 } 2506 }
2507 } else { 2507 } else {
2508 for (Dependency dependency in metadataConstants) { 2508 for (Dependency dependency in metadataConstants) {
2509 registerCompileTimeConstant( 2509 registerCompileTimeConstant(
2510 dependency.constant, 2510 dependency.constant,
2511 new CodegenRegistry(compiler, 2511 new CodegenRegistry(compiler,
2512 dependency.annotatedElement.analyzableElement.treeElements), 2512 dependency.annotatedElement.analyzableElement.treeElements));
2513 addForEmission: false);
2514 } 2513 }
2515 metadataConstants.clear(); 2514 metadataConstants.clear();
2516 } 2515 }
2517 } 2516 }
2518 return true; 2517 return true;
2519 } 2518 }
2520 2519
2521 void onQueueClosed() { 2520 void onQueueClosed() {
2522 lookupMapAnalysis.onQueueClosed(); 2521 lookupMapAnalysis.onQueueClosed();
2523 jsInteropAnalysis.onQueueClosed(); 2522 jsInteropAnalysis.onQueueClosed();
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 } 3032 }
3034 3033
3035 /// Records that [constant] is used by the element behind [registry]. 3034 /// Records that [constant] is used by the element behind [registry].
3036 class Dependency { 3035 class Dependency {
3037 final ConstantValue constant; 3036 final ConstantValue constant;
3038 final Element annotatedElement; 3037 final Element annotatedElement;
3039 3038
3040 const Dependency(this.constant, this.annotatedElement); 3039 const Dependency(this.constant, this.annotatedElement);
3041 } 3040 }
3042 3041
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/codegen.dart ('k') | pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698