src/hotspot/share/gc/shared/cardTableRS.cpp
changeset 49733 6f0a3ea5ab75
parent 49592 77fb0be7d19f
child 49982 9042ffe5b7fe
equal deleted inserted replaced
49732:c09da96f609e 49733:6f0a3ea5ab75
   277 }
   277 }
   278 
   278 
   279 void CardTableRS::younger_refs_in_space_iterate(Space* sp,
   279 void CardTableRS::younger_refs_in_space_iterate(Space* sp,
   280                                                 OopsInGenClosure* cl,
   280                                                 OopsInGenClosure* cl,
   281                                                 uint n_threads) {
   281                                                 uint n_threads) {
       
   282   verify_used_region_at_save_marks(sp);
       
   283 
   282   const MemRegion urasm = sp->used_region_at_save_marks();
   284   const MemRegion urasm = sp->used_region_at_save_marks();
       
   285   non_clean_card_iterate_possibly_parallel(sp, urasm, cl, this, n_threads);
       
   286 }
       
   287 
   283 #ifdef ASSERT
   288 #ifdef ASSERT
   284   // Convert the assertion check to a warning if we are running
   289 void CardTableRS::verify_used_region_at_save_marks(Space* sp) const {
   285   // CMS+ParNew until related bug is fixed.
       
   286   MemRegion ur    = sp->used_region();
   290   MemRegion ur    = sp->used_region();
   287   assert(ur.contains(urasm) || (UseConcMarkSweepGC),
   291   MemRegion urasm = sp->used_region_at_save_marks();
       
   292 
       
   293   assert(ur.contains(urasm),
   288          "Did you forget to call save_marks()? "
   294          "Did you forget to call save_marks()? "
   289          "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in "
   295          "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in "
   290          "[" PTR_FORMAT ", " PTR_FORMAT ")",
   296          "[" PTR_FORMAT ", " PTR_FORMAT ")",
   291          p2i(urasm.start()), p2i(urasm.end()), p2i(ur.start()), p2i(ur.end()));
   297          p2i(urasm.start()), p2i(urasm.end()), p2i(ur.start()), p2i(ur.end()));
   292   // In the case of CMS+ParNew, issue a warning
   298 }
   293   if (!ur.contains(urasm)) {
       
   294     assert(UseConcMarkSweepGC, "Tautology: see assert above");
       
   295     log_warning(gc)("CMS+ParNew: Did you forget to call save_marks()? "
       
   296                     "[" PTR_FORMAT ", " PTR_FORMAT ") is not contained in "
       
   297                     "[" PTR_FORMAT ", " PTR_FORMAT ")",
       
   298                     p2i(urasm.start()), p2i(urasm.end()), p2i(ur.start()), p2i(ur.end()));
       
   299     MemRegion ur2 = sp->used_region();
       
   300     MemRegion urasm2 = sp->used_region_at_save_marks();
       
   301     if (!ur.equals(ur2)) {
       
   302       log_warning(gc)("CMS+ParNew: Flickering used_region()!!");
       
   303     }
       
   304     if (!urasm.equals(urasm2)) {
       
   305       log_warning(gc)("CMS+ParNew: Flickering used_region_at_save_marks()!!");
       
   306     }
       
   307     ShouldNotReachHere();
       
   308   }
       
   309 #endif
   299 #endif
   310   non_clean_card_iterate_possibly_parallel(sp, urasm, cl, this, n_threads);
       
   311 }
       
   312 
   300 
   313 void CardTableRS::clear_into_younger(Generation* old_gen) {
   301 void CardTableRS::clear_into_younger(Generation* old_gen) {
   314   assert(GenCollectedHeap::heap()->is_old_gen(old_gen),
   302   assert(GenCollectedHeap::heap()->is_old_gen(old_gen),
   315          "Should only be called for the old generation");
   303          "Should only be called for the old generation");
   316   // The card tables for the youngest gen need never be cleared.
   304   // The card tables for the youngest gen need never be cleared.
   609   VerifyCTGenClosure blk(this);
   597   VerifyCTGenClosure blk(this);
   610   GenCollectedHeap::heap()->generation_iterate(&blk, false);
   598   GenCollectedHeap::heap()->generation_iterate(&blk, false);
   611   CardTable::verify();
   599   CardTable::verify();
   612 }
   600 }
   613 
   601 
   614 CardTableRS::CardTableRS(MemRegion whole_heap) :
   602 CardTableRS::CardTableRS(MemRegion whole_heap, bool scanned_concurrently) :
   615   CardTable(whole_heap, /* scanned concurrently */ UseConcMarkSweepGC && CMSPrecleaningEnabled),
   603   CardTable(whole_heap, scanned_concurrently),
   616   _cur_youngergen_card_val(youngergenP1_card),
   604   _cur_youngergen_card_val(youngergenP1_card),
   617   // LNC functionality
   605   // LNC functionality
   618   _lowest_non_clean(NULL),
   606   _lowest_non_clean(NULL),
   619   _lowest_non_clean_chunk_size(NULL),
   607   _lowest_non_clean_chunk_size(NULL),
   620   _lowest_non_clean_base_chunk_index(NULL),
   608   _lowest_non_clean_base_chunk_index(NULL),
   696   CardTableRS* ct,
   684   CardTableRS* ct,
   697   uint n_threads)
   685   uint n_threads)
   698 {
   686 {
   699   if (!mr.is_empty()) {
   687   if (!mr.is_empty()) {
   700     if (n_threads > 0) {
   688     if (n_threads > 0) {
   701 #if INCLUDE_ALL_GCS
       
   702       non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
   689       non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
   703 #else  // INCLUDE_ALL_GCS
       
   704       fatal("Parallel gc not supported here.");
       
   705 #endif // INCLUDE_ALL_GCS
       
   706     } else {
   690     } else {
   707       // clear_cl finds contiguous dirty ranges of cards to process and clear.
   691       // clear_cl finds contiguous dirty ranges of cards to process and clear.
   708 
   692 
   709       // This is the single-threaded version used by DefNew.
   693       // This is the single-threaded version used by DefNew.
   710       const bool parallel = false;
   694       const bool parallel = false;
   715       clear_cl.do_MemRegion(mr);
   699       clear_cl.do_MemRegion(mr);
   716     }
   700     }
   717   }
   701   }
   718 }
   702 }
   719 
   703 
       
   704 void CardTableRS::non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
       
   705                                                        OopsInGenClosure* cl, CardTableRS* ct,
       
   706                                                        uint n_threads) {
       
   707   fatal("Parallel gc not supported here.");
       
   708 }
       
   709 
   720 bool CardTableRS::is_in_young(oop obj) const {
   710 bool CardTableRS::is_in_young(oop obj) const {
   721   return GenCollectedHeap::heap()->is_in_young(obj);
   711   return GenCollectedHeap::heap()->is_in_young(obj);
   722 }
   712 }