< 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
*** 22,31 ****
--- 22,32 ----
*
*/
#include "precompiled.hpp"
#include "gc/g1/g1Allocator.inline.hpp"
+ #include "gc/g1/g1AllocRegion.inline.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1CollectorPolicy.hpp"
#include "gc/g1/g1MarkSweep.hpp"
#include "gc/g1/heapRegion.inline.hpp"
#include "gc/g1/heapRegionSet.inline.hpp"
*** 141,155 ****
}
HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
size_t word_size,
AllocationContext_t context) {
switch (dest.value()) {
case InCSetState::Young:
! return survivor_attempt_allocation(word_size, context);
case InCSetState::Old:
! return old_attempt_allocation(word_size, context);
default:
ShouldNotReachHere();
return NULL; // Keep some compilers happy
}
}
--- 142,165 ----
}
HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
size_t word_size,
AllocationContext_t context) {
+ size_t temp;
+ return par_allocate_during_gc(dest, word_size, word_size, &temp, context);
+ }
+
+ HeapWord* G1Allocator::par_allocate_during_gc(InCSetState dest,
+ size_t min_word_size,
+ size_t desired_word_size,
+ size_t* actual_word_size,
+ AllocationContext_t context) {
switch (dest.value()) {
case InCSetState::Young:
! return survivor_attempt_allocation(min_word_size, desired_word_size, actual_word_size, context);
case InCSetState::Old:
! return old_attempt_allocation(min_word_size, desired_word_size, actual_word_size, context);
default:
ShouldNotReachHere();
return NULL; // Keep some compilers happy
}
}
*** 168,208 ****
void G1Allocator::set_old_full(AllocationContext_t context) {
_old_is_full = true;
}
! HeapWord* G1Allocator::survivor_attempt_allocation(size_t word_size,
AllocationContext_t context) {
! assert(!_g1h->is_humongous(word_size),
"we should not be seeing humongous-size allocations in this path");
! HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(word_size,
false /* bot_updates */);
if (result == NULL && !survivor_is_full(context)) {
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
! result = survivor_gc_alloc_region(context)->attempt_allocation_locked(word_size,
false /* bot_updates */);
if (result == NULL) {
set_survivor_full(context);
}
}
if (result != NULL) {
! _g1h->dirty_young_block(result, word_size);
}
return result;
}
! HeapWord* G1Allocator::old_attempt_allocation(size_t word_size,
AllocationContext_t context) {
! assert(!_g1h->is_humongous(word_size),
"we should not be seeing humongous-size allocations in this path");
! HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(word_size,
true /* bot_updates */);
if (result == NULL && !old_is_full(context)) {
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
! result = old_gc_alloc_region(context)->attempt_allocation_locked(word_size,
true /* bot_updates */);
if (result == NULL) {
set_old_full(context);
}
}
--- 178,230 ----
void G1Allocator::set_old_full(AllocationContext_t context) {
_old_is_full = true;
}
! HeapWord* G1Allocator::survivor_attempt_allocation(size_t min_word_size,
! size_t desired_word_size,
! size_t* actual_word_size,
AllocationContext_t context) {
! assert(!_g1h->is_humongous(desired_word_size),
"we should not be seeing humongous-size allocations in this path");
! HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(min_word_size,
! desired_word_size,
! actual_word_size,
false /* bot_updates */);
if (result == NULL && !survivor_is_full(context)) {
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
! result = survivor_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
! desired_word_size,
! actual_word_size,
false /* bot_updates */);
if (result == NULL) {
set_survivor_full(context);
}
}
if (result != NULL) {
! _g1h->dirty_young_block(result, *actual_word_size);
}
return result;
}
! HeapWord* G1Allocator::old_attempt_allocation(size_t min_word_size,
! size_t desired_word_size,
! size_t* actual_word_size,
AllocationContext_t context) {
! assert(!_g1h->is_humongous(desired_word_size),
"we should not be seeing humongous-size allocations in this path");
! HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(min_word_size,
! desired_word_size,
! actual_word_size,
true /* bot_updates */);
if (result == NULL && !old_is_full(context)) {
MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
! result = old_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
! desired_word_size,
! actual_word_size,
true /* bot_updates */);
if (result == NULL) {
set_old_full(context);
}
}
*** 240,253 ****
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));
--- 262,279 ----
may_throw_away_buffer(required_in_plab, plab_word_size)) {
G1PLAB* alloc_buf = alloc_buffer(dest, context);
alloc_buf->retire();
! size_t actual_plab_size;
! HeapWord* buf = _allocator->par_allocate_during_gc(dest,
! required_in_plab,
! plab_word_size,
! &actual_plab_size,
! context);
if (buf != NULL) {
! alloc_buf->set_buf(buf, actual_plab_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));
< prev index next >