< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp

Print this page




 147     } else {
 148       AlwaysTrueClosure always_true;;
 149       _root_updater->roots_do<AlwaysTrueClosure, ShenandoahUpdateRefsClosure>(worker_id, &always_true, &cl);
 150     }
 151   }
 152 };
 153 
 154 class ShenandoahConcurrentMarkingTask : public AbstractGangTask {
 155 private:
 156   ShenandoahConcurrentMark* _cm;
 157   TaskTerminator* _terminator;
 158 
 159 public:
 160   ShenandoahConcurrentMarkingTask(ShenandoahConcurrentMark* cm, TaskTerminator* terminator) :
 161     AbstractGangTask("Root Region Scan"), _cm(cm), _terminator(terminator) {
 162   }
 163 
 164   void work(uint worker_id) {
 165     ShenandoahHeap* heap = ShenandoahHeap::heap();
 166     ShenandoahConcurrentWorkerSession worker_session(worker_id);
 167     ShenandoahSuspendibleThreadSetJoiner stsj(ShenandoahSuspendibleWorkers);
 168     ShenandoahObjToScanQueue* q = _cm->get_queue(worker_id);
 169     ReferenceProcessor* rp;
 170     if (heap->process_references()) {
 171       rp = heap->ref_processor();
 172       shenandoah_assert_rp_isalive_installed();
 173     } else {
 174       rp = NULL;
 175     }
 176 
 177     _cm->mark_loop(worker_id, _terminator, rp,
 178                    true, // cancellable
 179                    ShenandoahStringDedup::is_enabled()); // perform string dedup
 180   }
 181 };
 182 
 183 class ShenandoahSATBAndRemarkCodeRootsThreadsClosure : public ThreadClosure {
 184 private:
 185   ShenandoahSATBBufferClosure* _satb_cl;
 186   OopClosure*            const _cl;
 187   MarkingCodeBlobClosure*      _code_cl;


 987     }
 988 
 989     while (satb_mq_set.completed_buffers_num() > 0) {
 990       satb_mq_set.apply_closure_to_completed_buffer(&drain_satb);
 991     }
 992 
 993     uint work = 0;
 994     for (uint i = 0; i < stride; i++) {
 995       if (q->pop(t) ||
 996           queues->steal(worker_id, t)) {
 997         do_task<T>(q, cl, live_data, &t);
 998         work++;
 999       } else {
1000         break;
1001       }
1002     }
1003 
1004     if (work == 0) {
1005       // No work encountered in current stride, try to terminate.
1006       // Need to leave the STS here otherwise it might block safepoints.
1007       ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
1008       ShenandoahTerminatorTerminator tt(heap);
1009       if (terminator->offer_termination(&tt)) return;
1010     }
1011   }
1012 }


 147     } else {
 148       AlwaysTrueClosure always_true;;
 149       _root_updater->roots_do<AlwaysTrueClosure, ShenandoahUpdateRefsClosure>(worker_id, &always_true, &cl);
 150     }
 151   }
 152 };
 153 
 154 class ShenandoahConcurrentMarkingTask : public AbstractGangTask {
 155 private:
 156   ShenandoahConcurrentMark* _cm;
 157   TaskTerminator* _terminator;
 158 
 159 public:
 160   ShenandoahConcurrentMarkingTask(ShenandoahConcurrentMark* cm, TaskTerminator* terminator) :
 161     AbstractGangTask("Root Region Scan"), _cm(cm), _terminator(terminator) {
 162   }
 163 
 164   void work(uint worker_id) {
 165     ShenandoahHeap* heap = ShenandoahHeap::heap();
 166     ShenandoahConcurrentWorkerSession worker_session(worker_id);
 167     SuspendibleThreadSetJoiner stsj(ShenandoahSuspendibleWorkers);
 168     ShenandoahObjToScanQueue* q = _cm->get_queue(worker_id);
 169     ReferenceProcessor* rp;
 170     if (heap->process_references()) {
 171       rp = heap->ref_processor();
 172       shenandoah_assert_rp_isalive_installed();
 173     } else {
 174       rp = NULL;
 175     }
 176 
 177     _cm->mark_loop(worker_id, _terminator, rp,
 178                    true, // cancellable
 179                    ShenandoahStringDedup::is_enabled()); // perform string dedup
 180   }
 181 };
 182 
 183 class ShenandoahSATBAndRemarkCodeRootsThreadsClosure : public ThreadClosure {
 184 private:
 185   ShenandoahSATBBufferClosure* _satb_cl;
 186   OopClosure*            const _cl;
 187   MarkingCodeBlobClosure*      _code_cl;


 987     }
 988 
 989     while (satb_mq_set.completed_buffers_num() > 0) {
 990       satb_mq_set.apply_closure_to_completed_buffer(&drain_satb);
 991     }
 992 
 993     uint work = 0;
 994     for (uint i = 0; i < stride; i++) {
 995       if (q->pop(t) ||
 996           queues->steal(worker_id, t)) {
 997         do_task<T>(q, cl, live_data, &t);
 998         work++;
 999       } else {
1000         break;
1001       }
1002     }
1003 
1004     if (work == 0) {
1005       // No work encountered in current stride, try to terminate.
1006       // Need to leave the STS here otherwise it might block safepoints.
1007       SuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
1008       ShenandoahTerminatorTerminator tt(heap);
1009       if (terminator->offer_termination(&tt)) return;
1010     }
1011   }
1012 }
< prev index next >