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

Unified Diff: runtime/vm/precompiler.cc

Issue 2100533002: Last reference to a library may be through a top-level type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: const Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.cc
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index bb6175f6f36f0ea2ea482ffa19a4c93b92a82fb8..9f8b2a3f48d4a2da4b7a3bf26d69b15d5bdf1d16 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -1720,12 +1720,26 @@ void Precompiler::DropLibraries() {
it.GetNext();
entries++;
}
- // The root library might have no surviving members if it only exports main
- // from another library. It will still be referenced from the object store,
- // so retain it.
- bool retain = (entries > 0) ||
- lib.is_dart_scheme() ||
- (lib.raw() == root_lib.raw());
+ bool retain = false;
+ if (entries > 0) {
+ retain = true;
+ } else if (lib.is_dart_scheme()) {
+ // The core libraries are referenced from the object store.
+ retain = true;
+ } else if (lib.raw() == root_lib.raw()) {
+ // The root library might have no surviving members if it only exports
+ // main from another library. It will still be referenced from the object
+ // store, so retain it.
+ retain = true;
+ } else {
+ // A type for a top-level class may be referenced from an object pool as
+ // part of an error message.
+ const Class& top = Class::Handle(Z, lib.toplevel_class());
+ if (classes_to_retain_.Lookup(&top) != NULL) {
+ retain = true;
+ }
+ }
+
if (retain) {
lib.set_index(retained_libraries.Length());
retained_libraries.Add(lib);
« 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