Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp @ 20192:581e70386ec9
8039147: Cleanup SuspendibleThreadSet
Reviewed-by: brutisso, tschatzl, mgerdin
author | pliden |
---|---|
date | Fri, 11 Apr 2014 12:29:24 +0200 |
parents | 8847586c9037 |
children | 570cb6369f17 |
comparison
equal
deleted
inserted
replaced
20191:fd81a5764900 | 20192:581e70386ec9 |
---|---|
69 set_active(true); | 69 set_active(true); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void ConcurrentG1RefineThread::sample_young_list_rs_lengths() { | 73 void ConcurrentG1RefineThread::sample_young_list_rs_lengths() { |
74 SuspendibleThreadSetJoiner sts; | |
74 G1CollectedHeap* g1h = G1CollectedHeap::heap(); | 75 G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
75 G1CollectorPolicy* g1p = g1h->g1_policy(); | 76 G1CollectorPolicy* g1p = g1h->g1_policy(); |
76 if (g1p->adaptive_young_list_length()) { | 77 if (g1p->adaptive_young_list_length()) { |
77 int regions_visited = 0; | 78 int regions_visited = 0; |
78 g1h->young_list()->rs_length_sampling_init(); | 79 g1h->young_list()->rs_length_sampling_init(); |
80 g1h->young_list()->rs_length_sampling_next(); | 81 g1h->young_list()->rs_length_sampling_next(); |
81 ++regions_visited; | 82 ++regions_visited; |
82 | 83 |
83 // we try to yield every time we visit 10 regions | 84 // we try to yield every time we visit 10 regions |
84 if (regions_visited == 10) { | 85 if (regions_visited == 10) { |
85 if (_sts.should_yield()) { | 86 if (sts.should_yield()) { |
86 _sts.yield("G1 refine"); | 87 sts.yield(); |
87 // we just abandon the iteration | 88 // we just abandon the iteration |
88 break; | 89 break; |
89 } | 90 } |
90 regions_visited = 0; | 91 regions_visited = 0; |
91 } | 92 } |
97 | 98 |
98 void ConcurrentG1RefineThread::run_young_rs_sampling() { | 99 void ConcurrentG1RefineThread::run_young_rs_sampling() { |
99 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); | 100 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
100 _vtime_start = os::elapsedVTime(); | 101 _vtime_start = os::elapsedVTime(); |
101 while(!_should_terminate) { | 102 while(!_should_terminate) { |
102 _sts.join(); | |
103 sample_young_list_rs_lengths(); | 103 sample_young_list_rs_lengths(); |
104 _sts.leave(); | |
105 | 104 |
106 if (os::supports_vtime()) { | 105 if (os::supports_vtime()) { |
107 _vtime_accum = (os::elapsedVTime() - _vtime_start); | 106 _vtime_accum = (os::elapsedVTime() - _vtime_start); |
108 } else { | 107 } else { |
109 _vtime_accum = 0.0; | 108 _vtime_accum = 0.0; |
180 | 179 |
181 if (_should_terminate) { | 180 if (_should_terminate) { |
182 break; | 181 break; |
183 } | 182 } |
184 | 183 |
185 _sts.join(); | 184 { |
186 | 185 SuspendibleThreadSetJoiner sts; |
187 do { | 186 |
188 int curr_buffer_num = (int)dcqs.completed_buffers_num(); | 187 do { |
189 // If the number of the buffers falls down into the yellow zone, | 188 int curr_buffer_num = (int)dcqs.completed_buffers_num(); |
190 // that means that the transition period after the evacuation pause has ended. | 189 // If the number of the buffers falls down into the yellow zone, |
191 if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) { | 190 // that means that the transition period after the evacuation pause has ended. |
192 dcqs.set_completed_queue_padding(0); | 191 if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) { |
192 dcqs.set_completed_queue_padding(0); | |
193 } | |
194 | |
195 if (_worker_id > 0 && curr_buffer_num <= _deactivation_threshold) { | |
196 // If the number of the buffer has fallen below our threshold | |
197 // we should deactivate. The predecessor will reactivate this | |
198 // thread should the number of the buffers cross the threshold again. | |
199 deactivate(); | |
200 break; | |
201 } | |
202 | |
203 // Check if we need to activate the next thread. | |
204 if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) { | |
205 _next->activate(); | |
206 } | |
207 } while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, cg1r()->green_zone())); | |
208 | |
209 // We can exit the loop above while being active if there was a yield request. | |
210 if (is_active()) { | |
211 deactivate(); | |
193 } | 212 } |
194 | 213 } |
195 if (_worker_id > 0 && curr_buffer_num <= _deactivation_threshold) { | |
196 // If the number of the buffer has fallen below our threshold | |
197 // we should deactivate. The predecessor will reactivate this | |
198 // thread should the number of the buffers cross the threshold again. | |
199 deactivate(); | |
200 break; | |
201 } | |
202 | |
203 // Check if we need to activate the next thread. | |
204 if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) { | |
205 _next->activate(); | |
206 } | |
207 } while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, cg1r()->green_zone())); | |
208 | |
209 // We can exit the loop above while being active if there was a yield request. | |
210 if (is_active()) { | |
211 deactivate(); | |
212 } | |
213 | |
214 _sts.leave(); | |
215 | 214 |
216 if (os::supports_vtime()) { | 215 if (os::supports_vtime()) { |
217 _vtime_accum = (os::elapsedVTime() - _vtime_start); | 216 _vtime_accum = (os::elapsedVTime() - _vtime_start); |
218 } else { | 217 } else { |
219 _vtime_accum = 0.0; | 218 _vtime_accum = 0.0; |
220 } | 219 } |
221 } | 220 } |
222 assert(_should_terminate, "just checking"); | 221 assert(_should_terminate, "just checking"); |
223 terminate(); | 222 terminate(); |
224 } | |
225 | |
226 | |
227 void ConcurrentG1RefineThread::yield() { | |
228 if (G1TraceConcRefinement) { | |
229 gclog_or_tty->print_cr("G1-Refine-yield"); | |
230 } | |
231 _sts.yield("G1 refine"); | |
232 if (G1TraceConcRefinement) { | |
233 gclog_or_tty->print_cr("G1-Refine-yield-end"); | |
234 } | |
235 } | 223 } |
236 | 224 |
237 void ConcurrentG1RefineThread::stop() { | 225 void ConcurrentG1RefineThread::stop() { |
238 // it is ok to take late safepoints here, if needed | 226 // it is ok to take late safepoints here, if needed |
239 { | 227 { |