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

Side by Side Diff: pkg/compiler/lib/src/common/resolution.dart

Issue 1394923003: Use WorldImpact for element dependencies in deferred_load (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 1
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 library dart2js.common.resolution; 6 library dart2js.common.resolution;
7 7
8 import '../common.dart'; 8 import '../common.dart';
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 /// [WorkItem] used exclusively by the [ResolutionEnqueuer]. 45 /// [WorkItem] used exclusively by the [ResolutionEnqueuer].
46 class ResolutionWorkItem extends WorkItem { 46 class ResolutionWorkItem extends WorkItem {
47 bool _isAnalyzed = false; 47 bool _isAnalyzed = false;
48 48
49 ResolutionWorkItem(AstElement element, 49 ResolutionWorkItem(AstElement element,
50 ItemCompilationContext compilationContext) 50 ItemCompilationContext compilationContext)
51 : super(element, compilationContext); 51 : super(element, compilationContext);
52 52
53 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) { 53 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) {
54 WorldImpact impact = compiler.analyze(this, world); 54 WorldImpact impact = compiler.analyze(this, world);
55 impact = compiler.backend.resolutionCallbacks.transformImpact(impact);
56 _isAnalyzed = true; 55 _isAnalyzed = true;
57 return impact; 56 return impact;
58 } 57 }
59 58
60 bool get isAnalyzed => _isAnalyzed; 59 bool get isAnalyzed => _isAnalyzed;
61 } 60 }
62 61
63 // TODO(johnniwinther): Rename this to something like `BackendResolutionApi` 62 // TODO(johnniwinther): Rename this to something like `BackendResolutionApi`
64 // and clean up the interface. 63 // and clean up the interface.
65 /// Backend callbacks function specific to the resolution phase. 64 /// Backend callbacks function specific to the resolution phase.
66 class ResolutionCallbacks { 65 class ResolutionCallbacks {
67 /// Transform the [ResolutionWorldImpact] into a [WorldImpact] adding the 66 /// Transform the [ResolutionImpact] into a [WorldImpact] adding the
68 /// backend dependencies for features used in [worldImpact]. 67 /// backend dependencies for features used in [worldImpact].
69 WorldImpact transformImpact(ResolutionWorldImpact worldImpact) => worldImpact; 68 WorldImpact transformImpact(ResolutionImpact worldImpact) => worldImpact;
70 } 69 }
71 70
72 class ResolutionWorldImpact extends WorldImpact { 71 class ResolutionImpact extends WorldImpact {
73 const ResolutionWorldImpact(); 72 const ResolutionImpact();
74 73
75 // TODO(johnniwinther): Remove this. 74 // TODO(johnniwinther): Remove this.
76 void registerDependency(Element element) {} 75 void registerDependency(Element element) {}
77 76
78 Iterable<Feature> get features => const <Feature>[]; 77 Iterable<Feature> get features => const <Feature>[];
79 Iterable<DartType> get requiredTypes => const <DartType>[]; 78 Iterable<DartType> get requiredTypes => const <DartType>[];
80 Iterable<MapLiteralUse> get mapLiterals => const <MapLiteralUse>[]; 79 Iterable<MapLiteralUse> get mapLiterals => const <MapLiteralUse>[];
81 Iterable<ListLiteralUse> get listLiterals => const <ListLiteralUse>[]; 80 Iterable<ListLiteralUse> get listLiterals => const <ListLiteralUse>[];
82 Iterable<DartType> get typeLiterals => const <DartType>[]; 81 Iterable<DartType> get typeLiterals => const <DartType>[];
83 Iterable<String> get constSymbolNames => const <String>[]; 82 Iterable<String> get constSymbolNames => const <String>[];
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (identical(this, other)) return true; 176 if (identical(this, other)) return true;
178 if (other is! ListLiteralUse) return false; 177 if (other is! ListLiteralUse) return false;
179 return 178 return
180 type == other.type && 179 type == other.type &&
181 isConstant == other.isConstant && 180 isConstant == other.isConstant &&
182 isEmpty == other.isEmpty; 181 isEmpty == other.isEmpty;
183 } 182 }
184 } 183 }
185 184
186 /// Mutable implementation of [WorldImpact] used to transform 185 /// Mutable implementation of [WorldImpact] used to transform
187 /// [ResolutionWorldImpact] to [WorldImpact]. 186 /// [ResolutionImpact] to [WorldImpact].
188 // TODO(johnniwinther): Remove [Registry] when dependency is tracked directly 187 // TODO(johnniwinther): Remove [Registry] when dependency is tracked directly
189 // on [WorldImpact]. 188 // on [WorldImpact].
190 class TransformedWorldImpact implements WorldImpact { 189 class TransformedWorldImpact extends WorldImpact {
191 final ResolutionWorldImpact worldImpact; 190 final ResolutionImpact worldImpact;
192 191
193 Setlet<Element> _staticUses; 192 Setlet<Element> _staticUses;
194 Setlet<InterfaceType> _instantiatedTypes; 193 Setlet<InterfaceType> _instantiatedTypes;
195 Setlet<UniverseSelector> _dynamicGetters; 194 Setlet<UniverseSelector> _dynamicGetters;
196 Setlet<UniverseSelector> _dynamicInvocations; 195 Setlet<UniverseSelector> _dynamicInvocations;
197 Setlet<UniverseSelector> _dynamicSetters; 196 Setlet<UniverseSelector> _dynamicSetters;
198 197
199 TransformedWorldImpact(this.worldImpact); 198 TransformedWorldImpact(this.worldImpact);
200 199
201 @override 200 @override
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 272 }
274 _instantiatedTypes.add(type); 273 _instantiatedTypes.add(type);
275 } 274 }
276 275
277 @override 276 @override
278 Iterable<InterfaceType> get instantiatedTypes { 277 Iterable<InterfaceType> get instantiatedTypes {
279 return _instantiatedTypes != null 278 return _instantiatedTypes != null
280 ? _instantiatedTypes : const <InterfaceType>[]; 279 ? _instantiatedTypes : const <InterfaceType>[];
281 } 280 }
282 281
282 @override
283 Iterable<DartType> get typeLiterals {
284 return worldImpact.typeLiterals;
285 }
286
283 void registerStaticUse(Element element) { 287 void registerStaticUse(Element element) {
284 // TODO(johnniwinther): Remove this when dependency tracking is done on 288 // TODO(johnniwinther): Remove this when dependency tracking is done on
285 // the world impact itself. 289 // the world impact itself.
286 worldImpact.registerDependency(element); 290 worldImpact.registerDependency(element);
287 if (_staticUses == null) { 291 if (_staticUses == null) {
288 _staticUses = new Setlet<Element>(); 292 _staticUses = new Setlet<Element>();
289 } 293 }
290 _staticUses.add(element); 294 _staticUses.add(element);
291 } 295 }
292 296
293 @override 297 @override
294 Iterable<LocalFunctionElement> get closures => worldImpact.closures; 298 Iterable<LocalFunctionElement> get closures => worldImpact.closures;
299
300 String toString() {
301 StringBuffer sb = new StringBuffer();
302 sb.write('TransformedWorldImpact($worldImpact)');
303 sb.write(super.toString());
304 return sb.toString();
305 }
295 } 306 }
296 307
297 // TODO(johnniwinther): Rename to `Resolver` or `ResolverContext`. 308 // TODO(johnniwinther): Rename to `Resolver` or `ResolverContext`.
298 abstract class Resolution { 309 abstract class Resolution {
299 Parsing get parsing; 310 Parsing get parsing;
300 DiagnosticReporter get reporter; 311 DiagnosticReporter get reporter;
301 CoreTypes get coreTypes; 312 CoreTypes get coreTypes;
302 313
303 void resolveTypedef(TypedefElement typdef); 314 void resolveTypedef(TypedefElement typdef);
304 void resolveClass(ClassElement cls); 315 void resolveClass(ClassElement cls);
305 void registerClass(ClassElement cls); 316 void registerClass(ClassElement cls);
306 void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation); 317 void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation);
307 FunctionSignature resolveSignature(FunctionElement function); 318 FunctionSignature resolveSignature(FunctionElement function);
308 DartType resolveTypeAnnotation(Element element, TypeAnnotation node); 319 DartType resolveTypeAnnotation(Element element, TypeAnnotation node);
309 320
310 bool hasBeenResolved(Element element); 321 bool hasBeenResolved(Element element);
311 ResolutionWorldImpact analyzeElement(Element element); 322 WorldImpact getWorldImpact(Element element);
323 WorldImpact computeWorldImpact(Element element);
312 } 324 }
313 325
314 // TODO(johnniwinther): Rename to `Parser` or `ParsingContext`. 326 // TODO(johnniwinther): Rename to `Parser` or `ParsingContext`.
315 abstract class Parsing { 327 abstract class Parsing {
316 DiagnosticReporter get reporter; 328 DiagnosticReporter get reporter;
317 void parsePatchClass(ClassElement cls); 329 void parsePatchClass(ClassElement cls);
318 measure(f()); 330 measure(f());
319 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698