comparison src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @ 3766:c3f1170908be

7045330: G1: Simplify/fix the HeapRegionSeq class 7042285: G1: native memory leak during humongous object allocation 6804436: G1: heap region indices should be size_t Summary: A series of fixes and improvements to the HeapRegionSeq class: a) replace the _regions growable array with a standard C array, b) avoid de-allocating / re-allocating HeapRegion instances when the heap shrinks / grows (fix for 7042285), c) introduce fast method to map address to HeapRegion via a "biased" array pointer, d) embed the _hrs object in G1CollectedHeap, instead of pointing to it via an indirection, e) assume that all the regions added to the HeapRegionSeq instance are contiguous, f) replace int's with size_t's for indexes (and expand that to HeapRegion as part of 6804436), g) remove unnecessary / unused methods, h) rename a couple of fields (_alloc_search_start and _seq_bottom), i) fix iterate_from() not to always start from index 0 irrespective of the region passed to it, j) add a verification method to check the HeapRegionSeq assumptions, k) always call the wrappers for _hrs.iterate(), _hrs_length(), and _hrs.at() from G1CollectedHeap, not those methods directly, and l) unify the code that expands the sequence (by either re-using or creating a new HeapRegion) and make it robust wrt to a HeapRegion allocation failing. Reviewed-by: stefank, johnc, brutisso
author tonyp
date Fri, 10 Jun 2011 13:16:40 -0400
parents ae5b2f1dcf12
children 5f6f2615433a
comparison
equal deleted inserted replaced
3765:ae5b2f1dcf12 3766:c3f1170908be
2637 add_to_collection_set(HeapRegion* hr) { 2637 add_to_collection_set(HeapRegion* hr) {
2638 assert(_inc_cset_build_state == Active, "Precondition"); 2638 assert(_inc_cset_build_state == Active, "Precondition");
2639 assert(!hr->is_young(), "non-incremental add of young region"); 2639 assert(!hr->is_young(), "non-incremental add of young region");
2640 2640
2641 if (G1PrintHeapRegions) { 2641 if (G1PrintHeapRegions) {
2642 gclog_or_tty->print_cr("added region to cset " 2642 gclog_or_tty->print_cr("added region to cset "HR_FORMAT,
2643 "%d:["PTR_FORMAT", "PTR_FORMAT"], " 2643 HR_FORMAT_PARAMS(hr));
2644 "top "PTR_FORMAT", %s",
2645 hr->hrs_index(), hr->bottom(), hr->end(),
2646 hr->top(), hr->is_young() ? "YOUNG" : "NOT_YOUNG");
2647 } 2644 }
2648 2645
2649 if (_g1->mark_in_progress()) 2646 if (_g1->mark_in_progress())
2650 _g1->concurrent_mark()->registerCSetRegion(hr); 2647 _g1->concurrent_mark()->registerCSetRegion(hr);
2651 2648
2811 _inc_cset_tail->set_next_in_collection_set(hr); 2808 _inc_cset_tail->set_next_in_collection_set(hr);
2812 } 2809 }
2813 _inc_cset_tail = hr; 2810 _inc_cset_tail = hr;
2814 2811
2815 if (G1PrintHeapRegions) { 2812 if (G1PrintHeapRegions) {
2816 gclog_or_tty->print_cr(" added region to incremental cset (RHS) " 2813 gclog_or_tty->print_cr(" added region to incremental cset (RHS) "HR_FORMAT,
2817 "%d:["PTR_FORMAT", "PTR_FORMAT"], " 2814 HR_FORMAT_PARAMS(hr));
2818 "top "PTR_FORMAT", young %s",
2819 hr->hrs_index(), hr->bottom(), hr->end(),
2820 hr->top(), (hr->is_young()) ? "YES" : "NO");
2821 } 2815 }
2822 } 2816 }
2823 2817
2824 // Add the region to the LHS of the incremental cset 2818 // Add the region to the LHS of the incremental cset
2825 void G1CollectorPolicy::add_region_to_incremental_cset_lhs(HeapRegion* hr) { 2819 void G1CollectorPolicy::add_region_to_incremental_cset_lhs(HeapRegion* hr) {
2836 _inc_cset_tail = hr; 2830 _inc_cset_tail = hr;
2837 } 2831 }
2838 _inc_cset_head = hr; 2832 _inc_cset_head = hr;
2839 2833
2840 if (G1PrintHeapRegions) { 2834 if (G1PrintHeapRegions) {
2841 gclog_or_tty->print_cr(" added region to incremental cset (LHS) " 2835 gclog_or_tty->print_cr(" added region to incremental cset (LHS) "HR_FORMAT,
2842 "%d:["PTR_FORMAT", "PTR_FORMAT"], " 2836 HR_FORMAT_PARAMS(hr));
2843 "top "PTR_FORMAT", young %s",
2844 hr->hrs_index(), hr->bottom(), hr->end(),
2845 hr->top(), (hr->is_young()) ? "YES" : "NO");
2846 } 2837 }
2847 } 2838 }
2848 2839
2849 #ifndef PRODUCT 2840 #ifndef PRODUCT
2850 void G1CollectorPolicy::print_collection_set(HeapRegion* list_head, outputStream* st) { 2841 void G1CollectorPolicy::print_collection_set(HeapRegion* list_head, outputStream* st) {