Skip to content

Commit f9e3754

Browse files
committed
Revert "Revert "ART: Give JIT thread pool workers a peer""
This reverts commit 9dfb707. Accept a live Java thread for the JIT, and adjust the tests accordingly. (cherry picked from commit 4471e4f) Bug: 31684920 Test: m ART_TEST_JIT=true ART_TEST_INTERPRETER=true test-art-host Change-Id: I92cbae1eaae05711b9069335cf1a5f7eb58b9fd8
1 parent 2db6c40 commit f9e3754

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

runtime/jit/jit.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ Jit::Jit() : dump_info_on_shutdown_(false),
145145
memory_use_("Memory used for compilation", 16),
146146
lock_("JIT memory use lock"),
147147
use_jit_compilation_(true),
148-
save_profiling_info_(false) {}
148+
save_profiling_info_(false),
149+
hot_method_threshold_(0),
150+
warm_method_threshold_(0),
151+
osr_method_threshold_(0),
152+
priority_thread_weight_(0),
153+
invoke_transition_weight_(0) {}
149154

150155
Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
151156
DCHECK(options->UseJitCompilation() || options->GetSaveProfilingInfo());
@@ -280,7 +285,11 @@ bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
280285
void Jit::CreateThreadPool() {
281286
// There is a DCHECK in the 'AddSamples' method to ensure the tread pool
282287
// is not null when we instrument.
283-
thread_pool_.reset(new ThreadPool("Jit thread pool", 1));
288+
289+
// We need peers as we may report the JIT thread, e.g., in the debugger.
290+
constexpr bool kJitPoolNeedsPeers = true;
291+
thread_pool_.reset(new ThreadPool("Jit thread pool", 1, kJitPoolNeedsPeers));
292+
284293
thread_pool_->SetPthreadPriority(kJitPoolThreadPthreadPriority);
285294
thread_pool_->StartWorkers(Thread::Current());
286295
}

runtime/runtime.cc

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -583,24 +583,6 @@ bool Runtime::Start() {
583583

584584
started_ = true;
585585

586-
// Create the JIT either if we have to use JIT compilation or save profiling info.
587-
// TODO(calin): We use the JIT class as a proxy for JIT compilation and for
588-
// recoding profiles. Maybe we should consider changing the name to be more clear it's
589-
// not only about compiling. b/28295073.
590-
if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) {
591-
std::string error_msg;
592-
if (!IsZygote()) {
593-
// If we are the zygote then we need to wait until after forking to create the code cache
594-
// due to SELinux restrictions on r/w/x memory regions.
595-
CreateJit();
596-
} else if (jit_options_->UseJitCompilation()) {
597-
if (!jit::Jit::LoadCompilerLibrary(&error_msg)) {
598-
// Try to load compiler pre zygote to reduce PSS. b/27744947
599-
LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
600-
}
601-
}
602-
}
603-
604586
if (!IsImageDex2OatEnabled() || !GetHeap()->HasBootImageSpace()) {
605587
ScopedObjectAccess soa(self);
606588
StackHandleScope<2> hs(soa.Self());
@@ -625,6 +607,27 @@ bool Runtime::Start() {
625607

626608
Thread::FinishStartup();
627609

610+
// Create the JIT either if we have to use JIT compilation or save profiling info. This is
611+
// done after FinishStartup as the JIT pool needs Java thread peers, which require the main
612+
// ThreadGroup to exist.
613+
//
614+
// TODO(calin): We use the JIT class as a proxy for JIT compilation and for
615+
// recoding profiles. Maybe we should consider changing the name to be more clear it's
616+
// not only about compiling. b/28295073.
617+
if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) {
618+
std::string error_msg;
619+
if (!IsZygote()) {
620+
// If we are the zygote then we need to wait until after forking to create the code cache
621+
// due to SELinux restrictions on r/w/x memory regions.
622+
CreateJit();
623+
} else if (jit_options_->UseJitCompilation()) {
624+
if (!jit::Jit::LoadCompilerLibrary(&error_msg)) {
625+
// Try to load compiler pre zygote to reduce PSS. b/27744947
626+
LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
627+
}
628+
}
629+
}
630+
628631
system_class_loader_ = CreateSystemClassLoader(this);
629632

630633
if (is_zygote_) {

0 commit comments

Comments
 (0)