8200374: Add ThreadsSMRSupport::verify_hazard_pointer_scanned() to verify threads_do()

Add verification for the threads_do() part of the Thread-SMR protocol.

Reviewed-by: eosterlund, dholmes, rehn
This commit is contained in:
Daniel D. Daugherty 2018-04-12 09:03:46 -04:00
parent 3e27d7412e
commit d974f0b162
6 changed files with 188 additions and 22 deletions

View file

@ -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 @@ static inline void *prefetch_and_load_ptr(void **addr, intx prefetch_interval) {
// 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 @@ void Threads::threads_do(ThreadClosure* tc) {
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) {