--- a/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp Fri Mar 25 15:54:18 2016 +0300
+++ b/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp Fri Mar 25 15:50:31 2016 -0400
@@ -76,7 +76,6 @@
}
void ConcurrentG1RefineThread::wait_for_completed_buffers() {
- DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
while (!should_terminate() && !is_active()) {
_monitor->wait(Mutex::_no_safepoint_check_flag);
@@ -126,7 +125,12 @@
{
SuspendibleThreadSetJoiner sts_join;
- do {
+ while (!should_terminate()) {
+ if (sts_join.should_yield()) {
+ sts_join.yield();
+ continue; // Re-check for termination after yield delay.
+ }
+
size_t curr_buffer_num = dcqs.completed_buffers_num();
// If the number of the buffers falls down into the yellow zone,
// that means that the transition period after the evacuation pause has ended.
@@ -138,17 +142,23 @@
if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) {
_next->activate();
}
- } while (dcqs.apply_closure_to_completed_buffer(_refine_closure,
- _worker_id + _worker_id_offset,
- _deactivation_threshold,
- false /* during_pause */));
- deactivate();
- log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT ", current: " SIZE_FORMAT,
- _worker_id, _deactivation_threshold,
- dcqs.completed_buffers_num());
+ // Process the next buffer, if there are enough left.
+ if (!dcqs.apply_closure_to_completed_buffer(_refine_closure,
+ _worker_id + _worker_id_offset,
+ _deactivation_threshold,
+ false /* during_pause */)) {
+ break; // Deactivate, number of buffers fell below threshold.
+ }
+ }
}
+ deactivate();
+ log_debug(gc, refine)("Deactivated %d, off threshold: " SIZE_FORMAT
+ ", current: " SIZE_FORMAT,
+ _worker_id, _deactivation_threshold,
+ dcqs.completed_buffers_num());
+
if (os::supports_vtime()) {
_vtime_accum = (os::elapsedVTime() - _vtime_start);
} else {