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

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

Issue 2694653005: Extract BackendUsageBuilder from BackendUsage (Closed)
Patch Set: Created 3 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
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 '../elements/resolution_types.dart'; 7 import '../elements/resolution_types.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../universe/use.dart' show StaticUse; 9 import '../universe/use.dart' show StaticUse;
10 import '../universe/world_impact.dart' 10 import '../universe/world_impact.dart'
11 show WorldImpact, StagedWorldImpactBuilder; 11 show WorldImpact, StagedWorldImpactBuilder;
12 import 'backend.dart'; 12 import 'backend.dart';
13 import 'backend_usage.dart' show BackendUsageBuilder;
13 14
14 /** 15 /**
15 * Support for Custom Elements. 16 * Support for Custom Elements.
16 * 17 *
17 * 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
18 * 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
19 * constructor(s) for the class. 20 * constructor(s) for the class.
20 * 21 *
21 * 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
22 * want to avoid resolving and compiling constructors that are not used since 23 * want to avoid resolving and compiling constructors that are not used since
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 bool allClassesSelected = false; 147 bool allClassesSelected = false;
147 148
148 // Did we see a demand for the data? 149 // Did we see a demand for the data?
149 bool demanded = false; 150 bool demanded = false;
150 151
151 // ClassesOutput: classes requiring metadata. 152 // ClassesOutput: classes requiring metadata.
152 final activeClasses = new Set<ClassElement>(); 153 final activeClasses = new Set<ClassElement>();
153 154
154 CustomElementsAnalysisJoin(this.backend); 155 CustomElementsAnalysisJoin(this.backend);
155 156
157 BackendUsageBuilder get backendUsageBuilder => backend.backendUsageBuilder;
158
156 WorldImpact flush() { 159 WorldImpact flush() {
157 if (!demanded) return const WorldImpact(); 160 if (!demanded) return const WorldImpact();
158 var newActiveClasses = new Set<ClassElement>(); 161 var newActiveClasses = new Set<ClassElement>();
159 for (ClassElement classElement in instantiatedClasses) { 162 for (ClassElement classElement in instantiatedClasses) {
160 bool isNative = backend.isNative(classElement); 163 bool isNative = backend.isNative(classElement);
161 bool isExtension = 164 bool isExtension =
162 !isNative && backend.nativeData.isNativeOrExtendsNative(classElement); 165 !isNative && backend.nativeData.isNativeOrExtendsNative(classElement);
163 // Generate table entries for native classes that are explicitly named and 166 // Generate table entries for native classes that are explicitly named and
164 // extensions that fix our criteria. 167 // extensions that fix our criteria.
165 if ((isNative && selectedClasses.contains(classElement)) || 168 if ((isNative && selectedClasses.contains(classElement)) ||
166 (isExtension && 169 (isExtension &&
167 (allClassesSelected || selectedClasses.contains(classElement)))) { 170 (allClassesSelected || selectedClasses.contains(classElement)))) {
168 newActiveClasses.add(classElement); 171 newActiveClasses.add(classElement);
169 Iterable<ConstructorElement> escapingConstructors = 172 Iterable<ConstructorElement> escapingConstructors =
170 computeEscapingConstructors(classElement); 173 computeEscapingConstructors(classElement);
171 for (ConstructorElement constructor in escapingConstructors) { 174 for (ConstructorElement constructor in escapingConstructors) {
172 impactBuilder 175 impactBuilder
173 .registerStaticUse(new StaticUse.foreignUse(constructor)); 176 .registerStaticUse(new StaticUse.foreignUse(constructor));
174 } 177 }
175 escapingConstructors 178 escapingConstructors
176 .forEach(backend.backendUsage.registerGlobalDependency); 179 .forEach(backendUsageBuilder.registerGlobalDependency);
177 // Force the generaton of the type constant that is the key to an entry 180 // Force the generaton of the type constant that is the key to an entry
178 // in the generated table. 181 // in the generated table.
179 ConstantValue constant = makeTypeConstant(classElement); 182 ConstantValue constant = makeTypeConstant(classElement);
180 backend.computeImpactForCompileTimeConstant( 183 backend.computeImpactForCompileTimeConstant(
181 constant, impactBuilder, false); 184 constant, impactBuilder, false);
182 backend.addCompileTimeConstantForEmission(constant); 185 backend.addCompileTimeConstantForEmission(constant);
183 } 186 }
184 } 187 }
185 activeClasses.addAll(newActiveClasses); 188 activeClasses.addAll(newActiveClasses);
186 instantiatedClasses.removeAll(newActiveClasses); 189 instantiatedClasses.removeAll(newActiveClasses);
(...skipping 24 matching lines...) Expand all
211 result.add(member); 214 result.add(member);
212 } 215 }
213 } 216 }
214 } 217 }
215 218
216 classElement.forEachMember(selectGenerativeConstructors, 219 classElement.forEachMember(selectGenerativeConstructors,
217 includeBackendMembers: false, includeSuperAndInjectedMembers: false); 220 includeBackendMembers: false, includeSuperAndInjectedMembers: false);
218 return result; 221 return result;
219 } 222 }
220 } 223 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend_usage.dart ('k') | pkg/compiler/lib/src/js_backend/type_variable_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698