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

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

Issue 2488353004: Remove Compiler access from ResolutionEnqueuer (Closed)
Patch Set: Updated cf. comments. Created 4 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/universe/function_set.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library universe; 5 library universe;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import '../cache_strategy.dart';
9 import '../common.dart'; 10 import '../common.dart';
11 import '../common/backend_api.dart' show Backend;
12 import '../common/resolution.dart' show Resolution;
10 import '../compiler.dart' show Compiler; 13 import '../compiler.dart' show Compiler;
14 import '../core_types.dart' show CoreClasses;
11 import '../dart_types.dart'; 15 import '../dart_types.dart';
12 import '../elements/elements.dart'; 16 import '../elements/elements.dart';
17 import '../types/masks.dart' show CommonMasks;
13 import '../universe/class_set.dart' show Instantiation; 18 import '../universe/class_set.dart' show Instantiation;
14 import '../util/enumset.dart'; 19 import '../util/enumset.dart';
15 import '../util/util.dart'; 20 import '../util/util.dart';
16 import '../world.dart' show World, ClosedWorld, OpenWorld; 21 import '../world.dart' show World, ClosedWorld, OpenWorld, WorldImpl;
17 import 'selector.dart' show Selector; 22 import 'selector.dart' show Selector;
18 import 'use.dart' show DynamicUse, DynamicUseKind, StaticUse, StaticUseKind; 23 import 'use.dart' show DynamicUse, DynamicUseKind, StaticUse, StaticUseKind;
19 24
20 /// The known constraint on receiver for a dynamic call site. 25 /// The known constraint on receiver for a dynamic call site.
21 /// 26 ///
22 /// This can for instance be used to constrain this dynamic call to `foo` to 27 /// This can for instance be used to constrain this dynamic call to `foo` to
23 /// 'receivers of the exact instance `Bar`': 28 /// 'receivers of the exact instance `Bar`':
24 /// 29 ///
25 /// class Bar { 30 /// class Bar {
26 /// void foo() {} 31 /// void foo() {}
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// constructor that has been called directly and not only through a 118 /// constructor that has been called directly and not only through a
114 /// super-call. 119 /// super-call.
115 // TODO(johnniwinther): Improve semantic precision. 120 // TODO(johnniwinther): Improve semantic precision.
116 Iterable<ClassElement> get directlyInstantiatedClasses; 121 Iterable<ClassElement> get directlyInstantiatedClasses;
117 122
118 /// All types that are checked either through is, as or checked mode checks. 123 /// All types that are checked either through is, as or checked mode checks.
119 Iterable<DartType> get isChecks; 124 Iterable<DartType> get isChecks;
120 125
121 /// Registers that [type] is checked in this universe. The unaliased type is 126 /// Registers that [type] is checked in this universe. The unaliased type is
122 /// returned. 127 /// returned.
123 DartType registerIsCheck(DartType type, Compiler compiler); 128 DartType registerIsCheck(DartType type, Resolution resolution);
124 129
125 /// All directly instantiated types, that is, the types of the directly 130 /// All directly instantiated types, that is, the types of the directly
126 /// instantiated classes. 131 /// instantiated classes.
127 // TODO(johnniwinther): Improve semantic precision. 132 // TODO(johnniwinther): Improve semantic precision.
128 Iterable<DartType> get instantiatedTypes; 133 Iterable<DartType> get instantiatedTypes;
129 134
130 /// Returns `true` if [member] is invoked as a setter. 135 /// Returns `true` if [member] is invoked as a setter.
131 bool hasInvokedSetter(Element member, World world); 136 bool hasInvokedSetter(Element member, World world);
132 } 137 }
133 138
(...skipping 21 matching lines...) Expand all
155 /// subtypes. The latter case only contains spurious information from 160 /// subtypes. The latter case only contains spurious information from
156 /// instantiations through factory constructors and mixins. 161 /// instantiations through factory constructors and mixins.
157 bool isImplemented(ClassElement cls); 162 bool isImplemented(ClassElement cls);
158 163
159 /// Set of all fields that are statically known to be written to. 164 /// Set of all fields that are statically known to be written to.
160 Iterable<Element> get fieldSetters; 165 Iterable<Element> get fieldSetters;
161 166
162 /// Call [f] for all directly or abstractly instantiated classes. 167 /// Call [f] for all directly or abstractly instantiated classes.
163 void forEachInstantiatedClass( 168 void forEachInstantiatedClass(
164 f(ClassElement cls, EnumSet<Instantiation> instantiations)); 169 f(ClassElement cls, EnumSet<Instantiation> instantiations));
170
171 /// `true` of `Object.runtimeType` is supported.
172 bool get hasRuntimeTypeSupport;
173
174 /// `true` of use of the `dart:isolate` library is supported.
175 bool get hasIsolateSupport;
176
177 /// `true` of `Function.apply` is supported.
178 bool get hasFunctionApplySupport;
179
180 /// The [OpenWorld] being created by this world builder.
181 // TODO(johnniwinther): Merge this with [ResolutionWorldBuilder].
182 OpenWorld get openWorld;
165 } 183 }
166 184
167 class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder { 185 class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
168 /// The set of all directly instantiated classes, that is, classes with a 186 /// The set of all directly instantiated classes, that is, classes with a
169 /// generative constructor that has been called directly and not only through 187 /// generative constructor that has been called directly and not only through
170 /// a super-call. 188 /// a super-call.
171 /// 189 ///
172 /// Invariant: Elements are declaration elements. 190 /// Invariant: Elements are declaration elements.
173 // TODO(johnniwinther): [_directlyInstantiatedClasses] and 191 // TODO(johnniwinther): [_directlyInstantiatedClasses] and
174 // [_instantiatedTypes] sets should be merged. 192 // [_instantiatedTypes] sets should be merged.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 final Set<LocalFunctionElement> allClosures = new Set<LocalFunctionElement>(); 247 final Set<LocalFunctionElement> allClosures = new Set<LocalFunctionElement>();
230 248
231 /** 249 /**
232 * Set of methods in instantiated classes that are potentially 250 * Set of methods in instantiated classes that are potentially
233 * closurized. 251 * closurized.
234 */ 252 */
235 final Set<Element> closurizedMembers = new Set<Element>(); 253 final Set<Element> closurizedMembers = new Set<Element>();
236 254
237 final SelectorConstraintsStrategy selectorConstraintsStrategy; 255 final SelectorConstraintsStrategy selectorConstraintsStrategy;
238 256
239 ResolutionWorldBuilderImpl(this.selectorConstraintsStrategy); 257 bool hasRuntimeTypeSupport = false;
258 bool hasIsolateSupport = false;
259 bool hasFunctionApplySupport = false;
260
261 OpenWorld _openWorld;
262
263 ResolutionWorldBuilderImpl(Backend backend, CoreClasses coreClasses,
264 CacheStrategy cacheStrategy, this.selectorConstraintsStrategy) {
265 _openWorld = new WorldImpl(this, backend, coreClasses, cacheStrategy);
266 }
267
268 OpenWorld get openWorld => _openWorld;
240 269
241 /// All directly instantiated classes, that is, classes with a generative 270 /// All directly instantiated classes, that is, classes with a generative
242 /// constructor that has been called directly and not only through a 271 /// constructor that has been called directly and not only through a
243 /// super-call. 272 /// super-call.
244 // TODO(johnniwinther): Improve semantic precision. 273 // TODO(johnniwinther): Improve semantic precision.
245 Iterable<ClassElement> get directlyInstantiatedClasses { 274 Iterable<ClassElement> get directlyInstantiatedClasses {
246 return _directlyInstantiatedClasses.keys; 275 return _directlyInstantiatedClasses.keys;
247 } 276 }
248 277
249 /// All directly instantiated types, that is, the types of the directly 278 /// All directly instantiated types, that is, the types of the directly
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 ReceiverConstraint mask = dynamicUse.mask; 387 ReceiverConstraint mask = dynamicUse.mask;
359 Map<Selector, SelectorConstraints> selectors = selectorMap.putIfAbsent( 388 Map<Selector, SelectorConstraints> selectors = selectorMap.putIfAbsent(
360 name, () => new Maplet<Selector, SelectorConstraints>()); 389 name, () => new Maplet<Selector, SelectorConstraints>());
361 UniverseSelectorConstraints constraints = 390 UniverseSelectorConstraints constraints =
362 selectors.putIfAbsent(selector, () { 391 selectors.putIfAbsent(selector, () {
363 return selectorConstraintsStrategy.createSelectorConstraints(selector); 392 return selectorConstraintsStrategy.createSelectorConstraints(selector);
364 }); 393 });
365 return constraints.addReceiverConstraint(mask); 394 return constraints.addReceiverConstraint(mask);
366 } 395 }
367 396
368 DartType registerIsCheck(DartType type, Compiler compiler) { 397 DartType registerIsCheck(DartType type, Resolution resolution) {
369 type.computeUnaliased(compiler.resolution); 398 type.computeUnaliased(resolution);
370 type = type.unaliased; 399 type = type.unaliased;
371 // Even in checked mode, type annotations for return type and argument 400 // Even in checked mode, type annotations for return type and argument
372 // types do not imply type checks, so there should never be a check 401 // types do not imply type checks, so there should never be a check
373 // against the type variable of a typedef. 402 // against the type variable of a typedef.
374 isChecks.add(type); 403 isChecks.add(type);
375 return type; 404 return type;
376 } 405 }
377 406
378 void registerStaticUse(StaticUse staticUse) { 407 void registerStaticUse(StaticUse staticUse) {
379 Element element = staticUse.element; 408 Element element = staticUse.element;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 void forEachInvokedGetter( 666 void forEachInvokedGetter(
638 f(String name, Map<Selector, SelectorConstraints> selectors)) { 667 f(String name, Map<Selector, SelectorConstraints> selectors)) {
639 _invokedGetters.forEach(f); 668 _invokedGetters.forEach(f);
640 } 669 }
641 670
642 void forEachInvokedSetter( 671 void forEachInvokedSetter(
643 f(String name, Map<Selector, SelectorConstraints> selectors)) { 672 f(String name, Map<Selector, SelectorConstraints> selectors)) {
644 _invokedSetters.forEach(f); 673 _invokedSetters.forEach(f);
645 } 674 }
646 675
647 DartType registerIsCheck(DartType type, Compiler compiler) { 676 DartType registerIsCheck(DartType type, Resolution resolution) {
648 type.computeUnaliased(compiler.resolution);
649 type = type.unaliased; 677 type = type.unaliased;
650 // Even in checked mode, type annotations for return type and argument 678 // Even in checked mode, type annotations for return type and argument
651 // types do not imply type checks, so there should never be a check 679 // types do not imply type checks, so there should never be a check
652 // against the type variable of a typedef. 680 // against the type variable of a typedef.
653 isChecks.add(type); 681 isChecks.add(type);
654 return type; 682 return type;
655 } 683 }
656 684
657 void registerStaticUse(StaticUse staticUse) { 685 void registerStaticUse(StaticUse staticUse) {
658 Element element = staticUse.element; 686 Element element = staticUse.element;
(...skipping 21 matching lines...) Expand all
680 708
681 void forgetElement(Element element, Compiler compiler) { 709 void forgetElement(Element element, Compiler compiler) {
682 _directlyInstantiatedClasses.remove(element); 710 _directlyInstantiatedClasses.remove(element);
683 if (element is ClassElement) { 711 if (element is ClassElement) {
684 assert(invariant(element, element.thisType.isRaw, 712 assert(invariant(element, element.thisType.isRaw,
685 message: 'Generic classes not supported (${element.thisType}).')); 713 message: 'Generic classes not supported (${element.thisType}).'));
686 _instantiatedTypes..remove(element.rawType)..remove(element.thisType); 714 _instantiatedTypes..remove(element.rawType)..remove(element.thisType);
687 } 715 }
688 } 716 }
689 } 717 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/function_set.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698