Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 626:87fa6e083d82
6760309: G1: update remembered sets during Full GCs
Reviewed-by: iveresov, tonyp
author | apetrusenko |
---|---|
date | Tue, 10 Mar 2009 00:47:05 -0700 |
parents | bcedf688d882 |
children | 7bb995fbd3c0 6c4cea9bfa11 |
comparison
equal
deleted
inserted
replaced
620:bcedf688d882 | 626:87fa6e083d82 |
---|---|
818 } | 818 } |
819 return false; | 819 return false; |
820 } | 820 } |
821 }; | 821 }; |
822 | 822 |
823 class RebuildRSOutOfRegionClosure: public HeapRegionClosure { | |
824 G1CollectedHeap* _g1h; | |
825 UpdateRSOopClosure _cl; | |
826 int _worker_i; | |
827 public: | |
828 RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, int worker_i = 0) : | |
829 _cl(g1->g1_rem_set()->as_HRInto_G1RemSet(), worker_i), | |
830 _worker_i(worker_i), | |
831 _g1h(g1) | |
832 { } | |
833 bool doHeapRegion(HeapRegion* r) { | |
834 if (!r->continuesHumongous()) { | |
835 _cl.set_from(r); | |
836 r->oop_iterate(&_cl); | |
837 } | |
838 return false; | |
839 } | |
840 }; | |
841 | |
842 class ParRebuildRSTask: public AbstractGangTask { | |
843 G1CollectedHeap* _g1; | |
844 public: | |
845 ParRebuildRSTask(G1CollectedHeap* g1) | |
846 : AbstractGangTask("ParRebuildRSTask"), | |
847 _g1(g1) | |
848 { } | |
849 | |
850 void work(int i) { | |
851 RebuildRSOutOfRegionClosure rebuild_rs(_g1, i); | |
852 _g1->heap_region_par_iterate_chunked(&rebuild_rs, i, | |
853 HeapRegion::RebuildRSClaimValue); | |
854 } | |
855 }; | |
856 | |
823 void G1CollectedHeap::do_collection(bool full, bool clear_all_soft_refs, | 857 void G1CollectedHeap::do_collection(bool full, bool clear_all_soft_refs, |
824 size_t word_size) { | 858 size_t word_size) { |
825 ResourceMark rm; | 859 ResourceMark rm; |
826 | 860 |
827 if (full && DisableExplicitGC) { | 861 if (full && DisableExplicitGC) { |
924 } | 958 } |
925 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); | 959 NOT_PRODUCT(ref_processor()->verify_no_references_recorded()); |
926 | 960 |
927 reset_gc_time_stamp(); | 961 reset_gc_time_stamp(); |
928 // Since everything potentially moved, we will clear all remembered | 962 // Since everything potentially moved, we will clear all remembered |
929 // sets, and clear all cards. Later we will also cards in the used | 963 // sets, and clear all cards. Later we will rebuild remebered |
930 // portion of the heap after the resizing (which could be a shrinking.) | 964 // sets. We will also reset the GC time stamps of the regions. |
931 // We will also reset the GC time stamps of the regions. | |
932 PostMCRemSetClearClosure rs_clear(mr_bs()); | 965 PostMCRemSetClearClosure rs_clear(mr_bs()); |
933 heap_region_iterate(&rs_clear); | 966 heap_region_iterate(&rs_clear); |
934 | 967 |
935 // Resize the heap if necessary. | 968 // Resize the heap if necessary. |
936 resize_if_necessary_after_full_collection(full ? 0 : word_size); | 969 resize_if_necessary_after_full_collection(full ? 0 : word_size); |
937 | 970 |
938 // Since everything potentially moved, we will clear all remembered | |
939 // sets, but also dirty all cards corresponding to used regions. | |
940 PostMCRemSetInvalidateClosure rs_invalidate(mr_bs()); | |
941 heap_region_iterate(&rs_invalidate); | |
942 if (_cg1r->use_cache()) { | 971 if (_cg1r->use_cache()) { |
943 _cg1r->clear_and_record_card_counts(); | 972 _cg1r->clear_and_record_card_counts(); |
944 _cg1r->clear_hot_cache(); | 973 _cg1r->clear_hot_cache(); |
974 } | |
975 | |
976 // Rebuild remembered sets of all regions. | |
977 if (ParallelGCThreads > 0) { | |
978 ParRebuildRSTask rebuild_rs_task(this); | |
979 assert(check_heap_region_claim_values( | |
980 HeapRegion::InitialClaimValue), "sanity check"); | |
981 set_par_threads(workers()->total_workers()); | |
982 workers()->run_task(&rebuild_rs_task); | |
983 set_par_threads(0); | |
984 assert(check_heap_region_claim_values( | |
985 HeapRegion::RebuildRSClaimValue), "sanity check"); | |
986 reset_heap_region_claim_values(); | |
987 } else { | |
988 RebuildRSOutOfRegionClosure rebuild_rs(this); | |
989 heap_region_iterate(&rebuild_rs); | |
945 } | 990 } |
946 | 991 |
947 if (PrintGC) { | 992 if (PrintGC) { |
948 print_size_transition(gclog_or_tty, g1h_prev_used, used(), capacity()); | 993 print_size_transition(gclog_or_tty, g1h_prev_used, used(), capacity()); |
949 } | 994 } |