--- old/src/share/vm/gc_implementation/g1/g1Allocator.cpp 2015-04-07 20:38:38.829789108 +0400 +++ new/src/share/vm/gc_implementation/g1/g1Allocator.cpp 2015-04-07 20:38:38.749789115 +0400 @@ -119,7 +119,6 @@ size_t gclab_word_size = _g1h->desired_plab_sz(dest); if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context); - add_to_alloc_buffer_waste(alloc_buf->words_remaining()); alloc_buf->retire(); HeapWord* buf = _g1h->par_allocate_during_gc(dest, gclab_word_size, context); @@ -153,7 +152,8 @@ for (uint state = 0; state < InCSetState::Num; state++) { G1ParGCAllocBuffer* const buf = _alloc_buffers[state]; if (buf != NULL) { - add_to_alloc_buffer_waste(buf->words_remaining()); + add_to_alloc_buffer_waste(buf->wasted()); + add_to_undo_waste(buf->undo_wasted()); buf->flush_and_retire_stats(_g1h->alloc_buffer_stats(state)); } } --- old/src/share/vm/gc_implementation/g1/g1Allocator.hpp 2015-04-07 20:38:39.125789098 +0400 +++ new/src/share/vm/gc_implementation/g1/g1Allocator.hpp 2015-04-07 20:38:39.045789105 +0400 @@ -250,7 +250,7 @@ alloc_buffer(dest, context)->undo_allocation(obj, word_sz); } else { CollectedHeap::fill_with_object(obj, word_sz); - add_to_undo_waste(word_sz); + alloc_buffer(dest, context)->add_undo_waste(word_sz); } } }; @@ -271,7 +271,7 @@ return _alloc_buffers[dest.value()]; } - virtual void retire_alloc_buffers() ; + virtual void retire_alloc_buffers(); }; #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCATOR_HPP --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-04-07 20:38:39.429789088 +0400 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-04-07 20:38:39.337789094 +0400 @@ -4470,6 +4470,7 @@ if (PrintTerminationStats) { MutexLocker x(stats_lock()); + pss.retire_alloc_buffers(); pss.print_termination_stats(worker_id); } --- old/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp 2015-04-07 20:38:39.805789073 +0400 +++ new/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp 2015-04-07 20:38:39.721789079 +0400 @@ -68,6 +68,10 @@ _start = os::elapsedTime(); } +void G1ParScanThreadState::retire_alloc_buffers() { + _g1_par_allocator->retire_alloc_buffers(); +} + G1ParScanThreadState::~G1ParScanThreadState() { _g1_par_allocator->retire_alloc_buffers(); delete _g1_par_allocator; --- old/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp 2015-04-07 20:38:40.097789060 +0400 +++ new/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp 2015-04-07 20:38:40.021789066 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,9 +54,6 @@ uint _tenuring_threshold; G1ParScanClosure _scanner; - size_t _alloc_buffer_waste; - size_t _undo_waste; - OopsInHeapRegionClosure* _evac_failure_cl; int _hash_seed; @@ -78,9 +75,6 @@ #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t)) - void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; } - void add_to_undo_waste(size_t waste) { _undo_waste += waste; } - DirtyCardQueue& dirty_card_queue() { return _dcq; } G1SATBCardTableModRefBS* ctbs() { return _ct_bs; } @@ -165,6 +159,8 @@ return _surviving_young_words; } + void retire_alloc_buffers(); + private: #define G1_PARTIAL_ARRAY_MASK 0x2 --- old/src/share/vm/gc_implementation/shared/parGCAllocBuffer.cpp 2015-04-07 20:38:40.393789049 +0400 +++ new/src/share/vm/gc_implementation/shared/parGCAllocBuffer.cpp 2015-04-07 20:38:40.309789057 +0400 @@ -39,7 +39,7 @@ ParGCAllocBuffer::ParGCAllocBuffer(size_t desired_plab_sz_) : _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL), - _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0) + _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0) { // ArrayOopDesc::header_size depends on command line initialization. AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0; @@ -69,6 +69,7 @@ // will artifically inflate the values in the statistics. _allocated = 0; _wasted = 0; + _undo_wasted = 0; } void ParGCAllocBuffer::retire() { --- old/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp 2015-04-07 20:38:40.697789039 +0400 +++ new/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp 2015-04-07 20:38:40.605789046 +0400 @@ -45,6 +45,7 @@ // In support of ergonomic sizing of PLAB's size_t _allocated; // in HeapWord units size_t _wasted; // in HeapWord units + size_t _undo_wasted; char tail[32]; static size_t AlignmentReserve; @@ -97,11 +98,18 @@ assert(pointer_delta(_top, obj) == word_sz, "Bad undo"); _top = obj; } + + void add_undo_waste(size_t word_sz) { + _undo_wasted += word_sz; + } // The total (word) size of the buffer, including both allocated and // unallocated space. size_t word_sz() { return _word_sz; } + size_t wasted() { return _wasted; } + size_t undo_wasted() { return _undo_wasted; } + // Should only be done if we are about to reset with a new buffer of the // given size. void set_word_size(size_t new_word_sz) {