178 // from the mark word can make verification of the dictionaries 179 // fail. At the end of the GC, the original mark word values 180 // (including hash values) are restored to the appropriate 181 // objects. 182 if (!VerifySilently) { 183 gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying "); 184 } 185 Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord); 186 if (!VerifySilently) { 187 gclog_or_tty->print_cr("]"); 188 } 189 } 190 191 gc_tracer()->report_object_count_after_gc(&GenMarkSweep::is_alive); 192 } 193 194 class G1PrepareCompactClosure: public HeapRegionClosure { 195 G1CollectedHeap* _g1h; 196 ModRefBarrierSet* _mrbs; 197 CompactPoint _cp; 198 HumongousRegionSet _humongous_proxy_set; 199 200 void free_humongous_region(HeapRegion* hr) { 201 HeapWord* end = hr->end(); 202 size_t dummy_pre_used; 203 FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep"); 204 205 assert(hr->startsHumongous(), 206 "Only the start of a humongous region should be freed."); 207 _g1h->free_humongous_region(hr, &dummy_pre_used, &dummy_free_list, 208 &_humongous_proxy_set, false /* par */); 209 hr->prepare_for_compaction(&_cp); 210 // Also clear the part of the card table that will be unused after 211 // compaction. 212 _mrbs->clear(MemRegion(hr->compaction_top(), end)); 213 dummy_free_list.remove_all(); 214 } 215 216 public: 217 G1PrepareCompactClosure(CompactibleSpace* cs) 218 : _g1h(G1CollectedHeap::heap()), 219 _mrbs(_g1h->g1_barrier_set()), 220 _cp(NULL, cs, cs->initialize_threshold()), 221 _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { } 222 223 void update_sets() { 224 // We'll recalculate total used bytes and recreate the free list 225 // at the end of the GC, so no point in updating those values here. 226 _g1h->update_sets_after_freeing_regions(0, /* pre_used */ 227 NULL, /* free_list */ 228 NULL, /* old_proxy_set */ 229 &_humongous_proxy_set, 230 false /* par */); 231 } 232 233 bool doHeapRegion(HeapRegion* hr) { 234 if (hr->isHumongous()) { 235 if (hr->startsHumongous()) { 236 oop obj = oop(hr->bottom()); 237 if (obj->is_gc_marked()) { 238 obj->forward_to(obj); 239 } else { 240 free_humongous_region(hr); 241 } 242 } else { 243 assert(hr->continuesHumongous(), "Invalid humongous."); 244 } 245 } else { 246 hr->prepare_for_compaction(&_cp); 247 // Also clear the part of the card table that will be unused after 248 // compaction. 249 _mrbs->clear(MemRegion(hr->compaction_top(), hr->end())); 250 } | 178 // from the mark word can make verification of the dictionaries 179 // fail. At the end of the GC, the original mark word values 180 // (including hash values) are restored to the appropriate 181 // objects. 182 if (!VerifySilently) { 183 gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying "); 184 } 185 Universe::heap()->verify(VerifySilently, VerifyOption_G1UseMarkWord); 186 if (!VerifySilently) { 187 gclog_or_tty->print_cr("]"); 188 } 189 } 190 191 gc_tracer()->report_object_count_after_gc(&GenMarkSweep::is_alive); 192 } 193 194 class G1PrepareCompactClosure: public HeapRegionClosure { 195 G1CollectedHeap* _g1h; 196 ModRefBarrierSet* _mrbs; 197 CompactPoint _cp; 198 HeapRegionSetCount _humongous_regions_removed; 199 200 void free_humongous_region(HeapRegion* hr) { 201 HeapWord* end = hr->end(); 202 FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep", NULL); 203 204 assert(hr->startsHumongous(), 205 "Only the start of a humongous region should be freed."); 206 207 hr->set_containing_set(NULL); 208 _humongous_regions_removed.increment(1u, hr->capacity()); 209 210 _g1h->free_humongous_region(hr, &dummy_free_list, false /* par */); 211 hr->prepare_for_compaction(&_cp); 212 // Also clear the part of the card table that will be unused after 213 // compaction. 214 _mrbs->clear(MemRegion(hr->compaction_top(), end)); 215 dummy_free_list.remove_all(); 216 } 217 218 public: 219 G1PrepareCompactClosure(CompactibleSpace* cs) 220 : _g1h(G1CollectedHeap::heap()), 221 _mrbs(_g1h->g1_barrier_set()), 222 _cp(NULL, cs, cs->initialize_threshold()), 223 _humongous_regions_removed() { } 224 225 void update_sets() { 226 // We'll recalculate total used bytes and recreate the free list 227 // at the end of the GC, so no point in updating those values here. 228 HeapRegionSetCount empty_set; 229 _g1h->remove_from_sets(empty_set, _humongous_regions_removed); 230 } 231 232 bool doHeapRegion(HeapRegion* hr) { 233 if (hr->isHumongous()) { 234 if (hr->startsHumongous()) { 235 oop obj = oop(hr->bottom()); 236 if (obj->is_gc_marked()) { 237 obj->forward_to(obj); 238 } else { 239 free_humongous_region(hr); 240 } 241 } else { 242 assert(hr->continuesHumongous(), "Invalid humongous."); 243 } 244 } else { 245 hr->prepare_for_compaction(&_cp); 246 // Also clear the part of the card table that will be unused after 247 // compaction. 248 _mrbs->clear(MemRegion(hr->compaction_top(), hr->end())); 249 } |