Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 20481:c02ec279b062
8057768: Make heap region region type in G1 HeapRegion explicit
Reviewed-by: brutisso, tschatzl
author | brutisso |
---|---|
date | Tue, 16 Sep 2014 14:27:40 +0200 |
parents | e5668dcf12e9 |
children | 7baf47cb97cb |
comparison
equal
deleted
inserted
replaced
20478:00448aa81791 | 20481:c02ec279b062 |
---|---|
205 void YoungList::empty_list(HeapRegion* list) { | 205 void YoungList::empty_list(HeapRegion* list) { |
206 while (list != NULL) { | 206 while (list != NULL) { |
207 HeapRegion* next = list->get_next_young_region(); | 207 HeapRegion* next = list->get_next_young_region(); |
208 list->set_next_young_region(NULL); | 208 list->set_next_young_region(NULL); |
209 list->uninstall_surv_rate_group(); | 209 list->uninstall_surv_rate_group(); |
210 list->set_not_young(); | 210 // This is called before a Full GC and all the non-empty / |
211 // non-humongous regions at the end of the Full GC will end up as | |
212 // old anyway. | |
213 list->set_old(); | |
211 list = next; | 214 list = next; |
212 } | 215 } |
213 } | 216 } |
214 | 217 |
215 void YoungList::empty_list() { | 218 void YoungList::empty_list() { |
364 gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]); | 367 gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]); |
365 HeapRegion *curr = lists[list]; | 368 HeapRegion *curr = lists[list]; |
366 if (curr == NULL) | 369 if (curr == NULL) |
367 gclog_or_tty->print_cr(" empty"); | 370 gclog_or_tty->print_cr(" empty"); |
368 while (curr != NULL) { | 371 while (curr != NULL) { |
369 gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT "N: "PTR_FORMAT", age: %4d", | 372 gclog_or_tty->print_cr(" "HR_FORMAT", P: "PTR_FORMAT ", N: "PTR_FORMAT", age: %4d", |
370 HR_FORMAT_PARAMS(curr), | 373 HR_FORMAT_PARAMS(curr), |
371 curr->prev_top_at_mark_start(), | 374 curr->prev_top_at_mark_start(), |
372 curr->next_top_at_mark_start(), | 375 curr->next_top_at_mark_start(), |
373 curr->age_in_surv_rate_group_cond()); | 376 curr->age_in_surv_rate_group_cond()); |
374 curr = curr->get_next_young_region(); | 377 curr = curr->get_next_young_region(); |
798 g1_policy()->record_new_heap_size(num_regions()); | 801 g1_policy()->record_new_heap_size(num_regions()); |
799 | 802 |
800 #ifdef ASSERT | 803 #ifdef ASSERT |
801 for (uint i = first; i < first + obj_regions; ++i) { | 804 for (uint i = first; i < first + obj_regions; ++i) { |
802 HeapRegion* hr = region_at(i); | 805 HeapRegion* hr = region_at(i); |
806 assert(hr->is_free(), "sanity"); | |
803 assert(hr->is_empty(), "sanity"); | 807 assert(hr->is_empty(), "sanity"); |
804 assert(is_on_master_free_list(hr), "sanity"); | 808 assert(is_on_master_free_list(hr), "sanity"); |
805 } | 809 } |
806 #endif | 810 #endif |
807 _hrm.allocate_free_regions_starting_at(first, obj_regions); | 811 _hrm.allocate_free_regions_starting_at(first, obj_regions); |
1225 private: | 1229 private: |
1226 G1HRPrinter* _hr_printer; | 1230 G1HRPrinter* _hr_printer; |
1227 public: | 1231 public: |
1228 bool doHeapRegion(HeapRegion* hr) { | 1232 bool doHeapRegion(HeapRegion* hr) { |
1229 assert(!hr->is_young(), "not expecting to find young regions"); | 1233 assert(!hr->is_young(), "not expecting to find young regions"); |
1230 // We only generate output for non-empty regions. | 1234 if (hr->is_free()) { |
1231 if (!hr->is_empty()) { | 1235 // We only generate output for non-empty regions. |
1232 if (!hr->isHumongous()) { | 1236 } else if (hr->startsHumongous()) { |
1233 _hr_printer->post_compaction(hr, G1HRPrinter::Old); | 1237 if (hr->region_num() == 1) { |
1234 } else if (hr->startsHumongous()) { | 1238 // single humongous region |
1235 if (hr->region_num() == 1) { | 1239 _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous); |
1236 // single humongous region | |
1237 _hr_printer->post_compaction(hr, G1HRPrinter::SingleHumongous); | |
1238 } else { | |
1239 _hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous); | |
1240 } | |
1241 } else { | 1240 } else { |
1242 assert(hr->continuesHumongous(), "only way to get here"); | 1241 _hr_printer->post_compaction(hr, G1HRPrinter::StartsHumongous); |
1243 _hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous); | |
1244 } | 1242 } |
1243 } else if (hr->continuesHumongous()) { | |
1244 _hr_printer->post_compaction(hr, G1HRPrinter::ContinuesHumongous); | |
1245 } else if (hr->is_old()) { | |
1246 _hr_printer->post_compaction(hr, G1HRPrinter::Old); | |
1247 } else { | |
1248 ShouldNotReachHere(); | |
1245 } | 1249 } |
1246 return false; | 1250 return false; |
1247 } | 1251 } |
1248 | 1252 |
1249 PostCompactionPrinterClosure(G1HRPrinter* hr_printer) | 1253 PostCompactionPrinterClosure(G1HRPrinter* hr_printer) |
2125 HeapRegion* dummy_region = _hrm.get_dummy_region(); | 2129 HeapRegion* dummy_region = _hrm.get_dummy_region(); |
2126 | 2130 |
2127 // We'll re-use the same region whether the alloc region will | 2131 // We'll re-use the same region whether the alloc region will |
2128 // require BOT updates or not and, if it doesn't, then a non-young | 2132 // require BOT updates or not and, if it doesn't, then a non-young |
2129 // region will complain that it cannot support allocations without | 2133 // region will complain that it cannot support allocations without |
2130 // BOT updates. So we'll tag the dummy region as young to avoid that. | 2134 // BOT updates. So we'll tag the dummy region as eden to avoid that. |
2131 dummy_region->set_young(); | 2135 dummy_region->set_eden(); |
2132 // Make sure it's full. | 2136 // Make sure it's full. |
2133 dummy_region->set_top(dummy_region->end()); | 2137 dummy_region->set_top(dummy_region->end()); |
2134 G1AllocRegion::setup(this, dummy_region); | 2138 G1AllocRegion::setup(this, dummy_region); |
2135 | 2139 |
2136 _allocator->init_mutator_alloc_region(); | 2140 _allocator->init_mutator_alloc_region(); |
4019 true /* verify_fingers */); | 4023 true /* verify_fingers */); |
4020 | 4024 |
4021 if (_hr_printer.is_active()) { | 4025 if (_hr_printer.is_active()) { |
4022 HeapRegion* hr = g1_policy()->collection_set(); | 4026 HeapRegion* hr = g1_policy()->collection_set(); |
4023 while (hr != NULL) { | 4027 while (hr != NULL) { |
4024 G1HRPrinter::RegionType type; | |
4025 if (!hr->is_young()) { | |
4026 type = G1HRPrinter::Old; | |
4027 } else if (hr->is_survivor()) { | |
4028 type = G1HRPrinter::Survivor; | |
4029 } else { | |
4030 type = G1HRPrinter::Eden; | |
4031 } | |
4032 _hr_printer.cset(hr); | 4028 _hr_printer.cset(hr); |
4033 hr = hr->next_in_collection_set(); | 4029 hr = hr->next_in_collection_set(); |
4034 } | 4030 } |
4035 } | 4031 } |
4036 | 4032 |
5946 | 5942 |
5947 void G1CollectedHeap::free_region(HeapRegion* hr, | 5943 void G1CollectedHeap::free_region(HeapRegion* hr, |
5948 FreeRegionList* free_list, | 5944 FreeRegionList* free_list, |
5949 bool par, | 5945 bool par, |
5950 bool locked) { | 5946 bool locked) { |
5951 assert(!hr->isHumongous(), "this is only for non-humongous regions"); | 5947 assert(!hr->is_free(), "the region should not be free"); |
5952 assert(!hr->is_empty(), "the region should not be empty"); | 5948 assert(!hr->is_empty(), "the region should not be empty"); |
5953 assert(_hrm.is_available(hr->hrm_index()), "region should be committed"); | 5949 assert(_hrm.is_available(hr->hrm_index()), "region should be committed"); |
5954 assert(free_list != NULL, "pre-condition"); | 5950 assert(free_list != NULL, "pre-condition"); |
5955 | 5951 |
5956 if (G1VerifyBitmaps) { | 5952 if (G1VerifyBitmaps) { |
5976 | 5972 |
5977 size_t hr_capacity = hr->capacity(); | 5973 size_t hr_capacity = hr->capacity(); |
5978 // We need to read this before we make the region non-humongous, | 5974 // We need to read this before we make the region non-humongous, |
5979 // otherwise the information will be gone. | 5975 // otherwise the information will be gone. |
5980 uint last_index = hr->last_hc_index(); | 5976 uint last_index = hr->last_hc_index(); |
5981 hr->set_notHumongous(); | 5977 hr->clear_humongous(); |
5982 free_region(hr, free_list, par); | 5978 free_region(hr, free_list, par); |
5983 | 5979 |
5984 uint i = hr->hrm_index() + 1; | 5980 uint i = hr->hrm_index() + 1; |
5985 while (i < last_index) { | 5981 while (i < last_index) { |
5986 HeapRegion* curr_hr = region_at(i); | 5982 HeapRegion* curr_hr = region_at(i); |
5987 assert(curr_hr->continuesHumongous(), "invariant"); | 5983 assert(curr_hr->continuesHumongous(), "invariant"); |
5988 curr_hr->set_notHumongous(); | 5984 curr_hr->clear_humongous(); |
5989 free_region(curr_hr, free_list, par); | 5985 free_region(curr_hr, free_list, par); |
5990 i += 1; | 5986 i += 1; |
5991 } | 5987 } |
5992 } | 5988 } |
5993 | 5989 |
6288 } else { | 6284 } else { |
6289 cur->uninstall_surv_rate_group(); | 6285 cur->uninstall_surv_rate_group(); |
6290 if (cur->is_young()) { | 6286 if (cur->is_young()) { |
6291 cur->set_young_index_in_cset(-1); | 6287 cur->set_young_index_in_cset(-1); |
6292 } | 6288 } |
6293 cur->set_not_young(); | |
6294 cur->set_evacuation_failed(false); | 6289 cur->set_evacuation_failed(false); |
6295 // The region is now considered to be old. | 6290 // The region is now considered to be old. |
6291 cur->set_old(); | |
6296 _old_set.add(cur); | 6292 _old_set.add(cur); |
6297 evacuation_info.increment_collectionset_used_after(cur->used()); | 6293 evacuation_info.increment_collectionset_used_after(cur->used()); |
6298 } | 6294 } |
6299 cur = next; | 6295 cur = next; |
6300 } | 6296 } |
6577 | 6573 |
6578 public: | 6574 public: |
6579 TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { } | 6575 TearDownRegionSetsClosure(HeapRegionSet* old_set) : _old_set(old_set) { } |
6580 | 6576 |
6581 bool doHeapRegion(HeapRegion* r) { | 6577 bool doHeapRegion(HeapRegion* r) { |
6582 if (r->is_empty()) { | 6578 if (r->is_old()) { |
6583 // We ignore empty regions, we'll empty the free list afterwards | 6579 _old_set->remove(r); |
6584 } else if (r->is_young()) { | 6580 } else { |
6585 // We ignore young regions, we'll empty the young list afterwards | 6581 // We ignore free regions, we'll empty the free list afterwards. |
6586 } else if (r->isHumongous()) { | 6582 // We ignore young regions, we'll empty the young list afterwards. |
6587 // We ignore humongous regions, we're not tearing down the | 6583 // We ignore humongous regions, we're not tearing down the |
6588 // humongous region set | 6584 // humongous regions set. |
6589 } else { | 6585 assert(r->is_free() || r->is_young() || r->isHumongous(), |
6590 // The rest should be old | 6586 "it cannot be another type"); |
6591 _old_set->remove(r); | |
6592 } | 6587 } |
6593 return false; | 6588 return false; |
6594 } | 6589 } |
6595 | 6590 |
6596 ~TearDownRegionSetsClosure() { | 6591 ~TearDownRegionSetsClosure() { |
6636 return false; | 6631 return false; |
6637 } | 6632 } |
6638 | 6633 |
6639 if (r->is_empty()) { | 6634 if (r->is_empty()) { |
6640 // Add free regions to the free list | 6635 // Add free regions to the free list |
6636 r->set_free(); | |
6641 r->set_allocation_context(AllocationContext::system()); | 6637 r->set_allocation_context(AllocationContext::system()); |
6642 _hrm->insert_into_free_list(r); | 6638 _hrm->insert_into_free_list(r); |
6643 } else if (!_free_list_only) { | 6639 } else if (!_free_list_only) { |
6644 assert(!r->is_young(), "we should not come across young regions"); | 6640 assert(!r->is_young(), "we should not come across young regions"); |
6645 | 6641 |
6646 if (r->isHumongous()) { | 6642 if (r->isHumongous()) { |
6647 // We ignore humongous regions, we left the humongous set unchanged | 6643 // We ignore humongous regions, we left the humongous set unchanged |
6648 } else { | 6644 } else { |
6649 // The rest should be old, add them to the old set | 6645 // Objects that were compacted would have ended up on regions |
6646 // that were previously old or free. | |
6647 assert(r->is_free() || r->is_old(), "invariant"); | |
6648 // We now consider them old, so register as such. | |
6649 r->set_old(); | |
6650 _old_set->add(r); | 6650 _old_set->add(r); |
6651 } | 6651 } |
6652 _total_used += r->used(); | 6652 _total_used += r->used(); |
6653 } | 6653 } |
6654 | 6654 |
6711 } | 6711 } |
6712 | 6712 |
6713 void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region, | 6713 void G1CollectedHeap::retire_mutator_alloc_region(HeapRegion* alloc_region, |
6714 size_t allocated_bytes) { | 6714 size_t allocated_bytes) { |
6715 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); | 6715 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); |
6716 assert(alloc_region->is_young(), "all mutator alloc regions should be young"); | 6716 assert(alloc_region->is_eden(), "all mutator alloc regions should be eden"); |
6717 | 6717 |
6718 g1_policy()->add_region_to_incremental_cset_lhs(alloc_region); | 6718 g1_policy()->add_region_to_incremental_cset_lhs(alloc_region); |
6719 _allocator->increase_used(allocated_bytes); | 6719 _allocator->increase_used(allocated_bytes); |
6720 _hr_printer.retire(alloc_region); | 6720 _hr_printer.retire(alloc_region); |
6721 // We update the eden sizes here, when the region is retired, | 6721 // We update the eden sizes here, when the region is retired, |
6760 if (survivor) { | 6760 if (survivor) { |
6761 new_alloc_region->set_survivor(); | 6761 new_alloc_region->set_survivor(); |
6762 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); | 6762 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); |
6763 check_bitmaps("Survivor Region Allocation", new_alloc_region); | 6763 check_bitmaps("Survivor Region Allocation", new_alloc_region); |
6764 } else { | 6764 } else { |
6765 new_alloc_region->set_old(); | |
6765 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); | 6766 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); |
6766 check_bitmaps("Old Region Allocation", new_alloc_region); | 6767 check_bitmaps("Old Region Allocation", new_alloc_region); |
6767 } | 6768 } |
6768 bool during_im = g1_policy()->during_initial_mark_pause(); | 6769 bool during_im = g1_policy()->during_initial_mark_pause(); |
6769 new_alloc_region->note_start_of_copying(during_im); | 6770 new_alloc_region->note_start_of_copying(during_im); |
6819 assert(hr->containing_set() == _humongous_set, err_msg("Heap region %u is starts humongous but not in humongous set.", hr->hrm_index())); | 6820 assert(hr->containing_set() == _humongous_set, err_msg("Heap region %u is starts humongous but not in humongous set.", hr->hrm_index())); |
6820 _humongous_count.increment(1u, hr->capacity()); | 6821 _humongous_count.increment(1u, hr->capacity()); |
6821 } else if (hr->is_empty()) { | 6822 } else if (hr->is_empty()) { |
6822 assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index())); | 6823 assert(_hrm->is_free(hr), err_msg("Heap region %u is empty but not on the free list.", hr->hrm_index())); |
6823 _free_count.increment(1u, hr->capacity()); | 6824 _free_count.increment(1u, hr->capacity()); |
6824 } else { | 6825 } else if (hr->is_old()) { |
6825 assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index())); | 6826 assert(hr->containing_set() == _old_set, err_msg("Heap region %u is old but not in the old set.", hr->hrm_index())); |
6826 _old_count.increment(1u, hr->capacity()); | 6827 _old_count.increment(1u, hr->capacity()); |
6828 } else { | |
6829 ShouldNotReachHere(); | |
6827 } | 6830 } |
6828 return false; | 6831 return false; |
6829 } | 6832 } |
6830 | 6833 |
6831 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) { | 6834 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) { |