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

Unified Diff: pkg/compiler/lib/src/universe/world_builder.dart

Issue 2443953002: Introduce isAbstractlyInstantiated to avoid exact masks of abstract classes. (Closed)
Patch Set: Updated cf. comments. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/universe/class_set.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/universe/world_builder.dart
diff --git a/pkg/compiler/lib/src/universe/world_builder.dart b/pkg/compiler/lib/src/universe/world_builder.dart
index d574f3ae4b6518bd9a822a8d76bdbae1c51818fe..470adf3b6437a1ba8af1ca28866e5fe22d1c068f 100644
--- a/pkg/compiler/lib/src/universe/world_builder.dart
+++ b/pkg/compiler/lib/src/universe/world_builder.dart
@@ -10,6 +10,8 @@ import '../common.dart';
import '../compiler.dart' show Compiler;
import '../dart_types.dart';
import '../elements/elements.dart';
+import '../universe/class_set.dart' show Instantiation;
+import '../util/enumset.dart';
import '../util/util.dart';
import '../world.dart' show World, ClosedWorld, OpenWorld;
import 'selector.dart' show Selector;
@@ -156,6 +158,10 @@ abstract class ResolutionWorldBuilder implements WorldBuilder {
/// Set of all fields that are statically known to be written to.
Iterable<Element> get fieldSetters;
+
+ /// Call [f] for all directly or abstractly instantiated classes.
+ void forEachInstantiatedClass(
+ f(ClassElement cls, EnumSet<Instantiation> instantiations));
}
class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
@@ -166,8 +172,8 @@ class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
/// Invariant: Elements are declaration elements.
// TODO(johnniwinther): [_directlyInstantiatedClasses] and
// [_instantiatedTypes] sets should be merged.
- final Set<ClassElement> _directlyInstantiatedClasses =
- new Set<ClassElement>();
+ final Map<ClassElement, EnumSet<Instantiation>> _directlyInstantiatedClasses =
+ <ClassElement, EnumSet<Instantiation>>{};
/// The set of all directly instantiated types, that is, the types of the
/// directly instantiated classes.
@@ -237,7 +243,7 @@ class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
/// super-call.
// TODO(johnniwinther): Improve semantic precision.
Iterable<ClassElement> get directlyInstantiatedClasses {
- return _directlyInstantiatedClasses;
+ return _directlyInstantiatedClasses.keys;
}
/// All directly instantiated types, that is, the types of the directly
@@ -280,7 +286,13 @@ class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
// TODO(herhut): Track classes required by mirrors seperately.
||
byMirrors) {
- _directlyInstantiatedClasses.add(cls);
+ EnumSet<Instantiation> instantiations = _directlyInstantiatedClasses
+ .putIfAbsent(cls, () => new EnumSet<Instantiation>());
+ if (isNative || byMirrors) {
+ instantiations.add(Instantiation.ABSTRACTLY_INSTANTIATED);
+ } else {
+ instantiations.add(Instantiation.DIRECTLY_INSTANTIATED);
+ }
}
// TODO(johnniwinther): Replace this by separate more specific mappings that
@@ -295,6 +307,12 @@ class ResolutionWorldBuilderImpl implements ResolutionWorldBuilder {
}
}
+ @override
+ void forEachInstantiatedClass(
+ f(ClassElement cls, EnumSet<Instantiation> instantiations)) {
+ _directlyInstantiatedClasses.forEach(f);
+ }
+
bool _hasMatchingSelector(Map<Selector, SelectorConstraints> selectors,
Element member, OpenWorld world) {
if (selectors == null) return false;
« no previous file with comments | « pkg/compiler/lib/src/universe/class_set.dart ('k') | pkg/compiler/lib/src/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698