| Index: pkg/compiler/lib/src/library_loader.dart
|
| diff --git a/pkg/compiler/lib/src/library_loader.dart b/pkg/compiler/lib/src/library_loader.dart
|
| index f4cd6796b907029185f8a5b48c994e0692a846d1..d555a732d7a55fbffbcd90aba79e7a4f43b8d3f1 100644
|
| --- a/pkg/compiler/lib/src/library_loader.dart
|
| +++ b/pkg/compiler/lib/src/library_loader.dart
|
| @@ -35,6 +35,9 @@ import 'serialization/serialization.dart' show LibraryDeserializer;
|
| import 'tree/tree.dart';
|
| import 'util/util.dart' show Link, LinkBuilder;
|
|
|
| +typedef Future<Iterable<LibraryElement>> ReuseLibrariesFunction(
|
| + Iterable<LibraryElement> libraries);
|
| +
|
| /**
|
| * [CompilerTask] for loading libraries and setting up the import/export scopes.
|
| *
|
| @@ -167,6 +170,10 @@ abstract class LibraryLoaderTask implements CompilerTask {
|
|
|
| /// Asynchronous version of [reset].
|
| Future resetAsync(Future<bool> reuseLibrary(LibraryElement library));
|
| +
|
| + /// Similar to [resetAsync] but [reuseLibrary] maps all libraries to a list
|
| + /// of libraries that can be reused.
|
| + Future<Null> resetLibraries(ReuseLibrariesFunction reuseLibraries);
|
| }
|
|
|
| /// Handle for creating synthesized/patch libraries during library loading.
|
| @@ -363,12 +370,32 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
|
|
|
| return Future
|
| .wait(reusedLibrariesFuture)
|
| - .then((List<LibraryElement> reusedLibraries) {
|
| + .then((Iterable<LibraryElement> reusedLibraries) {
|
| resetImplementation(reusedLibraries.where((e) => e != null));
|
| });
|
| });
|
| }
|
|
|
| + Future<Null> resetLibraries(
|
| + Future<Iterable<LibraryElement>> reuseLibraries(
|
| + Iterable<LibraryElement> libraries)) {
|
| + assert(currentHandler == null);
|
| + return compiler.reuseLibraryTask.measure(() {
|
| + return new Future<Iterable<LibraryElement>>(() {
|
| + // Wrap in Future to shield against errors in user code.
|
| + return reuseLibraries(libraryCanonicalUriMap.values);
|
| + }).catchError((exception, StackTrace trace) {
|
| + compiler.reportCrashInUserCode(
|
| + 'Uncaught exception in reuseLibraries', exception, trace);
|
| + throw exception; // Async rethrow.
|
| + }).then((Iterable<LibraryElement> reusedLibraries) {
|
| + measure(() {
|
| + resetImplementation(reusedLibraries);
|
| + });
|
| + });
|
| + });
|
| + }
|
| +
|
| /// Insert [library] in the internal maps. Used for compiler reuse.
|
| void mapLibrary(LibraryElement library) {
|
| libraryCanonicalUriMap[library.canonicalUri] = library;
|
|
|