< prev index next >

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

Print this page
rev 51979 : imported patch 8071913-almost-done
rev 51980 : [mq]: 8071913-alternate


 734   _coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1),
 735   _fine_cur_prt(NULL),
 736   _cur_card_in_prt(HeapRegion::CardsPerRegion),
 737   _sparse_iter(&hrrs->_other_regions._sparse_table) {}
 738 
 739 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
 740   if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
 741   // Go to the next card.
 742   _coarse_cur_region_cur_card++;
 743   // Was the last the last card in the current region?
 744   if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) {
 745     // Yes: find the next region.  This may leave _coarse_cur_region_index
 746     // Set to the last index, in which case there are no more coarse
 747     // regions.
 748     _coarse_cur_region_index =
 749       (int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1);
 750     if ((size_t)_coarse_cur_region_index < _coarse_map->size()) {
 751       _coarse_cur_region_cur_card = 0;
 752       HeapWord* r_bot =
 753         _g1h->region_at((uint) _coarse_cur_region_index)->bottom();
 754       _cur_region_card_offset = _bot->index_for(r_bot);
 755     } else {
 756       return false;
 757     }
 758   }
 759   // If we didn't return false above, then we can yield a card.
 760   card_index = _cur_region_card_offset + _coarse_cur_region_cur_card;
 761   return true;
 762 }
 763 
 764 bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) {
 765   if (fine_has_next()) {
 766     _cur_card_in_prt =
 767       _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1);
 768   }
 769   if (_cur_card_in_prt == HeapRegion::CardsPerRegion) {
 770     // _fine_cur_prt may still be NULL in case if there are not PRTs at all for
 771     // the remembered set.
 772     if (_fine_cur_prt == NULL || _fine_cur_prt->next() == NULL) {
 773       return false;
 774     }
 775     PerRegionTable* next_prt = _fine_cur_prt->next();
 776     switch_to_prt(next_prt);
 777     _cur_card_in_prt = _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1);
 778   }
 779 
 780   card_index = _cur_region_card_offset + _cur_card_in_prt;
 781   guarantee(_cur_card_in_prt < HeapRegion::CardsPerRegion,
 782             "Card index " SIZE_FORMAT " must be within the region", _cur_card_in_prt);
 783   return true;
 784 }
 785 
 786 bool HeapRegionRemSetIterator::fine_has_next() {
 787   return _cur_card_in_prt != HeapRegion::CardsPerRegion;
 788 }
 789 
 790 void HeapRegionRemSetIterator::switch_to_prt(PerRegionTable* prt) {
 791   assert(prt != NULL, "Cannot switch to NULL prt");
 792   _fine_cur_prt = prt;
 793 
 794   HeapWord* r_bot = _fine_cur_prt->hr()->bottom();
 795   _cur_region_card_offset = _bot->index_for(r_bot);
 796 
 797   // The bitmap scan for the PRT always scans from _cur_region_cur_card + 1.
 798   // To avoid special-casing this start case, and not miss the first bitmap
 799   // entry, initialize _cur_region_cur_card with -1 instead of 0.
 800   _cur_card_in_prt = (size_t)-1;
 801 }
 802 
 803 bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
 804   switch (_is) {
 805   case Sparse: {
 806     if (_sparse_iter.has_next(card_index)) {
 807       _n_yielded_sparse++;
 808       return true;
 809     }
 810     // Otherwise, deliberate fall-through
 811     _is = Fine;
 812     PerRegionTable* initial_fine_prt = _hrrs->_other_regions._first_all_fine_prts;
 813     if (initial_fine_prt != NULL) {
 814       switch_to_prt(_hrrs->_other_regions._first_all_fine_prts);
 815     }




 734   _coarse_cur_region_cur_card(HeapRegion::CardsPerRegion-1),
 735   _fine_cur_prt(NULL),
 736   _cur_card_in_prt(HeapRegion::CardsPerRegion),
 737   _sparse_iter(&hrrs->_other_regions._sparse_table) {}
 738 
 739 bool HeapRegionRemSetIterator::coarse_has_next(size_t& card_index) {
 740   if (_hrrs->_other_regions._n_coarse_entries == 0) return false;
 741   // Go to the next card.
 742   _coarse_cur_region_cur_card++;
 743   // Was the last the last card in the current region?
 744   if (_coarse_cur_region_cur_card == HeapRegion::CardsPerRegion) {
 745     // Yes: find the next region.  This may leave _coarse_cur_region_index
 746     // Set to the last index, in which case there are no more coarse
 747     // regions.
 748     _coarse_cur_region_index =
 749       (int) _coarse_map->get_next_one_offset(_coarse_cur_region_index + 1);
 750     if ((size_t)_coarse_cur_region_index < _coarse_map->size()) {
 751       _coarse_cur_region_cur_card = 0;
 752       HeapWord* r_bot =
 753         _g1h->region_at((uint) _coarse_cur_region_index)->bottom();
 754       _cur_region_card_offset = _bot->index_for_raw(r_bot);
 755     } else {
 756       return false;
 757     }
 758   }
 759   // If we didn't return false above, then we can yield a card.
 760   card_index = _cur_region_card_offset + _coarse_cur_region_cur_card;
 761   return true;
 762 }
 763 
 764 bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) {
 765   if (fine_has_next()) {
 766     _cur_card_in_prt =
 767       _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1);
 768   }
 769   if (_cur_card_in_prt == HeapRegion::CardsPerRegion) {
 770     // _fine_cur_prt may still be NULL in case if there are not PRTs at all for
 771     // the remembered set.
 772     if (_fine_cur_prt == NULL || _fine_cur_prt->next() == NULL) {
 773       return false;
 774     }
 775     PerRegionTable* next_prt = _fine_cur_prt->next();
 776     switch_to_prt(next_prt);
 777     _cur_card_in_prt = _fine_cur_prt->_bm.get_next_one_offset(_cur_card_in_prt + 1);
 778   }
 779 
 780   card_index = _cur_region_card_offset + _cur_card_in_prt;
 781   guarantee(_cur_card_in_prt < HeapRegion::CardsPerRegion,
 782             "Card index " SIZE_FORMAT " must be within the region", _cur_card_in_prt);
 783   return true;
 784 }
 785 
 786 bool HeapRegionRemSetIterator::fine_has_next() {
 787   return _cur_card_in_prt != HeapRegion::CardsPerRegion;
 788 }
 789 
 790 void HeapRegionRemSetIterator::switch_to_prt(PerRegionTable* prt) {
 791   assert(prt != NULL, "Cannot switch to NULL prt");
 792   _fine_cur_prt = prt;
 793 
 794   HeapWord* r_bot = _fine_cur_prt->hr()->bottom();
 795   _cur_region_card_offset = _bot->index_for_raw(r_bot);
 796 
 797   // The bitmap scan for the PRT always scans from _cur_region_cur_card + 1.
 798   // To avoid special-casing this start case, and not miss the first bitmap
 799   // entry, initialize _cur_region_cur_card with -1 instead of 0.
 800   _cur_card_in_prt = (size_t)-1;
 801 }
 802 
 803 bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
 804   switch (_is) {
 805   case Sparse: {
 806     if (_sparse_iter.has_next(card_index)) {
 807       _n_yielded_sparse++;
 808       return true;
 809     }
 810     // Otherwise, deliberate fall-through
 811     _is = Fine;
 812     PerRegionTable* initial_fine_prt = _hrrs->_other_regions._first_all_fine_prts;
 813     if (initial_fine_prt != NULL) {
 814       switch_to_prt(_hrrs->_other_regions._first_all_fine_prts);
 815     }


< prev index next >