Fix race between post fork initialization and JIT.
Only start JIT threads after all zygote fork logic has been setup.
For robustness, also set the runtime state as the first thing post fork.
Test: m
Change-Id: Icf5db341275002599d0e89add4d9f6b2f799004d
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 52c0e9d..ad60546 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -1128,18 +1128,11 @@
code_cache_->SetGarbageCollectCode(!jit_compiler_->GenerateDebugInfo() &&
!Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled());
- if (thread_pool_ != nullptr) {
- if (is_system_server &&
- Runtime::Current()->IsUsingApexBootImageLocation() &&
- UseJitCompilation()) {
- // Disable garbage collection: we don't want it to delete methods we're compiling
- // through boot and system server profiles.
- // TODO(ngeoffray): Fix this so we still collect deoptimized and unused code.
- code_cache_->SetGarbageCollectCode(false);
- }
-
- // Resume JIT compilation.
- thread_pool_->CreateThreads();
+ if (is_system_server && Runtime::Current()->IsUsingApexBootImageLocation()) {
+ // Disable garbage collection: we don't want it to delete methods we're compiling
+ // through boot and system server profiles.
+ // TODO(ngeoffray): Fix this so we still collect deoptimized and unused code.
+ code_cache_->SetGarbageCollectCode(false);
}
}