194 hrrs->clear(); 195 CardTableModRefBS* ct_bs = 196 barrier_set_cast<CardTableModRefBS>(G1CollectedHeap::heap()->barrier_set()); 197 ct_bs->clear(MemRegion(bottom(), end())); 198 } 199 200 void HeapRegion::calc_gc_efficiency() { 201 // GC efficiency is the ratio of how much space would be 202 // reclaimed over how long we predict it would take to reclaim it. 203 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 204 G1CollectorPolicy* g1p = g1h->g1_policy(); 205 206 // Retrieve a prediction of the elapsed time for this region for 207 // a mixed gc because the region will only be evacuated during a 208 // mixed gc. 209 double region_elapsed_time_ms = 210 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); 211 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; 212 } 213 214 void HeapRegion::set_starts_humongous(HeapWord* obj_top) { 215 assert(!is_humongous(), "sanity / pre-condition"); 216 assert(top() == bottom(), "should be empty"); 217 218 _type.set_starts_humongous(); 219 _humongous_start_region = this; 220 221 _offsets.set_for_starts_humongous(obj_top); 222 } 223 224 void HeapRegion::set_continues_humongous(HeapRegion* first_hr) { 225 assert(!is_humongous(), "sanity / pre-condition"); 226 assert(top() == bottom(), "should be empty"); 227 assert(first_hr->is_starts_humongous(), "pre-condition"); 228 229 _type.set_continues_humongous(); 230 _humongous_start_region = first_hr; 231 } 232 233 void HeapRegion::clear_humongous() { 234 assert(is_humongous(), "pre-condition"); 235 236 assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); 237 _humongous_start_region = NULL; 238 } 239 240 HeapRegion::HeapRegion(uint hrm_index, 241 G1BlockOffsetSharedArray* sharedOffsetArray, 739 } 740 }; 741 742 // This really ought to be commoned up into OffsetTableContigSpace somehow. 743 // We would need a mechanism to make that code skip dead objects. 744 745 void HeapRegion::verify(VerifyOption vo, 746 bool* failures) const { 747 G1CollectedHeap* g1 = G1CollectedHeap::heap(); 748 *failures = false; 749 HeapWord* p = bottom(); 750 HeapWord* prev_p = NULL; 751 VerifyLiveClosure vl_cl(g1, vo); 752 bool is_region_humongous = is_humongous(); 753 size_t object_num = 0; 754 while (p < top()) { 755 oop obj = oop(p); 756 size_t obj_size = block_size(p); 757 object_num += 1; 758 759 if (is_region_humongous != g1->is_humongous(obj_size) && 760 !g1->is_obj_dead(obj, this)) { // Dead objects may have bigger block_size since they span several objects. 761 gclog_or_tty->print_cr("obj " PTR_FORMAT " is of %shumongous size (" 762 SIZE_FORMAT " words) in a %shumongous region", 763 p2i(p), g1->is_humongous(obj_size) ? "" : "non-", 764 obj_size, is_region_humongous ? "" : "non-"); 765 *failures = true; 766 return; 767 } 768 769 if (!g1->is_obj_dead_cond(obj, this, vo)) { 770 if (obj->is_oop()) { 771 Klass* klass = obj->klass(); 772 bool is_metaspace_object = Metaspace::contains(klass) || 773 (vo == VerifyOption_G1UsePrevMarking && 774 ClassLoaderDataGraph::unload_list_contains(klass)); 775 if (!is_metaspace_object) { 776 gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " " 777 "not metadata", p2i(klass), p2i(obj)); 778 *failures = true; 779 return; 780 } else if (!klass->is_klass()) { 781 gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " " 782 "not a klass", p2i(klass), p2i(obj)); 783 *failures = true; 784 return; 785 } else { 786 vl_cl.set_containing_obj(obj); 787 obj->oop_iterate_no_header(&vl_cl); 788 if (vl_cl.failures()) { 857 HeapWord* b_start_3 = _offsets.block_start_const(addr_3); 858 if (b_start_3 != p) { 859 gclog_or_tty->print_cr("BOT look up for top + diff: " PTR_FORMAT " " 860 " yielded " PTR_FORMAT ", expecting " PTR_FORMAT, 861 p2i(addr_3), p2i(b_start_3), p2i(p)); 862 *failures = true; 863 return; 864 } 865 } 866 867 // Look up end - 1 868 HeapWord* addr_4 = the_end - 1; 869 HeapWord* b_start_4 = _offsets.block_start_const(addr_4); 870 if (b_start_4 != p) { 871 gclog_or_tty->print_cr("BOT look up for end - 1: " PTR_FORMAT " " 872 " yielded " PTR_FORMAT ", expecting " PTR_FORMAT, 873 p2i(addr_4), p2i(b_start_4), p2i(p)); 874 *failures = true; 875 return; 876 } 877 } 878 879 if (is_region_humongous && object_num > 1) { 880 gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] is humongous " 881 "but has " SIZE_FORMAT ", objects", 882 p2i(bottom()), p2i(end()), object_num); 883 *failures = true; 884 return; 885 } 886 887 verify_strong_code_roots(vo, failures); 888 } 889 890 void HeapRegion::verify() const { 891 bool dummy = false; 892 verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy); 893 } 894 895 void HeapRegion::prepare_for_compaction(CompactPoint* cp) { 896 scan_and_forward(this, cp); 897 } 898 899 // G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go 900 // away eventually. 901 902 void G1OffsetTableContigSpace::clear(bool mangle_space) { 903 set_top(bottom()); 904 _scan_top = bottom(); | 194 hrrs->clear(); 195 CardTableModRefBS* ct_bs = 196 barrier_set_cast<CardTableModRefBS>(G1CollectedHeap::heap()->barrier_set()); 197 ct_bs->clear(MemRegion(bottom(), end())); 198 } 199 200 void HeapRegion::calc_gc_efficiency() { 201 // GC efficiency is the ratio of how much space would be 202 // reclaimed over how long we predict it would take to reclaim it. 203 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 204 G1CollectorPolicy* g1p = g1h->g1_policy(); 205 206 // Retrieve a prediction of the elapsed time for this region for 207 // a mixed gc because the region will only be evacuated during a 208 // mixed gc. 209 double region_elapsed_time_ms = 210 g1p->predict_region_elapsed_time_ms(this, false /* for_young_gc */); 211 _gc_efficiency = (double) reclaimable_bytes() / region_elapsed_time_ms; 212 } 213 214 void HeapRegion::set_starts_humongous(HeapWord* end) { 215 assert(!is_humongous(), "sanity / pre-condition"); 216 assert(top() == bottom(), "should be empty"); 217 218 _type.set_starts_humongous(); 219 _humongous_start_region = this; 220 221 _offsets.set_for_starts_humongous(end); 222 } 223 224 void HeapRegion::set_continues_humongous(HeapRegion* first_hr) { 225 assert(!is_humongous(), "sanity / pre-condition"); 226 assert(top() == bottom(), "should be empty"); 227 assert(first_hr->is_starts_humongous(), "pre-condition"); 228 229 _type.set_continues_humongous(); 230 _humongous_start_region = first_hr; 231 } 232 233 void HeapRegion::clear_humongous() { 234 assert(is_humongous(), "pre-condition"); 235 236 assert(capacity() == HeapRegion::GrainBytes, "pre-condition"); 237 _humongous_start_region = NULL; 238 } 239 240 HeapRegion::HeapRegion(uint hrm_index, 241 G1BlockOffsetSharedArray* sharedOffsetArray, 739 } 740 }; 741 742 // This really ought to be commoned up into OffsetTableContigSpace somehow. 743 // We would need a mechanism to make that code skip dead objects. 744 745 void HeapRegion::verify(VerifyOption vo, 746 bool* failures) const { 747 G1CollectedHeap* g1 = G1CollectedHeap::heap(); 748 *failures = false; 749 HeapWord* p = bottom(); 750 HeapWord* prev_p = NULL; 751 VerifyLiveClosure vl_cl(g1, vo); 752 bool is_region_humongous = is_humongous(); 753 size_t object_num = 0; 754 while (p < top()) { 755 oop obj = oop(p); 756 size_t obj_size = block_size(p); 757 object_num += 1; 758 759 if (!g1->is_obj_dead_cond(obj, this, vo)) { 760 if (obj->is_oop()) { 761 Klass* klass = obj->klass(); 762 bool is_metaspace_object = Metaspace::contains(klass) || 763 (vo == VerifyOption_G1UsePrevMarking && 764 ClassLoaderDataGraph::unload_list_contains(klass)); 765 if (!is_metaspace_object) { 766 gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " " 767 "not metadata", p2i(klass), p2i(obj)); 768 *failures = true; 769 return; 770 } else if (!klass->is_klass()) { 771 gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " " 772 "not a klass", p2i(klass), p2i(obj)); 773 *failures = true; 774 return; 775 } else { 776 vl_cl.set_containing_obj(obj); 777 obj->oop_iterate_no_header(&vl_cl); 778 if (vl_cl.failures()) { 847 HeapWord* b_start_3 = _offsets.block_start_const(addr_3); 848 if (b_start_3 != p) { 849 gclog_or_tty->print_cr("BOT look up for top + diff: " PTR_FORMAT " " 850 " yielded " PTR_FORMAT ", expecting " PTR_FORMAT, 851 p2i(addr_3), p2i(b_start_3), p2i(p)); 852 *failures = true; 853 return; 854 } 855 } 856 857 // Look up end - 1 858 HeapWord* addr_4 = the_end - 1; 859 HeapWord* b_start_4 = _offsets.block_start_const(addr_4); 860 if (b_start_4 != p) { 861 gclog_or_tty->print_cr("BOT look up for end - 1: " PTR_FORMAT " " 862 " yielded " PTR_FORMAT ", expecting " PTR_FORMAT, 863 p2i(addr_4), p2i(b_start_4), p2i(p)); 864 *failures = true; 865 return; 866 } 867 } 868 869 verify_strong_code_roots(vo, failures); 870 } 871 872 void HeapRegion::verify() const { 873 bool dummy = false; 874 verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy); 875 } 876 877 void HeapRegion::prepare_for_compaction(CompactPoint* cp) { 878 scan_and_forward(this, cp); 879 } 880 881 // G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go 882 // away eventually. 883 884 void G1OffsetTableContigSpace::clear(bool mangle_space) { 885 set_top(bottom()); 886 _scan_top = bottom(); |