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

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

Issue 1454383002: Add LibraryLoader.resetLibraries (Closed) Base URL: git@github.com:dart-lang/sdk.git@_temporary_fletch_patches
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 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 9919cee4c203dbe5fd6988af572494e34bfd513b..7c3c701942381e7c6b12bcdfe1f1703891f7793c 100644
--- a/pkg/compiler/lib/src/library_loader.dart
+++ b/pkg/compiler/lib/src/library_loader.dart
@@ -155,6 +155,13 @@ 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(
+ Future<Iterable<LibraryElement>> reuseLibraries(
Johnni Winther 2015/11/19 10:04:31 Maybe typedef this to make it more readable.
ahe 2015/11/19 11:20:56 I find typedefs less readable, but if you prefer a
Johnni Winther 2015/11/19 11:25:37 In this case where the signature is too long, I do
ahe 2015/11/19 11:33:13 OK. Calling it *Function helps a bit.
ahe 2016/01/08 10:25:23 Done.
+ Iterable<LibraryElement> libraries));
+
}
/// Handle for creating synthesized/patch libraries during library loading.
@@ -324,12 +331,32 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
() => libraryCanonicalUriMap.values.map(wrapper).toList());
return Future.wait(reusedLibrariesFuture).then(
- (List<LibraryElement> reusedLibraries) {
+ (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.diagnoseCrashInUserCode(
+ '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