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

Unified Diff: pkg/compiler/lib/src/enqueue.dart

Issue 1146813009: Introduce WorldImpact (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 7 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/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/enqueue.dart
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index ebbef36b1c274fbd11fd75ff30c385e0561d199e..d94476ad811bc5ebfc916a6af345aeb42eadbcc7 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -32,6 +32,27 @@ class EnqueueTask extends CompilerTask {
}
}
+class WorldImpact {
+ const WorldImpact();
+
+ Iterable<Selector> get dynamicInvocations => const <Selector>[];
+ Iterable<Selector> get dynamicGetters => const <Selector>[];
+ Iterable<Selector> get dynamicSetters => const <Selector>[];
+
+ // TODO(johnniwinther): Split this into more precise subsets.
+ Iterable<Element> get staticUses => const <Element>[];
+
+ // TODO(johnniwinther): Replace this by called constructors with type
+ // arguments.
+ Iterable<InterfaceType> get instantiatedTypes => const <InterfaceType>[];
+
+ // TODO(johnniwinther): Collect checked types for checked mode separately to
+ // support serialization.
+ Iterable<DartType> get checkedTypes => const <DartType>[];
+
+ Iterable<MethodElement> get closurizedFunctions => const <MethodElement>[];
+}
+
abstract class Enqueuer {
final String name;
final Compiler compiler; // TODO(ahe): Remove this dependency.
@@ -84,6 +105,20 @@ abstract class Enqueuer {
*/
bool internalAddToWorkList(Element element);
+ /// Apply the [worldImpact] of processing [element] to this enqueuer.
+ void applyImpact(Element element, WorldImpact worldImpact) {
+ // TODO(johnniwinther): Optimize the application of the world impact.
+ worldImpact.dynamicInvocations.forEach(registerDynamicInvocation);
+ worldImpact.dynamicGetters.forEach(registerDynamicGetter);
+ worldImpact.dynamicSetters.forEach(registerDynamicSetter);
+ worldImpact.staticUses.forEach(registerStaticUse);
+ // TODO(johnniwinther): Register [worldImpact.instantiatedTypes] when it
+ // doesn't require a [Registry].
+ worldImpact.checkedTypes.forEach(registerIsCheck);
+ worldImpact.closurizedFunctions.forEach(registerGetOfStaticFunction);
+ }
+
+ // TODO(johnniwinther): Remove the need for passing the [registry].
void registerInstantiatedType(InterfaceType type, Registry registry,
{bool mirrorUsage: false}) {
task.measure(() {
@@ -96,12 +131,6 @@ abstract class Enqueuer {
});
}
- void registerInstantiatedClass(ClassElement cls, Registry registry,
- {bool mirrorUsage: false}) {
- cls.ensureResolved(compiler);
- registerInstantiatedType(cls.rawType, registry, mirrorUsage: mirrorUsage);
- }
-
bool checkNoEnqueuedInvokedInstanceMethods() {
return filter.checkNoEnqueuedInvokedInstanceMethods(this);
}
@@ -350,7 +379,8 @@ abstract class Enqueuer {
if (includeClass) {
logEnqueueReflectiveAction(cls, "register");
ClassElement decl = cls.declaration;
- registerInstantiatedClass(decl, compiler.mirrorDependencies,
+ decl.ensureResolved(compiler);
+ registerInstantiatedType(decl.rawType, compiler.mirrorDependencies,
mirrorUsage: true);
}
// If the class is never instantiated, we know nothing of it can possibly
@@ -380,7 +410,8 @@ abstract class Enqueuer {
for (ClassElement cls in classes) {
if (compiler.backend.referencedFromMirrorSystem(cls)) {
logEnqueueReflectiveAction(cls);
- registerInstantiatedClass(cls, compiler.mirrorDependencies,
+ cls.ensureResolved(compiler);
+ registerInstantiatedType(cls.rawType, compiler.mirrorDependencies,
mirrorUsage: true);
}
}
@@ -564,7 +595,7 @@ abstract class Enqueuer {
universe.fieldSetters.add(element);
}
- void registerIsCheck(DartType type, Registry registry) {
+ void registerIsCheck(DartType type) {
type = universe.registerIsCheck(type, compiler);
// Even in checked mode, type annotations for return type and argument
// types do not imply type checks, so there should never be a check
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698