--- old/src/hotspot/share/gc/shared/owstTaskTerminator.cpp 2020-01-30 17:09:51.617442727 +0100 +++ new/src/hotspot/share/gc/shared/owstTaskTerminator.cpp 2020-01-30 17:09:50.465426224 +0100 @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "gc/shared/owstTaskTerminator.hpp" +#include "gc/shared/taskqueue.hpp" #include "logging/log.hpp" #ifdef TRACESPINNING @@ -40,16 +41,16 @@ _offered_termination(0), _spin_master(NULL) { - _blocker = new Monitor(Mutex::leaf, "OWSTTaskTerminator", false, Monitor::_safepoint_check_never); + _blocker = new Monitor(Mutex::leaf, "OWSTTaskTerminator", false, Monitor::_safepoint_check_never); } OWSTTaskTerminator::~OWSTTaskTerminator() { + assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition"); + assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" ); + assert(_spin_master == NULL, "Should have been reset"); assert(_blocker != NULL, "Can not be NULL"); delete _blocker; - - assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition"); - assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" ); } #ifdef ASSERT @@ -65,11 +66,8 @@ #ifdef TRACESPINNING void OWSTTaskTerminator::print_termination_counts() { - log_trace(gc, task)("ParallelTaskTerminator Total yields: %u" - " Total spins: %u Total peeks: %u", - total_yields(), - total_spins(), - total_peeks()); + log_trace(gc, task)("TaskTerminator Yields: %u Spins: %u Peeks: %u", + total_yields(), total_spins(), total_peeks()); } #endif @@ -90,6 +88,10 @@ return tasks > 0 || (terminator != NULL && terminator->should_exit_termination()); } +size_t OWSTTaskTerminator::tasks_in_queue_set() const { + return _queue_set->tasks(); +} + bool OWSTTaskTerminator::offer_termination(TerminatorTerminator* terminator) { assert(_n_threads > 0, "Initialization is incorrect"); assert(_offered_termination < _n_threads, "Invariant"); @@ -222,7 +224,7 @@ } #ifdef TRACESPINNING - _total_peeks++; + _total_peeks++; #endif size_t tasks = tasks_in_queue_set(); bool exit = exit_termination(tasks, terminator); --- old/src/hotspot/share/gc/shared/owstTaskTerminator.hpp 2020-01-30 17:09:56.113507138 +0100 +++ new/src/hotspot/share/gc/shared/owstTaskTerminator.hpp 2020-01-30 17:09:54.929490177 +0100 @@ -25,7 +25,6 @@ #ifndef SHARE_GC_SHARED_OWSTTASKTERMINATOR_HPP #define SHARE_GC_SHARED_OWSTTASKTERMINATOR_HPP -#include "gc/shared/taskqueue.hpp" #include "memory/allocation.hpp" #include "runtime/mutex.hpp" #include "runtime/thread.hpp" @@ -33,6 +32,9 @@ // Define this to enable additional tracing probes. #undef TRACESPINNING +class TaskQueueSetSuper; +class TerminatorTerminator; + /* * Provides a task termination protocol. OWST stands for Optimized Work Stealing Threads * @@ -73,7 +75,7 @@ // If we should exit current termination protocol bool exit_termination(size_t tasks, TerminatorTerminator* terminator); - size_t tasks_in_queue_set() { return _queue_set->tasks(); } + size_t tasks_in_queue_set() const; // Perform spin-master task. // Return true if termination condition is detected, otherwise return false