OSDN Git Service

Only call jit_load after the zygote fork
authorMathieu Chartier <mathieuc@google.com>
Fri, 25 Mar 2016 00:22:52 +0000 (17:22 -0700)
committerMathieu Chartier <mathieuc@google.com>
Fri, 25 Mar 2016 00:22:52 +0000 (17:22 -0700)
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
Change-Id: I9854716902c79e16bdfd64754cc1ed05e852a5de

runtime/jit/jit.cc
runtime/jit/jit.h
runtime/runtime.cc

index 70d47ef..91f485e 100644 (file)
@@ -134,7 +134,7 @@ Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
   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) {
@@ -170,6 +170,13 @@ bool Jit::LoadCompiler(std::string* error_msg) {
     *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();
index 8786828..2f851a8 100644 (file)
@@ -110,11 +110,13 @@ class Jit {
                                         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_;
index b78a3d4..d493d4c 100644 (file)
@@ -573,7 +573,7 @@ bool Runtime::Start() {
     // 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;
     }