--- old/src/hotspot/share/runtime/thread.cpp 2018-04-03 17:01:21.000000000 -0400 +++ new/src/hotspot/share/runtime/thread.cpp 2018-04-03 17:01:20.000000000 -0400 @@ -105,6 +105,7 @@ #include "services/threadService.hpp" #include "trace/traceMacros.hpp" #include "trace/tracing.hpp" +#include "trace/tracingExport.hpp" #include "utilities/align.hpp" #include "utilities/defaultStream.hpp" #include "utilities/dtrace.hpp" @@ -3432,17 +3433,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, @@ -3455,9 +3453,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) {