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

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

Issue 1911453002: Add LibraryLoader.resetLibraries (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with 74144aece4b9c6eb9c63ea1de26423b53d1f7286 Created 4 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698