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

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

Issue 2349163003: Move towards using WorldImpact for codegen (Closed)
Patch Set: Reinsert missing features uses. Created 4 years, 3 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import '../compiler.dart' show Compiler; 5 import '../compiler.dart' show Compiler;
6 import '../constants/values.dart'; 6 import '../constants/values.dart';
7 import '../dart_types.dart'; 7 import '../dart_types.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../enqueue.dart' show Enqueuer; 9 import '../enqueue.dart' show Enqueuer;
10 import '../universe/use.dart' show StaticUse; 10 import '../universe/use.dart' show StaticUse;
11 import '../universe/world_impact.dart'
12 show WorldImpact, StagedWorldImpactBuilder;
11 import 'backend.dart'; 13 import 'backend.dart';
12 14
13 /** 15 /**
14 * Support for Custom Elements. 16 * Support for Custom Elements.
15 * 17 *
16 * The support for custom elements the compiler builds a table that maps the 18 * The support for custom elements the compiler builds a table that maps the
17 * custom element class's [Type] to the interceptor for the class and the 19 * custom element class's [Type] to the interceptor for the class and the
18 * constructor(s) for the class. 20 * constructor(s) for the class.
19 * 21 *
20 * We want the table to contain only the custom element classes used, and we 22 * We want the table to contain only the custom element classes used, and we
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 codegenJoin.activeClasses.contains(classElement); 125 codegenJoin.activeClasses.contains(classElement);
124 126
125 List<Element> constructors(ClassElement classElement) => 127 List<Element> constructors(ClassElement classElement) =>
126 codegenJoin.computeEscapingConstructors(classElement); 128 codegenJoin.computeEscapingConstructors(classElement);
127 } 129 }
128 130
129 class CustomElementsAnalysisJoin { 131 class CustomElementsAnalysisJoin {
130 final JavaScriptBackend backend; 132 final JavaScriptBackend backend;
131 Compiler get compiler => backend.compiler; 133 Compiler get compiler => backend.compiler;
132 134
135 final StagedWorldImpactBuilder impactBuilder = new StagedWorldImpactBuilder();
136
133 // Classes that are candidates for needing constructors. Classes are moved to 137 // Classes that are candidates for needing constructors. Classes are moved to
134 // [activeClasses] when we know they need constructors. 138 // [activeClasses] when we know they need constructors.
135 final instantiatedClasses = new Set<ClassElement>(); 139 final instantiatedClasses = new Set<ClassElement>();
136 140
137 // Classes explicitly named. 141 // Classes explicitly named.
138 final selectedClasses = new Set<ClassElement>(); 142 final selectedClasses = new Set<ClassElement>();
139 143
140 // True if we must conservatively include all extension classes. 144 // True if we must conservatively include all extension classes.
141 bool allClassesSelected = false; 145 bool allClassesSelected = false;
142 146
(...skipping 21 matching lines...) Expand all
164 Iterable<ConstructorElement> escapingConstructors = 168 Iterable<ConstructorElement> escapingConstructors =
165 computeEscapingConstructors(classElement); 169 computeEscapingConstructors(classElement);
166 for (ConstructorElement constructor in escapingConstructors) { 170 for (ConstructorElement constructor in escapingConstructors) {
167 enqueuer.registerStaticUse(new StaticUse.foreignUse(constructor)); 171 enqueuer.registerStaticUse(new StaticUse.foreignUse(constructor));
168 } 172 }
169 escapingConstructors 173 escapingConstructors
170 .forEach(compiler.globalDependencies.registerDependency); 174 .forEach(compiler.globalDependencies.registerDependency);
171 // Force the generaton of the type constant that is the key to an entry 175 // Force the generaton of the type constant that is the key to an entry
172 // in the generated table. 176 // in the generated table.
173 ConstantValue constant = makeTypeConstant(classElement); 177 ConstantValue constant = makeTypeConstant(classElement);
174 backend.registerCompileTimeConstant( 178 backend.computeImpactForCompileTimeConstant(
175 constant, compiler.globalDependencies); 179 constant, impactBuilder, false);
176 backend.addCompileTimeConstantForEmission(constant); 180 backend.addCompileTimeConstantForEmission(constant);
177 } 181 }
178 } 182 }
179 activeClasses.addAll(newActiveClasses); 183 activeClasses.addAll(newActiveClasses);
180 instantiatedClasses.removeAll(newActiveClasses); 184 instantiatedClasses.removeAll(newActiveClasses);
185 enqueuer.applyImpact(null, impactBuilder.flush());
181 } 186 }
182 187
183 TypeConstantValue makeTypeConstant(ClassElement element) { 188 TypeConstantValue makeTypeConstant(ClassElement element) {
184 DartType elementType = element.rawType; 189 DartType elementType = element.rawType;
185 return backend.constantSystem.createType(compiler, elementType); 190 return backend.constantSystem.createType(compiler, elementType);
186 } 191 }
187 192
188 List<ConstructorElement> computeEscapingConstructors( 193 List<ConstructorElement> computeEscapingConstructors(
189 ClassElement classElement) { 194 ClassElement classElement) {
190 List<ConstructorElement> result = <ConstructorElement>[]; 195 List<ConstructorElement> result = <ConstructorElement>[];
(...skipping 12 matching lines...) Expand all
203 result.add(member); 208 result.add(member);
204 } 209 }
205 } 210 }
206 } 211 }
207 212
208 classElement.forEachMember(selectGenerativeConstructors, 213 classElement.forEachMember(selectGenerativeConstructors,
209 includeBackendMembers: false, includeSuperAndInjectedMembers: false); 214 includeBackendMembers: false, includeSuperAndInjectedMembers: false);
210 return result; 215 return result;
211 } 216 }
212 } 217 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend_impact.dart ('k') | pkg/compiler/lib/src/js_backend/js_interop_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698