jitzygote: Special case system server to keep the JIT queue at fork.
am: 0d54cfb1a6
Change-Id: I3a026925fd05cb6820873f024859525de9cf3b3a
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index dd07545..3087ccc 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -937,7 +937,7 @@
}
}
-void Jit::PostForkChildAction(bool is_zygote) {
+void Jit::PostForkChildAction(bool is_system_server, bool is_zygote) {
if (is_zygote) {
// Remove potential tasks that have been inherited from the zygote. Child zygotes
// currently don't need the whole boot image compiled (ie webview_zygote).
@@ -959,8 +959,12 @@
!Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled());
if (thread_pool_ != nullptr) {
- // Remove potential tasks that have been inherited from the zygote.
- thread_pool_->RemoveAllTasks(Thread::Current());
+ if (!is_system_server) {
+ // Remove potential tasks that have been inherited from the zygote.
+ // We keep the queue for system server, as not having those methods compiled
+ // impacts app startup.
+ thread_pool_->RemoveAllTasks(Thread::Current());
+ }
// Resume JIT compilation.
thread_pool_->CreateThreads();
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index f48ad46..15cdacb 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -296,7 +296,7 @@
void Start();
// Transition to a child state.
- void PostForkChildAction(bool is_zygote);
+ void PostForkChildAction(bool is_system_server, bool is_zygote);
// Prepare for forking.
void PreZygoteFork();
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index ab30a10..77ec795 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -324,7 +324,7 @@
/* is_system_server= */ false, is_zygote);
}
// This must be called after EnableDebugFeatures.
- runtime->GetJit()->PostForkChildAction(is_zygote);
+ runtime->GetJit()->PostForkChildAction(is_system_server, is_zygote);
}
// Update tracing.
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 0031e14..a0b2f1e 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -373,7 +373,7 @@
// Mimic the transition behavior a zygote fork would have.
jit->PreZygoteFork();
jit->GetCodeCache()->PostForkChildAction(/*is_system_server=*/ false, /*is_zygote=*/ false);
- jit->PostForkChildAction(/*is_zygote=*/ false);
+ jit->PostForkChildAction(/*is_system_server=*/ false, /*is_zygote=*/ false);
}
extern "C" JNIEXPORT void JNICALL Java_Main_deoptimizeBootImage(JNIEnv*, jclass) {