Move location of where we clear thread pool tasks post fork.
Bug: 119800099
Test: boot jitzygote, system server methods get JIT compiled.
Change-Id: Ieb66b36aefad7a570ebfdfa296a2713c20d36f22
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index a29201c..ffb0117 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1742,7 +1742,18 @@
}
void JitCodeCache::PostForkChildAction(bool is_system_server, bool is_zygote) {
- MutexLock mu(Thread::Current(), *Locks::jit_lock_);
+ Thread* self = Thread::Current();
+
+ // Remove potential tasks that have been inherited from the zygote.
+ // We do this now and not in Jit::PostForkChildAction, as system server calls
+ // JitCodeCache::PostForkChildAction first, and then does some code loading
+ // that may result in new JIT tasks that we want to keep.
+ ThreadPool* pool = Runtime::Current()->GetJit()->GetThreadPool();
+ if (pool != nullptr) {
+ pool->RemoveAllTasks(self);
+ }
+
+ MutexLock mu(self, *Locks::jit_lock_);
// Reset potential writable MemMaps inherited from the zygote. We never want
// to write to them.