Tue, 16 Sep 2014 13:30:48 +0000
Merge
1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Jun 11 09:16:19 2014 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Sep 16 13:30:48 2014 +0000 1.3 @@ -4736,7 +4736,7 @@ 1.4 } 1.5 1.6 bool G1PrintRegionLivenessInfoClosure::doHeapRegion(HeapRegion* r) { 1.7 - const char* type = ""; 1.8 + const char* type = r->get_type_str(); 1.9 HeapWord* bottom = r->bottom(); 1.10 HeapWord* end = r->end(); 1.11 size_t capacity_bytes = r->capacity(); 1.12 @@ -4747,15 +4747,7 @@ 1.13 size_t remset_bytes = r->rem_set()->mem_size(); 1.14 size_t strong_code_roots_bytes = r->rem_set()->strong_code_roots_mem_size(); 1.15 1.16 - if (r->used() == 0) { 1.17 - type = "FREE"; 1.18 - } else if (r->is_survivor()) { 1.19 - type = "SURV"; 1.20 - } else if (r->is_young()) { 1.21 - type = "EDEN"; 1.22 - } else if (r->startsHumongous()) { 1.23 - type = "HUMS"; 1.24 - 1.25 + if (r->startsHumongous()) { 1.26 assert(_hum_used_bytes == 0 && _hum_capacity_bytes == 0 && 1.27 _hum_prev_live_bytes == 0 && _hum_next_live_bytes == 0, 1.28 "they should have been zeroed after the last time we used them"); 1.29 @@ -4768,12 +4760,9 @@ 1.30 &prev_live_bytes, &next_live_bytes); 1.31 end = bottom + HeapRegion::GrainWords; 1.32 } else if (r->continuesHumongous()) { 1.33 - type = "HUMC"; 1.34 get_hum_bytes(&used_bytes, &capacity_bytes, 1.35 &prev_live_bytes, &next_live_bytes); 1.36 assert(end == bottom + HeapRegion::GrainWords, "invariant"); 1.37 - } else { 1.38 - type = "OLD"; 1.39 } 1.40 1.41 _total_used_bytes += used_bytes;
2.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Jun 11 09:16:19 2014 +0200 2.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Sep 16 13:30:48 2014 +0000 2.3 @@ -207,7 +207,10 @@ 2.4 HeapRegion* next = list->get_next_young_region(); 2.5 list->set_next_young_region(NULL); 2.6 list->uninstall_surv_rate_group(); 2.7 - list->set_not_young(); 2.8 + // This is called before a Full GC and all the non-empty / 2.9 + // non-humongous regions at the end of the Full GC will end up as 2.10 + // old anyway. 2.11 + list->set_old(); 2.12 list = next; 2.13 } 2.14 } 2.15 @@ -366,7 +369,7 @@ 2.16 if (curr == NULL) 2.17 gclog_or_tty->print_cr(" empty"); 2.18 while (curr != NULL) { 2.19 - gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT "N: "PTR_FORMAT", age: %4d", 2.20 + gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT ", N: "PTR_FORMAT", age: %4d", 2.21 HR_FORMAT_PARAMS(curr), 2.22 curr->prev_top_at_mark_start(), 2.23 curr->next_top_at_mark_start(), 2.24 @@ -800,6 +803,7 @@ 2.25 #ifdef ASSERT 2.26 for (uint i = first; i < first + obj_regions; ++i) { 2.27 HeapRegion* hr = region_at(i); 2.28 + assert(hr->is_free(), "sanity"); 2.29 assert(hr->is_empty(), "sanity"); 2.30 assert(is_on_master_free_list(hr), "sanity"); 2.31 } 2.32 @@ -1227,21 +1231,21 @@ 2.33 public: 2.34 bool doHeapRegion(HeapRegion* hr) { 2.35 assert(!hr->is_young(), "not expecting to find young regions"); 2.36 - // We only generate output for non-empty regions. 2.37 - if (!hr->is_empty()) { 2.38 - if (!hr->isHumongous()) { 2.39 - _hr_printer->post_compaction(hr, G1HRPrinter::Old); 2.40 - } else if (hr->startsHumongous()) { 2.41 - if (hr->region_num() == 1) { 2.42 - // single humongous region 2.43 - _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous); 2.44 - } else { 2.45 - _hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous); 2.46 - } 2.47 + if (hr->is_free()) { 2.48 + // We only generate output for non-empty regions. 2.49 + } else if (hr->startsHumongous()) { 2.50 + if (hr->region_num() == 1) { 2.51 + // single humongous region 2.52 + _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous); 2.53 } else { 2.54 - assert(hr->continuesHumongous(), "only way to get here"); 2.55 - _hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous); 2.56 + _hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous); 2.57 } 2.58 + } else if (hr->continuesHumongous()) { 2.59 + _hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous); 2.60 + } else if (hr->is_old()) { 2.61 + _hr_printer->post_compaction(hr, G1HRPrinter::Old); 2.62 + } else { 2.63 + ShouldNotReachHere(); 2.64 } 2.65 return false; 2.66 } 2.67 @@ -2127,8 +2131,8 @@ 2.68 // We'll re-use the same region whether the alloc region will 2.69 // require BOT updates or not and, if it doesn't, then a non-young 2.70 // region will complain that it cannot support allocations without 2.71 - // BOT updates. So we'll tag the dummy region as young to avoid that. 2.72 - dummy_region->set_young(); 2.73 + // BOT updates. So we'll tag the dummy region as eden to avoid that. 2.74 + dummy_region->set_eden(); 2.75 // Make sure it's full. 2.76 dummy_region->set_top(dummy_region->end()); 2.77 G1AllocRegion::setup(this, dummy_region); 2.78 @@ -4021,14 +4025,6 @@ 2.79 if (_hr_printer.is_active()) { 2.80 HeapRegion* hr = g1_policy()->collection_set(); 2.81 while (hr != NULL) { 2.82 - G1HRPrinter::RegionType type; 2.83 - if (!hr->is_young()) { 2.84 - type = G1HRPrinter::Old; 2.85 - } else if (hr->is_survivor()) { 2.86 - type = G1HRPrinter::Survivor; 2.87 - } else { 2.88 - type = G1HRPrinter::Eden; 2.89 - } 2.90 _hr_printer.cset(hr); 2.91 hr = hr->next_in_collection_set(); 2.92 } 2.93 @@ -5948,7 +5944,7 @@ 2.94 FreeRegionList* free_list, 2.95 bool par, 2.96 bool locked) { 2.97 - assert(!hr->isHumongous(), "this is only for non-humongous regions"); 2.98 + assert(!hr->is_free(), "the region should not be free"); 2.99 assert(!hr->is_empty(), "the region should not be empty"); 2.100 assert(_hrm.is_available(hr->hrm_index()), "region should be committed"); 2.101 assert(free_list != NULL, "pre-condition"); 2.102 @@ -5978,14 +5974,14 @@ 2.103 // We need to read this before we make the region non-humongous, 2.104 // otherwise the information will be gone. 2.105 uint last_index = hr->last_hc_index(); 2.106 - hr->set_notHumongous(); 2.107 + hr->clear_humongous(); 2.108 free_region(hr, free_list, par); 2.109 2.110 uint i = hr->hrm_index() + 1; 2.111 while (i < last_index) { 2.112 HeapRegion* curr_hr = region_at(i); 2.113 assert(curr_hr->continuesHumongous(), "invariant"); 2.114 - curr_hr->set_notHumongous(); 2.115 + curr_hr->clear_humongous(); 2.116 free_region(curr_hr, free_list, par); 2.117 i += 1; 2.118 } 2.119 @@ -6290,9 +6286,9 @@ 2.120 if (cur->is_young()) { 2.121 cur->set_young_index_in_cset(-1); 2.122 } 2.123 - cur->set_not_young(); 2.124 cur->set_evacuation_failed(false); 2.125 // The region is now considered to be old. 2.126 + cur->set_old(); 2.127 _old_set.add(cur); 2.128 evacuation_info.increment_collectionset_used_after(cur->used()); 2.129 } 2.130 @@ -6579,16 +6575,15 @@ 2.131 TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { } 2.132 2.133 bool doHeapRegion(HeapRegion* r) { 2.134 - if (r->is_empty()) { 2.135 - // We ignore empty regions, we'll empty the free list afterwards 2.136 - } else if (r->is_young()) { 2.137 - // We ignore young regions, we'll empty the young list afterwards 2.138 - } else if (r->isHumongous()) { 2.139 + if (r->is_old()) { 2.140 + _old_set->remove(r); 2.141 + } else { 2.142 + // We ignore free regions, we'll empty the free list afterwards. 2.143 + // We ignore young regions, we'll empty the young list afterwards. 2.144 // We ignore humongous regions, we're not tearing down the 2.145 - // humongous region set 2.146 - } else { 2.147 - // The rest should be old 2.148 - _old_set->remove(r); 2.149 + // humongous regions set. 2.150 + assert(r->is_free() || r->is_young() || r->isHumongous(), 2.151 + "it cannot be another type"); 2.152 } 2.153 return false; 2.154 } 2.155 @@ -6638,6 +6633,7 @@ 2.156 2.157 if (r->is_empty()) { 2.158 // Add free regions to the free list 2.159 + r->set_free(); 2.160 r->set_allocation_context(AllocationContext::system()); 2.161 _hrm->insert_into_free_list(r); 2.162 } else if (!_free_list_only) { 2.163 @@ -6646,7 +6642,11 @@ 2.164 if (r->isHumongous()) { 2.165 // We ignore humongous regions, we left the humongous set unchanged 2.166 } else { 2.167 - // The rest should be old, add them to the old set 2.168 + // Objects that were compacted would have ended up on regions 2.169 + // that were previously old or free. 2.170 + assert(r->is_free() || r->is_old(), "invariant"); 2.171 + // We now consider them old, so register as such. 2.172 + r->set_old(); 2.173 _old_set->add(r); 2.174 } 2.175 _total_used += r->used(); 2.176 @@ -6713,7 +6713,7 @@ 2.177 void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region, 2.178 size_t allocated_bytes) { 2.179 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); 2.180 - assert(alloc_region->is_young(), "all mutator alloc regions should be young"); 2.181 + assert(alloc_region->is_eden(), "all mutator alloc regions should be eden"); 2.182 2.183 g1_policy()->add_region_to_incremental_cset_lhs(alloc_region); 2.184 _allocator->increase_used(allocated_bytes); 2.185 @@ -6762,6 +6762,7 @@ 2.186 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); 2.187 check_bitmaps("Survivor Region Allocation", new_alloc_region); 2.188 } else { 2.189 + new_alloc_region->set_old(); 2.190 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); 2.191 check_bitmaps("Old Region Allocation", new_alloc_region); 2.192 } 2.193 @@ -6821,9 +6822,11 @@ 2.194 } else if (hr->is_empty()) { 2.195 assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index())); 2.196 _free_count.increment(1u, hr->capacity()); 2.197 - } else { 2.198 + } else if (hr->is_old()) { 2.199 assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index())); 2.200 _old_count.increment(1u, hr->capacity()); 2.201 + } else { 2.202 + ShouldNotReachHere(); 2.203 } 2.204 return false; 2.205 }
3.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Wed Jun 11 09:16:19 2014 +0200 3.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Sep 16 13:30:48 2014 +0000 3.3 @@ -1664,7 +1664,7 @@ 3.4 // Add the heap region at the head of the non-incremental collection set 3.5 void G1CollectorPolicy::add_old_region_to_cset(HeapRegion* hr) { 3.6 assert(_inc_cset_build_state == Active, "Precondition"); 3.7 - assert(!hr->is_young(), "non-incremental add of young region"); 3.8 + assert(hr->is_old(), "the region should be old"); 3.9 3.10 assert(!hr->in_collection_set(), "should not already be in the CSet"); 3.11 hr->set_in_collection_set(true); 3.12 @@ -1810,7 +1810,7 @@ 3.13 // Add the region at the RHS of the incremental cset 3.14 void G1CollectorPolicy::add_region_to_incremental_cset_rhs(HeapRegion* hr) { 3.15 // We should only ever be appending survivors at the end of a pause 3.16 - assert( hr->is_survivor(), "Logic"); 3.17 + assert(hr->is_survivor(), "Logic"); 3.18 3.19 // Do the 'common' stuff 3.20 add_region_to_incremental_cset_common(hr); 3.21 @@ -1828,7 +1828,7 @@ 3.22 // Add the region to the LHS of the incremental cset 3.23 void G1CollectorPolicy::add_region_to_incremental_cset_lhs(HeapRegion* hr) { 3.24 // Survivors should be added to the RHS at the end of a pause 3.25 - assert(!hr->is_survivor(), "Logic"); 3.26 + assert(hr->is_eden(), "Logic"); 3.27 3.28 // Do the 'common' stuff 3.29 add_region_to_incremental_cset_common(hr); 3.30 @@ -1988,7 +1988,11 @@ 3.31 HeapRegion* hr = young_list->first_survivor_region(); 3.32 while (hr != NULL) { 3.33 assert(hr->is_survivor(), "badly formed young list"); 3.34 - hr->set_young(); 3.35 + // There is a convention that all the young regions in the CSet 3.36 + // are tagged as "eden", so we do this for the survivors here. We 3.37 + // use the special set_eden_pre_gc() as it doesn't check that the 3.38 + // region is free (which is not the case here). 3.39 + hr->set_eden_pre_gc(); 3.40 hr = hr->get_next_young_region(); 3.41 } 3.42
4.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Wed Jun 11 09:16:19 2014 +0200 4.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Tue Sep 16 13:30:48 2014 +0000 4.3 @@ -299,13 +299,13 @@ 4.4 // Accessors 4.5 4.6 void set_region_eden(HeapRegion* hr, int young_index_in_cset) { 4.7 - hr->set_young(); 4.8 + hr->set_eden(); 4.9 hr->install_surv_rate_group(_short_lived_surv_rate_group); 4.10 hr->set_young_index_in_cset(young_index_in_cset); 4.11 } 4.12 4.13 void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { 4.14 - assert(hr->is_young() && hr->is_survivor(), "pre-condition"); 4.15 + assert(hr->is_survivor(), "pre-condition"); 4.16 hr->install_surv_rate_group(_survivor_surv_rate_group); 4.17 hr->set_young_index_in_cset(young_index_in_cset); 4.18 }
5.1 --- a/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Wed Jun 11 09:16:19 2014 +0200 5.2 +++ b/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Tue Sep 16 13:30:48 2014 +0000 5.3 @@ -27,7 +27,6 @@ 5.4 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" 5.5 #include "gc_implementation/g1/g1HotCardCache.hpp" 5.6 #include "gc_implementation/g1/g1RemSet.hpp" 5.7 -#include "gc_implementation/g1/heapRegion.hpp" 5.8 #include "runtime/atomic.hpp" 5.9 5.10 G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h): 5.11 @@ -136,7 +135,6 @@ 5.12 } 5.13 5.14 void G1HotCardCache::reset_card_counts(HeapRegion* hr) { 5.15 - assert(!hr->isHumongous(), "Should have been cleared"); 5.16 _card_counts.clear_region(hr); 5.17 } 5.18
6.1 --- a/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Wed Jun 11 09:16:19 2014 +0200 6.2 +++ b/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp Tue Sep 16 13:30:48 2014 +0000 6.3 @@ -258,14 +258,16 @@ 6.4 size_t code_root_elems = hrrs->strong_code_roots_list_length(); 6.5 6.6 RegionTypeCounter* current = NULL; 6.7 - if (r->is_young()) { 6.8 + if (r->is_free()) { 6.9 + current = &_free; 6.10 + } else if (r->is_young()) { 6.11 current = &_young; 6.12 } else if (r->isHumongous()) { 6.13 current = &_humonguous; 6.14 - } else if (r->is_empty()) { 6.15 - current = &_free; 6.16 + } else if (r->is_old()) { 6.17 + current = &_old; 6.18 } else { 6.19 - current = &_old; 6.20 + ShouldNotReachHere(); 6.21 } 6.22 current->add(rs_mem_sz, occupied_cards, code_root_mem_sz, code_root_elems); 6.23 _all.add(rs_mem_sz, occupied_cards, code_root_mem_sz, code_root_elems);
7.1 --- a/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Wed Jun 11 09:16:19 2014 +0200 7.2 +++ b/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Tue Sep 16 13:30:48 2014 +0000 7.3 @@ -31,8 +31,6 @@ 7.4 #include "oops/oop.inline.hpp" 7.5 #include "utilities/macros.hpp" 7.6 7.7 -#if INCLUDE_ALL_GCS 7.8 - 7.9 class DirtyCardQueueSet; 7.10 class G1SATBCardTableLoggingModRefBS; 7.11 7.12 @@ -180,7 +178,4 @@ 7.13 void write_ref_array_work(MemRegion mr) { invalidate(mr); } 7.14 }; 7.15 7.16 - 7.17 -#endif // INCLUDE_ALL_GCS 7.18 - 7.19 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
8.1 --- a/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Jun 11 09:16:19 2014 +0200 8.2 +++ b/src/share/vm/gc_implementation/g1/heapRegion.cpp Tue Sep 16 13:30:48 2014 +0000 8.3 @@ -195,8 +195,6 @@ 8.4 } 8.5 8.6 void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) { 8.7 - assert(_humongous_type == NotHumongous, 8.8 - "we should have already filtered out humongous regions"); 8.9 assert(_humongous_start_region == NULL, 8.10 "we should have already filtered out humongous regions"); 8.11 assert(_end == _orig_end, 8.12 @@ -207,7 +205,7 @@ 8.13 set_allocation_context(AllocationContext::system()); 8.14 set_young_index_in_cset(-1); 8.15 uninstall_surv_rate_group(); 8.16 - set_young_type(NotYoung); 8.17 + set_free(); 8.18 reset_pre_dummy_top(); 8.19 8.20 if (!par) { 8.21 @@ -258,7 +256,7 @@ 8.22 assert(top() == bottom(), "should be empty"); 8.23 assert(bottom() <= new_top && new_top <= new_end, "pre-condition"); 8.24 8.25 - _humongous_type = StartsHumongous; 8.26 + _type.set_starts_humongous(); 8.27 _humongous_start_region = this; 8.28 8.29 set_end(new_end); 8.30 @@ -272,11 +270,11 @@ 8.31 assert(top() == bottom(), "should be empty"); 8.32 assert(first_hr->startsHumongous(), "pre-condition"); 8.33 8.34 - _humongous_type = ContinuesHumongous; 8.35 + _type.set_continues_humongous(); 8.36 _humongous_start_region = first_hr; 8.37 } 8.38 8.39 -void HeapRegion::set_notHumongous() { 8.40 +void HeapRegion::clear_humongous() { 8.41 assert(isHumongous(), "pre-condition"); 8.42 8.43 if (startsHumongous()) { 8.44 @@ -292,7 +290,6 @@ 8.45 } 8.46 8.47 assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); 8.48 - _humongous_type = NotHumongous; 8.49 _humongous_start_region = NULL; 8.50 } 8.51 8.52 @@ -336,12 +333,12 @@ 8.53 G1OffsetTableContigSpace(sharedOffsetArray, mr), 8.54 _hrm_index(hrm_index), 8.55 _allocation_context(AllocationContext::system()), 8.56 - _humongous_type(NotHumongous), _humongous_start_region(NULL), 8.57 + _humongous_start_region(NULL), 8.58 _in_collection_set(false), 8.59 _next_in_special_set(NULL), _orig_end(NULL), 8.60 _claimed(InitialClaimValue), _evacuation_failed(false), 8.61 _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0), 8.62 - _young_type(NotYoung), _next_young_region(NULL), 8.63 + _next_young_region(NULL), 8.64 _next_dirty_cards_region(NULL), _next(NULL), _prev(NULL), 8.65 #ifdef ASSERT 8.66 _containing_set(NULL), 8.67 @@ -703,27 +700,11 @@ 8.68 void HeapRegion::print() const { print_on(gclog_or_tty); } 8.69 void HeapRegion::print_on(outputStream* st) const { 8.70 st->print("AC%4u", allocation_context()); 8.71 - 8.72 - if (isHumongous()) { 8.73 - if (startsHumongous()) 8.74 - st->print(" HS"); 8.75 - else 8.76 - st->print(" HC"); 8.77 - } else { 8.78 - st->print(" "); 8.79 - } 8.80 + st->print(" %2s", get_short_type_str()); 8.81 if (in_collection_set()) 8.82 st->print(" CS"); 8.83 else 8.84 st->print(" "); 8.85 - if (is_young()) 8.86 - st->print(is_survivor() ? " SU" : " Y "); 8.87 - else 8.88 - st->print(" "); 8.89 - if (is_empty()) 8.90 - st->print(" F"); 8.91 - else 8.92 - st->print(" "); 8.93 st->print(" TS %5d", _gc_time_stamp); 8.94 st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT, 8.95 prev_top_at_mark_start(), next_top_at_mark_start());
9.1 --- a/src/share/vm/gc_implementation/g1/heapRegion.hpp Wed Jun 11 09:16:19 2014 +0200 9.2 +++ b/src/share/vm/gc_implementation/g1/heapRegion.hpp Tue Sep 16 13:30:48 2014 +0000 9.3 @@ -28,6 +28,7 @@ 9.4 #include "gc_implementation/g1/g1AllocationContext.hpp" 9.5 #include "gc_implementation/g1/g1BlockOffsetTable.hpp" 9.6 #include "gc_implementation/g1/g1_specialized_oop_closures.hpp" 9.7 +#include "gc_implementation/g1/heapRegionType.hpp" 9.8 #include "gc_implementation/g1/survRateGroup.hpp" 9.9 #include "gc_implementation/shared/ageTable.hpp" 9.10 #include "gc_implementation/shared/spaceDecorator.hpp" 9.11 @@ -35,8 +36,6 @@ 9.12 #include "memory/watermark.hpp" 9.13 #include "utilities/macros.hpp" 9.14 9.15 -#if INCLUDE_ALL_GCS 9.16 - 9.17 // A HeapRegion is the smallest piece of a G1CollectedHeap that 9.18 // can be collected independently. 9.19 9.20 @@ -56,10 +55,7 @@ 9.21 #define HR_FORMAT "%u:(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]" 9.22 #define HR_FORMAT_PARAMS(_hr_) \ 9.23 (_hr_)->hrm_index(), \ 9.24 - (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : \ 9.25 - (_hr_)->startsHumongous() ? "HS" : \ 9.26 - (_hr_)->continuesHumongous() ? "HC" : \ 9.27 - !(_hr_)->is_empty() ? "O" : "F", \ 9.28 + (_hr_)->get_short_type_str(), \ 9.29 p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end()) 9.30 9.31 // sentinel value for hrm_index 9.32 @@ -220,12 +216,6 @@ 9.33 friend class VMStructs; 9.34 private: 9.35 9.36 - enum HumongousType { 9.37 - NotHumongous = 0, 9.38 - StartsHumongous, 9.39 - ContinuesHumongous 9.40 - }; 9.41 - 9.42 // The remembered set for this region. 9.43 // (Might want to make this "inline" later, to avoid some alloc failure 9.44 // issues.) 9.45 @@ -239,7 +229,8 @@ 9.46 9.47 AllocationContext_t _allocation_context; 9.48 9.49 - HumongousType _humongous_type; 9.50 + HeapRegionType _type; 9.51 + 9.52 // For a humongous region, region in which it starts. 9.53 HeapRegion* _humongous_start_region; 9.54 // For the start region of a humongous sequence, it's original end(). 9.55 @@ -281,13 +272,6 @@ 9.56 // The calculated GC efficiency of the region. 9.57 double _gc_efficiency; 9.58 9.59 - enum YoungType { 9.60 - NotYoung, // a region is not young 9.61 - Young, // a region is young 9.62 - Survivor // a region is young and it contains survivors 9.63 - }; 9.64 - 9.65 - volatile YoungType _young_type; 9.66 int _young_index_in_cset; 9.67 SurvRateGroup* _surv_rate_group; 9.68 int _age_index; 9.69 @@ -312,12 +296,6 @@ 9.70 _next_top_at_mark_start = bot; 9.71 } 9.72 9.73 - void set_young_type(YoungType new_type) { 9.74 - //assert(_young_type != new_type, "setting the same type" ); 9.75 - // TODO: add more assertions here 9.76 - _young_type = new_type; 9.77 - } 9.78 - 9.79 // Cached attributes used in the collection set policy information 9.80 9.81 // The RSet length that was added to the total value 9.82 @@ -437,9 +415,21 @@ 9.83 _prev_marked_bytes = _next_marked_bytes = 0; 9.84 } 9.85 9.86 - bool isHumongous() const { return _humongous_type != NotHumongous; } 9.87 - bool startsHumongous() const { return _humongous_type == StartsHumongous; } 9.88 - bool continuesHumongous() const { return _humongous_type == ContinuesHumongous; } 9.89 + const char* get_type_str() const { return _type.get_str(); } 9.90 + const char* get_short_type_str() const { return _type.get_short_str(); } 9.91 + 9.92 + bool is_free() const { return _type.is_free(); } 9.93 + 9.94 + bool is_young() const { return _type.is_young(); } 9.95 + bool is_eden() const { return _type.is_eden(); } 9.96 + bool is_survivor() const { return _type.is_survivor(); } 9.97 + 9.98 + bool isHumongous() const { return _type.is_humongous(); } 9.99 + bool startsHumongous() const { return _type.is_starts_humongous(); } 9.100 + bool continuesHumongous() const { return _type.is_continues_humongous(); } 9.101 + 9.102 + bool is_old() const { return _type.is_old(); } 9.103 + 9.104 // For a humongous region, region in which it starts. 9.105 HeapRegion* humongous_start_region() const { 9.106 return _humongous_start_region; 9.107 @@ -503,7 +493,7 @@ 9.108 void set_continuesHumongous(HeapRegion* first_hr); 9.109 9.110 // Unsets the humongous-related fields on the region. 9.111 - void set_notHumongous(); 9.112 + void clear_humongous(); 9.113 9.114 // If the region has a remembered set, return a pointer to it. 9.115 HeapRegionRemSet* rem_set() const { 9.116 @@ -638,9 +628,6 @@ 9.117 void calc_gc_efficiency(void); 9.118 double gc_efficiency() { return _gc_efficiency;} 9.119 9.120 - bool is_young() const { return _young_type != NotYoung; } 9.121 - bool is_survivor() const { return _young_type == Survivor; } 9.122 - 9.123 int young_index_in_cset() const { return _young_index_in_cset; } 9.124 void set_young_index_in_cset(int index) { 9.125 assert( (index == -1) || is_young(), "pre-condition" ); 9.126 @@ -692,11 +679,13 @@ 9.127 } 9.128 } 9.129 9.130 - void set_young() { set_young_type(Young); } 9.131 + void set_free() { _type.set_free(); } 9.132 9.133 - void set_survivor() { set_young_type(Survivor); } 9.134 + void set_eden() { _type.set_eden(); } 9.135 + void set_eden_pre_gc() { _type.set_eden_pre_gc(); } 9.136 + void set_survivor() { _type.set_survivor(); } 9.137 9.138 - void set_not_young() { set_young_type(NotYoung); } 9.139 + void set_old() { _type.set_old(); } 9.140 9.141 // Determine if an object has been allocated since the last 9.142 // mark performed by the collector. This returns true iff the object 9.143 @@ -841,6 +830,4 @@ 9.144 bool complete() { return _complete; } 9.145 }; 9.146 9.147 -#endif // INCLUDE_ALL_GCS 9.148 - 9.149 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP
10.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Wed Jun 11 09:16:19 2014 +0200 10.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Tue Sep 16 13:30:48 2014 +0000 10.3 @@ -42,7 +42,9 @@ 10.4 assert(hr->containing_set() == this, err_msg("Inconsistent containing set for %u", hr->hrm_index())); 10.5 assert(!hr->is_young(), err_msg("Adding young region %u", hr->hrm_index())); // currently we don't use these sets for young regions 10.6 assert(hr->isHumongous() == regions_humongous(), err_msg("Wrong humongous state for region %u and set %s", hr->hrm_index(), name())); 10.7 - assert(hr->is_empty() == regions_empty(), err_msg("Wrong empty state for region %u and set %s", hr->hrm_index(), name())); 10.8 + assert(hr->is_free() == regions_free(), err_msg("Wrong free state for region %u and set %s", hr->hrm_index(), name())); 10.9 + assert(!hr->is_free() || hr->is_empty(), err_msg("Free region %u is not empty for set %s", hr->hrm_index(), name())); 10.10 + assert(!hr->is_empty() || hr->is_free(), err_msg("Empty region %u is not free for set %s", hr->hrm_index(), name())); 10.11 assert(hr->rem_set()->verify_ready_for_par_iteration(), err_msg("Wrong iteration state %u", hr->hrm_index())); 10.12 } 10.13 #endif 10.14 @@ -85,16 +87,16 @@ 10.15 out->print_cr("Set: %s ("PTR_FORMAT")", name(), this); 10.16 out->print_cr(" Region Assumptions"); 10.17 out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous())); 10.18 - out->print_cr(" empty : %s", BOOL_TO_STR(regions_empty())); 10.19 + out->print_cr(" free : %s", BOOL_TO_STR(regions_free())); 10.20 out->print_cr(" Attributes"); 10.21 out->print_cr(" length : %14u", length()); 10.22 out->print_cr(" total capacity : "SIZE_FORMAT_W(14)" bytes", 10.23 total_capacity_bytes()); 10.24 } 10.25 10.26 -HeapRegionSetBase::HeapRegionSetBase(const char* name, bool humongous, bool empty, HRSMtSafeChecker* mt_safety_checker) 10.27 +HeapRegionSetBase::HeapRegionSetBase(const char* name, bool humongous, bool free, HRSMtSafeChecker* mt_safety_checker) 10.28 : _name(name), _verify_in_progress(false), 10.29 - _is_humongous(humongous), _is_empty(empty), _mt_safety_checker(mt_safety_checker), 10.30 + _is_humongous(humongous), _is_free(free), _mt_safety_checker(mt_safety_checker), 10.31 _count() 10.32 { } 10.33
11.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Wed Jun 11 09:16:19 2014 +0200 11.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Tue Sep 16 13:30:48 2014 +0000 11.3 @@ -81,7 +81,7 @@ 11.4 friend class VMStructs; 11.5 private: 11.6 bool _is_humongous; 11.7 - bool _is_empty; 11.8 + bool _is_free; 11.9 HRSMtSafeChecker* _mt_safety_checker; 11.10 11.11 protected: 11.12 @@ -102,9 +102,9 @@ 11.13 // not. Only used during verification. 11.14 bool regions_humongous() { return _is_humongous; } 11.15 11.16 - // Indicates whether all regions in the set should be empty or 11.17 + // Indicates whether all regions in the set should be free or 11.18 // not. Only used during verification. 11.19 - bool regions_empty() { return _is_empty; } 11.20 + bool regions_free() { return _is_free; } 11.21 11.22 void check_mt_safety() { 11.23 if (_mt_safety_checker != NULL) { 11.24 @@ -114,7 +114,7 @@ 11.25 11.26 virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg) { } 11.27 11.28 - HeapRegionSetBase(const char* name, bool humongous, bool empty, HRSMtSafeChecker* mt_safety_checker); 11.29 + HeapRegionSetBase(const char* name, bool humongous, bool free, HRSMtSafeChecker* mt_safety_checker); 11.30 11.31 public: 11.32 const char* name() { return _name; } 11.33 @@ -171,7 +171,7 @@ 11.34 do { \ 11.35 assert(((_set1_)->regions_humongous() == \ 11.36 (_set2_)->regions_humongous()) && \ 11.37 - ((_set1_)->regions_empty() == (_set2_)->regions_empty()), \ 11.38 + ((_set1_)->regions_free() == (_set2_)->regions_free()), \ 11.39 hrs_err_msg("the contents of set %s and set %s should match", \ 11.40 (_set1_)->name(), (_set2_)->name())); \ 11.41 } while (0) 11.42 @@ -184,7 +184,7 @@ 11.43 class HeapRegionSet : public HeapRegionSetBase { 11.44 public: 11.45 HeapRegionSet(const char* name, bool humongous, HRSMtSafeChecker* mt_safety_checker): 11.46 - HeapRegionSetBase(name, humongous, false /* empty */, mt_safety_checker) { } 11.47 + HeapRegionSetBase(name, humongous, false /* free */, mt_safety_checker) { } 11.48 11.49 void bulk_remove(const HeapRegionSetCount& removed) { 11.50 _count.decrement(removed.length(), removed.capacity());
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionType.cpp Tue Sep 16 13:30:48 2014 +0000 12.3 @@ -0,0 +1,69 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + * 12.26 + */ 12.27 + 12.28 +#include "precompiled.hpp" 12.29 +#include "gc_implementation/g1/heapRegionType.hpp" 12.30 + 12.31 +bool HeapRegionType::is_valid(Tag tag) { 12.32 + switch (tag) { 12.33 + case FreeTag: 12.34 + case EdenTag: 12.35 + case SurvTag: 12.36 + case HumStartsTag: 12.37 + case HumContTag: 12.38 + case OldTag: 12.39 + return true; 12.40 + } 12.41 + return false; 12.42 +} 12.43 + 12.44 +const char* HeapRegionType::get_str() const { 12.45 + hrt_assert_is_valid(_tag); 12.46 + switch (_tag) { 12.47 + case FreeTag: return "FREE"; 12.48 + case EdenTag: return "EDEN"; 12.49 + case SurvTag: return "SURV"; 12.50 + case HumStartsTag: return "HUMS"; 12.51 + case HumContTag: return "HUMC"; 12.52 + case OldTag: return "OLD"; 12.53 + } 12.54 + ShouldNotReachHere(); 12.55 + // keep some compilers happy 12.56 + return NULL; 12.57 +} 12.58 + 12.59 +const char* HeapRegionType::get_short_str() const { 12.60 + hrt_assert_is_valid(_tag); 12.61 + switch (_tag) { 12.62 + case FreeTag: return "F"; 12.63 + case EdenTag: return "E"; 12.64 + case SurvTag: return "S"; 12.65 + case HumStartsTag: return "HS"; 12.66 + case HumContTag: return "HC"; 12.67 + case OldTag: return "O"; 12.68 + } 12.69 + ShouldNotReachHere(); 12.70 + // keep some compilers happy 12.71 + return NULL; 12.72 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionType.hpp Tue Sep 16 13:30:48 2014 +0000 13.3 @@ -0,0 +1,134 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + * 13.26 + */ 13.27 + 13.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP 13.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP 13.30 + 13.31 +#include "memory/allocation.hpp" 13.32 + 13.33 +#define hrt_assert_is_valid(tag) \ 13.34 + assert(is_valid((tag)), err_msg("invalid HR type: %u", (uint) (tag))) 13.35 + 13.36 +class HeapRegionType VALUE_OBJ_CLASS_SPEC { 13.37 +private: 13.38 + // We encode the value of the heap region type so the generation can be 13.39 + // determined quickly. The tag is split into two parts: 13.40 + // 13.41 + // major type (young, humongous) : top N-1 bits 13.42 + // minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit 13.43 + // 13.44 + // If there's need to increase the number of minor types in the 13.45 + // future, we'll have to increase the size of the latter and hence 13.46 + // decrease the size of the former. 13.47 + // 13.48 + // 0000 0 [ 0] Free 13.49 + // 13.50 + // 0001 0 Young Mask 13.51 + // 0001 0 [ 2] Eden 13.52 + // 0001 1 [ 3] Survivor 13.53 + // 13.54 + // 0010 0 Humongous Mask 13.55 + // 0010 0 [ 4] Humongous Starts 13.56 + // 0010 1 [ 5] Humongous Continues 13.57 + // 13.58 + // 01000 [ 8] Old 13.59 + typedef enum { 13.60 + FreeTag = 0, 13.61 + 13.62 + YoungMask = 2, 13.63 + EdenTag = YoungMask, 13.64 + SurvTag = YoungMask + 1, 13.65 + 13.66 + HumMask = 4, 13.67 + HumStartsTag = HumMask, 13.68 + HumContTag = HumMask + 1, 13.69 + 13.70 + OldTag = 8 13.71 + } Tag; 13.72 + 13.73 + volatile Tag _tag; 13.74 + 13.75 + static bool is_valid(Tag tag); 13.76 + 13.77 + Tag get() const { 13.78 + hrt_assert_is_valid(_tag); 13.79 + return _tag; 13.80 + } 13.81 + 13.82 + // Sets the type to 'tag'. 13.83 + void set(Tag tag) { 13.84 + hrt_assert_is_valid(tag); 13.85 + hrt_assert_is_valid(_tag); 13.86 + _tag = tag; 13.87 + } 13.88 + 13.89 + // Sets the type to 'tag', expecting the type to be 'before'. This 13.90 + // is available for when we want to add sanity checking to the type 13.91 + // transition. 13.92 + void set_from(Tag tag, Tag before) { 13.93 + hrt_assert_is_valid(tag); 13.94 + hrt_assert_is_valid(before); 13.95 + hrt_assert_is_valid(_tag); 13.96 + assert(_tag == before, 13.97 + err_msg("HR tag: %u, expected: %u new tag; %u", _tag, before, tag)); 13.98 + _tag = tag; 13.99 + } 13.100 + 13.101 +public: 13.102 + // Queries 13.103 + 13.104 + bool is_free() const { return get() == FreeTag; } 13.105 + 13.106 + bool is_young() const { return (get() & YoungMask) != 0; } 13.107 + bool is_eden() const { return get() == EdenTag; } 13.108 + bool is_survivor() const { return get() == SurvTag; } 13.109 + 13.110 + bool is_humongous() const { return (get() & HumMask) != 0; } 13.111 + bool is_starts_humongous() const { return get() == HumStartsTag; } 13.112 + bool is_continues_humongous() const { return get() == HumContTag; } 13.113 + 13.114 + bool is_old() const { return get() == OldTag; } 13.115 + 13.116 + // Setters 13.117 + 13.118 + void set_free() { set(FreeTag); } 13.119 + 13.120 + void set_eden() { set_from(EdenTag, FreeTag); } 13.121 + void set_eden_pre_gc() { set_from(EdenTag, SurvTag); } 13.122 + void set_survivor() { set_from(SurvTag, FreeTag); } 13.123 + 13.124 + void set_starts_humongous() { set_from(HumStartsTag, FreeTag); } 13.125 + void set_continues_humongous() { set_from(HumContTag, FreeTag); } 13.126 + 13.127 + void set_old() { set(OldTag); } 13.128 + 13.129 + // Misc 13.130 + 13.131 + const char* get_str() const; 13.132 + const char* get_short_str() const; 13.133 + 13.134 + HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); } 13.135 +}; 13.136 + 13.137 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP