< prev index next >
src/share/vm/gc/g1/heapRegionManager.cpp
Print this page
*** 90,100 ****
_card_counts_mapper->commit_regions(index, num_regions);
}
void HeapRegionManager::uncommit_regions(uint start, size_t num_regions) {
! guarantee(num_regions >= 1, err_msg("Need to specify at least one region to uncommit, tried to uncommit zero regions at %u", start));
guarantee(_num_committed >= num_regions, "pre-condition");
// Print before uncommitting.
if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
for (uint i = start; i < start + num_regions; i++) {
--- 90,100 ----
_card_counts_mapper->commit_regions(index, num_regions);
}
void HeapRegionManager::uncommit_regions(uint start, size_t num_regions) {
! guarantee(num_regions >= 1, "Need to specify at least one region to uncommit, tried to uncommit zero regions at %u", start);
guarantee(_num_committed >= num_regions, "pre-condition");
// Print before uncommitting.
if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
for (uint i = start; i < start + num_regions; i++) {
*** 130,140 ****
}
_available_map.par_set_range(start, start + num_regions, BitMap::unknown_range);
for (uint i = start; i < start + num_regions; i++) {
! assert(is_available(i), err_msg("Just made region %u available but is apparently not.", i));
HeapRegion* hr = at(i);
if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
G1CollectedHeap::heap()->hr_printer()->commit(hr->bottom(), hr->end());
}
HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i);
--- 130,140 ----
}
_available_map.par_set_range(start, start + num_regions, BitMap::unknown_range);
for (uint i = start; i < start + num_regions; i++) {
! assert(is_available(i), "Just made region %u available but is apparently not.", i);
HeapRegion* hr = at(i);
if (G1CollectedHeap::heap()->hr_printer()->is_active()) {
G1CollectedHeap::heap()->hr_printer()->commit(hr->bottom(), hr->end());
}
HeapWord* bottom = G1CollectedHeap::heap()->bottom_addr_for_region(i);
*** 211,232 ****
if (length_found == num) {
for (uint i = found; i < (found + num); i++) {
HeapRegion* hr = _regions.get_by_index(i);
// sanity check
guarantee((!empty_only && !is_available(i)) || (is_available(i) && hr != NULL && hr->is_empty()),
! err_msg("Found region sequence starting at " UINT32_FORMAT ", length " SIZE_FORMAT
! " that is not empty at " UINT32_FORMAT ". Hr is " PTR_FORMAT, found, num, i, p2i(hr)));
}
return found;
} else {
return G1_NO_HRM_INDEX;
}
}
HeapRegion* HeapRegionManager::next_region_in_heap(const HeapRegion* r) const {
guarantee(r != NULL, "Start region must be a valid region");
! guarantee(is_available(r->hrm_index()), err_msg("Trying to iterate starting from region %u which is not in the heap", r->hrm_index()));
for (uint i = r->hrm_index() + 1; i < _allocated_heapregions_length; i++) {
HeapRegion* hr = _regions.get_by_index(i);
if (is_available(i)) {
return hr;
}
--- 211,232 ----
if (length_found == num) {
for (uint i = found; i < (found + num); i++) {
HeapRegion* hr = _regions.get_by_index(i);
// sanity check
guarantee((!empty_only && !is_available(i)) || (is_available(i) && hr != NULL && hr->is_empty()),
! "Found region sequence starting at " UINT32_FORMAT ", length " SIZE_FORMAT
! " that is not empty at " UINT32_FORMAT ". Hr is " PTR_FORMAT, found, num, i, p2i(hr));
}
return found;
} else {
return G1_NO_HRM_INDEX;
}
}
HeapRegion* HeapRegionManager::next_region_in_heap(const HeapRegion* r) const {
guarantee(r != NULL, "Start region must be a valid region");
! guarantee(is_available(r->hrm_index()), "Trying to iterate starting from region %u which is not in the heap", r->hrm_index());
for (uint i = r->hrm_index() + 1; i < _allocated_heapregions_length; i++) {
HeapRegion* hr = _regions.get_by_index(i);
if (is_available(i)) {
return hr;
}
*** 239,249 ****
for (uint i = 0; i < len; i++) {
if (!is_available(i)) {
continue;
}
! guarantee(at(i) != NULL, err_msg("Tried to access region %u that has a NULL HeapRegion*", i));
bool res = blk->doHeapRegion(at(i));
if (res) {
blk->incomplete();
return;
}
--- 239,249 ----
for (uint i = 0; i < len; i++) {
if (!is_available(i)) {
continue;
}
! guarantee(at(i) != NULL, "Tried to access region %u that has a NULL HeapRegion*", i);
bool res = blk->doHeapRegion(at(i));
if (res) {
blk->incomplete();
return;
}
*** 271,281 ****
#ifdef ASSERT
for (uint i = *res_idx; i < (*res_idx + num_regions); i++) {
assert(!is_available(i), "just checking");
}
assert(cur == max_length() || num_regions == 0 || is_available(cur),
! err_msg("The region at the current position %u must be available or at the end of the heap.", cur));
#endif
return num_regions;
}
uint HeapRegionManager::find_highest_free(bool* expanded) {
--- 271,281 ----
#ifdef ASSERT
for (uint i = *res_idx; i < (*res_idx + num_regions); i++) {
assert(!is_available(i), "just checking");
}
assert(cur == max_length() || num_regions == 0 || is_available(cur),
! "The region at the current position %u must be available or at the end of the heap.", cur);
#endif
return num_regions;
}
uint HeapRegionManager::find_highest_free(bool* expanded) {
*** 372,383 ****
for (uint ch_index = index + 1; ch_index < index + r->region_num(); ch_index++) {
HeapRegion* chr = _regions.get_by_index(ch_index);
assert(chr->is_continues_humongous(), "Must be humongous region");
assert(chr->humongous_start_region() == r,
! err_msg("Must work on humongous continuation of the original start region "
! PTR_FORMAT ", but is " PTR_FORMAT, p2i(r), p2i(chr)));
assert(!hrclaimer->is_region_claimed(ch_index),
"Must not have been claimed yet because claiming of humongous continuation first claims the start region");
// Claim the region so no other worker tries to process the region. When a worker processes a
// starts_humongous region it may also process the associated continues_humongous regions.
--- 372,383 ----
for (uint ch_index = index + 1; ch_index < index + r->region_num(); ch_index++) {
HeapRegion* chr = _regions.get_by_index(ch_index);
assert(chr->is_continues_humongous(), "Must be humongous region");
assert(chr->humongous_start_region() == r,
! "Must work on humongous continuation of the original start region "
! PTR_FORMAT ", but is " PTR_FORMAT, p2i(r), p2i(chr));
assert(!hrclaimer->is_region_claimed(ch_index),
"Must not have been claimed yet because claiming of humongous continuation first claims the start region");
// Claim the region so no other worker tries to process the region. When a worker processes a
// starts_humongous region it may also process the associated continues_humongous regions.
*** 438,450 ****
}
void HeapRegionManager::shrink_at(uint index, size_t num_regions) {
#ifdef ASSERT
for (uint i = index; i < (index + num_regions); i++) {
! assert(is_available(i), err_msg("Expected available region at index %u", i));
! assert(at(i)->is_empty(), err_msg("Expected empty region at index %u", i));
! assert(at(i)->is_free(), err_msg("Expected free region at index %u", i));
}
#endif
uncommit_regions(index, num_regions);
}
--- 438,450 ----
}
void HeapRegionManager::shrink_at(uint index, size_t num_regions) {
#ifdef ASSERT
for (uint i = index; i < (index + num_regions); i++) {
! assert(is_available(i), "Expected available region at index %u", i);
! assert(at(i)->is_empty(), "Expected empty region at index %u", i);
! assert(at(i)->is_free(), "Expected free region at index %u", i);
}
#endif
uncommit_regions(index, num_regions);
}
*** 477,491 ****
return num_regions_found;
}
void HeapRegionManager::verify() {
guarantee(length() <= _allocated_heapregions_length,
! err_msg("invariant: _length: %u _allocated_length: %u",
! length(), _allocated_heapregions_length));
guarantee(_allocated_heapregions_length <= max_length(),
! err_msg("invariant: _allocated_length: %u _max_length: %u",
! _allocated_heapregions_length, max_length()));
bool prev_committed = true;
uint num_committed = 0;
HeapWord* prev_end = heap_bottom();
for (uint i = 0; i < _allocated_heapregions_length; i++) {
--- 477,491 ----
return num_regions_found;
}
void HeapRegionManager::verify() {
guarantee(length() <= _allocated_heapregions_length,
! "invariant: _length: %u _allocated_length: %u",
! length(), _allocated_heapregions_length);
guarantee(_allocated_heapregions_length <= max_length(),
! "invariant: _allocated_length: %u _max_length: %u",
! _allocated_heapregions_length, max_length());
bool prev_committed = true;
uint num_committed = 0;
HeapWord* prev_end = heap_bottom();
for (uint i = 0; i < _allocated_heapregions_length; i++) {
*** 493,508 ****
prev_committed = false;
continue;
}
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,
! err_msg("invariant i: %u " HR_FORMAT " prev_end: " PTR_FORMAT,
! i, HR_FORMAT_PARAMS(hr), p2i(prev_end)));
guarantee(hr->hrm_index() == i,
! err_msg("invariant: i: %u hrm_index(): %u", i, hr->hrm_index()));
// Asserts will fire if i is >= _length
HeapWord* addr = hr->bottom();
guarantee(addr_to_region(addr) == hr, "sanity");
// We cannot check whether the region is part of a particular set: at the time
// this method may be called, we have only completed allocation of the regions,
--- 493,508 ----
prev_committed = false;
continue;
}
num_committed++;
HeapRegion* hr = _regions.get_by_index(i);
! guarantee(hr != NULL, "invariant: i: %u", i);
guarantee(!prev_committed || hr->bottom() == prev_end,
! "invariant i: %u " HR_FORMAT " prev_end: " PTR_FORMAT,
! i, HR_FORMAT_PARAMS(hr), p2i(prev_end));
guarantee(hr->hrm_index() == i,
! "invariant: i: %u hrm_index(): %u", i, hr->hrm_index());
// Asserts will fire if i is >= _length
HeapWord* addr = hr->bottom();
guarantee(addr_to_region(addr) == hr, "sanity");
// We cannot check whether the region is part of a particular set: at the time
// this method may be called, we have only completed allocation of the regions,
*** 513,526 ****
} else {
prev_end = hr->end();
}
}
for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
! guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i));
}
! guarantee(num_committed == _num_committed, err_msg("Found %u committed regions, but should be %u", num_committed, _num_committed));
_free_list.verify();
}
#ifndef PRODUCT
void HeapRegionManager::verify_optional() {
--- 513,526 ----
} else {
prev_end = hr->end();
}
}
for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
! guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
}
! guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
_free_list.verify();
}
#ifndef PRODUCT
void HeapRegionManager::verify_optional() {
< prev index next >