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

Unified Diff: runtime/vm/precompiler.cc

Issue 2933603002: 1. Dynamic compute the main closure that needs to be run by the main isolate (Closed)
Patch Set: Remove redundant check. Created 3 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
« runtime/include/dart_api.h ('K') | « runtime/vm/precompiler.h ('k') | 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 8b2ab1340ec1ca5139725e1e01de19e739015812..e484f0a72028d096e1aff9979359cd6610e41329 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -346,6 +346,7 @@ Precompiler::Precompiler(Thread* thread)
isolate_(thread->isolate()),
jit_feedback_(NULL),
changed_(false),
+ retain_root_library_caches_(false),
function_count_(0),
class_count_(0),
selector_count_(0),
@@ -689,6 +690,20 @@ void Precompiler::AddRoots(Dart_QualifiedFunctionName embedder_entry_points[]) {
AddEntryPoints(vm_entry_points);
AddEntryPoints(embedder_entry_points);
+ const Library& lib = Library::Handle(I->object_store()->root_library());
+ const String& name = String::Handle(String::New("main"));
+ const Object& main_closure = Object::Handle(lib.GetFunctionClosure(name));
rmacnak 2017/06/15 01:48:54 Propagate if error
siva 2017/06/15 17:34:41 Done.
+ if (main_closure.IsClosure()) {
+ if (lib.LookupLocalFunction(name) == Function::null()) {
+ // Check whether the function is in exported namespace of library, in
+ // this case we have to retain the root library caches.
+ if (lib.LookupFunctionAllowPrivate(name) != Function::null() ||
+ lib.LookupReExport(name) != Object::null()) {
+ retain_root_library_caches_ = true;
+ }
+ }
+ AddConstObject(Closure::Cast(main_closure));
+ }
}
@@ -2028,7 +2043,10 @@ void Precompiler::DropLibraryEntries() {
dict.SetAt(j, Object::null_object());
}
lib.RehashDictionary(dict, used * 4 / 3 + 1);
- lib.DropDependenciesAndCaches();
+ if (!(retain_root_library_caches_ &&
+ (lib.raw() == I->object_store()->root_library()))) {
+ lib.DropDependenciesAndCaches();
+ }
}
}
« runtime/include/dart_api.h ('K') | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698