< prev index next >

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

Print this page




 303     cur++;
 304   }
 305   num_regions = cur - *res_idx;
 306 #ifdef ASSERT
 307   for (uint i = *res_idx; i < (*res_idx + num_regions); i++) {
 308     assert(!is_available(i), "just checking");
 309   }
 310   assert(cur == max_length() || num_regions == 0 || is_available(cur),
 311          "The region at the current position %u must be available or at the end of the heap.", cur);
 312 #endif
 313   return num_regions;
 314 }
 315 
 316 uint HeapRegionManager::find_highest_free(bool* expanded) {
 317   // Loop downwards from the highest region index, looking for an
 318   // entry which is either free or not yet committed.  If not yet
 319   // committed, expand_at that index.
 320   uint curr = max_length() - 1;
 321   while (true) {
 322     HeapRegion *hr = _regions.get_by_index(curr);
 323     if (hr == NULL) {
 324       uint res = expand_at(curr, 1, NULL);
 325       if (res == 1) {
 326         *expanded = true;
 327         return curr;
 328       }
 329     } else {
 330       if (hr->is_free()) {
 331         *expanded = false;
 332         return curr;
 333       }
 334     }
 335     if (curr == 0) {
 336       return G1_NO_HRM_INDEX;
 337     }
 338     curr--;
 339   }
 340 }
 341 
 342 bool HeapRegionManager::allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers) {
 343   size_t commits = 0;




 303     cur++;
 304   }
 305   num_regions = cur - *res_idx;
 306 #ifdef ASSERT
 307   for (uint i = *res_idx; i < (*res_idx + num_regions); i++) {
 308     assert(!is_available(i), "just checking");
 309   }
 310   assert(cur == max_length() || num_regions == 0 || is_available(cur),
 311          "The region at the current position %u must be available or at the end of the heap.", cur);
 312 #endif
 313   return num_regions;
 314 }
 315 
 316 uint HeapRegionManager::find_highest_free(bool* expanded) {
 317   // Loop downwards from the highest region index, looking for an
 318   // entry which is either free or not yet committed.  If not yet
 319   // committed, expand_at that index.
 320   uint curr = max_length() - 1;
 321   while (true) {
 322     HeapRegion *hr = _regions.get_by_index(curr);
 323     if (hr == NULL || !is_available(curr)) {
 324       uint res = expand_at(curr, 1, NULL);
 325       if (res == 1) {
 326         *expanded = true;
 327         return curr;
 328       }
 329     } else {
 330       if (hr->is_free()) {
 331         *expanded = false;
 332         return curr;
 333       }
 334     }
 335     if (curr == 0) {
 336       return G1_NO_HRM_INDEX;
 337     }
 338     curr--;
 339   }
 340 }
 341 
 342 bool HeapRegionManager::allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers) {
 343   size_t commits = 0;


< prev index next >