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

Unified Diff: runtime/vm/precompiler.cc

Issue 1904623002: Precompilation: The root library may have no survivors if it just re-exports main. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 f080f4d95f40c604333e0e24290050cb86191ae9..0bb66695f31193e5d1a3aa19f8339f1f2eaf3d4c 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -1638,6 +1638,7 @@ void Precompiler::DropClasses() {
void Precompiler::DropLibraries() {
const GrowableObjectArray& retained_libraries =
GrowableObjectArray::Handle(Z, GrowableObjectArray::New());
+ Library& root_lib = Library::Handle(Z, I->object_store()->root_library());
Library& lib = Library::Handle(Z);
for (intptr_t i = 0; i < libraries_.Length(); i++) {
@@ -1649,7 +1650,12 @@ void Precompiler::DropLibraries() {
it.GetNext();
entries++;
}
- bool retain = (entries > 0) || lib.is_dart_scheme();
+ // 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());
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