summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2017-01-30 16:40:49 +0000
committerAndreas Gampe <agampe@google.com>2017-02-09 12:09:03 -0800
commitf9e3754e8a2f6244e037362c03db32d4244ecb2d (patch)
tree0524f55012a7defa887c0676a2a1a3eabbe3681a
parent2db6c407e948941cead24e4fc0907716ffcd45a1 (diff)
downloadart-nougat-mr2.1-release.tar.gz
This reverts commit 9dfb707ba2f8c2ff67d42c26e3214f5d7142b6d3. Accept a live Java thread for the JIT, and adjust the tests accordingly. (cherry picked from commit 4471e4f7c5874bdaf93762b6047d4a4bebc465df) Bug: 31684920 Test: m ART_TEST_JIT=true ART_TEST_INTERPRETER=true test-art-host Change-Id: I92cbae1eaae05711b9069335cf1a5f7eb58b9fd8
-rw-r--r--runtime/jit/jit.cc13
-rw-r--r--runtime/runtime.cc39
2 files changed, 32 insertions, 20 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 74d99176c4..8cd867d0ba 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -145,7 +145,12 @@ Jit::Jit() : dump_info_on_shutdown_(false),
memory_use_("Memory used for compilation", 16),
lock_("JIT memory use lock"),
use_jit_compilation_(true),
- save_profiling_info_(false) {}
+ save_profiling_info_(false),
+ hot_method_threshold_(0),
+ warm_method_threshold_(0),
+ osr_method_threshold_(0),
+ priority_thread_weight_(0),
+ invoke_transition_weight_(0) {}
Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
DCHECK(options->UseJitCompilation() || options->GetSaveProfilingInfo());
@@ -280,7 +285,11 @@ bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
void Jit::CreateThreadPool() {
// There is a DCHECK in the 'AddSamples' method to ensure the tread pool
// is not null when we instrument.
- thread_pool_.reset(new ThreadPool("Jit thread pool", 1));
+
+ // We need peers as we may report the JIT thread, e.g., in the debugger.
+ constexpr bool kJitPoolNeedsPeers = true;
+ thread_pool_.reset(new ThreadPool("Jit thread pool", 1, kJitPoolNeedsPeers));
+
thread_pool_->SetPthreadPriority(kJitPoolThreadPthreadPriority);
thread_pool_->StartWorkers(Thread::Current());
}
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 4300cd23ff..6d0d6ed7fc 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -583,24 +583,6 @@ bool Runtime::Start() {
started_ = true;
- // Create the JIT either if we have to use JIT compilation or save profiling info.
- // TODO(calin): We use the JIT class as a proxy for JIT compilation and for
- // recoding profiles. Maybe we should consider changing the name to be more clear it's
- // not only about compiling. b/28295073.
- if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) {
- 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_options_->UseJitCompilation()) {
- if (!jit::Jit::LoadCompilerLibrary(&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()) {
ScopedObjectAccess soa(self);
StackHandleScope<2> hs(soa.Self());
@@ -625,6 +607,27 @@ bool Runtime::Start() {
Thread::FinishStartup();
+ // Create the JIT either if we have to use JIT compilation or save profiling info. This is
+ // done after FinishStartup as the JIT pool needs Java thread peers, which require the main
+ // ThreadGroup to exist.
+ //
+ // TODO(calin): We use the JIT class as a proxy for JIT compilation and for
+ // recoding profiles. Maybe we should consider changing the name to be more clear it's
+ // not only about compiling. b/28295073.
+ if (jit_options_->UseJitCompilation() || jit_options_->GetSaveProfilingInfo()) {
+ 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_options_->UseJitCompilation()) {
+ if (!jit::Jit::LoadCompilerLibrary(&error_msg)) {
+ // Try to load compiler pre zygote to reduce PSS. b/27744947
+ LOG(WARNING) << "Failed to load JIT compiler with error " << error_msg;
+ }
+ }
+ }
+
system_class_loader_ = CreateSystemClassLoader(this);
if (is_zygote_) {