--- old/src/hotspot/share/gc/shared/taskTerminator.cpp 2020-07-24 12:37:47.906688283 +0200 +++ new/src/hotspot/share/gc/shared/taskTerminator.cpp 2020-07-24 12:37:47.782686335 +0200 @@ -43,10 +43,8 @@ _n_threads(n_threads), _queue_set(queue_set), _offered_termination(0), - _spin_master(NULL) { - - _blocker = new Monitor(Mutex::leaf, "TaskTerminator", false, Monitor::_safepoint_check_never); -} + _blocker(Mutex::leaf, "TaskTerminator", false, Monitor::_safepoint_check_never), + _spin_master(NULL) { } TaskTerminator::~TaskTerminator() { if (_offered_termination != 0) { @@ -55,8 +53,6 @@ } assert(_spin_master == NULL, "Should have been reset"); - assert(_blocker != NULL, "Can not be NULL"); - delete _blocker; } #ifdef ASSERT @@ -65,11 +61,6 @@ } #endif -void TaskTerminator::yield() { - assert(_offered_termination <= _n_threads, "Invariant"); - os::naked_yield(); -} - void TaskTerminator::reset_for_reuse() { if (_offered_termination != 0) { assert(_offered_termination == _n_threads, @@ -93,8 +84,8 @@ } void TaskTerminator::prepare_for_return(Thread* this_thread, size_t tasks) { - assert(_blocker->is_locked(), "must be"); - assert(_blocker->owned_by_self(), "must be"); + assert(_blocker.is_locked(), "must be"); + assert(_blocker.owned_by_self(), "must be"); assert(_offered_termination >= 1, "must be"); if (_spin_master == this_thread) { @@ -102,16 +93,16 @@ } if (tasks >= _offered_termination - 1) { - _blocker->notify_all(); + _blocker.notify_all(); } else { for (; tasks > 1; tasks--) { - _blocker->notify(); + _blocker.notify(); } } } bool TaskTerminator::do_delay_step(DelayContext& delay_context) { - assert(!_blocker->owned_by_self(), "should not be owned by self"); + assert(!_blocker.owned_by_self(), "should not be owned by self"); if (delay_context._yield_count < WorkStealingYieldsBeforeSleep) { delay_context._yield_count++; @@ -141,7 +132,6 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { assert(_n_threads > 0, "Initialization is incorrect"); assert(_offered_termination < _n_threads, "Invariant"); - assert(_blocker != NULL, "Invariant"); // Single worker, done if (_n_threads == 1) { @@ -152,7 +142,7 @@ Thread* the_thread = Thread::current(); - MonitorLocker x(_blocker, Mutex::_no_safepoint_check_flag); + MonitorLocker x(&_blocker, Mutex::_no_safepoint_check_flag); _offered_termination++; if (_offered_termination == _n_threads) { @@ -173,7 +163,7 @@ size_t tasks; bool should_exit_termination; { - MutexUnlocker y(_blocker, Mutex::_no_safepoint_check_flag); + MutexUnlocker y(&_blocker, Mutex::_no_safepoint_check_flag); do_delay_step(delay_context); // Intentionally read the number of tasks outside the mutex since this // is potentially a long operation making the locked section long.