diff options
| -rw-r--r-- | runtime/jit/jit.cc | 13 | ||||
| -rw-r--r-- | runtime/runtime.cc | 39 | ||||
| -rw-r--r-- | test/911-get-stack-trace/src/PrintThread.java | 3 | ||||
| -rw-r--r-- | test/924-threads/src/Main.java | 17 | ||||
| -rw-r--r-- | test/925-threadgroups/src/Main.java | 21 |
5 files changed, 69 insertions, 24 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc index 6deb03dc41..fec3c4f7b8 100644 --- a/runtime/jit/jit.cc +++ b/runtime/jit/jit.cc @@ -145,7 +145,12 @@ Jit::Jit() : dump_info_on_shutdown_(false), cumulative_timings_("JIT timings"), memory_use_("Memory used for compilation", 16), lock_("JIT memory use lock"), - use_jit_compilation_(true) {} + use_jit_compilation_(true), + 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->GetProfileSaverOptions().IsEnabled()); @@ -289,7 +294,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); Start(); } diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 693b8f4e2f..9609bee022 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -672,24 +672,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()); @@ -714,6 +696,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; + } + } + } + // Send the start phase event. We have to wait till here as this is when the main thread peer // has just been generated, important root clinits have been run and JNI is completely functional. { diff --git a/test/911-get-stack-trace/src/PrintThread.java b/test/911-get-stack-trace/src/PrintThread.java index 97815ccad9..136fd80d40 100644 --- a/test/911-get-stack-trace/src/PrintThread.java +++ b/test/911-get-stack-trace/src/PrintThread.java @@ -44,6 +44,9 @@ public class PrintThread { if (name.contains("Daemon")) { // Do not print daemon stacks, as they're non-deterministic. stackSerialization = "<not printed>"; + } else if (name.startsWith("Jit thread pool worker")) { + // Skip JIT thread pool. It may or may not be there depending on configuration. + continue; } else { StringBuilder sb = new StringBuilder(); for (String[] stackElement : (String[][])stackInfo[1]) { diff --git a/test/924-threads/src/Main.java b/test/924-threads/src/Main.java index 29c4aa330c..f18d70e8e1 100644 --- a/test/924-threads/src/Main.java +++ b/test/924-threads/src/Main.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.concurrent.CountDownLatch; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -162,8 +163,20 @@ public class Main { private static void doAllThreadsTests() { Thread[] threads = getAllThreads(); - Arrays.sort(threads, THREAD_COMP); - System.out.println(Arrays.toString(threads)); + List<Thread> threadList = new ArrayList<>(Arrays.asList(threads)); + + // Filter out JIT thread. It may or may not be there depending on configuration. + Iterator<Thread> it = threadList.iterator(); + while (it.hasNext()) { + Thread t = it.next(); + if (t.getName().startsWith("Jit thread pool worker")) { + it.remove(); + break; + } + } + + Collections.sort(threadList, THREAD_COMP); + System.out.println(threadList); } private static void doTLSTests() throws Exception { diff --git a/test/925-threadgroups/src/Main.java b/test/925-threadgroups/src/Main.java index 3d7a4ca740..bf7441f9bf 100644 --- a/test/925-threadgroups/src/Main.java +++ b/test/925-threadgroups/src/Main.java @@ -14,8 +14,12 @@ * limitations under the License. */ +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; public class Main { public static void main(String[] args) throws Exception { @@ -64,10 +68,23 @@ public class Main { Thread[] threads = (Thread[])data[0]; ThreadGroup[] groups = (ThreadGroup[])data[1]; - Arrays.sort(threads, THREAD_COMP); + List<Thread> threadList = new ArrayList<>(Arrays.asList(threads)); + + // Filter out JIT thread. It may or may not be there depending on configuration. + Iterator<Thread> it = threadList.iterator(); + while (it.hasNext()) { + Thread t = it.next(); + if (t.getName().startsWith("Jit thread pool worker")) { + it.remove(); + break; + } + } + + Collections.sort(threadList, THREAD_COMP); + Arrays.sort(groups, THREADGROUP_COMP); System.out.println(tg.getName() + ":"); - System.out.println(" " + Arrays.toString(threads)); + System.out.println(" " + threadList); System.out.println(" " + Arrays.toString(groups)); if (tg.getParent() != null) { |