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

Side by Side Diff: pkg/compiler/lib/src/universe/codegen_world_builder.dart

Issue 2725933006: Reduce use of elements/resolution_types in enqueuer. (Closed)
Patch Set: Updated cf. comment. Created 3 years, 9 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 world_builder; 5 part of world_builder;
6 6
7 /// World builder specific to codegen. 7 /// World builder specific to codegen.
8 /// 8 ///
9 /// This adds additional access to liveness of selectors and elements. 9 /// This adds additional access to liveness of selectors and elements.
10 abstract class CodegenWorldBuilder implements WorldBuilder { 10 abstract class CodegenWorldBuilder implements WorldBuilder {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 /// Invariant: Elements are declaration elements. 62 /// Invariant: Elements are declaration elements.
63 // TODO(johnniwinther): [_directlyInstantiatedClasses] and 63 // TODO(johnniwinther): [_directlyInstantiatedClasses] and
64 // [_instantiatedTypes] sets should be merged. 64 // [_instantiatedTypes] sets should be merged.
65 final Set<ClassElement> _directlyInstantiatedClasses = 65 final Set<ClassElement> _directlyInstantiatedClasses =
66 new Set<ClassElement>(); 66 new Set<ClassElement>();
67 67
68 /// The set of all directly instantiated types, that is, the types of the 68 /// The set of all directly instantiated types, that is, the types of the
69 /// directly instantiated classes. 69 /// directly instantiated classes.
70 /// 70 ///
71 /// See [_directlyInstantiatedClasses]. 71 /// See [_directlyInstantiatedClasses].
72 final Set<ResolutionDartType> _instantiatedTypes = 72 final Set<InterfaceType> _instantiatedTypes = new Set<InterfaceType>();
73 new Set<ResolutionDartType>();
74 73
75 /// Classes implemented by directly instantiated classes. 74 /// Classes implemented by directly instantiated classes.
76 final Set<ClassElement> _implementedClasses = new Set<ClassElement>(); 75 final Set<ClassElement> _implementedClasses = new Set<ClassElement>();
77 76
78 /// The set of all referenced static fields. 77 /// The set of all referenced static fields.
79 /// 78 ///
80 /// Invariant: Elements are declaration elements. 79 /// Invariant: Elements are declaration elements.
81 final Set<FieldElement> allReferencedStaticFields = new Set<FieldElement>(); 80 final Set<FieldElement> allReferencedStaticFields = new Set<FieldElement>();
82 81
83 /** 82 /**
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // TODO(johnniwinther): Improve semantic precision. 160 // TODO(johnniwinther): Improve semantic precision.
162 Iterable<ClassElement> get directlyInstantiatedClasses { 161 Iterable<ClassElement> get directlyInstantiatedClasses {
163 return _directlyInstantiatedClasses; 162 return _directlyInstantiatedClasses;
164 } 163 }
165 164
166 /// All directly instantiated types, that is, the types of the directly 165 /// All directly instantiated types, that is, the types of the directly
167 /// instantiated classes. 166 /// instantiated classes.
168 /// 167 ///
169 /// See [directlyInstantiatedClasses]. 168 /// See [directlyInstantiatedClasses].
170 // TODO(johnniwinther): Improve semantic precision. 169 // TODO(johnniwinther): Improve semantic precision.
171 Iterable<ResolutionDartType> get instantiatedTypes => _instantiatedTypes; 170 Iterable<InterfaceType> get instantiatedTypes => _instantiatedTypes;
172 171
173 /// Register [type] as (directly) instantiated. 172 /// Register [type] as (directly) instantiated.
174 /// 173 ///
175 /// If [byMirrors] is `true`, the instantiation is through mirrors. 174 /// If [byMirrors] is `true`, the instantiation is through mirrors.
176 // TODO(johnniwinther): Fully enforce the separation between exact, through 175 // TODO(johnniwinther): Fully enforce the separation between exact, through
177 // subclass and through subtype instantiated types/classes. 176 // subclass and through subtype instantiated types/classes.
178 // TODO(johnniwinther): Support unknown type arguments for generic types. 177 // TODO(johnniwinther): Support unknown type arguments for generic types.
179 void registerTypeInstantiation( 178 void registerTypeInstantiation(
180 ResolutionInterfaceType type, ClassUsedCallback classUsed, 179 ResolutionInterfaceType type, ClassUsedCallback classUsed,
181 {bool byMirrors: false}) { 180 {bool byMirrors: false}) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 void forEachInvokedGetter( 317 void forEachInvokedGetter(
319 f(String name, Map<Selector, SelectorConstraints> selectors)) { 318 f(String name, Map<Selector, SelectorConstraints> selectors)) {
320 _invokedGetters.forEach(f); 319 _invokedGetters.forEach(f);
321 } 320 }
322 321
323 void forEachInvokedSetter( 322 void forEachInvokedSetter(
324 f(String name, Map<Selector, SelectorConstraints> selectors)) { 323 f(String name, Map<Selector, SelectorConstraints> selectors)) {
325 _invokedSetters.forEach(f); 324 _invokedSetters.forEach(f);
326 } 325 }
327 326
328 ResolutionDartType registerIsCheck(ResolutionDartType type) { 327 void registerIsCheck(ResolutionDartType type) {
329 type = type.unaliased; 328 type = type.unaliased;
330 // Even in checked mode, type annotations for return type and argument 329 // Even in checked mode, type annotations for return type and argument
331 // types do not imply type checks, so there should never be a check 330 // types do not imply type checks, so there should never be a check
332 // against the type variable of a typedef. 331 // against the type variable of a typedef.
332 assert(!type.isTypeVariable || !type.element.enclosingElement.isTypedef);
333 isChecks.add(type); 333 isChecks.add(type);
334 return type;
335 } 334 }
336 335
337 void _registerStaticUse(StaticUse staticUse) { 336 void _registerStaticUse(StaticUse staticUse) {
338 Element element = staticUse.element; 337 Element element = staticUse.element;
339 if (Elements.isStaticOrTopLevel(element) && element.isField) { 338 if (Elements.isStaticOrTopLevel(element) && element.isField) {
340 allReferencedStaticFields.add(element); 339 allReferencedStaticFields.add(element);
341 } 340 }
342 switch (staticUse.kind) { 341 switch (staticUse.kind) {
343 case StaticUseKind.STATIC_TEAR_OFF: 342 case StaticUseKind.STATIC_TEAR_OFF:
344 staticFunctionsNeedingGetter.add(element); 343 staticFunctionsNeedingGetter.add(element);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 return true; 488 return true;
490 } 489 }
491 return false; 490 return false;
492 } 491 }
493 492
494 while (cls != null && processClass(cls)) { 493 while (cls != null && processClass(cls)) {
495 cls = cls.superclass; 494 cls = cls.superclass;
496 } 495 }
497 } 496 }
498 } 497 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/native/enqueue.dart ('k') | pkg/compiler/lib/src/universe/resolution_world_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698