283 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { |
283 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { |
284 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); |
284 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); |
285 _par_closures[i] = par_closure; |
285 _par_closures[i] = par_closure; |
286 } |
286 } |
287 |
287 |
288 void SATBMarkQueueSet::iterate_closure_all_threads() { |
|
289 for(JavaThread* t = Threads::first(); t; t = t->next()) { |
|
290 t->satb_mark_queue().apply_closure_and_empty(_closure); |
|
291 } |
|
292 shared_satb_queue()->apply_closure_and_empty(_closure); |
|
293 } |
|
294 |
|
295 void SATBMarkQueueSet::par_iterate_closure_all_threads(uint worker) { |
|
296 SharedHeap* sh = SharedHeap::heap(); |
|
297 int parity = sh->strong_roots_parity(); |
|
298 |
|
299 for(JavaThread* t = Threads::first(); t; t = t->next()) { |
|
300 if (t->claim_oops_do(true, parity)) { |
|
301 t->satb_mark_queue().apply_closure_and_empty(_par_closures[worker]); |
|
302 } |
|
303 } |
|
304 |
|
305 // We also need to claim the VMThread so that its parity is updated |
|
306 // otherwise the next call to Thread::possibly_parallel_oops_do inside |
|
307 // a StrongRootsScope might skip the VMThread because it has a stale |
|
308 // parity that matches the parity set by the StrongRootsScope |
|
309 // |
|
310 // Whichever worker succeeds in claiming the VMThread gets to do |
|
311 // the shared queue. |
|
312 |
|
313 VMThread* vmt = VMThread::vm_thread(); |
|
314 if (vmt->claim_oops_do(true, parity)) { |
|
315 shared_satb_queue()->apply_closure_and_empty(_par_closures[worker]); |
|
316 } |
|
317 } |
|
318 |
|
319 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
288 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
320 uint worker) { |
289 uint worker) { |
321 BufferNode* nd = NULL; |
290 BufferNode* nd = NULL; |
322 { |
291 { |
323 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
292 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |