< prev index next >

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

Print this page




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


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

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