1.1 --- a/src/share/vm/gc_implementation/g1/g1Allocator.cpp Wed Mar 25 15:50:17 2015 +0100 1.2 +++ b/src/share/vm/gc_implementation/g1/g1Allocator.cpp Fri Dec 19 09:21:06 2014 +0100 1.3 @@ -113,15 +113,16 @@ 1.4 G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : 1.5 ParGCAllocBuffer(gclab_word_size), _retired(true) { } 1.6 1.7 -HeapWord* G1ParGCAllocator::allocate_slow(GCAllocPurpose purpose, size_t word_sz, AllocationContext_t context) { 1.8 - HeapWord* obj = NULL; 1.9 - size_t gclab_word_size = _g1h->desired_plab_sz(purpose); 1.10 +HeapWord* G1ParGCAllocator::allocate_direct_or_new_plab(InCSetState dest, 1.11 + size_t word_sz, 1.12 + AllocationContext_t context) { 1.13 + size_t gclab_word_size = _g1h->desired_plab_sz(dest); 1.14 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { 1.15 - G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose, context); 1.16 + G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context); 1.17 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); 1.18 alloc_buf->retire(false /* end_of_gc */, false /* retain */); 1.19 1.20 - HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size, context); 1.21 + HeapWord* buf = _g1h->par_allocate_during_gc(dest, gclab_word_size, context); 1.22 if (buf == NULL) { 1.23 return NULL; // Let caller handle allocation failure. 1.24 } 1.25 @@ -129,30 +130,33 @@ 1.26 alloc_buf->set_word_size(gclab_word_size); 1.27 alloc_buf->set_buf(buf); 1.28 1.29 - obj = alloc_buf->allocate(word_sz); 1.30 + HeapWord* const obj = alloc_buf->allocate(word_sz); 1.31 assert(obj != NULL, "buffer was definitely big enough..."); 1.32 + return obj; 1.33 } else { 1.34 - obj = _g1h->par_allocate_during_gc(purpose, word_sz, context); 1.35 + return _g1h->par_allocate_during_gc(dest, word_sz, context); 1.36 } 1.37 - return obj; 1.38 } 1.39 1.40 G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) : 1.41 - G1ParGCAllocator(g1h), 1.42 - _surviving_alloc_buffer(g1h->desired_plab_sz(GCAllocForSurvived)), 1.43 - _tenured_alloc_buffer(g1h->desired_plab_sz(GCAllocForTenured)) { 1.44 - 1.45 - _alloc_buffers[GCAllocForSurvived] = &_surviving_alloc_buffer; 1.46 - _alloc_buffers[GCAllocForTenured] = &_tenured_alloc_buffer; 1.47 - 1.48 + G1ParGCAllocator(g1h), 1.49 + _surviving_alloc_buffer(g1h->desired_plab_sz(InCSetState::Young)), 1.50 + _tenured_alloc_buffer(g1h->desired_plab_sz(InCSetState::Old)) { 1.51 + for (uint state = 0; state < InCSetState::Num; state++) { 1.52 + _alloc_buffers[state] = NULL; 1.53 + } 1.54 + _alloc_buffers[InCSetState::Young] = &_surviving_alloc_buffer; 1.55 + _alloc_buffers[InCSetState::Old] = &_tenured_alloc_buffer; 1.56 } 1.57 1.58 void G1DefaultParGCAllocator::retire_alloc_buffers() { 1.59 - for (int ap = 0; ap < GCAllocPurposeCount; ++ap) { 1.60 - size_t waste = _alloc_buffers[ap]->words_remaining(); 1.61 - add_to_alloc_buffer_waste(waste); 1.62 - _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), 1.63 - true /* end_of_gc */, 1.64 - false /* retain */); 1.65 + for (uint state = 0; state < InCSetState::Num; state++) { 1.66 + G1ParGCAllocBuffer* const buf = _alloc_buffers[state]; 1.67 + if (buf != NULL) { 1.68 + add_to_alloc_buffer_waste(buf->words_remaining()); 1.69 + buf->flush_stats_and_retire(_g1h->alloc_buffer_stats(state), 1.70 + true /* end_of_gc */, 1.71 + false /* retain */); 1.72 + } 1.73 } 1.74 }