src/hotspot/share/gc/g1/heapRegionRemSet.cpp
changeset 51332 c25572739e7c
parent 49806 2d62570a615c
child 52345 418fb8bb5151
equal deleted inserted replaced
51331:7939b3c4e408 51332:c25572739e7c
    66   // We need access in order to union things into the base table.
    66   // We need access in order to union things into the base table.
    67   BitMap* bm() { return &_bm; }
    67   BitMap* bm() { return &_bm; }
    68 
    68 
    69   PerRegionTable(HeapRegion* hr) :
    69   PerRegionTable(HeapRegion* hr) :
    70     _hr(hr),
    70     _hr(hr),
       
    71     _bm(HeapRegion::CardsPerRegion, mtGC),
    71     _occupied(0),
    72     _occupied(0),
    72     _bm(HeapRegion::CardsPerRegion, mtGC),
    73     _next(NULL), _prev(NULL),
    73     _collision_list_next(NULL), _next(NULL), _prev(NULL)
    74     _collision_list_next(NULL)
    74   {}
    75   {}
    75 
    76 
    76   void add_card_work(CardIdx_t from_card, bool par) {
    77   void add_card_work(CardIdx_t from_card, bool par) {
    77     if (!_bm.at(from_card)) {
    78     if (!_bm.at(from_card)) {
    78       if (par) {
    79       if (par) {
   238 size_t OtherRegionsTable::_fine_eviction_stride = 0;
   239 size_t OtherRegionsTable::_fine_eviction_stride = 0;
   239 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
   240 size_t OtherRegionsTable::_fine_eviction_sample_size = 0;
   240 
   241 
   241 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
   242 OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) :
   242   _g1h(G1CollectedHeap::heap()),
   243   _g1h(G1CollectedHeap::heap()),
   243   _hr(hr), _m(m),
   244   _m(m),
       
   245   _hr(hr),
   244   _coarse_map(G1CollectedHeap::heap()->max_regions(), mtGC),
   246   _coarse_map(G1CollectedHeap::heap()->max_regions(), mtGC),
       
   247   _n_coarse_entries(0),
   245   _fine_grain_regions(NULL),
   248   _fine_grain_regions(NULL),
   246   _first_all_fine_prts(NULL), _last_all_fine_prts(NULL),
   249   _n_fine_entries(0),
   247   _n_fine_entries(0), _n_coarse_entries(0),
   250   _first_all_fine_prts(NULL),
       
   251   _last_all_fine_prts(NULL),
   248   _fine_eviction_start(0),
   252   _fine_eviction_start(0),
   249   _sparse_table(hr)
   253   _sparse_table(hr)
   250 {
   254 {
   251   typedef PerRegionTable* PerRegionTablePtr;
   255   typedef PerRegionTable* PerRegionTablePtr;
   252 
   256 
   619 }
   623 }
   620 
   624 
   621 HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot,
   625 HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot,
   622                                    HeapRegion* hr)
   626                                    HeapRegion* hr)
   623   : _bot(bot),
   627   : _bot(bot),
       
   628     _code_roots(),
   624     _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never),
   629     _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never),
   625     _code_roots(),
   630     _other_regions(hr, &_m),
   626     _state(Untracked),
   631     _state(Untracked)
   627     _other_regions(hr, &_m) {
   632 {
   628 }
   633 }
   629 
   634 
   630 void HeapRegionRemSet::setup_remset_size() {
   635 void HeapRegionRemSet::setup_remset_size() {
   631   // Setup sparse and fine-grain tables sizes.
   636   // Setup sparse and fine-grain tables sizes.
   632   // table_size = base * (log(region_size / 1M) + 1)
   637   // table_size = base * (log(region_size / 1M) + 1)
   714   return _code_roots.mem_size();
   719   return _code_roots.mem_size();
   715 }
   720 }
   716 
   721 
   717 HeapRegionRemSetIterator:: HeapRegionRemSetIterator(HeapRegionRemSet* hrrs) :
   722 HeapRegionRemSetIterator:: HeapRegionRemSetIterator(HeapRegionRemSet* hrrs) :
   718   _hrrs(hrrs),
   723   _hrrs(hrrs),
   719   _g1h(G1CollectedHeap::heap()),
       
   720   _coarse_map(&hrrs->_other_regions._coarse_map),
   724   _coarse_map(&hrrs->_other_regions._coarse_map),
   721   _bot(hrrs->_bot),
   725   _bot(hrrs->_bot),
       
   726   _g1h(G1CollectedHeap::heap()),
       
   727   _n_yielded_fine(0),
       
   728   _n_yielded_coarse(0),
       
   729   _n_yielded_sparse(0),
   722   _is(Sparse),
   730   _is(Sparse),
       
   731   _cur_region_card_offset(0),
   723   // Set these values so that we increment to the first region.
   732   // Set these values so that we increment to the first region.
   724   _coarse_cur_region_index(-1),
   733   _coarse_cur_region_index(-1),
   725   _coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1),
   734   _coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1),
       
   735   _fine_cur_prt(NULL),
   726   _cur_card_in_prt(HeapRegion::CardsPerRegion),
   736   _cur_card_in_prt(HeapRegion::CardsPerRegion),
   727   _fine_cur_prt(NULL),
       
   728   _n_yielded_coarse(0),
       
   729   _n_yielded_fine(0),
       
   730   _n_yielded_sparse(0),
       
   731   _sparse_iter(&hrrs->_other_regions._sparse_table) {}
   737   _sparse_iter(&hrrs->_other_regions._sparse_table) {}
   732 
   738 
   733 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
   739 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
   734   if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
   740   if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
   735   // Go to the next card.
   741   // Go to the next card.