src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 6796 : [mq]: 8052170-fix-crash-with-deferredrsupdate


5453  public:
5454   G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue) : AbstractGangTask("Redirty Cards"), _queue(queue) { }
5455 
5456   virtual void work(uint worker_id) {
5457     double start_time = os::elapsedTime();
5458 
5459     RedirtyLoggedCardTableEntryClosure cl;
5460     if (G1CollectedHeap::heap()->use_parallel_gc_threads()) {
5461       _queue->par_apply_closure_to_all_completed_buffers(&cl);
5462     } else {
5463       _queue->apply_closure_to_all_completed_buffers(&cl);
5464     }
5465 
5466     G1GCPhaseTimes* timer = G1CollectedHeap::heap()->g1_policy()->phase_times();
5467     timer->record_redirty_logged_cards_time_ms(worker_id, (os::elapsedTime() - start_time) * 1000.0);
5468     timer->record_redirty_logged_cards_processed_cards(worker_id, cl.num_processed());
5469   }
5470 };
5471 
5472 void G1CollectedHeap::redirty_logged_cards() {
5473   guarantee(G1DeferredRSUpdate, "Must only be called when using deferred RS updates.");
5474   double redirty_logged_cards_start = os::elapsedTime();
5475 
5476   uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
5477                    _g1h->workers()->active_workers() : 1);












5478 
5479   G1RedirtyLoggedCardsTask redirty_task(&dirty_card_queue_set());
5480   dirty_card_queue_set().reset_for_par_iteration();
5481   if (use_parallel_gc_threads()) {
5482     set_par_threads(n_workers);
5483     workers()->run_task(&redirty_task);
5484     set_par_threads(0);
5485   } else {
5486     redirty_task.work(0);
5487   }
5488 
5489   DirtyCardQueueSet& dcq = JavaThread::dirty_card_queue_set();
5490   dcq.merge_bufferlists(&dirty_card_queue_set());
5491   assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed");
5492 
5493   g1_policy()->phase_times()->record_redirty_logged_cards_time_ms((os::elapsedTime() - redirty_logged_cards_start) * 1000.0);
5494 }
5495 
5496 // Weak Reference Processing support
5497 


6118   finalize_for_evac_failure();
6119 
6120   if (evacuation_failed()) {
6121     remove_self_forwarding_pointers();
6122 
6123     // Reset the G1EvacuationFailureALot counters and flags
6124     // Note: the values are reset only when an actual
6125     // evacuation failure occurs.
6126     NOT_PRODUCT(reset_evacuation_should_fail();)
6127   }
6128 
6129   // Enqueue any remaining references remaining on the STW
6130   // reference processor's discovered lists. We need to do
6131   // this after the card table is cleaned (and verified) as
6132   // the act of enqueueing entries on to the pending list
6133   // will log these updates (and dirty their associated
6134   // cards). We need these updates logged to update any
6135   // RSets.
6136   enqueue_discovered_references(n_workers);
6137 
6138   if (G1DeferredRSUpdate) {
6139     redirty_logged_cards();
6140   }
6141   COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
6142 }
6143 
6144 void G1CollectedHeap::free_region(HeapRegion* hr,
6145                                   FreeRegionList* free_list,
6146                                   bool par,
6147                                   bool locked) {
6148   assert(!hr->isHumongous(), "this is only for non-humongous regions");
6149   assert(!hr->is_empty(), "the region should not be empty");
6150   assert(free_list != NULL, "pre-condition");
6151 
6152   if (G1VerifyBitmaps) {
6153     MemRegion mr(hr->bottom(), hr->end());
6154     concurrent_mark()->clearRangePrevBitmap(mr);
6155   }
6156 
6157   // Clear the card counts for this region.
6158   // Note: we only need to do this if the region is not young
6159   // (since we don't refine cards in young regions).
6160   if (!hr->is_young()) {




5453  public:
5454   G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue) : AbstractGangTask("Redirty Cards"), _queue(queue) { }
5455 
5456   virtual void work(uint worker_id) {
5457     double start_time = os::elapsedTime();
5458 
5459     RedirtyLoggedCardTableEntryClosure cl;
5460     if (G1CollectedHeap::heap()->use_parallel_gc_threads()) {
5461       _queue->par_apply_closure_to_all_completed_buffers(&cl);
5462     } else {
5463       _queue->apply_closure_to_all_completed_buffers(&cl);
5464     }
5465 
5466     G1GCPhaseTimes* timer = G1CollectedHeap::heap()->g1_policy()->phase_times();
5467     timer->record_redirty_logged_cards_time_ms(worker_id, (os::elapsedTime() - start_time) * 1000.0);
5468     timer->record_redirty_logged_cards_processed_cards(worker_id, cl.num_processed());
5469   }
5470 };
5471 
5472 void G1CollectedHeap::redirty_logged_cards() {



5473   uint n_workers = (G1CollectedHeap::use_parallel_gc_threads() ?
5474                    _g1h->workers()->active_workers() : 1);
5475   if (!G1DeferredRSUpdate) {
5476     G1GCPhaseTimes* timer = g1_policy()->phase_times();
5477 
5478     for (uint i = 0; i < n_workers; i++) {
5479       timer->record_redirty_logged_cards_time_ms(i, 0.0);
5480       timer->record_redirty_logged_cards_processed_cards(i, 0);
5481     }
5482 
5483     timer->record_redirty_logged_cards_time_ms(0.0);
5484     return;
5485   }
5486   double redirty_logged_cards_start = os::elapsedTime();
5487 
5488   G1RedirtyLoggedCardsTask redirty_task(&dirty_card_queue_set());
5489   dirty_card_queue_set().reset_for_par_iteration();
5490   if (use_parallel_gc_threads()) {
5491     set_par_threads(n_workers);
5492     workers()->run_task(&redirty_task);
5493     set_par_threads(0);
5494   } else {
5495     redirty_task.work(0);
5496   }
5497 
5498   DirtyCardQueueSet& dcq = JavaThread::dirty_card_queue_set();
5499   dcq.merge_bufferlists(&dirty_card_queue_set());
5500   assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed");
5501 
5502   g1_policy()->phase_times()->record_redirty_logged_cards_time_ms((os::elapsedTime() - redirty_logged_cards_start) * 1000.0);
5503 }
5504 
5505 // Weak Reference Processing support
5506 


6127   finalize_for_evac_failure();
6128 
6129   if (evacuation_failed()) {
6130     remove_self_forwarding_pointers();
6131 
6132     // Reset the G1EvacuationFailureALot counters and flags
6133     // Note: the values are reset only when an actual
6134     // evacuation failure occurs.
6135     NOT_PRODUCT(reset_evacuation_should_fail();)
6136   }
6137 
6138   // Enqueue any remaining references remaining on the STW
6139   // reference processor's discovered lists. We need to do
6140   // this after the card table is cleaned (and verified) as
6141   // the act of enqueueing entries on to the pending list
6142   // will log these updates (and dirty their associated
6143   // cards). We need these updates logged to update any
6144   // RSets.
6145   enqueue_discovered_references(n_workers);
6146 

6147   redirty_logged_cards();
6148 
6149   COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
6150 }
6151 
6152 void G1CollectedHeap::free_region(HeapRegion* hr,
6153                                   FreeRegionList* free_list,
6154                                   bool par,
6155                                   bool locked) {
6156   assert(!hr->isHumongous(), "this is only for non-humongous regions");
6157   assert(!hr->is_empty(), "the region should not be empty");
6158   assert(free_list != NULL, "pre-condition");
6159 
6160   if (G1VerifyBitmaps) {
6161     MemRegion mr(hr->bottom(), hr->end());
6162     concurrent_mark()->clearRangePrevBitmap(mr);
6163   }
6164 
6165   // Clear the card counts for this region.
6166   // Note: we only need to do this if the region is not young
6167   // (since we don't refine cards in young regions).
6168   if (!hr->is_young()) {