@@ -672,24 +672,6 @@ bool Runtime::Start() {
672672
673673 started_ = true ;
674674
675- // Create the JIT either if we have to use JIT compilation or save profiling info.
676- // TODO(calin): We use the JIT class as a proxy for JIT compilation and for
677- // recoding profiles. Maybe we should consider changing the name to be more clear it's
678- // not only about compiling. b/28295073.
679- if (jit_options_->UseJitCompilation () || jit_options_->GetSaveProfilingInfo ()) {
680- std::string error_msg;
681- if (!IsZygote ()) {
682- // If we are the zygote then we need to wait until after forking to create the code cache
683- // due to SELinux restrictions on r/w/x memory regions.
684- CreateJit ();
685- } else if (jit_options_->UseJitCompilation ()) {
686- if (!jit::Jit::LoadCompilerLibrary (&error_msg)) {
687- // Try to load compiler pre zygote to reduce PSS. b/27744947
688- LOG (WARNING) << " Failed to load JIT compiler with error " << error_msg;
689- }
690- }
691- }
692-
693675 if (!IsImageDex2OatEnabled () || !GetHeap ()->HasBootImageSpace ()) {
694676 ScopedObjectAccess soa (self);
695677 StackHandleScope<2 > hs (soa.Self ());
@@ -714,6 +696,27 @@ bool Runtime::Start() {
714696
715697 Thread::FinishStartup ();
716698
699+ // Create the JIT either if we have to use JIT compilation or save profiling info. This is
700+ // done after FinishStartup as the JIT pool needs Java thread peers, which require the main
701+ // ThreadGroup to exist.
702+ //
703+ // TODO(calin): We use the JIT class as a proxy for JIT compilation and for
704+ // recoding profiles. Maybe we should consider changing the name to be more clear it's
705+ // not only about compiling. b/28295073.
706+ if (jit_options_->UseJitCompilation () || jit_options_->GetSaveProfilingInfo ()) {
707+ std::string error_msg;
708+ if (!IsZygote ()) {
709+ // If we are the zygote then we need to wait until after forking to create the code cache
710+ // due to SELinux restrictions on r/w/x memory regions.
711+ CreateJit ();
712+ } else if (jit_options_->UseJitCompilation ()) {
713+ if (!jit::Jit::LoadCompilerLibrary (&error_msg)) {
714+ // Try to load compiler pre zygote to reduce PSS. b/27744947
715+ LOG (WARNING) << " Failed to load JIT compiler with error " << error_msg;
716+ }
717+ }
718+ }
719+
717720 // Send the start phase event. We have to wait till here as this is when the main thread peer
718721 // has just been generated, important root clinits have been run and JNI is completely functional.
719722 {
0 commit comments