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

Unified Diff: lib/src/mirror_loader.dart

Issue 977943005: update mirror-based crawling to only run from relative path libraries that are unreachable by the m… (Closed) Base URL: git@github.com:dart-lang/static-init.git@master
Patch Set: only crawl relative libraries in dartium Created 5 years, 10 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 | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/mirror_loader.dart
diff --git a/lib/src/mirror_loader.dart b/lib/src/mirror_loader.dart
index e73f0cc419c545fdd368e2682abe2b26d317de0f..4150b7445beec1dbb334e0c0fa24d46dd41cc4ba 100644
--- a/lib/src/mirror_loader.dart
+++ b/lib/src/mirror_loader.dart
@@ -37,32 +37,58 @@ class InitializationCrawler {
Queue<Function> run() {
var librariesSeen = new Set<LibraryMirror>();
var queue = new Queue<Function>();
-
var libraries = currentMirrorSystem().libraries;
- var nonDartOrPackageImports = new List.from(libraries.keys.where(
- (uri) => uri.scheme != 'package' && uri.scheme != 'dart'));
-
- for (var import in nonDartOrPackageImports.reversed) {
- // Always load the package: version of a library if available.
- var libToRun;
- if (_isHttpStylePackageUrl(import)) {
- var packageUri = _packageUriFor(import);
- libToRun = libraries[packageUri];
- }
- if (libToRun == null) libToRun = libraries[import];
- // Dartium creates an extra trampoline lib that loads the main dart script
- // and breaks our ordering.
- if (librariesSeen.contains(libToRun) ||
- libToRun.uri.path.endsWith('\$trampoline')) {
- continue;
+ var trampolineUri = Uri.parse('${_root.uri}\$trampoline');
+ if (libraries.containsKey(trampolineUri)) {
+ // In dartium, process all relative libraries in reverse order of when
Siggi Cherem (dart-lang) 2015/03/04 22:12:25 let's add the TODO here saying that this logic sho
jakemac 2015/03/06 19:06:39 Done.
+ // they were seen.
+ var relativeLibraryUris = new List.from(libraries.keys.where(
+ (uri) => uri.scheme != 'package' && uri.scheme != 'dart'));
+
+ for (var import in relativeLibraryUris.reversed) {
+ // Always load the package: version of a library if available for
+ // canonicalization purposes.
+ var libToRun;
+ if (_isHttpStylePackageUrl(import)) {
+ var packageUri = _packageUriFor(import);
+ libToRun = libraries[packageUri];
+ }
+ if (libToRun == null) libToRun = libraries[import];
+
+ // Dartium creates an extra trampoline lib that loads the main dart script
+ // and breaks our ordering, we should skip it.
+ if (librariesSeen.contains(libToRun) ||
+ libToRun.uri.path.endsWith('\$trampoline')) {
+ continue;
+ }
+ _readLibraryDeclarations(libToRun, librariesSeen, queue);
}
- _readLibraryDeclarations(libToRun, librariesSeen, queue);
+ } else {
+ // Not in dartium, just process from the root library.
+ _readLibraryDeclarations(_root, librariesSeen, queue);
}
return queue;
}
+ // Crawls all imports that are not dart: or package: urls from a given [root]
+ // and return them as a [Set]
+ Set<LibraryMirror> _visibleRelativeLibraries(
Siggi Cherem (dart-lang) 2015/03/04 22:12:25 we can delete this now I think
jakemac 2015/03/06 19:06:39 Done.
+ LibraryMirror root, [Set<LibraryMirror> libraries]) {
+ if (libraries == null) libraries = new Set<LibraryMirror>();
+ for (var import in root.libraryDependencies) {
+ var library = import.targetLibrary;
+ var scheme = library.uri.scheme;
+ if (scheme == 'dart' || scheme == 'package') continue;
+ if (libraries.contains(library)) continue;
+ libraries.add(library);
+ _visibleRelativeLibraries(library, libraries);
+ }
+ return libraries;
+ }
+
+
/// Whether [uri] is an http URI that contains a 'packages' segment, and
/// therefore could be converted into a 'package:' URI.
bool _isHttpStylePackageUrl(Uri uri) {
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698