src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
Print this page
rev 6676 : [mq]: ht-merge1
*** 205,215 ****
void YoungList::empty_list(HeapRegion* list) {
while (list != NULL) {
HeapRegion* next = list->get_next_young_region();
list->set_next_young_region(NULL);
list->uninstall_surv_rate_group();
! list->set_not_young();
list = next;
}
}
void YoungList::empty_list() {
--- 205,218 ----
void YoungList::empty_list(HeapRegion* list) {
while (list != NULL) {
HeapRegion* next = list->get_next_young_region();
list->set_next_young_region(NULL);
list->uninstall_surv_rate_group();
! // This is called before a Full GC and all the non-empty /
! // non-humongous regions at the end of the Full GC will end up as
! // old anyway.
! list->set_old();
list = next;
}
}
void YoungList::empty_list() {
*** 364,374 ****
gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
HeapRegion *curr = lists[list];
if (curr == NULL)
gclog_or_tty->print_cr(" empty");
while (curr != NULL) {
! gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT "N: "PTR_FORMAT", age: %4d",
HR_FORMAT_PARAMS(curr),
curr->prev_top_at_mark_start(),
curr->next_top_at_mark_start(),
curr->age_in_surv_rate_group_cond());
curr = curr->get_next_young_region();
--- 367,377 ----
gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
HeapRegion *curr = lists[list];
if (curr == NULL)
gclog_or_tty->print_cr(" empty");
while (curr != NULL) {
! gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT ", N: "PTR_FORMAT", age: %4d",
HR_FORMAT_PARAMS(curr),
curr->prev_top_at_mark_start(),
curr->next_top_at_mark_start(),
curr->age_in_surv_rate_group_cond());
curr = curr->get_next_young_region();
*** 798,807 ****
--- 801,811 ----
g1_policy()->record_new_heap_size(num_regions());
#ifdef ASSERT
for (uint i = first; i < first + obj_regions; ++i) {
HeapRegion* hr = region_at(i);
+ assert(hr->is_free(), "sanity");
assert(hr->is_empty(), "sanity");
assert(is_on_master_free_list(hr), "sanity");
}
#endif
_hrm.allocate_free_regions_starting_at(first, obj_regions);
*** 1225,1249 ****
private:
G1HRPrinter* _hr_printer;
public:
bool doHeapRegion(HeapRegion* hr) {
assert(!hr->is_young(), "not expecting to find young regions");
// We only generate output for non-empty regions.
- if (!hr->is_empty()) {
- if (!hr->isHumongous()) {
- _hr_printer->post_compaction(hr, G1HRPrinter::Old);
} else if (hr->startsHumongous()) {
if (hr->region_num() == 1) {
// single humongous region
_hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous);
} else {
_hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous);
}
! } else {
! assert(hr->continuesHumongous(), "only way to get here");
_hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous);
! }
}
return false;
}
PostCompactionPrinterClosure(G1HRPrinter* hr_printer)
--- 1229,1253 ----
private:
G1HRPrinter* _hr_printer;
public:
bool doHeapRegion(HeapRegion* hr) {
assert(!hr->is_young(), "not expecting to find young regions");
+ if (hr->is_free()) {
// We only generate output for non-empty regions.
} else if (hr->startsHumongous()) {
if (hr->region_num() == 1) {
// single humongous region
_hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous);
} else {
_hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous);
}
! } else if (hr->continuesHumongous()) {
_hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous);
! } else if (hr->is_old()) {
! _hr_printer->post_compaction(hr, G1HRPrinter::Old);
! } else {
! ShouldNotReachHere();
}
return false;
}
PostCompactionPrinterClosure(G1HRPrinter* hr_printer)
*** 2125,2136 ****
HeapRegion* dummy_region = _hrm.get_dummy_region();
// We'll re-use the same region whether the alloc region will
// require BOT updates or not and, if it doesn't, then a non-young
// region will complain that it cannot support allocations without
! // BOT updates. So we'll tag the dummy region as young to avoid that.
! dummy_region->set_young();
// Make sure it's full.
dummy_region->set_top(dummy_region->end());
G1AllocRegion::setup(this, dummy_region);
_allocator->init_mutator_alloc_region();
--- 2129,2140 ----
HeapRegion* dummy_region = _hrm.get_dummy_region();
// We'll re-use the same region whether the alloc region will
// require BOT updates or not and, if it doesn't, then a non-young
// region will complain that it cannot support allocations without
! // BOT updates. So we'll tag the dummy region as eden to avoid that.
! dummy_region->set_eden();
// Make sure it's full.
dummy_region->set_top(dummy_region->end());
G1AllocRegion::setup(this, dummy_region);
_allocator->init_mutator_alloc_region();
*** 4019,4036 ****
true /* verify_fingers */);
if (_hr_printer.is_active()) {
HeapRegion* hr = g1_policy()->collection_set();
while (hr != NULL) {
- G1HRPrinter::RegionType type;
- if (!hr->is_young()) {
- type = G1HRPrinter::Old;
- } else if (hr->is_survivor()) {
- type = G1HRPrinter::Survivor;
- } else {
- type = G1HRPrinter::Eden;
- }
_hr_printer.cset(hr);
hr = hr->next_in_collection_set();
}
}
--- 4023,4032 ----
*** 5946,5956 ****
void G1CollectedHeap::free_region(HeapRegion* hr,
FreeRegionList* free_list,
bool par,
bool locked) {
! assert(!hr->isHumongous(), "this is only for non-humongous regions");
assert(!hr->is_empty(), "the region should not be empty");
assert(_hrm.is_available(hr->hrm_index()), "region should be committed");
assert(free_list != NULL, "pre-condition");
if (G1VerifyBitmaps) {
--- 5942,5952 ----
void G1CollectedHeap::free_region(HeapRegion* hr,
FreeRegionList* free_list,
bool par,
bool locked) {
! assert(!hr->is_free(), "the region should not be free");
assert(!hr->is_empty(), "the region should not be empty");
assert(_hrm.is_available(hr->hrm_index()), "region should be committed");
assert(free_list != NULL, "pre-condition");
if (G1VerifyBitmaps) {
*** 5976,5993 ****
size_t hr_capacity = hr->capacity();
// We need to read this before we make the region non-humongous,
// otherwise the information will be gone.
uint last_index = hr->last_hc_index();
! hr->set_notHumongous();
free_region(hr, free_list, par);
uint i = hr->hrm_index() + 1;
while (i < last_index) {
HeapRegion* curr_hr = region_at(i);
assert(curr_hr->continuesHumongous(), "invariant");
! curr_hr->set_notHumongous();
free_region(curr_hr, free_list, par);
i += 1;
}
}
--- 5972,5989 ----
size_t hr_capacity = hr->capacity();
// We need to read this before we make the region non-humongous,
// otherwise the information will be gone.
uint last_index = hr->last_hc_index();
! hr->clear_humongous();
free_region(hr, free_list, par);
uint i = hr->hrm_index() + 1;
while (i < last_index) {
HeapRegion* curr_hr = region_at(i);
assert(curr_hr->continuesHumongous(), "invariant");
! curr_hr->clear_humongous();
free_region(curr_hr, free_list, par);
i += 1;
}
}
*** 6288,6300 ****
} else {
cur->uninstall_surv_rate_group();
if (cur->is_young()) {
cur->set_young_index_in_cset(-1);
}
- cur->set_not_young();
cur->set_evacuation_failed(false);
// The region is now considered to be old.
_old_set.add(cur);
evacuation_info.increment_collectionset_used_after(cur->used());
}
cur = next;
}
--- 6284,6296 ----
} else {
cur->uninstall_surv_rate_group();
if (cur->is_young()) {
cur->set_young_index_in_cset(-1);
}
cur->set_evacuation_failed(false);
// The region is now considered to be old.
+ cur->set_old();
_old_set.add(cur);
evacuation_info.increment_collectionset_used_after(cur->used());
}
cur = next;
}
*** 6577,6596 ****
public:
TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { }
bool doHeapRegion(HeapRegion* r) {
! if (r->is_empty()) {
! // We ignore empty regions, we'll empty the free list afterwards
! } else if (r->is_young()) {
! // We ignore young regions, we'll empty the young list afterwards
! } else if (r->isHumongous()) {
! // We ignore humongous regions, we're not tearing down the
! // humongous region set
! } else {
! // The rest should be old
_old_set->remove(r);
}
return false;
}
~TearDownRegionSetsClosure() {
--- 6573,6591 ----
public:
TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { }
bool doHeapRegion(HeapRegion* r) {
! if (r->is_old()) {
_old_set->remove(r);
+ } else {
+ // We ignore free regions, we'll empty the free list afterwards.
+ // We ignore young regions, we'll empty the young list afterwards.
+ // We ignore humongous regions, we're not tearing down the
+ // humongous regions set.
+ assert(r->is_free() || r->is_young() || r->isHumongous(),
+ "it cannot be another type");
}
return false;
}
~TearDownRegionSetsClosure() {
*** 6636,6654 ****
return false;
}
if (r->is_empty()) {
// Add free regions to the free list
r->set_allocation_context(AllocationContext::system());
_hrm->insert_into_free_list(r);
} else if (!_free_list_only) {
assert(!r->is_young(), "we should not come across young regions");
if (r->isHumongous()) {
// We ignore humongous regions, we left the humongous set unchanged
} else {
! // The rest should be old, add them to the old set
_old_set->add(r);
}
_total_used += r->used();
}
--- 6631,6654 ----
return false;
}
if (r->is_empty()) {
// Add free regions to the free list
+ r->set_free();
r->set_allocation_context(AllocationContext::system());
_hrm->insert_into_free_list(r);
} else if (!_free_list_only) {
assert(!r->is_young(), "we should not come across young regions");
if (r->isHumongous()) {
// We ignore humongous regions, we left the humongous set unchanged
} else {
! // Objects that were compacted would have ended up on regions
! // that were previously old or free.
! assert(r->is_free() || r->is_old(), "invariant");
! // We now consider them old, so register as such.
! r->set_old();
_old_set->add(r);
}
_total_used += r->used();
}
*** 6711,6721 ****
}
void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region,
size_t allocated_bytes) {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
! assert(alloc_region->is_young(), "all mutator alloc regions should be young");
g1_policy()->add_region_to_incremental_cset_lhs(alloc_region);
_allocator->increase_used(allocated_bytes);
_hr_printer.retire(alloc_region);
// We update the eden sizes here, when the region is retired,
--- 6711,6721 ----
}
void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region,
size_t allocated_bytes) {
assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
! assert(alloc_region->is_eden(), "all mutator alloc regions should be eden");
g1_policy()->add_region_to_incremental_cset_lhs(alloc_region);
_allocator->increase_used(allocated_bytes);
_hr_printer.retire(alloc_region);
// We update the eden sizes here, when the region is retired,
*** 6760,6769 ****
--- 6760,6770 ----
if (survivor) {
new_alloc_region->set_survivor();
_hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor);
check_bitmaps("Survivor Region Allocation", new_alloc_region);
} else {
+ new_alloc_region->set_old();
_hr_printer.alloc(new_alloc_region, G1HRPrinter::Old);
check_bitmaps("Old Region Allocation", new_alloc_region);
}
bool during_im = g1_policy()->during_initial_mark_pause();
new_alloc_region->note_start_of_copying(during_im);
*** 6819,6831 ****
assert(hr->containing_set() == _humongous_set, err_msg("Heap region %u is starts humongous but not in humongous set.", hr->hrm_index()));
_humongous_count.increment(1u, hr->capacity());
} else if (hr->is_empty()) {
assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index()));
_free_count.increment(1u, hr->capacity());
! } else {
assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index()));
_old_count.increment(1u, hr->capacity());
}
return false;
}
void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) {
--- 6820,6834 ----
assert(hr->containing_set() == _humongous_set, err_msg("Heap region %u is starts humongous but not in humongous set.", hr->hrm_index()));
_humongous_count.increment(1u, hr->capacity());
} else if (hr->is_empty()) {
assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index()));
_free_count.increment(1u, hr->capacity());
! } else if (hr->is_old()) {
assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index()));
_old_count.increment(1u, hr->capacity());
+ } else {
+ ShouldNotReachHere();
}
return false;
}
void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) {