From d66c8621610dc18d324132c8e5b081520f719777 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 11 Dec 2015 14:59:16 +0000 Subject: [PATCH] Special case system_server to not create the JIT code cache. Change-Id: I34485c709b0c70b8d9c34bebcf399781aebaf11b --- runtime/native/dalvik_system_ZygoteHooks.cc | 16 +++++++++++----- runtime/runtime.cc | 6 ++++-- runtime/runtime.h | 3 ++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index ae1a4d782..67d825efa 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -129,7 +129,11 @@ static jlong ZygoteHooks_nativePreFork(JNIEnv* env, jclass) { return reinterpret_cast(ThreadForEnv(env)); } -static void ZygoteHooks_nativePostForkChild(JNIEnv* env, jclass, jlong token, jint debug_flags, +static void ZygoteHooks_nativePostForkChild(JNIEnv* env, + jclass, + jlong token, + jint debug_flags, + jboolean is_system_server, jstring instruction_set) { Thread* thread = reinterpret_cast(token); // Our system thread ID, etc, has changed so reset Thread state. @@ -174,22 +178,24 @@ static void ZygoteHooks_nativePostForkChild(JNIEnv* env, jclass, jlong token, ji } } - if (instruction_set != nullptr) { + if (instruction_set != nullptr && !is_system_server) { ScopedUtfChars isa_string(env, instruction_set); InstructionSet isa = GetInstructionSetFromString(isa_string.c_str()); Runtime::NativeBridgeAction action = Runtime::NativeBridgeAction::kUnload; if (isa != kNone && isa != kRuntimeISA) { action = Runtime::NativeBridgeAction::kInitialize; } - Runtime::Current()->InitNonZygoteOrPostFork(env, action, isa_string.c_str()); + Runtime::Current()->InitNonZygoteOrPostFork( + env, is_system_server, action, isa_string.c_str()); } else { - Runtime::Current()->InitNonZygoteOrPostFork(env, Runtime::NativeBridgeAction::kUnload, nullptr); + Runtime::Current()->InitNonZygoteOrPostFork( + env, is_system_server, Runtime::NativeBridgeAction::kUnload, nullptr); } } static JNINativeMethod gMethods[] = { NATIVE_METHOD(ZygoteHooks, nativePreFork, "()J"), - NATIVE_METHOD(ZygoteHooks, nativePostForkChild, "(JILjava/lang/String;)V"), + NATIVE_METHOD(ZygoteHooks, nativePostForkChild, "(JIZLjava/lang/String;)V"), }; void register_dalvik_system_ZygoteHooks(JNIEnv* env) { diff --git a/runtime/runtime.cc b/runtime/runtime.cc index ee703eca3..64cb366da 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -595,6 +595,7 @@ bool Runtime::Start() { PreInitializeNativeBridge("."); } InitNonZygoteOrPostFork(self->GetJniEnv(), + /* is_system_server */ false, NativeBridgeAction::kInitialize, GetInstructionSetString(kRuntimeISA)); } @@ -684,7 +685,8 @@ bool Runtime::InitZygote() { #endif } -void Runtime::InitNonZygoteOrPostFork(JNIEnv* env, NativeBridgeAction action, const char* isa) { +void Runtime::InitNonZygoteOrPostFork( + JNIEnv* env, bool is_system_server, NativeBridgeAction action, const char* isa) { is_zygote_ = false; if (is_native_bridge_loaded_) { @@ -706,7 +708,7 @@ void Runtime::InitNonZygoteOrPostFork(JNIEnv* env, NativeBridgeAction action, co // before fork aren't attributed to an app. heap_->ResetGcPerformanceInfo(); - if (!safe_mode_ && jit_options_->UseJIT() && jit_.get() == nullptr) { + if (!is_system_server && !safe_mode_ && jit_options_->UseJIT() && jit_.get() == nullptr) { // Note that when running ART standalone (not zygote, nor zygote fork), // the jit may have already been created. CreateJit(); diff --git a/runtime/runtime.h b/runtime/runtime.h index 93d8fcfa4..7ca6b4f13 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -457,7 +457,8 @@ class Runtime { void PreZygoteFork(); bool InitZygote(); - void InitNonZygoteOrPostFork(JNIEnv* env, NativeBridgeAction action, const char* isa); + void InitNonZygoteOrPostFork( + JNIEnv* env, bool is_system_server, NativeBridgeAction action, const char* isa); const instrumentation::Instrumentation* GetInstrumentation() const { return &instrumentation_; -- 2.11.0