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

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: remove unused method and add todo 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..bda270404ffddc75782cdfca2ddf8a5f7ca3c52f 100644
--- a/lib/src/mirror_loader.dart
+++ b/lib/src/mirror_loader.dart
@@ -37,32 +37,44 @@ 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
+ // they were seen.
+ // TODO(jakemac): This is an approximation of what we actually want.
+ // https://github.com/dart-lang/initialize/issues/25
+ 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;
}
+
/// 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