268 } 269 shared_satb_queue()->set_active(active); 270 } 271 272 void SATBMarkQueueSet::filter_thread_buffers() { 273 for(JavaThread* t = Threads::first(); t; t = t->next()) { 274 t->satb_mark_queue().filter(); 275 } 276 shared_satb_queue()->filter(); 277 } 278 279 void SATBMarkQueueSet::set_closure(ObjectClosure* closure) { 280 _closure = closure; 281 } 282 283 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { 284 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); 285 _par_closures[i] = par_closure; 286 } 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, 320 uint worker) { 321 BufferNode* nd = NULL; 322 { 323 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); 324 if (_completed_buffers_head != NULL) { 325 nd = _completed_buffers_head; 326 _completed_buffers_head = nd->next(); 327 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; 328 _n_completed_buffers--; 329 if (_n_completed_buffers == 0) _process_completed = false; 330 } 331 } 332 ObjectClosure* cl = (par ? _par_closures[worker] : _closure); 333 if (nd != NULL) { 334 void **buf = BufferNode::make_buffer_from_node(nd); 335 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); 336 deallocate_buffer(buf); 337 return true; 338 } else { | 268 } 269 shared_satb_queue()->set_active(active); 270 } 271 272 void SATBMarkQueueSet::filter_thread_buffers() { 273 for(JavaThread* t = Threads::first(); t; t = t->next()) { 274 t->satb_mark_queue().filter(); 275 } 276 shared_satb_queue()->filter(); 277 } 278 279 void SATBMarkQueueSet::set_closure(ObjectClosure* closure) { 280 _closure = closure; 281 } 282 283 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { 284 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); 285 _par_closures[i] = par_closure; 286 } 287 288 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, 289 uint worker) { 290 BufferNode* nd = NULL; 291 { 292 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); 293 if (_completed_buffers_head != NULL) { 294 nd = _completed_buffers_head; 295 _completed_buffers_head = nd->next(); 296 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; 297 _n_completed_buffers--; 298 if (_n_completed_buffers == 0) _process_completed = false; 299 } 300 } 301 ObjectClosure* cl = (par ? _par_closures[worker] : _closure); 302 if (nd != NULL) { 303 void **buf = BufferNode::make_buffer_from_node(nd); 304 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); 305 deallocate_buffer(buf); 306 return true; 307 } else { |