--- old/src/share/vm/gc/g1/g1Allocator.cpp 2015-08-06 16:02:44.091946375 +0200 +++ new/src/share/vm/gc/g1/g1Allocator.cpp 2015-08-06 16:02:44.014944079 +0200 @@ -79,6 +79,8 @@ void G1DefaultAllocator::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { assert_at_safepoint(true /* should_be_vm_thread */); + G1Allocator::init_gc_alloc_regions(evacuation_info); + _survivor_gc_alloc_region.init(); _old_gc_alloc_region.init(); reuse_retained_old_region(evacuation_info, @@ -147,6 +149,22 @@ } } +bool G1Allocator::survivor_is_full(AllocationContext_t context) const { + return _survivor_is_full; +} + +bool G1Allocator::old_is_full(AllocationContext_t context) const { + return _old_is_full; +} + +void G1Allocator::set_survivor_full(AllocationContext_t context) { + _survivor_is_full = true; +} + +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), @@ -154,10 +172,13 @@ HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(word_size, false /* bot_updates */); - if (result == NULL && _g1h->has_more_free_regions()) { + 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); @@ -172,14 +193,22 @@ HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(word_size, true /* bot_updates */); - if (result == NULL && _g1h->has_more_free_regions()) { + 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); + } } return result; } +void G1Allocator::init_gc_alloc_regions(EvacuationInfo& evacuation_info) { + _survivor_is_full = false; + _old_is_full = false; +} + G1PLABAllocator::G1PLABAllocator(G1Allocator* allocator) : _g1h(G1CollectedHeap::heap()), _allocator(allocator),