Load jit compiler pre zygote fork
Reduces PSS for libart-compiler.so from 115KB to 2KB per app.
Also some clean-up.
Bug: 27810774
(cherry picked from commit ff2376770c1c6d301778c41e5c27c808a38e6968)
Change-Id: Ic0077a07c21ed9f1952a6c29863a5c0e5bacc01a
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 96f41b3..a9ff088 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -567,10 +567,16 @@
}
}
- // 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.
- if (!IsZygote() && jit_options_->UseJIT()) {
- CreateJit();
+ if (jit_options_->UseJIT()) {
+ std::string error_msg;
+ 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.
+ CreateJit();
+ } else if (!jit::Jit::LoadCompiler(&error_msg)) {
+ // Try to load compiler pre zygote to reduce PSS. b/27744947
+ LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
+ }
}
if (!IsImageDex2OatEnabled() || !GetHeap()->HasBootImageSpace()) {