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

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

Issue 1245583002: Deferred loading track type-dependencies for is, as and type-annotations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/deferred_load.dart
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index e261ff6d8f6fe51df293d7fbe5f2f41524584439..3ae1bae52e7094fa72a9620929864ec4de9a14c8 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -252,6 +252,30 @@ class DeferredLoadTask extends CompilerTask {
Set<ConstantValue> constants,
isMirrorUsage) {
+ /// Recursively collects all the dependencies of [type].
+ void collectTypeDependencies(DartType type) {
+ if (type is GenericType) {
+ type.typeArguments.forEach(collectTypeDependencies);
+ }
+ if (type is FunctionType) {
+ for (DartType argumentType in type.parameterTypes) {
+ collectTypeDependencies(argumentType);
+ }
+ for (DartType argumentType in type.optionalParameterTypes) {
+ collectTypeDependencies(argumentType);
+ }
+ for (DartType argumentType in type.namedParameterTypes) {
+ collectTypeDependencies(argumentType);
+ }
+ collectTypeDependencies(type.returnType);
+ } else if (type is TypedefType) {
+ elements.add(type.element);
+ collectTypeDependencies(type.unalias(compiler));
+ } else if (type is InterfaceType) {
+ elements.add(type.element);
+ }
+ }
+
/// Collects all direct dependencies of [element].
///
/// The collected dependent elements and constants are are added to
@@ -281,22 +305,10 @@ class DeferredLoadTask extends CompilerTask {
elements.add(dependency);
}
- void registerTypeArgumentsAsDependencies(DartType type) {
- Element dependency = type.element;
- if (dependency == null || dependency.isErroneous ||
- dependency.isTypeVariable) {
- return;
- }
- elements.add(dependency);
- if (type is GenericType) {
- type.typeArguments.forEach(registerTypeArgumentsAsDependencies);
- }
+ for (DartType type in treeElements.requiredTypes) {
+ collectTypeDependencies(type);
}
- treeElements.forEachType((Node node, DartType type) {
- if (node is NewExpression) registerTypeArgumentsAsDependencies(type);
- });
-
treeElements.forEachConstantNode((Node node, _) {
// Explicitly depend on the backend constants.
ConstantValue value =
@@ -319,34 +331,11 @@ class DeferredLoadTask extends CompilerTask {
}
}
- collectTypeDependencies(DartType type) {
- if (type is FunctionType) {
- for (DartType argumentType in type.parameterTypes) {
- collectTypeDependencies(argumentType);
- }
- for (DartType argumentType in type.optionalParameterTypes) {
- collectTypeDependencies(argumentType);
- }
- for (DartType argumentType in type.namedParameterTypes) {
- collectTypeDependencies(argumentType);
- }
- collectTypeDependencies(type.returnType);
- } else if (type is TypedefType) {
- elements.add(type.element);
- collectTypeDependencies(type.unalias(compiler));
- } else if (type is InterfaceType) {
- elements.add(type.element);
- }
- }
-
if (element is FunctionElement &&
compiler.resolverWorld.closurizedMembers.contains(element)) {
collectTypeDependencies(element.type);
}
- // TODO(sigurdm): Also collect types that are used in is checks and for
- // checked mode.
-
if (element.isClass) {
// If we see a class, add everything its live instance members refer
// to. Static members are not relevant, unless we are processing
« no previous file with comments | « no previous file | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698