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

Side by Side Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 1467733002: Revert "Remove WorldImpact from caches when no longer needed." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 deferred_load; 5 library deferred_load;
6 6
7 import 'common.dart'; 7 import 'common.dart';
8 import 'common/backend_api.dart' show 8 import 'common/backend_api.dart' show
9 Backend; 9 Backend;
10 import 'common/tasks.dart' show 10 import 'common/tasks.dart' show
(...skipping 10 matching lines...) Expand all
21 AccessorElement, 21 AccessorElement,
22 AstElement, 22 AstElement,
23 ClassElement, 23 ClassElement,
24 Element, 24 Element,
25 ElementKind, 25 ElementKind,
26 Elements, 26 Elements,
27 ExportElement, 27 ExportElement,
28 FunctionElement, 28 FunctionElement,
29 ImportElement, 29 ImportElement,
30 LibraryElement, 30 LibraryElement,
31 LocalFunctionElement,
32 MetadataAnnotation, 31 MetadataAnnotation,
33 PrefixElement, 32 PrefixElement,
34 ScopeContainerElement, 33 ScopeContainerElement,
35 TypedefElement; 34 TypedefElement;
36 import 'js_backend/js_backend.dart' show 35 import 'js_backend/js_backend.dart' show
37 JavaScriptBackend; 36 JavaScriptBackend;
38 import 'resolution/resolution.dart' show 37 import 'resolution/resolution.dart' show
39 AnalyzableElementX; 38 AnalyzableElementX;
40 import 'resolution/tree_elements.dart' show 39 import 'resolution/tree_elements.dart' show
41 TreeElements; 40 TreeElements;
42 import 'tree/tree.dart' as ast; 41 import 'tree/tree.dart' as ast;
43 import 'tree/tree.dart' show 42 import 'tree/tree.dart' show
44 Import, 43 Import,
45 LibraryTag, 44 LibraryTag,
46 LibraryDependency, 45 LibraryDependency,
47 LiteralDartString, 46 LiteralDartString,
48 LiteralString, 47 LiteralString,
49 NewExpression, 48 NewExpression,
50 Node; 49 Node;
51 import 'universe/use.dart' show 50 import 'universe/use.dart' show
52 DynamicUse,
53 StaticUse, 51 StaticUse,
54 TypeUse, 52 TypeUse,
55 TypeUseKind; 53 TypeUseKind;
56 import 'universe/world_impact.dart' show 54 import 'universe/world_impact.dart' show
57 ImpactUseCase, 55 WorldImpact;
58 WorldImpact,
59 WorldImpactVisitorImpl;
60 import 'util/setlet.dart' show 56 import 'util/setlet.dart' show
61 Setlet; 57 Setlet;
62 import 'util/uri_extras.dart' as uri_extras; 58 import 'util/uri_extras.dart' as uri_extras;
63 import 'util/util.dart' show 59 import 'util/util.dart' show
64 Link, makeUnique; 60 Link, makeUnique;
65 61
66 /// A "hunk" of the program that will be loaded whenever one of its [imports] 62 /// A "hunk" of the program that will be loaded whenever one of its [imports]
67 /// are loaded. 63 /// are loaded.
68 /// 64 ///
69 /// Elements that are only used in one deferred import, is in an OutputUnit with 65 /// Elements that are only used in one deferred import, is in an OutputUnit with
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 /// The OutputUnit that will be loaded when the program starts. 115 /// The OutputUnit that will be loaded when the program starts.
120 final OutputUnit mainOutputUnit = new OutputUnit(isMainOutput: true); 116 final OutputUnit mainOutputUnit = new OutputUnit(isMainOutput: true);
121 117
122 /// A set containing (eventually) all output units that will result from the 118 /// A set containing (eventually) all output units that will result from the
123 /// program. 119 /// program.
124 final Set<OutputUnit> allOutputUnits = new Set<OutputUnit>(); 120 final Set<OutputUnit> allOutputUnits = new Set<OutputUnit>();
125 121
126 /// Will be `true` if the program contains deferred libraries. 122 /// Will be `true` if the program contains deferred libraries.
127 bool isProgramSplit = false; 123 bool isProgramSplit = false;
128 124
129 static const ImpactUseCase IMPACT_USE = const ImpactUseCase('Deferred load');
130
131 /// A mapping from the name of a defer import to all the output units it 125 /// A mapping from the name of a defer import to all the output units it
132 /// depends on in a list of lists to be loaded in the order they appear. 126 /// depends on in a list of lists to be loaded in the order they appear.
133 /// 127 ///
134 /// For example {"lib1": [[lib1_lib2_lib3], [lib1_lib2, lib1_lib3], 128 /// For example {"lib1": [[lib1_lib2_lib3], [lib1_lib2, lib1_lib3],
135 /// [lib1]]} would mean that in order to load "lib1" first the hunk 129 /// [lib1]]} would mean that in order to load "lib1" first the hunk
136 /// lib1_lib2_lib2 should be loaded, then the hunks lib1_lib2 and lib1_lib3 130 /// lib1_lib2_lib2 should be loaded, then the hunks lib1_lib2 and lib1_lib3
137 /// can be loaded in parallel. And finally lib1 can be loaded. 131 /// can be loaded in parallel. And finally lib1 can be loaded.
138 final Map<String, List<OutputUnit>> hunksToLoad = 132 final Map<String, List<OutputUnit>> hunksToLoad =
139 new Map<String, List<OutputUnit>>(); 133 new Map<String, List<OutputUnit>>();
140 134
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } else { 311 } else {
318 // TODO(sigurdm): We want to be more specific about this - need a better 312 // TODO(sigurdm): We want to be more specific about this - need a better
319 // way to query "liveness". 313 // way to query "liveness".
320 AstElement analyzableElement = element.analyzableElement.declaration; 314 AstElement analyzableElement = element.analyzableElement.declaration;
321 if (!compiler.enqueuer.resolution.hasBeenProcessed(analyzableElement)) { 315 if (!compiler.enqueuer.resolution.hasBeenProcessed(analyzableElement)) {
322 return; 316 return;
323 } 317 }
324 318
325 WorldImpact worldImpact = 319 WorldImpact worldImpact =
326 compiler.resolution.getWorldImpact(analyzableElement); 320 compiler.resolution.getWorldImpact(analyzableElement);
327 compiler.impactStrategy.visitImpact( 321 worldImpact.staticUses.forEach((StaticUse staticUse) {
328 analyzableElement, 322 elements.add(staticUse.element);
329 worldImpact, 323 });
330 new WorldImpactVisitorImpl( 324 for (TypeUse typeUse in worldImpact.typeUses) {
331 visitStaticUse: (StaticUse staticUse) { 325 DartType type = typeUse.type;
332 elements.add(staticUse.element); 326 switch (typeUse.kind) {
333 }, 327 case TypeUseKind.TYPE_LITERAL:
334 visitTypeUse: (TypeUse typeUse) { 328 if (type.isTypedef || type.isInterfaceType) {
335 DartType type = typeUse.type; 329 elements.add(type.element);
336 switch (typeUse.kind) { 330 }
337 case TypeUseKind.TYPE_LITERAL: 331 break;
338 if (type.isTypedef || type.isInterfaceType) { 332 case TypeUseKind.INSTANTIATION:
339 elements.add(type.element); 333 case TypeUseKind.IS_CHECK:
340 } 334 case TypeUseKind.AS_CAST:
341 break; 335 case TypeUseKind.CATCH_TYPE:
342 case TypeUseKind.INSTANTIATION: 336 collectTypeDependencies(type);
343 case TypeUseKind.IS_CHECK: 337 break;
344 case TypeUseKind.AS_CAST: 338 case TypeUseKind.CHECKED_MODE_CHECK:
345 case TypeUseKind.CATCH_TYPE: 339 if (compiler.enableTypeAssertions) {
346 collectTypeDependencies(type); 340 collectTypeDependencies(type);
347 break; 341 }
348 case TypeUseKind.CHECKED_MODE_CHECK: 342 break;
349 if (compiler.enableTypeAssertions) { 343 }
350 collectTypeDependencies(type); 344 }
351 }
352 break;
353 }
354 }),
355 IMPACT_USE);
356 345
357 TreeElements treeElements = analyzableElement.resolvedAst.elements; 346 TreeElements treeElements = analyzableElement.resolvedAst.elements;
358 assert(treeElements != null); 347 assert(treeElements != null);
359 348
360 treeElements.forEachConstantNode((Node node, _) { 349 treeElements.forEachConstantNode((Node node, _) {
361 // Explicitly depend on the backend constants. 350 // Explicitly depend on the backend constants.
362 ConstantValue value = 351 ConstantValue value =
363 backend.constants.getConstantValueForNode(node, treeElements); 352 backend.constants.getConstantValueForNode(node, treeElements);
364 if (value != null) { 353 if (value != null) {
365 // TODO(johnniwinther): Assert that all constants have values when 354 // TODO(johnniwinther): Assert that all constants have values when
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 return result; 998 return result;
1010 } 999 }
1011 1000
1012 bool operator ==(other) { 1001 bool operator ==(other) {
1013 if (other is! _DeclaredDeferredImport) return false; 1002 if (other is! _DeclaredDeferredImport) return false;
1014 return declaration == other.declaration; 1003 return declaration == other.declaration;
1015 } 1004 }
1016 1005
1017 int get hashCode => declaration.hashCode * 17; 1006 int get hashCode => declaration.hashCode * 17;
1018 } 1007 }
OLDNEW
« 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