--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Sep 11 14:21:24 2014 +0200
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Sep 15 12:19:31 2014 +0200
@@ -211,7 +211,10 @@
HeapRegion* next = list->get_next_young_region();
list->set_next_young_region(NULL);
list->uninstall_surv_rate_group();
- list->set_not_young();
+ // 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;
}
}
@@ -370,7 +373,7 @@
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",
+ 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(),
@@ -802,6 +805,7 @@
#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");
}
@@ -1225,21 +1229,21 @@
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);
- }
+ 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 {
- assert(hr->continuesHumongous(), "only way to get here");
- _hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous);
+ _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;
}
@@ -2121,8 +2125,8 @@
// 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();
+ // 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);
@@ -4031,14 +4035,6 @@
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();
}
@@ -6063,7 +6059,7 @@
FreeRegionList* free_list,
bool par,
bool locked) {
- assert(!hr->isHumongous(), "this is only for non-humongous regions");
+ 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");
@@ -6093,14 +6089,14 @@
// 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();
+ 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->set_notHumongous();
+ curr_hr->clear_humongous();
free_region(curr_hr, free_list, par);
i += 1;
}
@@ -6408,9 +6404,9 @@
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.
+ cur->set_old();
_old_set.add(cur);
evacuation_info.increment_collectionset_used_after(cur->used());
}
@@ -6697,16 +6693,15 @@
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()) {
+ 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 region set
- } else {
- // The rest should be old
- _old_set->remove(r);
+ // humongous regions set.
+ assert(r->is_free() || r->is_young() || r->isHumongous(),
+ "it cannot be another type");
}
return false;
}
@@ -6756,6 +6751,7 @@
if (r->is_empty()) {
// Add free regions to the free list
+ r->set_free();
_hrm->insert_into_free_list(r);
} else if (!_free_list_only) {
assert(!r->is_young(), "we should not come across young regions");
@@ -6763,7 +6759,11 @@
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
+ // 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();
@@ -6830,7 +6830,7 @@
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");
+ assert(alloc_region->is_eden(), "all mutator alloc regions should be eden");
g1_policy()->add_region_to_incremental_cset_lhs(alloc_region);
_summary_bytes_used += allocated_bytes;
@@ -6889,6 +6889,7 @@
_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);
}
@@ -7000,9 +7001,11 @@
} 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 {
+ } 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;
}