< prev index next >

src/share/vm/gc/g1/g1MarkSweep.cpp

Print this page




 318   _archive_region_map.set_by_address(range, is_archive);
 319 }
 320 
 321 bool G1MarkSweep::in_archive_range(oop object) {
 322   // This is the out-of-line part of is_archive_object test, done separately
 323   // to avoid additional performance impact when the check is not enabled.
 324   return _archive_region_map.get_by_address((HeapWord*)object);
 325 }
 326 
 327 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) {
 328   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 329   g1h->heap_region_iterate(blk);
 330   blk->update_sets();
 331 }
 332 
 333 void G1PrepareCompactClosure::free_humongous_region(HeapRegion* hr) {
 334   HeapWord* end = hr->end();
 335   FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep");
 336 
 337   hr->set_containing_set(NULL);
 338   _humongous_regions_removed.increment(1u, hr->capacity());
 339 
 340   _g1h->free_humongous_region(hr, &dummy_free_list, false /* par */);
 341   prepare_for_compaction(hr, end);
 342   dummy_free_list.remove_all();
 343 }
 344 
 345 void G1PrepareCompactClosure::prepare_for_compaction(HeapRegion* hr, HeapWord* end) {
 346   // If this is the first live region that we came across which we can compact,
 347   // initialize the CompactPoint.
 348   if (!is_cp_initialized()) {
 349     _cp.space = hr;
 350     _cp.threshold = hr->initialize_threshold();
 351   }
 352   prepare_for_compaction_work(&_cp, hr, end);
 353 }
 354 
 355 void G1PrepareCompactClosure::prepare_for_compaction_work(CompactPoint* cp,
 356                                                           HeapRegion* hr,
 357                                                           HeapWord* end) {
 358   hr->prepare_for_compaction(cp);
 359   // Also clear the part of the card table that will be unused after
 360   // compaction.
 361   _mrbs->clear(MemRegion(hr->compaction_top(), end));
 362 }
 363 
 364 void G1PrepareCompactClosure::update_sets() {
 365   // We'll recalculate total used bytes and recreate the free list
 366   // at the end of the GC, so no point in updating those values here.
 367   HeapRegionSetCount empty_set;
 368   _g1h->remove_from_old_sets(empty_set, _humongous_regions_removed);
 369 }
 370 
 371 bool G1PrepareCompactClosure::doHeapRegion(HeapRegion* hr) {
 372   if (hr->is_humongous()) {
 373     oop obj = oop(hr->humongous_start_region()->bottom());
 374     if (hr->is_starts_humongous() && obj->is_gc_marked()) {
 375       obj->forward_to(obj);
 376     }
 377     if (!obj->is_gc_marked()) {
 378       free_humongous_region(hr);
 379     }
 380   } else if (!hr->is_pinned()) {
 381     prepare_for_compaction(hr, hr->end());
 382   }
 383   return false;
 384 }


 318   _archive_region_map.set_by_address(range, is_archive);
 319 }
 320 
 321 bool G1MarkSweep::in_archive_range(oop object) {
 322   // This is the out-of-line part of is_archive_object test, done separately
 323   // to avoid additional performance impact when the check is not enabled.
 324   return _archive_region_map.get_by_address((HeapWord*)object);
 325 }
 326 
 327 void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) {
 328   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 329   g1h->heap_region_iterate(blk);
 330   blk->update_sets();
 331 }
 332 
 333 void G1PrepareCompactClosure::free_humongous_region(HeapRegion* hr) {
 334   HeapWord* end = hr->end();
 335   FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep");
 336 
 337   hr->set_containing_set(NULL);
 338   _humongous_regions_removed++;
 339 
 340   _g1h->free_humongous_region(hr, &dummy_free_list, false /* par */);
 341   prepare_for_compaction(hr, end);
 342   dummy_free_list.remove_all();
 343 }
 344 
 345 void G1PrepareCompactClosure::prepare_for_compaction(HeapRegion* hr, HeapWord* end) {
 346   // If this is the first live region that we came across which we can compact,
 347   // initialize the CompactPoint.
 348   if (!is_cp_initialized()) {
 349     _cp.space = hr;
 350     _cp.threshold = hr->initialize_threshold();
 351   }
 352   prepare_for_compaction_work(&_cp, hr, end);
 353 }
 354 
 355 void G1PrepareCompactClosure::prepare_for_compaction_work(CompactPoint* cp,
 356                                                           HeapRegion* hr,
 357                                                           HeapWord* end) {
 358   hr->prepare_for_compaction(cp);
 359   // Also clear the part of the card table that will be unused after
 360   // compaction.
 361   _mrbs->clear(MemRegion(hr->compaction_top(), end));
 362 }
 363 
 364 void G1PrepareCompactClosure::update_sets() {
 365   // We'll recalculate total used bytes and recreate the free list
 366   // at the end of the GC, so no point in updating those values here.
 367   _g1h->remove_from_old_sets(0, _humongous_regions_removed);

 368 }
 369 
 370 bool G1PrepareCompactClosure::doHeapRegion(HeapRegion* hr) {
 371   if (hr->is_humongous()) {
 372     oop obj = oop(hr->humongous_start_region()->bottom());
 373     if (hr->is_starts_humongous() && obj->is_gc_marked()) {
 374       obj->forward_to(obj);
 375     }
 376     if (!obj->is_gc_marked()) {
 377       free_humongous_region(hr);
 378     }
 379   } else if (!hr->is_pinned()) {
 380     prepare_for_compaction(hr, hr->end());
 381   }
 382   return false;
 383 }
< prev index next >