23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/g1/g1ConcurrentRefine.hpp" |
26 #include "gc/g1/g1ConcurrentRefine.hpp" |
27 #include "gc/g1/g1ConcurrentRefineThread.hpp" |
27 #include "gc/g1/g1ConcurrentRefineThread.hpp" |
28 #include "gc/g1/g1YoungRemSetSamplingThread.hpp" |
|
29 #include "logging/log.hpp" |
28 #include "logging/log.hpp" |
30 #include "runtime/java.hpp" |
29 #include "runtime/java.hpp" |
31 #include "runtime/thread.hpp" |
30 #include "runtime/thread.hpp" |
32 #include "utilities/debug.hpp" |
31 #include "utilities/debug.hpp" |
33 #include "utilities/globalDefinitions.hpp" |
32 #include "utilities/globalDefinitions.hpp" |
115 G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone, |
114 G1ConcurrentRefine::G1ConcurrentRefine(size_t green_zone, |
116 size_t yellow_zone, |
115 size_t yellow_zone, |
117 size_t red_zone, |
116 size_t red_zone, |
118 size_t min_yellow_zone_size) : |
117 size_t min_yellow_zone_size) : |
119 _threads(NULL), |
118 _threads(NULL), |
120 _sample_thread(NULL), |
|
121 _n_worker_threads(thread_num()), |
119 _n_worker_threads(thread_num()), |
122 _green_zone(green_zone), |
120 _green_zone(green_zone), |
123 _yellow_zone(yellow_zone), |
121 _yellow_zone(yellow_zone), |
124 _red_zone(red_zone), |
122 _red_zone(red_zone), |
125 _min_yellow_zone_size(min_yellow_zone_size) |
123 _min_yellow_zone_size(min_yellow_zone_size) |
222 assert(t->cr() == cr, "Conc refine thread should refer to this"); |
220 assert(t->cr() == cr, "Conc refine thread should refer to this"); |
223 cr->_threads[i] = t; |
221 cr->_threads[i] = t; |
224 next = t; |
222 next = t; |
225 } |
223 } |
226 |
224 |
227 cr->_sample_thread = new G1YoungRemSetSamplingThread(); |
|
228 if (cr->_sample_thread->osthread() == NULL) { |
|
229 *ecode = JNI_ENOMEM; |
|
230 vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread"); |
|
231 return NULL; |
|
232 } |
|
233 |
|
234 *ecode = JNI_OK; |
225 *ecode = JNI_OK; |
235 return cr; |
226 return cr; |
236 } |
227 } |
237 |
228 |
238 void G1ConcurrentRefine::stop() { |
229 void G1ConcurrentRefine::stop() { |
239 for (uint i = 0; i < _n_worker_threads; i++) { |
230 for (uint i = 0; i < _n_worker_threads; i++) { |
240 _threads[i]->stop(); |
231 _threads[i]->stop(); |
241 } |
232 } |
242 _sample_thread->stop(); |
|
243 } |
233 } |
244 |
234 |
245 void G1ConcurrentRefine::update_thread_thresholds() { |
235 void G1ConcurrentRefine::update_thread_thresholds() { |
246 for (uint i = 0; i < _n_worker_threads; i++) { |
236 for (uint i = 0; i < _n_worker_threads; i++) { |
247 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i); |
237 Thresholds thresholds = calc_thresholds(_green_zone, _yellow_zone, i); |
253 G1ConcurrentRefine::~G1ConcurrentRefine() { |
243 G1ConcurrentRefine::~G1ConcurrentRefine() { |
254 for (uint i = 0; i < _n_worker_threads; i++) { |
244 for (uint i = 0; i < _n_worker_threads; i++) { |
255 delete _threads[i]; |
245 delete _threads[i]; |
256 } |
246 } |
257 FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); |
247 FREE_C_HEAP_ARRAY(G1ConcurrentRefineThread*, _threads); |
258 |
|
259 delete _sample_thread; |
|
260 } |
248 } |
261 |
249 |
262 void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { |
250 void G1ConcurrentRefine::threads_do(ThreadClosure *tc) { |
263 worker_threads_do(tc); |
|
264 tc->do_thread(_sample_thread); |
|
265 } |
|
266 |
|
267 void G1ConcurrentRefine::worker_threads_do(ThreadClosure * tc) { |
|
268 for (uint i = 0; i < _n_worker_threads; i++) { |
251 for (uint i = 0; i < _n_worker_threads; i++) { |
269 tc->do_thread(_threads[i]); |
252 tc->do_thread(_threads[i]); |
270 } |
253 } |
271 } |
254 } |
272 |
255 |
273 uint G1ConcurrentRefine::thread_num() { |
256 uint G1ConcurrentRefine::thread_num() { |
274 return G1ConcRefinementThreads; |
257 return G1ConcRefinementThreads; |
275 } |
258 } |
276 |
259 |
277 void G1ConcurrentRefine::print_worker_threads_on(outputStream* st) const { |
260 void G1ConcurrentRefine::print_threads_on(outputStream* st) const { |
278 for (uint i = 0; i < _n_worker_threads; ++i) { |
261 for (uint i = 0; i < _n_worker_threads; ++i) { |
279 _threads[i]->print_on(st); |
262 _threads[i]->print_on(st); |
280 st->cr(); |
263 st->cr(); |
281 } |
264 } |
282 _sample_thread->print_on(st); |
|
283 st->cr(); |
|
284 } |
265 } |
285 |
266 |
286 static size_t calc_new_green_zone(size_t green, |
267 static size_t calc_new_green_zone(size_t green, |
287 double update_rs_time, |
268 double update_rs_time, |
288 size_t update_rs_processed_buffers, |
269 size_t update_rs_processed_buffers, |