< prev index next >

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

Print this page
rev 8867 : imported patch 8067336-allow-that-plab-allocations-at-end-of-regions-are-flexible
rev 8869 : imported patch tom-review
rev 8870 : [mq]: tom-remove-obsolete-comment


 254                                                        AllocationContext_t context,
 255                                                        bool* plab_refill_failed) {
 256   size_t plab_word_size = G1CollectedHeap::heap()->desired_plab_sz(dest);
 257   size_t required_in_plab = PLAB::size_required_for_allocation(word_sz);
 258 
 259   // Only get a new PLAB if the allocation fits and it would not waste more than
 260   // ParallelGCBufferWastePct in the existing buffer.
 261   if ((required_in_plab <= plab_word_size) &&
 262     may_throw_away_buffer(required_in_plab, plab_word_size)) {
 263 
 264     G1PLAB* alloc_buf = alloc_buffer(dest, context);
 265     alloc_buf->retire();
 266 
 267     size_t actual_plab_size;
 268     HeapWord* buf = _allocator->par_allocate_during_gc(dest,
 269                                                        required_in_plab,
 270                                                        plab_word_size,
 271                                                        &actual_plab_size,
 272                                                        context);
 273     if (buf != NULL) {
 274       // Otherwise.
 275       alloc_buf->set_buf(buf, actual_plab_size);
 276 
 277       HeapWord* const obj = alloc_buf->allocate(word_sz);
 278       assert(obj != NULL, err_msg("PLAB should have been big enough, tried to allocate "
 279                                   SIZE_FORMAT " requiring " SIZE_FORMAT " PLAB size " SIZE_FORMAT,
 280                                   word_sz, required_in_plab, plab_word_size));
 281       return obj;
 282     }
 283     // Otherwise.
 284     *plab_refill_failed = true;
 285   }
 286   // Try direct allocation.
 287   HeapWord* result = _allocator->par_allocate_during_gc(dest, word_sz, context);
 288   if (result != NULL) {
 289     _direct_allocated[dest.value()] += word_sz;
 290   }
 291   return result;
 292 }
 293 
 294 void G1PLABAllocator::undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz, AllocationContext_t context) {




 254                                                        AllocationContext_t context,
 255                                                        bool* plab_refill_failed) {
 256   size_t plab_word_size = G1CollectedHeap::heap()->desired_plab_sz(dest);
 257   size_t required_in_plab = PLAB::size_required_for_allocation(word_sz);
 258 
 259   // Only get a new PLAB if the allocation fits and it would not waste more than
 260   // ParallelGCBufferWastePct in the existing buffer.
 261   if ((required_in_plab <= plab_word_size) &&
 262     may_throw_away_buffer(required_in_plab, plab_word_size)) {
 263 
 264     G1PLAB* alloc_buf = alloc_buffer(dest, context);
 265     alloc_buf->retire();
 266 
 267     size_t actual_plab_size;
 268     HeapWord* buf = _allocator->par_allocate_during_gc(dest,
 269                                                        required_in_plab,
 270                                                        plab_word_size,
 271                                                        &actual_plab_size,
 272                                                        context);
 273     if (buf != NULL) {

 274       alloc_buf->set_buf(buf, actual_plab_size);
 275 
 276       HeapWord* const obj = alloc_buf->allocate(word_sz);
 277       assert(obj != NULL, err_msg("PLAB should have been big enough, tried to allocate "
 278                                   SIZE_FORMAT " requiring " SIZE_FORMAT " PLAB size " SIZE_FORMAT,
 279                                   word_sz, required_in_plab, plab_word_size));
 280       return obj;
 281     }
 282     // Otherwise.
 283     *plab_refill_failed = true;
 284   }
 285   // Try direct allocation.
 286   HeapWord* result = _allocator->par_allocate_during_gc(dest, word_sz, context);
 287   if (result != NULL) {
 288     _direct_allocated[dest.value()] += word_sz;
 289   }
 290   return result;
 291 }
 292 
 293 void G1PLABAllocator::undo_allocation(InCSetState dest, HeapWord* obj, size_t word_sz, AllocationContext_t context) {


< prev index next >