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

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

Issue 2846433003: Run closed_world2_test using the normal compiler pipeline. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
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/tasks.dart' show CompilerTask; 7 import 'common/tasks.dart' show CompilerTask;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart' show ConstantExpression; 10 import 'constants/expressions.dart' show ConstantExpression;
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 hunksToLoad[importDeferName[import]] = new List<OutputUnit>(); 654 hunksToLoad[importDeferName[import]] = new List<OutputUnit>();
655 for (OutputUnit outputUnit in sortedOutputUnits) { 655 for (OutputUnit outputUnit in sortedOutputUnits) {
656 if (outputUnit == mainOutputUnit) continue; 656 if (outputUnit == mainOutputUnit) continue;
657 if (outputUnit.imports.contains(import)) { 657 if (outputUnit.imports.contains(import)) {
658 hunksToLoad[importDeferName[import]].add(outputUnit); 658 hunksToLoad[importDeferName[import]].add(outputUnit);
659 } 659 }
660 } 660 }
661 } 661 }
662 } 662 }
663 663
664 void onResolutionComplete(FunctionElement main) { 664 void onResolutionComplete(MethodElement main) {
665 if (!isProgramSplit) { 665 if (!isProgramSplit) {
666 allOutputUnits.add(mainOutputUnit); 666 allOutputUnits.add(mainOutputUnit);
667 return; 667 return;
668 } 668 }
669 if (main == null) return; 669 if (main == null) return;
670 LibraryElement mainLibrary = main.library; 670 LibraryElement mainLibrary = main.library;
671 _importedDeferredBy = new Map<_DeferredImport, Set<Element>>(); 671 _importedDeferredBy = new Map<_DeferredImport, Set<Element>>();
672 _constantsDeferredBy = new Map<_DeferredImport, Set<ConstantValue>>(); 672 _constantsDeferredBy = new Map<_DeferredImport, Set<ConstantValue>>();
673 _importedDeferredBy[_fakeMainImport] = _mainElements; 673 _importedDeferredBy[_fakeMainImport] = _mainElements;
674 674
675 reporter.withCurrentElement( 675 reporter.withCurrentElement(
676 mainLibrary, 676 mainLibrary,
677 () => measure(() { 677 () => measure(() {
678 // Starting from main, traverse the program and find all 678 // Starting from main, traverse the program and find all
679 // dependencies. 679 // dependencies.
680 _mapDependencies( 680 _mapDependencies(element: main, import: _fakeMainImport);
681 element: compiler.mainFunction, import: _fakeMainImport);
682 681
683 // Also add "global" dependencies to the main OutputUnit. These 682 // Also add "global" dependencies to the main OutputUnit. These
684 // are things that the backend needs but cannot associate with a 683 // are things that the backend needs but cannot associate with a
685 // particular element, for example, startRootIsolate. This set 684 // particular element, for example, startRootIsolate. This set
686 // also contains elements for which we lack precise information. 685 // also contains elements for which we lack precise information.
687 for (MethodElement element 686 for (MethodElement element
688 in _backendUsage.globalFunctionDependencies) { 687 in _backendUsage.globalFunctionDependencies) {
689 _mapDependencies( 688 _mapDependencies(
690 element: element.implementation, import: _fakeMainImport); 689 element: element.implementation, import: _fakeMainImport);
691 } 690 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // Generate a unique name for each OutputUnit. 763 // Generate a unique name for each OutputUnit.
765 _assignNamesToOutputUnits(allOutputUnits); 764 _assignNamesToOutputUnits(allOutputUnits);
766 })); 765 }));
767 // Notify the impact strategy impacts are no longer needed for deferred 766 // Notify the impact strategy impacts are no longer needed for deferred
768 // load. 767 // load.
769 compiler.impactStrategy.onImpactUsed(IMPACT_USE); 768 compiler.impactStrategy.onImpactUsed(IMPACT_USE);
770 } 769 }
771 770
772 void beforeResolution(Compiler compiler) { 771 void beforeResolution(Compiler compiler) {
773 if (compiler.mainApp == null) return; 772 if (compiler.mainApp == null) return;
773 // TODO(johnniwinther): Support deferred load for kernel based elements.
774 if (compiler.mainApp is! LibraryElement) return;
Siggi Cherem (dart-lang) 2017/04/26 16:39:18 to make this easier to read, I'd switch this to:
Johnni Winther 2017/04/27 06:50:14 Done.
774 _allDeferredImports[_fakeMainImport] = compiler.mainApp; 775 _allDeferredImports[_fakeMainImport] = compiler.mainApp;
775 var lastDeferred; 776 var lastDeferred;
776 // When detecting duplicate prefixes of deferred libraries there are 4 777 // When detecting duplicate prefixes of deferred libraries there are 4
777 // cases of duplicate prefixes: 778 // cases of duplicate prefixes:
778 // 1. 779 // 1.
779 // import "lib.dart" deferred as a; 780 // import "lib.dart" deferred as a;
780 // import "lib2.dart" deferred as a; 781 // import "lib2.dart" deferred as a;
781 // 2. 782 // 2.
782 // import "lib.dart" deferred as a; 783 // import "lib.dart" deferred as a;
783 // import "lib2.dart" as a; 784 // import "lib2.dart" as a;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1075
1075 bool operator ==(other) { 1076 bool operator ==(other) {
1076 if (other is! _DeclaredDeferredImport) return false; 1077 if (other is! _DeclaredDeferredImport) return false;
1077 return declaration == other.declaration; 1078 return declaration == other.declaration;
1078 } 1079 }
1079 1080
1080 int get hashCode => declaration.hashCode * 17; 1081 int get hashCode => declaration.hashCode * 17;
1081 1082
1082 String toString() => '$declaration'; 1083 String toString() => '$declaration';
1083 } 1084 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698