--- old/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp 2018-04-13 11:50:06.384450832 +0200 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp 2018-04-13 11:50:05.945437378 +0200 @@ -152,42 +152,46 @@ } } -inline bool G1ParScanThreadState::should_start_trim_queue_partially() const { +inline bool G1ParScanThreadState::needs_partial_trimming() const { return !_refs->overflow_empty() || _refs->size() > _stack_drain_upper_threshold; } -inline bool G1ParScanThreadState::should_end_trim_queue_partially() const { +inline bool G1ParScanThreadState::is_partially_trimmed() const { return _refs->overflow_empty() && _refs->size() <= _stack_drain_lower_threshold; } -inline void G1ParScanThreadState::trim_queue_partially_internal() { +inline void G1ParScanThreadState::trim_queue_to_threshold(uint threshold) { StarTask ref; - do { - // Drain the overflow stack first, so other threads can potentially steal. - while (_refs->pop_overflow(ref)) { - if (!_refs->try_push_to_taskqueue(ref)) { - dispatch_reference(ref); - } - } - - while (_refs->pop_local(ref, _stack_drain_lower_threshold)) { + // Drain the overflow stack first, so other threads can potentially steal. + while (_refs->pop_overflow(ref)) { + if (!_refs->try_push_to_taskqueue(ref)) { dispatch_reference(ref); } - } while (!should_end_trim_queue_partially()); + } + + while (_refs->pop_local(ref, threshold)) { + dispatch_reference(ref); + } } inline void G1ParScanThreadState::trim_queue_partially() { - if (should_start_trim_queue_partially()) { - const Ticks start = Ticks::now(); - trim_queue_partially_internal(); - _trim_ticks += Ticks::now() - start; + if (!needs_partial_trimming()) { + return; } + + const Ticks start = Ticks::now(); + do { + trim_queue_to_threshold(_stack_drain_lower_threshold); + } while (!is_partially_trimmed()); + _trim_ticks += Ticks::now() - start; +} + +inline Tickspan G1ParScanThreadState::trim_ticks() { + return _trim_ticks; } -inline Tickspan G1ParScanThreadState::trim_ticks_and_reset() { - Tickspan result = _trim_ticks; +inline void G1ParScanThreadState::reset_trim_ticks() { _trim_ticks = Tickspan(); - return result; } #endif // SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP