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

Unified Diff: runtime/vm/parser.cc

Issue 328923002: Lazy loading of deferred libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 37317)
+++ runtime/vm/parser.cc (working copy)
@@ -5163,16 +5163,20 @@
// Canonicalize library URL.
const String& canon_url = String::CheckedHandle(
CallLibraryTagHandler(Dart_kCanonicalizeUrl, import_pos, url));
- // Lookup the library URL.
- Library& library = Library::Handle(isolate(),
- Library::LookupLibrary(canon_url));
+
+ // Create a new library if it does not exist yet.
+ Library& library =
+ Library::Handle(isolate(), Library::LookupLibrary(canon_url));
if (library.IsNull()) {
- // Create an empty library to mark that we have initiated loading of this
- // library.
library = Library::New(canon_url);
library.Register();
- // Call the library tag handler to load the library.
- // TODO(hausner): do not load eagerly if import is deferred.
+ }
+
+ // If loading hasn't been requested yet, and if this is not a deferred
+ // library import, call the library tag handler to request loading
+ // the library.
+ if (library.LoadNotStarted() && !is_deferred_import) {
+ library.SetLoadRequested();
CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url);
}
@@ -5209,7 +5213,8 @@
}
library_prefix.AddImport(ns);
} else {
- library_prefix = LibraryPrefix::New(prefix, ns, is_deferred_import);
+ library_prefix =
+ LibraryPrefix::New(prefix, ns, is_deferred_import, library_);
library_.AddObject(library_prefix, prefix);
}
}
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698