ART: Fix JIT initialization
Ensure the JIT code cache is created before the JIT for
non-system-server processes.
Bug: 118833033
Bug: 119049908
Test: m test-art-host
Change-Id: I99d04d0d1ad335cffe0e68dc74c5bf40de5e1d35
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 34b84f5..f07bd58 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -791,10 +791,6 @@
std::string error_msg;
if (!jit::Jit::LoadCompiler(&error_msg)) {
LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
- } else if (!IsZygote()) {
- // 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.
- CreateJitCodeCache(/*rwx_memory_allowed=*/true);
}
}
@@ -900,6 +896,11 @@
}
if (jit_ == nullptr) {
+ // The system server's code cache was initialized specially. For other zygote forks or
+ // processes create it now.
+ if (!is_system_server) {
+ CreateJitCodeCache(/*rwx_memory_allowed=*/true);
+ }
// Note that when running ART standalone (not zygote, nor zygote fork),
// the jit may have already been created.
CreateJit();