diff -r 80e7764e4d09 -r 129d60b5dac7 src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp Thu Apr 12 14:27:23 2018 +0200 +++ b/src/hotspot/share/runtime/thread.cpp Thu Apr 12 09:03:46 2018 -0400 @@ -106,6 +106,7 @@ #include "services/threadService.hpp" #include "trace/traceMacros.hpp" #include "trace/tracing.hpp" +#include "trace/tracingExport.hpp" #include "utilities/align.hpp" #include "utilities/copy.hpp" #include "utilities/defaultStream.hpp" @@ -3435,17 +3436,14 @@ // All JavaThreads #define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_java_thread_list(), X) -// All JavaThreads + all non-JavaThreads (i.e., every thread in the system) -void Threads::threads_do(ThreadClosure* tc) { - assert_locked_or_safepoint(Threads_lock); - // ALL_JAVA_THREADS iterates through all JavaThreads - ALL_JAVA_THREADS(p) { - tc->do_thread(p); - } +// All non-JavaThreads (i.e., every non-JavaThread in the system). +void Threads::non_java_threads_do(ThreadClosure* tc) { // Someday we could have a table or list of all non-JavaThreads. // For now, just manually iterate through them. tc->do_thread(VMThread::vm_thread()); - Universe::heap()->gc_threads_do(tc); + if (Universe::heap() != NULL) { + Universe::heap()->gc_threads_do(tc); + } WatcherThread *wt = WatcherThread::watcher_thread(); // Strictly speaking, the following NULL check isn't sufficient to make sure // the data for WatcherThread is still valid upon being examined. However, @@ -3458,9 +3456,26 @@ tc->do_thread(wt); } +#if INCLUDE_TRACE + Thread* sampler_thread = TracingExport::sampler_thread_acquire(); + if (sampler_thread != NULL) { + tc->do_thread(sampler_thread); + } +#endif + // If CompilerThreads ever become non-JavaThreads, add them here } +// All JavaThreads + all non-JavaThreads (i.e., every thread in the system). +void Threads::threads_do(ThreadClosure* tc) { + assert_locked_or_safepoint(Threads_lock); + // ALL_JAVA_THREADS iterates through all JavaThreads. + ALL_JAVA_THREADS(p) { + tc->do_thread(p); + } + non_java_threads_do(tc); +} + void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) { int cp = Threads::thread_claim_parity(); ALL_JAVA_THREADS(p) {