--- old/src/share/vm/gc/g1/heapRegionManager.cpp 2015-05-27 14:30:59.904169325 -0400 +++ new/src/share/vm/gc/g1/heapRegionManager.cpp 2015-05-27 14:30:59.268133082 -0400 @@ -278,6 +278,31 @@ return num_regions; } +uint HeapRegionManager::find_highest_available(bool* expanded) { + // Loop downwards from the highest region index, looking for an + // entry which is either free or not yet committed. If not yet + // committed, expand_at that index, and set the 'expanded' output + // bool result to true. + uint curr = max_length() - 1; + while (curr != 0) { + HeapRegion *hr = _regions.get_by_index(curr); + if (hr == NULL) { + uint res = expand_at(curr, 1); + if (res == 1) { + *expanded = true; + return curr; + } + } else { + if (hr->is_free()) { + *expanded = false; + return curr; + } + } + curr--; + } + return G1_NO_HRM_INDEX; +} + void HeapRegionManager::par_iterate(HeapRegionClosure* blk, uint worker_id, HeapRegionClaimer* hrclaimer, bool concurrent) const { const uint start_index = hrclaimer->start_region_for_worker(worker_id); @@ -436,7 +461,7 @@ num_committed++; HeapRegion* hr = _regions.get_by_index(i); guarantee(hr != NULL, err_msg("invariant: i: %u", i)); - guarantee(!prev_committed || hr->bottom() == prev_end, + guarantee(!prev_committed || hr->bottom() == prev_end || hr->is_archive(), err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT, i, HR_FORMAT_PARAMS(hr), p2i(prev_end))); guarantee(hr->hrm_index() == i,