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

Print this page




 200     return found;
 201   } else {
 202     return G1_NO_HRS_INDEX;
 203   }
 204 }
 205 
 206 HeapRegion* HeapRegionSeq::next_region_in_heap(const HeapRegion* r) const {
 207   guarantee(r != NULL, "Start region must be a valid region");
 208   guarantee(is_available(r->hrs_index()), err_msg("Trying to iterate starting from region %u which is not in the heap", r->hrs_index()));
 209   for (uint i = r->hrs_index() + 1; i < _allocated_heapregions_length; i++) {
 210     HeapRegion* hr = _regions.get_by_index(i);
 211     if (is_available(i)) {
 212       return hr;
 213     }
 214   }
 215   return NULL;
 216 }
 217 
 218 void HeapRegionSeq::iterate(HeapRegionClosure* blk) const {
 219   uint len = max_length();


 220 
 221   for (uint i = 0; i < len; i++) {


 222     if (!is_available(i)) {
 223       continue;
 224     }
 225     guarantee(at(i) != NULL, err_msg("Tried to access region %u that has a NULL HeapRegion*", i));
 226     bool res = blk->doHeapRegion(at(i));
 227     if (res) {
 228       blk->incomplete();
 229       return;
 230     }
 231   }
 232 }
 233 
 234 uint HeapRegionSeq::find_unavailable_from_idx(uint start_idx, uint* res_idx) const {
 235   guarantee(res_idx != NULL, "checking");
 236   guarantee(start_idx <= (max_length() + 1), "checking");
 237 
 238   uint num_regions = 0;
 239 
 240   uint cur = start_idx;
 241   while (cur < max_length() && is_available(cur)) {




 200     return found;
 201   } else {
 202     return G1_NO_HRS_INDEX;
 203   }
 204 }
 205 
 206 HeapRegion* HeapRegionSeq::next_region_in_heap(const HeapRegion* r) const {
 207   guarantee(r != NULL, "Start region must be a valid region");
 208   guarantee(is_available(r->hrs_index()), err_msg("Trying to iterate starting from region %u which is not in the heap", r->hrs_index()));
 209   for (uint i = r->hrs_index() + 1; i < _allocated_heapregions_length; i++) {
 210     HeapRegion* hr = _regions.get_by_index(i);
 211     if (is_available(i)) {
 212       return hr;
 213     }
 214   }
 215   return NULL;
 216 }
 217 
 218 void HeapRegionSeq::iterate(HeapRegionClosure* blk) const {
 219   uint len = max_length();
 220   iterate_range(blk, 0, len);
 221 }
 222 
 223 void HeapRegionSeq::iterate_range(HeapRegionClosure* blk, uint start, uint end) const {
 224   assert(start <= end && end <= max_length(), "Invalid range.");
 225   for (uint i = start; i < end; i++) {
 226     if (!is_available(i)) {
 227       continue;
 228     }
 229     guarantee(at(i) != NULL, err_msg("Tried to access region %u that has a NULL HeapRegion*", i));
 230     bool res = blk->doHeapRegion(at(i));
 231     if (res) {
 232       blk->incomplete();
 233       return;
 234     }
 235   }
 236 }
 237 
 238 uint HeapRegionSeq::find_unavailable_from_idx(uint start_idx, uint* res_idx) const {
 239   guarantee(res_idx != NULL, "checking");
 240   guarantee(start_idx <= (max_length() + 1), "checking");
 241 
 242   uint num_regions = 0;
 243 
 244   uint cur = start_idx;
 245   while (cur < max_length() && is_available(cur)) {