< prev index next >

src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp

Print this page

        

*** 43,52 **** --- 43,53 ---- HeapWord* _end; // Last allocatable address + 1 HeapWord* _hard_end; // _end + AlignmentReserve // 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; // Force future allocations to fail and queries for contains() // to return false. Returns the amount of unused space in this PLAB.
*** 60,69 **** --- 61,83 ---- // Fill in remaining space with a dummy object and invalidate the PLAB. Returns // the amount of remaining space. size_t retire_internal(); + void add_undo_waste(HeapWord* obj, size_t word_sz) { + CollectedHeap::fill_with_object(obj, word_sz); + _undo_wasted += word_sz; + } + + // Undo the last allocation in the buffer, which is required to be of the + // "obj" of the given "word_sz". + void undo_last_allocation(HeapWord* obj, size_t word_sz) { + assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo"); + assert(pointer_delta(_top, obj) == word_sz, "Bad undo"); + _top = obj; + } + public: // Initializes the buffer to be empty, but with the given "word_sz". // Must get initialized with "set_buf" for an allocation to succeed. ParGCAllocBuffer(size_t word_sz); virtual ~ParGCAllocBuffer() {}
*** 88,109 **** } // Allocate the object aligned to "alignment_in_bytes". HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes); ! // Undo the last allocation in the buffer, which is required to be of the // "obj" of the given "word_sz". void undo_allocation(HeapWord* obj, size_t word_sz) { ! assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo"); ! assert(pointer_delta(_top, obj) == word_sz, "Bad undo"); ! _top = obj; } // The total (word) size of the buffer, including both allocated and // unallocated space. size_t word_sz() { return _word_sz; } // 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) { assert(new_word_sz > AlignmentReserve, "Too small"); _word_sz = new_word_sz; --- 102,131 ---- } // Allocate the object aligned to "alignment_in_bytes". HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes); ! // Undo any allocation in the buffer, which is required to be of the // "obj" of the given "word_sz". void undo_allocation(HeapWord* obj, size_t word_sz) { ! // Is the alloc in the current alloc buffer? ! if (contains(obj)) { ! assert(contains(obj + word_sz - 1), ! "should contain whole object"); ! undo_last_allocation(obj, word_sz); ! } else { ! add_undo_waste(obj,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) { assert(new_word_sz > AlignmentReserve, "Too small"); _word_sz = new_word_sz;
*** 144,167 **** --- 166,192 ---- // PLAB book-keeping. class PLABStats VALUE_OBJ_CLASS_SPEC { size_t _allocated; // Total allocated size_t _wasted; // of which wasted (internal fragmentation) + size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size) size_t _unused; // Unused in last buffer size_t _desired_plab_sz;// Output of filter (below), suitably trimmed and quantized AdaptiveWeightedAverage _filter; // Integrator with decay void reset() { _allocated = 0; _wasted = 0; + _undo_wasted = 0; _unused = 0; } public: PLABStats(size_t desired_plab_sz_, unsigned wt) : _allocated(0), _wasted(0), + _undo_wasted(0), _unused(0), _desired_plab_sz(desired_plab_sz_), _filter(wt) { }
*** 190,197 **** --- 215,226 ---- } void add_wasted(size_t v) { Atomic::add_ptr(v, &_wasted); } + + void add_undo_wasted(size_t v) { + Atomic::add_ptr(v, &_undo_wasted); + } }; #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
< prev index next >