src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 6668 : 8048112: G1 Full GC needs to support the case when the very first region is not available
Summary: To allow uncommit of regions within the heap, G1 Full GC should correctly handle the case when the very first region is not available (uncommitted). Provide support for that by lazily initializing the compaction point during iteration of the list of heap regions. Further refactor the code to let the G1CollectedHeap handle finding the next region to compact into.
Reviewed-by:

*** 2947,2961 **** } cur = next; } } ! CompactibleSpace* G1CollectedHeap::first_compactible_space() { ! return n_regions() > 0 ? region_at(0) : NULL; } - Space* G1CollectedHeap::space_containing(const void* addr) const { return heap_region_containing(addr); } HeapWord* G1CollectedHeap::block_start(const void* addr) const { --- 2947,2970 ---- } cur = next; } } ! HeapRegion* G1CollectedHeap::next_compaction_region(const HeapRegion* from) const { ! // We're not using an iterator given that it will wrap around when ! // it reaches the last region and this is not what we want here. ! uint index = from->hrs_index() + 1; ! while (index < n_regions()) { ! HeapRegion* hr = region_at(index); ! if (!hr->isHumongous()) { ! return hr; ! } ! index += 1; ! } ! return NULL; } Space* G1CollectedHeap::space_containing(const void* addr) const { return heap_region_containing(addr); } HeapWord* G1CollectedHeap::block_start(const void* addr) const {
*** 6240,6251 **** // Add free regions to the free list _free_list->add_as_tail(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(); --- 6249,6261 ---- // Add free regions to the free list _free_list->add_as_tail(r); } else if (!_free_list_only) { assert(!r->is_young(), "we should not come across young regions"); ! if (r->startsHumongous()) { // We ignore humongous regions, we left the humongous set unchanged + } else if (r->continuesHumongous()) { } else { // The rest should be old, add them to the old set _old_set->add(r); } _total_used += r->used();