194 |
194 |
195 class G1PrepareCompactClosure: public HeapRegionClosure { |
195 class G1PrepareCompactClosure: public HeapRegionClosure { |
196 G1CollectedHeap* _g1h; |
196 G1CollectedHeap* _g1h; |
197 ModRefBarrierSet* _mrbs; |
197 ModRefBarrierSet* _mrbs; |
198 CompactPoint _cp; |
198 CompactPoint _cp; |
199 HumongousRegionSet _humongous_proxy_set; |
199 HeapRegionSetCount _humongous_regions_removed; |
200 |
200 |
201 void free_humongous_region(HeapRegion* hr) { |
201 void free_humongous_region(HeapRegion* hr) { |
202 HeapWord* end = hr->end(); |
202 HeapWord* end = hr->end(); |
203 size_t dummy_pre_used; |
|
204 FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep"); |
203 FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep"); |
205 |
204 |
206 assert(hr->startsHumongous(), |
205 assert(hr->startsHumongous(), |
207 "Only the start of a humongous region should be freed."); |
206 "Only the start of a humongous region should be freed."); |
208 _g1h->free_humongous_region(hr, &dummy_pre_used, &dummy_free_list, |
207 |
209 &_humongous_proxy_set, false /* par */); |
208 hr->set_containing_set(NULL); |
|
209 _humongous_regions_removed.increment(1u, hr->capacity()); |
|
210 |
|
211 _g1h->free_humongous_region(hr, &dummy_free_list, false /* par */); |
210 hr->prepare_for_compaction(&_cp); |
212 hr->prepare_for_compaction(&_cp); |
211 // Also clear the part of the card table that will be unused after |
213 // Also clear the part of the card table that will be unused after |
212 // compaction. |
214 // compaction. |
213 _mrbs->clear(MemRegion(hr->compaction_top(), end)); |
215 _mrbs->clear(MemRegion(hr->compaction_top(), end)); |
214 dummy_free_list.remove_all(); |
216 dummy_free_list.remove_all(); |
217 public: |
219 public: |
218 G1PrepareCompactClosure(CompactibleSpace* cs) |
220 G1PrepareCompactClosure(CompactibleSpace* cs) |
219 : _g1h(G1CollectedHeap::heap()), |
221 : _g1h(G1CollectedHeap::heap()), |
220 _mrbs(_g1h->g1_barrier_set()), |
222 _mrbs(_g1h->g1_barrier_set()), |
221 _cp(NULL, cs, cs->initialize_threshold()), |
223 _cp(NULL, cs, cs->initialize_threshold()), |
222 _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { } |
224 _humongous_regions_removed() { } |
223 |
225 |
224 void update_sets() { |
226 void update_sets() { |
225 // We'll recalculate total used bytes and recreate the free list |
227 // We'll recalculate total used bytes and recreate the free list |
226 // at the end of the GC, so no point in updating those values here. |
228 // at the end of the GC, so no point in updating those values here. |
227 _g1h->update_sets_after_freeing_regions(0, /* pre_used */ |
229 HeapRegionSetCount empty_set; |
228 NULL, /* free_list */ |
230 _g1h->remove_from_old_sets(empty_set, _humongous_regions_removed); |
229 NULL, /* old_proxy_set */ |
|
230 &_humongous_proxy_set, |
|
231 false /* par */); |
|
232 } |
231 } |
233 |
232 |
234 bool doHeapRegion(HeapRegion* hr) { |
233 bool doHeapRegion(HeapRegion* hr) { |
235 if (hr->isHumongous()) { |
234 if (hr->isHumongous()) { |
236 if (hr->startsHumongous()) { |
235 if (hr->startsHumongous()) { |