< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page

 796 };
 797 
 798 void G1PreConcurrentStartTask::NoteStartOfMarkTask::do_work(uint worker_id) {
 799   NoteStartOfMarkHRClosure start_cl;
 800   G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&start_cl, &_claimer, worker_id);
 801 }
 802 
 803 void G1PreConcurrentStartTask::NoteStartOfMarkTask::set_max_workers(uint max_workers) {
 804   _claimer.set_n_workers(max_workers);
 805 }
 806 
 807 G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1ConcurrentMark* cm) :
 808   G1BatchedGangTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) {
 809   add_serial_task(new CLDClearClaimedMarksTask());
 810   add_serial_task(new ResetMarkingStateTask(cm));
 811   add_parallel_task(new NoteStartOfMarkTask());
 812 };
 813 
 814 void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
 815   assert_at_safepoint_on_vm_thread();


 816 
 817   G1PreConcurrentStartTask cl(cause, this);
 818   G1CollectedHeap::heap()->run_batch_task(&cl);
 819 
 820   _gc_tracer_cm->set_gc_cause(cause);
 821 }
 822 
 823 
 824 void G1ConcurrentMark::post_concurrent_mark_start() {
 825   // Start Concurrent Marking weak-reference discovery.
 826   ReferenceProcessor* rp = _g1h->ref_processor_cm();
 827   rp->start_discovery(false /* always_clear */);
 828 
 829   SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
 830   // This is the start of  the marking cycle, we're expected all
 831   // threads to have SATB queues with active set to false.
 832   satb_mq_set.set_active_all_threads(true, /* new active value */
 833                                      false /* expected_active */);
 834 
 835   _root_regions.prepare_for_scan();

1288 
1289     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark overflow");
1290 
1291     // Clear the marking state because we will be restarting
1292     // marking due to overflowing the global mark stack.
1293     reset_marking_for_restart();
1294   }
1295 
1296   {
1297     GCTraceTime(Debug, gc, phases) debug("Report Object Count", _gc_timer_cm);
1298     report_object_count(mark_finished);
1299   }
1300 
1301   // Statistics
1302   double now = os::elapsedTime();
1303   _remark_mark_times.add((mark_work_end - start) * 1000.0);
1304   _remark_weak_ref_times.add((now - mark_work_end) * 1000.0);
1305   _remark_times.add((now - start) * 1000.0);
1306 
1307   policy->record_concurrent_mark_remark_end();

1308 }
1309 
1310 class G1ReclaimEmptyRegionsTask : public AbstractGangTask {
1311   // Per-region work during the Cleanup pause.
1312   class G1ReclaimEmptyRegionsClosure : public HeapRegionClosure {
1313     G1CollectedHeap* _g1h;
1314     size_t _freed_bytes;
1315     FreeRegionList* _local_cleanup_list;
1316     uint _old_regions_removed;
1317     uint _archive_regions_removed;
1318     uint _humongous_regions_removed;
1319 
1320   public:
1321     G1ReclaimEmptyRegionsClosure(G1CollectedHeap* g1h,
1322                                  FreeRegionList* local_cleanup_list) :
1323       _g1h(g1h),
1324       _freed_bytes(0),
1325       _local_cleanup_list(local_cleanup_list),
1326       _old_regions_removed(0),
1327       _archive_regions_removed(0),

1765   G1CMSATBBufferClosure(G1CMTask* task, G1CollectedHeap* g1h)
1766     : _task(task), _g1h(g1h) { }
1767 
1768   virtual void do_buffer(void** buffer, size_t size) {
1769     for (size_t i = 0; i < size; ++i) {
1770       do_entry(buffer[i]);
1771     }
1772   }
1773 };
1774 
1775 class G1RemarkThreadsClosure : public ThreadClosure {
1776   G1SATBMarkQueueSet& _qset;
1777   G1CMOopClosure _cm_cl;
1778   MarkingCodeBlobClosure _code_cl;
1779   uintx _claim_token;
1780 
1781  public:
1782   G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
1783     _qset(G1BarrierSet::satb_mark_queue_set()),
1784     _cm_cl(g1h, task),
1785     _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
1786     _claim_token(Threads::thread_claim_token()) {}
1787 
1788   void do_thread(Thread* thread) {
1789     if (thread->claim_threads_do(true, _claim_token)) {
1790       // Transfer any partial buffer to the qset for completed buffer processing.
1791       _qset.flush_queue(G1ThreadLocalData::satb_mark_queue(thread));
1792       if (thread->is_Java_thread()) {
1793         // In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
1794         // however the liveness of oops reachable from nmethods have very complex lifecycles:
1795         // * Alive if on the stack of an executing method
1796         // * Weakly reachable otherwise
1797         // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
1798         // live by the SATB invariant but other oops recorded in nmethods may behave differently.
1799         JavaThread::cast(thread)->nmethods_do(&_code_cl);
1800       }
1801     }
1802   }
1803 };
1804 
1805 class G1CMRemarkTask : public AbstractGangTask {

 796 };
 797 
 798 void G1PreConcurrentStartTask::NoteStartOfMarkTask::do_work(uint worker_id) {
 799   NoteStartOfMarkHRClosure start_cl;
 800   G1CollectedHeap::heap()->heap_region_par_iterate_from_worker_offset(&start_cl, &_claimer, worker_id);
 801 }
 802 
 803 void G1PreConcurrentStartTask::NoteStartOfMarkTask::set_max_workers(uint max_workers) {
 804   _claimer.set_n_workers(max_workers);
 805 }
 806 
 807 G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1ConcurrentMark* cm) :
 808   G1BatchedGangTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) {
 809   add_serial_task(new CLDClearClaimedMarksTask());
 810   add_serial_task(new ResetMarkingStateTask(cm));
 811   add_parallel_task(new NoteStartOfMarkTask());
 812 };
 813 
 814 void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
 815   assert_at_safepoint_on_vm_thread();
 816     
 817   CodeCache::increment_marking_cycle();
 818 
 819   G1PreConcurrentStartTask cl(cause, this);
 820   G1CollectedHeap::heap()->run_batch_task(&cl);
 821 
 822   _gc_tracer_cm->set_gc_cause(cause);
 823 }
 824 
 825 
 826 void G1ConcurrentMark::post_concurrent_mark_start() {
 827   // Start Concurrent Marking weak-reference discovery.
 828   ReferenceProcessor* rp = _g1h->ref_processor_cm();
 829   rp->start_discovery(false /* always_clear */);
 830 
 831   SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
 832   // This is the start of  the marking cycle, we're expected all
 833   // threads to have SATB queues with active set to false.
 834   satb_mq_set.set_active_all_threads(true, /* new active value */
 835                                      false /* expected_active */);
 836 
 837   _root_regions.prepare_for_scan();

1290 
1291     verify_during_pause(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "Remark overflow");
1292 
1293     // Clear the marking state because we will be restarting
1294     // marking due to overflowing the global mark stack.
1295     reset_marking_for_restart();
1296   }
1297 
1298   {
1299     GCTraceTime(Debug, gc, phases) debug("Report Object Count", _gc_timer_cm);
1300     report_object_count(mark_finished);
1301   }
1302 
1303   // Statistics
1304   double now = os::elapsedTime();
1305   _remark_mark_times.add((mark_work_end - start) * 1000.0);
1306   _remark_weak_ref_times.add((now - mark_work_end) * 1000.0);
1307   _remark_times.add((now - start) * 1000.0);
1308 
1309   policy->record_concurrent_mark_remark_end();
1310   CodeCache::increment_marking_cycle();
1311 }
1312 
1313 class G1ReclaimEmptyRegionsTask : public AbstractGangTask {
1314   // Per-region work during the Cleanup pause.
1315   class G1ReclaimEmptyRegionsClosure : public HeapRegionClosure {
1316     G1CollectedHeap* _g1h;
1317     size_t _freed_bytes;
1318     FreeRegionList* _local_cleanup_list;
1319     uint _old_regions_removed;
1320     uint _archive_regions_removed;
1321     uint _humongous_regions_removed;
1322 
1323   public:
1324     G1ReclaimEmptyRegionsClosure(G1CollectedHeap* g1h,
1325                                  FreeRegionList* local_cleanup_list) :
1326       _g1h(g1h),
1327       _freed_bytes(0),
1328       _local_cleanup_list(local_cleanup_list),
1329       _old_regions_removed(0),
1330       _archive_regions_removed(0),

1768   G1CMSATBBufferClosure(G1CMTask* task, G1CollectedHeap* g1h)
1769     : _task(task), _g1h(g1h) { }
1770 
1771   virtual void do_buffer(void** buffer, size_t size) {
1772     for (size_t i = 0; i < size; ++i) {
1773       do_entry(buffer[i]);
1774     }
1775   }
1776 };
1777 
1778 class G1RemarkThreadsClosure : public ThreadClosure {
1779   G1SATBMarkQueueSet& _qset;
1780   G1CMOopClosure _cm_cl;
1781   MarkingCodeBlobClosure _code_cl;
1782   uintx _claim_token;
1783 
1784  public:
1785   G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
1786     _qset(G1BarrierSet::satb_mark_queue_set()),
1787     _cm_cl(g1h, task),
1788     _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations, true /* keepalive nmethods */),
1789     _claim_token(Threads::thread_claim_token()) {}
1790 
1791   void do_thread(Thread* thread) {
1792     if (thread->claim_threads_do(true, _claim_token)) {
1793       // Transfer any partial buffer to the qset for completed buffer processing.
1794       _qset.flush_queue(G1ThreadLocalData::satb_mark_queue(thread));
1795       if (thread->is_Java_thread()) {
1796         // In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
1797         // however the liveness of oops reachable from nmethods have very complex lifecycles:
1798         // * Alive if on the stack of an executing method
1799         // * Weakly reachable otherwise
1800         // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
1801         // live by the SATB invariant but other oops recorded in nmethods may behave differently.
1802         JavaThread::cast(thread)->nmethods_do(&_code_cl);
1803       }
1804     }
1805   }
1806 };
1807 
1808 class G1CMRemarkTask : public AbstractGangTask {
< prev index next >