226 ShenandoahFinalTraversalCollectionTask(ShenandoahRootProcessor* rp, ParallelTaskTerminator* terminator) :
227 AbstractGangTask("Shenandoah Final Traversal Collection"),
228 _rp(rp),
229 _terminator(terminator),
230 _heap(ShenandoahHeap::heap()) {}
231
232 void work(uint worker_id) {
233 ShenandoahEvacOOMScope oom_evac_scope;
234 ShenandoahTraversalGC* traversal_gc = _heap->traversal_gc();
235
236 ShenandoahObjToScanQueueSet* queues = traversal_gc->task_queues();
237 ShenandoahObjToScanQueue* q = queues->queue(worker_id);
238
239 bool process_refs = _heap->process_references();
240 bool unload_classes = _heap->unload_classes();
241 ReferenceProcessor* rp = NULL;
242 if (process_refs) {
243 rp = _heap->ref_processor();
244 }
245
246 // Step 1: Process ordinary GC roots.
247 ShenandoahTraversalSATBBufferClosure satb_cl(q);
248 if (!_heap->is_degenerated_gc_in_progress()) {
249 ShenandoahTraversalClosure roots_cl(q, rp);
250 CLDToOopClosure cld_cl(&roots_cl);
251 MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
252 ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
253 if (unload_classes) {
254 ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
255 _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, &code_cl, &tc, worker_id);
256 } else {
257 _rp->process_all_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &code_cl, &tc, worker_id);
258 }
259 } else {
260 ShenandoahTraversalDegenClosure roots_cl(q, rp);
261 CLDToOopClosure cld_cl(&roots_cl);
262 MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
263 ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
264 if (unload_classes) {
265 ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
266 _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, &code_cl, &tc, worker_id);
267 } else {
|
226 ShenandoahFinalTraversalCollectionTask(ShenandoahRootProcessor* rp, ParallelTaskTerminator* terminator) :
227 AbstractGangTask("Shenandoah Final Traversal Collection"),
228 _rp(rp),
229 _terminator(terminator),
230 _heap(ShenandoahHeap::heap()) {}
231
232 void work(uint worker_id) {
233 ShenandoahEvacOOMScope oom_evac_scope;
234 ShenandoahTraversalGC* traversal_gc = _heap->traversal_gc();
235
236 ShenandoahObjToScanQueueSet* queues = traversal_gc->task_queues();
237 ShenandoahObjToScanQueue* q = queues->queue(worker_id);
238
239 bool process_refs = _heap->process_references();
240 bool unload_classes = _heap->unload_classes();
241 ReferenceProcessor* rp = NULL;
242 if (process_refs) {
243 rp = _heap->ref_processor();
244 }
245
246 // Step 0: Drain outstanding SATB queues.
247 // NOTE: we piggy-back draining of remaining thread SATB buffers on the final root scan below.
248 ShenandoahTraversalSATBBufferClosure satb_cl(q);
249 {
250 // Process remaining finished SATB buffers.
251 SATBMarkQueueSet& satb_mq_set = ShenandoahBarrierSet::satb_mark_queue_set();
252 while (satb_mq_set.apply_closure_to_completed_buffer(&satb_cl));
253 // Process remaining threads SATB buffers below.
254 }
255
256 // Step 1: Process ordinary GC roots.
257 if (!_heap->is_degenerated_gc_in_progress()) {
258 ShenandoahTraversalClosure roots_cl(q, rp);
259 CLDToOopClosure cld_cl(&roots_cl);
260 MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
261 ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
262 if (unload_classes) {
263 ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
264 _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, &code_cl, &tc, worker_id);
265 } else {
266 _rp->process_all_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &code_cl, &tc, worker_id);
267 }
268 } else {
269 ShenandoahTraversalDegenClosure roots_cl(q, rp);
270 CLDToOopClosure cld_cl(&roots_cl);
271 MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations);
272 ShenandoahTraversalSATBThreadsClosure tc(&satb_cl);
273 if (unload_classes) {
274 ShenandoahRemarkCLDClosure weak_cld_cl(&roots_cl);
275 _rp->process_strong_roots(&roots_cl, process_refs ? NULL : &roots_cl, &cld_cl, &weak_cld_cl, &code_cl, &tc, worker_id);
276 } else {
|