hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
changeset 17854 d65bc1546091
parent 17327 4bd0581aa231
child 17855 9d0719d7bb85
equal deleted inserted replaced
17853:54b0245a5aa8 17854:d65bc1546091
    32 #include "gc_implementation/g1/g1HotCardCache.hpp"
    32 #include "gc_implementation/g1/g1HotCardCache.hpp"
    33 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
    33 #include "gc_implementation/g1/g1GCPhaseTimes.hpp"
    34 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
    34 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
    35 #include "gc_implementation/g1/g1RemSet.inline.hpp"
    35 #include "gc_implementation/g1/g1RemSet.inline.hpp"
    36 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
    36 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
       
    37 #include "gc_implementation/g1/heapRegionRemSet.hpp"
    37 #include "memory/iterator.hpp"
    38 #include "memory/iterator.hpp"
    38 #include "oops/oop.inline.hpp"
    39 #include "oops/oop.inline.hpp"
    39 #include "utilities/intHisto.hpp"
    40 #include "utilities/intHisto.hpp"
    40 
    41 
    41 #define CARD_REPEAT_HISTO 0
    42 #define CARD_REPEAT_HISTO 0
    71 G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs)
    72 G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs)
    72   : _g1(g1), _conc_refine_cards(0),
    73   : _g1(g1), _conc_refine_cards(0),
    73     _ct_bs(ct_bs), _g1p(_g1->g1_policy()),
    74     _ct_bs(ct_bs), _g1p(_g1->g1_policy()),
    74     _cg1r(g1->concurrent_g1_refine()),
    75     _cg1r(g1->concurrent_g1_refine()),
    75     _cset_rs_update_cl(NULL),
    76     _cset_rs_update_cl(NULL),
    76     _cards_scanned(NULL), _total_cards_scanned(0)
    77     _cards_scanned(NULL), _total_cards_scanned(0),
       
    78     _prev_period_summary()
    77 {
    79 {
    78   _seq_task = new SubTasksDone(NumSeqTasks);
    80   _seq_task = new SubTasksDone(NumSeqTasks);
    79   guarantee(n_workers() > 0, "There should be some workers");
    81   guarantee(n_workers() > 0, "There should be some workers");
    80   _cset_rs_update_cl = NEW_C_HEAP_ARRAY(OopsInHeapRegionClosure*, n_workers(), mtGC);
    82   _cset_rs_update_cl = NEW_C_HEAP_ARRAY(OopsInHeapRegionClosure*, n_workers(), mtGC);
    81   for (uint i = 0; i < n_workers(); i++) {
    83   for (uint i = 0; i < n_workers(); i++) {
    82     _cset_rs_update_cl[i] = NULL;
    84     _cset_rs_update_cl[i] = NULL;
    83   }
    85   }
       
    86   _prev_period_summary.initialize(this, n_workers());
    84 }
    87 }
    85 
    88 
    86 G1RemSet::~G1RemSet() {
    89 G1RemSet::~G1RemSet() {
    87   delete _seq_task;
    90   delete _seq_task;
    88   for (uint i = 0; i < n_workers(); i++) {
    91   for (uint i = 0; i < n_workers(); i++) {
   695            "invalid result at non safepoint");
   698            "invalid result at non safepoint");
   696 
   699 
   697   return has_refs_into_cset;
   700   return has_refs_into_cset;
   698 }
   701 }
   699 
   702 
   700 class HRRSStatsIter: public HeapRegionClosure {
   703 void G1RemSet::print_periodic_summary_info() {
   701   size_t _occupied;
   704   G1RemSetSummary current;
   702   size_t _total_mem_sz;
   705   current.initialize(this, n_workers());
   703   size_t _max_mem_sz;
   706 
   704   HeapRegion* _max_mem_sz_region;
   707   _prev_period_summary.subtract_from(&current);
   705 public:
   708   print_summary_info(&_prev_period_summary);
   706   HRRSStatsIter() :
   709 
   707     _occupied(0),
   710   _prev_period_summary.set(&current);
   708     _total_mem_sz(0),
   711 }
   709     _max_mem_sz(0),
       
   710     _max_mem_sz_region(NULL)
       
   711   {}
       
   712 
       
   713   bool doHeapRegion(HeapRegion* r) {
       
   714     if (r->continuesHumongous()) return false;
       
   715     size_t mem_sz = r->rem_set()->mem_size();
       
   716     if (mem_sz > _max_mem_sz) {
       
   717       _max_mem_sz = mem_sz;
       
   718       _max_mem_sz_region = r;
       
   719     }
       
   720     _total_mem_sz += mem_sz;
       
   721     size_t occ = r->rem_set()->occupied();
       
   722     _occupied += occ;
       
   723     return false;
       
   724   }
       
   725   size_t total_mem_sz() { return _total_mem_sz; }
       
   726   size_t max_mem_sz() { return _max_mem_sz; }
       
   727   size_t occupied() { return _occupied; }
       
   728   HeapRegion* max_mem_sz_region() { return _max_mem_sz_region; }
       
   729 };
       
   730 
       
   731 class PrintRSThreadVTimeClosure : public ThreadClosure {
       
   732 public:
       
   733   virtual void do_thread(Thread *t) {
       
   734     ConcurrentG1RefineThread* crt = (ConcurrentG1RefineThread*) t;
       
   735     gclog_or_tty->print("    %5.2f", crt->vtime_accum());
       
   736   }
       
   737 };
       
   738 
   712 
   739 void G1RemSet::print_summary_info() {
   713 void G1RemSet::print_summary_info() {
   740   G1CollectedHeap* g1 = G1CollectedHeap::heap();
   714   G1RemSetSummary current;
       
   715   current.initialize(this, n_workers());
       
   716 
       
   717   print_summary_info(&current, " Cumulative RS summary");
       
   718 }
       
   719 
       
   720 void G1RemSet::print_summary_info(G1RemSetSummary * summary, const char * header) {
       
   721   assert(summary != NULL, "just checking");
       
   722 
       
   723   if (header != NULL) {
       
   724     gclog_or_tty->print_cr("%s", header);
       
   725   }
   741 
   726 
   742 #if CARD_REPEAT_HISTO
   727 #if CARD_REPEAT_HISTO
   743   gclog_or_tty->print_cr("\nG1 card_repeat count histogram: ");
   728   gclog_or_tty->print_cr("\nG1 card_repeat count histogram: ");
   744   gclog_or_tty->print_cr("  # of repeats --> # of cards with that number.");
   729   gclog_or_tty->print_cr("  # of repeats --> # of cards with that number.");
   745   card_repeat_count.print_on(gclog_or_tty);
   730   card_repeat_count.print_on(gclog_or_tty);
   746 #endif
   731 #endif
   747 
   732 
   748   gclog_or_tty->print_cr("\n Concurrent RS processed %d cards",
   733   summary->print_on(gclog_or_tty);
   749                          _conc_refine_cards);
       
   750   DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
       
   751   jint tot_processed_buffers =
       
   752     dcqs.processed_buffers_mut() + dcqs.processed_buffers_rs_thread();
       
   753   gclog_or_tty->print_cr("  Of %d completed buffers:", tot_processed_buffers);
       
   754   gclog_or_tty->print_cr("     %8d (%5.1f%%) by conc RS threads.",
       
   755                 dcqs.processed_buffers_rs_thread(),
       
   756                 100.0*(float)dcqs.processed_buffers_rs_thread()/
       
   757                 (float)tot_processed_buffers);
       
   758   gclog_or_tty->print_cr("     %8d (%5.1f%%) by mutator threads.",
       
   759                 dcqs.processed_buffers_mut(),
       
   760                 100.0*(float)dcqs.processed_buffers_mut()/
       
   761                 (float)tot_processed_buffers);
       
   762   gclog_or_tty->print_cr("  Conc RS threads times(s)");
       
   763   PrintRSThreadVTimeClosure p;
       
   764   gclog_or_tty->print("     ");
       
   765   g1->concurrent_g1_refine()->threads_do(&p);
       
   766   gclog_or_tty->print_cr("");
       
   767 
       
   768   HRRSStatsIter blk;
       
   769   g1->heap_region_iterate(&blk);
       
   770   gclog_or_tty->print_cr("  Total heap region rem set sizes = "SIZE_FORMAT"K."
       
   771                          "  Max = "SIZE_FORMAT"K.",
       
   772                          blk.total_mem_sz()/K, blk.max_mem_sz()/K);
       
   773   gclog_or_tty->print_cr("  Static structures = "SIZE_FORMAT"K,"
       
   774                          " free_lists = "SIZE_FORMAT"K.",
       
   775                          HeapRegionRemSet::static_mem_size() / K,
       
   776                          HeapRegionRemSet::fl_mem_size() / K);
       
   777   gclog_or_tty->print_cr("    "SIZE_FORMAT" occupied cards represented.",
       
   778                          blk.occupied());
       
   779   HeapRegion* max_mem_sz_region = blk.max_mem_sz_region();
       
   780   HeapRegionRemSet* rem_set = max_mem_sz_region->rem_set();
       
   781   gclog_or_tty->print_cr("    Max size region = "HR_FORMAT", "
       
   782                          "size = "SIZE_FORMAT "K, occupied = "SIZE_FORMAT"K.",
       
   783                          HR_FORMAT_PARAMS(max_mem_sz_region),
       
   784                          (rem_set->mem_size() + K - 1)/K,
       
   785                          (rem_set->occupied() + K - 1)/K);
       
   786   gclog_or_tty->print_cr("    Did %d coarsenings.",
       
   787                          HeapRegionRemSet::n_coarsenings());
       
   788 }
   734 }
   789 
   735 
   790 void G1RemSet::prepare_for_verify() {
   736 void G1RemSet::prepare_for_verify() {
   791   if (G1HRRSFlushLogBuffersOnVerify &&
   737   if (G1HRRSFlushLogBuffersOnVerify &&
   792       (VerifyBeforeGC || VerifyAfterGC)
   738       (VerifyBeforeGC || VerifyAfterGC)