< prev index next >

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

Print this page




 349   HeapRegion* hr = NULL;
 350   for (uint i = first + 1; i < last; ++i) {
 351     hr = region_at(i);
 352     hr->set_continues_humongous(first_hr);
 353     hr->set_allocation_context(context);
 354   }
 355 
 356   // Up to this point no concurrent thread would have been able to
 357   // do any scanning on any region in this series. All the top
 358   // fields still point to bottom, so the intersection between
 359   // [bottom,top] and [card_start,card_end] will be empty. Before we
 360   // update the top fields, we'll do a storestore to make sure that
 361   // no thread sees the update to top before the zeroing of the
 362   // object header and the BOT initialization.
 363   OrderAccess::storestore();
 364 
 365   // Now that the BOT and the object header have been initialized,
 366   // we can update top of the "starts humongous" region.
 367   first_hr->set_top(MIN2(first_hr->end(), obj_top));
 368   if (_hr_printer.is_active()) {
 369     _hr_printer.alloc(G1HRPrinter::StartsHumongous, first_hr, first_hr->end());
 370   }
 371 
 372   // Now, we will update the top fields of the "continues humongous"
 373   // regions. The reason we need to do this is that, otherwise,
 374   // these regions would look empty and this will confuse parts of
 375   // G1. For example, the code that looks for a consecutive number
 376   // of empty regions will consider them empty and try to
 377   // re-allocate them. We can extend is_empty() to also include
 378   // !is_continues_humongous(), but it is easier to just update the top
 379   // fields here. The way we set top for all regions (i.e., top ==
 380   // end for all regions but the last one, top == new_top for the
 381   // last one) is actually used when we will free up the humongous
 382   // region in free_humongous_region().
 383   hr = NULL;
 384   for (uint i = first + 1; i < last; ++i) {
 385     hr = region_at(i);
 386     if ((i + 1) == last) {
 387       // last continues humongous region
 388       assert(hr->bottom() < obj_top && obj_top <= hr->end(),
 389              "new_top should fall on this region");


1111 
1112   ShouldNotReachHere();
1113 }
1114 
1115 class PostMCRemSetClearClosure: public HeapRegionClosure {
1116   G1CollectedHeap* _g1h;
1117   ModRefBarrierSet* _mr_bs;
1118 public:
1119   PostMCRemSetClearClosure(G1CollectedHeap* g1h, ModRefBarrierSet* mr_bs) :
1120     _g1h(g1h), _mr_bs(mr_bs) {}
1121 
1122   bool doHeapRegion(HeapRegion* r) {
1123     HeapRegionRemSet* hrrs = r->rem_set();
1124 
1125     _g1h->reset_gc_time_stamps(r);
1126 
1127     if (r->is_continues_humongous()) {
1128       // We'll assert that the strong code root list and RSet is empty
1129       assert(hrrs->strong_code_roots_list_length() == 0, "sanity");
1130       assert(hrrs->occupied() == 0, "RSet should be empty");
1131       return false;
1132     }
1133 
1134     hrrs->clear();

1135     // You might think here that we could clear just the cards
1136     // corresponding to the used region.  But no: if we leave a dirty card
1137     // in a region we might allocate into, then it would prevent that card
1138     // from being enqueued, and cause it to be missed.
1139     // Re: the performance cost: we shouldn't be doing full GC anyway!
1140     _mr_bs->clear(MemRegion(r->bottom(), r->end()));
1141 
1142     return false;
1143   }
1144 };
1145 
1146 void G1CollectedHeap::clear_rsets_post_compaction() {
1147   PostMCRemSetClearClosure rs_clear(this, g1_barrier_set());
1148   heap_region_iterate(&rs_clear);
1149 }
1150 
1151 class RebuildRSOutOfRegionClosure: public HeapRegionClosure {
1152   G1CollectedHeap*   _g1h;
1153   UpdateRSOopClosure _cl;
1154 public:


5742               "Only eagerly reclaiming type arrays is supported, but the object "
5743               PTR_FORMAT " is not.", p2i(r->bottom()));
5744 
5745     if (G1TraceEagerReclaimHumongousObjects) {
5746       gclog_or_tty->print_cr("Dead humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT " with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
5747                              region_idx,
5748                              (size_t)obj->size() * HeapWordSize,
5749                              p2i(r->bottom()),
5750                              r->rem_set()->occupied(),
5751                              r->rem_set()->strong_code_roots_list_length(),
5752                              next_bitmap->isMarked(r->bottom()),
5753                              g1h->is_humongous_reclaim_candidate(region_idx),
5754                              obj->is_typeArray()
5755                             );
5756     }
5757     // Need to clear mark bit of the humongous object if already set.
5758     if (next_bitmap->isMarked(r->bottom())) {
5759       next_bitmap->clear(r->bottom());
5760     }
5761     do {
5762       HeapRegion* next = g1h->next_humongous_region(r);
5763       _freed_bytes += r->used();
5764       r->set_containing_set(NULL);
5765       _humongous_regions_removed.increment(1u, r->capacity());
5766       g1h->free_humongous_region(r, _free_region_list, false);
5767       r = next;
5768     } while (r != NULL);
5769 
5770     return false;
5771   }
5772 
5773   HeapRegionSetCount& humongous_free_count() {
5774     return _humongous_regions_removed;
5775   }
5776 
5777   size_t bytes_freed() const {
5778     return _freed_bytes;
5779   }
5780 
5781   size_t humongous_reclaimed() const {
5782     return _humongous_regions_removed.length();




 349   HeapRegion* hr = NULL;
 350   for (uint i = first + 1; i < last; ++i) {
 351     hr = region_at(i);
 352     hr->set_continues_humongous(first_hr);
 353     hr->set_allocation_context(context);
 354   }
 355 
 356   // Up to this point no concurrent thread would have been able to
 357   // do any scanning on any region in this series. All the top
 358   // fields still point to bottom, so the intersection between
 359   // [bottom,top] and [card_start,card_end] will be empty. Before we
 360   // update the top fields, we'll do a storestore to make sure that
 361   // no thread sees the update to top before the zeroing of the
 362   // object header and the BOT initialization.
 363   OrderAccess::storestore();
 364 
 365   // Now that the BOT and the object header have been initialized,
 366   // we can update top of the "starts humongous" region.
 367   first_hr->set_top(MIN2(first_hr->end(), obj_top));
 368   if (_hr_printer.is_active()) {
 369     _hr_printer.alloc(G1HRPrinter::StartsHumongous, first_hr, first_hr->top());
 370   }
 371 
 372   // Now, we will update the top fields of the "continues humongous"
 373   // regions. The reason we need to do this is that, otherwise,
 374   // these regions would look empty and this will confuse parts of
 375   // G1. For example, the code that looks for a consecutive number
 376   // of empty regions will consider them empty and try to
 377   // re-allocate them. We can extend is_empty() to also include
 378   // !is_continues_humongous(), but it is easier to just update the top
 379   // fields here. The way we set top for all regions (i.e., top ==
 380   // end for all regions but the last one, top == new_top for the
 381   // last one) is actually used when we will free up the humongous
 382   // region in free_humongous_region().
 383   hr = NULL;
 384   for (uint i = first + 1; i < last; ++i) {
 385     hr = region_at(i);
 386     if ((i + 1) == last) {
 387       // last continues humongous region
 388       assert(hr->bottom() < obj_top && obj_top <= hr->end(),
 389              "new_top should fall on this region");


1111 
1112   ShouldNotReachHere();
1113 }
1114 
1115 class PostMCRemSetClearClosure: public HeapRegionClosure {
1116   G1CollectedHeap* _g1h;
1117   ModRefBarrierSet* _mr_bs;
1118 public:
1119   PostMCRemSetClearClosure(G1CollectedHeap* g1h, ModRefBarrierSet* mr_bs) :
1120     _g1h(g1h), _mr_bs(mr_bs) {}
1121 
1122   bool doHeapRegion(HeapRegion* r) {
1123     HeapRegionRemSet* hrrs = r->rem_set();
1124 
1125     _g1h->reset_gc_time_stamps(r);
1126 
1127     if (r->is_continues_humongous()) {
1128       // We'll assert that the strong code root list and RSet is empty
1129       assert(hrrs->strong_code_roots_list_length() == 0, "sanity");
1130       assert(hrrs->occupied() == 0, "RSet should be empty");
1131     } else {


1132       hrrs->clear();
1133     }
1134     // You might think here that we could clear just the cards
1135     // corresponding to the used region.  But no: if we leave a dirty card
1136     // in a region we might allocate into, then it would prevent that card
1137     // from being enqueued, and cause it to be missed.
1138     // Re: the performance cost: we shouldn't be doing full GC anyway!
1139     _mr_bs->clear(MemRegion(r->bottom(), r->end()));
1140 
1141     return false;
1142   }
1143 };
1144 
1145 void G1CollectedHeap::clear_rsets_post_compaction() {
1146   PostMCRemSetClearClosure rs_clear(this, g1_barrier_set());
1147   heap_region_iterate(&rs_clear);
1148 }
1149 
1150 class RebuildRSOutOfRegionClosure: public HeapRegionClosure {
1151   G1CollectedHeap*   _g1h;
1152   UpdateRSOopClosure _cl;
1153 public:


5741               "Only eagerly reclaiming type arrays is supported, but the object "
5742               PTR_FORMAT " is not.", p2i(r->bottom()));
5743 
5744     if (G1TraceEagerReclaimHumongousObjects) {
5745       gclog_or_tty->print_cr("Dead humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT " with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
5746                              region_idx,
5747                              (size_t)obj->size() * HeapWordSize,
5748                              p2i(r->bottom()),
5749                              r->rem_set()->occupied(),
5750                              r->rem_set()->strong_code_roots_list_length(),
5751                              next_bitmap->isMarked(r->bottom()),
5752                              g1h->is_humongous_reclaim_candidate(region_idx),
5753                              obj->is_typeArray()
5754                             );
5755     }
5756     // Need to clear mark bit of the humongous object if already set.
5757     if (next_bitmap->isMarked(r->bottom())) {
5758       next_bitmap->clear(r->bottom());
5759     }
5760     do {
5761       HeapRegion* next = g1h->next_region_in_humongous(r);
5762       _freed_bytes += r->used();
5763       r->set_containing_set(NULL);
5764       _humongous_regions_removed.increment(1u, r->capacity());
5765       g1h->free_humongous_region(r, _free_region_list, false);
5766       r = next;
5767     } while (r != NULL);
5768 
5769     return false;
5770   }
5771 
5772   HeapRegionSetCount& humongous_free_count() {
5773     return _humongous_regions_removed;
5774   }
5775 
5776   size_t bytes_freed() const {
5777     return _freed_bytes;
5778   }
5779 
5780   size_t humongous_reclaimed() const {
5781     return _humongous_regions_removed.length();


< prev index next >