< prev index next >
src/share/vm/gc/g1/g1Allocator.cpp
Print this page
rev 8849 : imported patch 8003237-no-wait-for-free-list
rev 8850 : imported patch jon-fast-evac-failure
rev 8851 : imported patch bengt-jon-more-naming
rev 8854 : imported patch 8073013-add-detailed-information-about-plab-memory-usage
rev 8855 : imported patch jon-review-statistics
rev 8866 : imported patch 8067339-PLAB-reallocation-might-result-in-failure-to-allocate
rev 8867 : [mq]: bengt-refactoring
*** 221,247 ****
for (size_t i = 0; i < ARRAY_SIZE(_direct_allocated); i++) {
_direct_allocated[i] = 0;
}
}
HeapWord* G1PLABAllocator::allocate_direct_or_new_plab(InCSetState dest,
size_t word_sz,
AllocationContext_t context,
bool* plab_refill_failed) {
! size_t gclab_word_size = _g1h->desired_plab_sz(dest);
! if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) {
G1PLAB* alloc_buf = alloc_buffer(dest, context);
alloc_buf->retire();
! HeapWord* buf = _allocator->par_allocate_during_gc(dest, gclab_word_size, context);
if (buf != NULL) {
// Otherwise.
! alloc_buf->set_word_size(gclab_word_size);
! alloc_buf->set_buf(buf);
HeapWord* const obj = alloc_buf->allocate(word_sz);
! assert(obj != NULL, "buffer was definitely big enough...");
return obj;
}
// Otherwise.
*plab_refill_failed = true;
}
--- 221,258 ----
for (size_t i = 0; i < ARRAY_SIZE(_direct_allocated); i++) {
_direct_allocated[i] = 0;
}
}
+ bool G1PLABAllocator::may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const {
+ return (allocation_word_sz * 100 < buffer_size * ParallelGCBufferWastePct);
+ }
+
HeapWord* G1PLABAllocator::allocate_direct_or_new_plab(InCSetState dest,
size_t word_sz,
AllocationContext_t context,
bool* plab_refill_failed) {
! size_t plab_word_size = G1CollectedHeap::heap()->desired_plab_sz(dest);
! size_t required_in_plab = PLAB::size_required_for_allocation(word_sz);
!
! // Only get a new PLAB if the allocation fits and it would not waste more than
! // ParallelGCBufferWastePct in the existing buffer.
! if ((required_in_plab <= plab_word_size) &&
! may_throw_away_buffer(required_in_plab, plab_word_size)) {
!
G1PLAB* alloc_buf = alloc_buffer(dest, context);
alloc_buf->retire();
! HeapWord* buf = _allocator->par_allocate_during_gc(dest, plab_word_size, context);
if (buf != NULL) {
// Otherwise.
! alloc_buf->set_buf(buf, plab_word_size);
HeapWord* const obj = alloc_buf->allocate(word_sz);
! assert(obj != NULL, err_msg("PLAB should have been big enough, tried to allocate "
! SIZE_FORMAT " requiring " SIZE_FORMAT " PLAB size " SIZE_FORMAT,
! word_sz, required_in_plab, plab_word_size));
return obj;
}
// Otherwise.
*plab_refill_failed = true;
}
< prev index next >