Only call jit_load after the zygote fork
Otherwise we always get that enable_debug_features is false since
that flag passed as a compiler option post zygote fork.
No significant change to libart-compiler PSS on calculator.
Bug: 27810774
(cherry picked from commit b10cef442594dd0d6c5f1a5784643931a25cc431)
Change-Id: Ie50668ba05ad07a5cf046497959f6d27e09f8fe2
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index bfe8d9a..6496afd 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -129,7 +129,7 @@
return jit.release();
}
-bool Jit::LoadCompiler(std::string* error_msg) {
+bool Jit::LoadCompilerLibrary(std::string* error_msg) {
jit_library_handle_ = dlopen(
kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW);
if (jit_library_handle_ == nullptr) {
@@ -165,6 +165,13 @@
*error_msg = "JIT couldn't find jit_types_loaded entry point";
return false;
}
+ return true;
+}
+
+bool Jit::LoadCompiler(std::string* error_msg) {
+ if (jit_library_handle_ == nullptr && !LoadCompilerLibrary(error_msg)) {
+ return false;
+ }
bool will_generate_debug_symbols = false;
VLOG(jit) << "Calling JitLoad interpreter_only="
<< Runtime::Current()->GetInstrumentation()->InterpretOnly();
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index b98c6d3..76f540d 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -112,11 +112,13 @@
JValue* result)
SHARED_REQUIRES(Locks::mutator_lock_);
- static bool LoadCompiler(std::string* error_msg);
+ static bool LoadCompilerLibrary(std::string* error_msg);
private:
Jit();
+ static bool LoadCompiler(std::string* error_msg);
+
// JIT compiler
static void* jit_library_handle_;
static void* jit_compiler_handle_;
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index a9ff088..8a38f3a 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -573,7 +573,7 @@
// If we are the zygote then we need to wait until after forking to create the code cache
// due to SELinux restrictions on r/w/x memory regions.
CreateJit();
- } else if (!jit::Jit::LoadCompiler(&error_msg)) {
+ } else if (!jit::Jit::LoadCompilerLibrary(&error_msg)) {
// Try to load compiler pre zygote to reduce PSS. b/27744947
LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
}