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

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: Address Johnni's comment Created 4 years, 11 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 01a3592213af4cb9254f1dc7fe8ed25a33021f0f..a4a13c59aa2be5a29c6cb8aa5ba30c6df25ca718 100644
--- a/pkg/compiler/lib/src/library_loader.dart
+++ b/pkg/compiler/lib/src/library_loader.dart
@@ -37,6 +37,9 @@ 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.
*
@@ -157,6 +160,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.
@@ -326,12 +333,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