270 size_t allocated_bytes) {
271 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, _purpose);
272 }
273
274 size_t G1GCAllocRegion::retire(bool fill_up) {
275 HeapRegion* retired = get();
276 size_t end_waste = G1AllocRegion::retire(fill_up);
277 // Do not count retirement of the dummy allocation region.
278 if (retired != NULL) {
279 _stats->add_region_end_waste(end_waste / HeapWordSize);
280 }
281 return end_waste;
282 }
283
284 HeapRegion* OldGCAllocRegion::release() {
285 HeapRegion* cur = get();
286 if (cur != NULL) {
287 // Determine how far we are from the next card boundary. If it is smaller than
288 // the minimum object size we can allocate into, expand into the next card.
289 HeapWord* top = cur->top();
290 HeapWord* aligned_top = align_ptr_up(top, BOTConstants::N_bytes);
291
292 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
293
294 if (to_allocate_words != 0) {
295 // We are not at a card boundary. Fill up, possibly into the next, taking the
296 // end of the region and the minimum object size into account.
297 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize),
298 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size()));
299
300 // Skip allocation if there is not enough space to allocate even the smallest
301 // possible object. In this case this region will not be retained, so the
302 // original problem cannot occur.
303 if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
304 HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
305 CollectedHeap::fill_with_object(dummy, to_allocate_words);
306 }
307 }
308 }
309 return G1AllocRegion::release();
310 }
|
270 size_t allocated_bytes) {
271 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, _purpose);
272 }
273
274 size_t G1GCAllocRegion::retire(bool fill_up) {
275 HeapRegion* retired = get();
276 size_t end_waste = G1AllocRegion::retire(fill_up);
277 // Do not count retirement of the dummy allocation region.
278 if (retired != NULL) {
279 _stats->add_region_end_waste(end_waste / HeapWordSize);
280 }
281 return end_waste;
282 }
283
284 HeapRegion* OldGCAllocRegion::release() {
285 HeapRegion* cur = get();
286 if (cur != NULL) {
287 // Determine how far we are from the next card boundary. If it is smaller than
288 // the minimum object size we can allocate into, expand into the next card.
289 HeapWord* top = cur->top();
290 HeapWord* aligned_top = align_up(top, BOTConstants::N_bytes);
291
292 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize);
293
294 if (to_allocate_words != 0) {
295 // We are not at a card boundary. Fill up, possibly into the next, taking the
296 // end of the region and the minimum object size into account.
297 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize),
298 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size()));
299
300 // Skip allocation if there is not enough space to allocate even the smallest
301 // possible object. In this case this region will not be retained, so the
302 // original problem cannot occur.
303 if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
304 HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
305 CollectedHeap::fill_with_object(dummy, to_allocate_words);
306 }
307 }
308 }
309 return G1AllocRegion::release();
310 }
|