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

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

Issue 1464773002: Remove WorldImpact from caches when no longer needed. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Make deferred uncaching global. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dump_info.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 78c0a37a05d5c7751b1355935c7dc62d2aafae28..c24ecbf03bfd9457151621d47de8cc60814d5b78 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -28,6 +28,7 @@ import 'elements/elements.dart' show
FunctionElement,
ImportElement,
LibraryElement,
+ LocalFunctionElement,
MetadataAnnotation,
PrefixElement,
ScopeContainerElement,
@@ -48,11 +49,14 @@ import 'tree/tree.dart' show
NewExpression,
Node;
import 'universe/use.dart' show
+ DynamicUse,
StaticUse,
TypeUse,
TypeUseKind;
import 'universe/world_impact.dart' show
- WorldImpact;
+ ImpactUseCase,
+ WorldImpact,
+ WorldImpactVisitorImpl;
import 'util/setlet.dart' show
Setlet;
import 'util/uri_extras.dart' as uri_extras;
@@ -122,6 +126,8 @@ class DeferredLoadTask extends CompilerTask {
/// Will be `true` if the program contains deferred libraries.
bool isProgramSplit = false;
+ static const ImpactUseCase IMPACT_USE = const ImpactUseCase('Deferred load');
+
/// A mapping from the name of a defer import to all the output units it
/// depends on in a list of lists to be loaded in the order they appear.
///
@@ -318,30 +324,35 @@ class DeferredLoadTask extends CompilerTask {
WorldImpact worldImpact =
compiler.resolution.getWorldImpact(analyzableElement);
- worldImpact.staticUses.forEach((StaticUse staticUse) {
- elements.add(staticUse.element);
- });
- for (TypeUse typeUse in worldImpact.typeUses) {
- DartType type = typeUse.type;
- switch (typeUse.kind) {
- case TypeUseKind.TYPE_LITERAL:
- if (type.isTypedef || type.isInterfaceType) {
- elements.add(type.element);
- }
- break;
- case TypeUseKind.INSTANTIATION:
- case TypeUseKind.IS_CHECK:
- case TypeUseKind.AS_CAST:
- case TypeUseKind.CATCH_TYPE:
- collectTypeDependencies(type);
- break;
- case TypeUseKind.CHECKED_MODE_CHECK:
- if (compiler.enableTypeAssertions) {
- collectTypeDependencies(type);
- }
- break;
- }
- }
+ compiler.impactStrategy.visitImpact(
+ analyzableElement,
+ worldImpact,
+ new WorldImpactVisitorImpl(
+ visitStaticUse: (StaticUse staticUse) {
+ elements.add(staticUse.element);
+ },
+ visitTypeUse: (TypeUse typeUse) {
+ DartType type = typeUse.type;
+ switch (typeUse.kind) {
+ case TypeUseKind.TYPE_LITERAL:
+ if (type.isTypedef || type.isInterfaceType) {
+ elements.add(type.element);
+ }
+ break;
+ case TypeUseKind.INSTANTIATION:
+ case TypeUseKind.IS_CHECK:
+ case TypeUseKind.AS_CAST:
+ case TypeUseKind.CATCH_TYPE:
+ collectTypeDependencies(type);
+ break;
+ case TypeUseKind.CHECKED_MODE_CHECK:
+ if (compiler.enableTypeAssertions) {
+ collectTypeDependencies(type);
+ }
+ break;
+ }
+ }),
+ IMPACT_USE);
TreeElements treeElements = analyzableElement.resolvedAst.elements;
assert(treeElements != null);
@@ -711,6 +722,9 @@ class DeferredLoadTask extends CompilerTask {
// Generate a unique name for each OutputUnit.
_assignNamesToOutputUnits(allOutputUnits);
});
+ // Notify the impact strategy impacts are no longer needed for deferred
+ // load.
+ compiler.impactStrategy.onImpactUsed(IMPACT_USE);
}
void beforeResolution(Compiler compiler) {
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698