1.1 --- a/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Mon Jun 23 16:43:41 2014 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Fri Apr 11 12:29:24 2014 +0200 1.3 @@ -71,6 +71,7 @@ 1.4 } 1.5 1.6 void ConcurrentG1RefineThread::sample_young_list_rs_lengths() { 1.7 + SuspendibleThreadSetJoiner sts; 1.8 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 1.9 G1CollectorPolicy* g1p = g1h->g1_policy(); 1.10 if (g1p->adaptive_young_list_length()) { 1.11 @@ -82,8 +83,8 @@ 1.12 1.13 // we try to yield every time we visit 10 regions 1.14 if (regions_visited == 10) { 1.15 - if (_sts.should_yield()) { 1.16 - _sts.yield("G1 refine"); 1.17 + if (sts.should_yield()) { 1.18 + sts.yield(); 1.19 // we just abandon the iteration 1.20 break; 1.21 } 1.22 @@ -99,9 +100,7 @@ 1.23 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 1.24 _vtime_start = os::elapsedVTime(); 1.25 while(!_should_terminate) { 1.26 - _sts.join(); 1.27 sample_young_list_rs_lengths(); 1.28 - _sts.leave(); 1.29 1.30 if (os::supports_vtime()) { 1.31 _vtime_accum = (os::elapsedVTime() - _vtime_start); 1.32 @@ -182,37 +181,37 @@ 1.33 break; 1.34 } 1.35 1.36 - _sts.join(); 1.37 + { 1.38 + SuspendibleThreadSetJoiner sts; 1.39 1.40 - do { 1.41 - int curr_buffer_num = (int)dcqs.completed_buffers_num(); 1.42 - // If the number of the buffers falls down into the yellow zone, 1.43 - // that means that the transition period after the evacuation pause has ended. 1.44 - if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) { 1.45 - dcqs.set_completed_queue_padding(0); 1.46 + do { 1.47 + int curr_buffer_num = (int)dcqs.completed_buffers_num(); 1.48 + // If the number of the buffers falls down into the yellow zone, 1.49 + // that means that the transition period after the evacuation pause has ended. 1.50 + if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) { 1.51 + dcqs.set_completed_queue_padding(0); 1.52 + } 1.53 + 1.54 + if (_worker_id > 0 && curr_buffer_num <= _deactivation_threshold) { 1.55 + // If the number of the buffer has fallen below our threshold 1.56 + // we should deactivate. The predecessor will reactivate this 1.57 + // thread should the number of the buffers cross the threshold again. 1.58 + deactivate(); 1.59 + break; 1.60 + } 1.61 + 1.62 + // Check if we need to activate the next thread. 1.63 + if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) { 1.64 + _next->activate(); 1.65 + } 1.66 + } while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, cg1r()->green_zone())); 1.67 + 1.68 + // We can exit the loop above while being active if there was a yield request. 1.69 + if (is_active()) { 1.70 + deactivate(); 1.71 } 1.72 - 1.73 - if (_worker_id > 0 && curr_buffer_num <= _deactivation_threshold) { 1.74 - // If the number of the buffer has fallen below our threshold 1.75 - // we should deactivate. The predecessor will reactivate this 1.76 - // thread should the number of the buffers cross the threshold again. 1.77 - deactivate(); 1.78 - break; 1.79 - } 1.80 - 1.81 - // Check if we need to activate the next thread. 1.82 - if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) { 1.83 - _next->activate(); 1.84 - } 1.85 - } while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, cg1r()->green_zone())); 1.86 - 1.87 - // We can exit the loop above while being active if there was a yield request. 1.88 - if (is_active()) { 1.89 - deactivate(); 1.90 } 1.91 1.92 - _sts.leave(); 1.93 - 1.94 if (os::supports_vtime()) { 1.95 _vtime_accum = (os::elapsedVTime() - _vtime_start); 1.96 } else { 1.97 @@ -223,17 +222,6 @@ 1.98 terminate(); 1.99 } 1.100 1.101 - 1.102 -void ConcurrentG1RefineThread::yield() { 1.103 - if (G1TraceConcRefinement) { 1.104 - gclog_or_tty->print_cr("G1-Refine-yield"); 1.105 - } 1.106 - _sts.yield("G1 refine"); 1.107 - if (G1TraceConcRefinement) { 1.108 - gclog_or_tty->print_cr("G1-Refine-yield-end"); 1.109 - } 1.110 -} 1.111 - 1.112 void ConcurrentG1RefineThread::stop() { 1.113 // it is ok to take late safepoints here, if needed 1.114 {