8211955: GC abstraction for LAB reserve

Reviewed-by: pliden, shade
This commit is contained in:
Roman Kennke 2018-10-10 23:05:15 +02:00
parent a3a7edbd4d
commit 7d7da8976b
5 changed files with 19 additions and 8 deletions

View file

@ -445,6 +445,15 @@ void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool
CollectedHeap::fill_with_object(start, end, zap); CollectedHeap::fill_with_object(start, end, zap);
} }
size_t CollectedHeap::min_dummy_object_size() const {
return oopDesc::header_size();
}
size_t CollectedHeap::tlab_alloc_reserve() const {
size_t min_size = min_dummy_object_size();
return min_size > (size_t)MinObjAlignment ? align_object_size(min_size) : 0;
}
HeapWord* CollectedHeap::allocate_new_tlab(size_t min_size, HeapWord* CollectedHeap::allocate_new_tlab(size_t min_size,
size_t requested_size, size_t requested_size,
size_t* actual_size) { size_t* actual_size) {

View file

@ -309,6 +309,8 @@ class CollectedHeap : public CHeapObj<mtInternal> {
} }
virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap); virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap);
virtual size_t min_dummy_object_size() const;
size_t tlab_alloc_reserve() const;
// Return the address "addr" aligned by "alignment_in_bytes" if such // Return the address "addr" aligned by "alignment_in_bytes" if such
// an address is below "end". Return NULL otherwise. // an address is below "end". Return NULL otherwise.

View file

@ -27,7 +27,6 @@
#include "gc/shared/plab.inline.hpp" #include "gc/shared/plab.inline.hpp"
#include "gc/shared/threadLocalAllocBuffer.hpp" #include "gc/shared/threadLocalAllocBuffer.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "oops/arrayOop.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
size_t PLAB::min_size() { size_t PLAB::min_size() {
@ -43,8 +42,7 @@ PLAB::PLAB(size_t desired_plab_sz_) :
_word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL), _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
_end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0) _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
{ {
// ArrayOopDesc::header_size depends on command line initialization. AlignmentReserve = Universe::heap()->tlab_alloc_reserve();
AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0;
assert(min_size() > AlignmentReserve, assert(min_size() > AlignmentReserve,
"Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " " "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
"to be able to contain objects", min_size(), AlignmentReserve); "to be able to contain objects", min_size(), AlignmentReserve);

View file

@ -23,6 +23,7 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
@ -461,3 +462,8 @@ void ThreadLocalAllocStats::publish() {
_perf_max_slow_allocations ->set_value(_max_slow_allocations); _perf_max_slow_allocations ->set_value(_max_slow_allocations);
} }
} }
size_t ThreadLocalAllocBuffer::end_reserve() {
size_t reserve_size = Universe::heap()->tlab_alloc_reserve();
return MAX2(reserve_size, (size_t)_reserve_for_allocation_prefetch);
}

View file

@ -26,7 +26,6 @@
#define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP #define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
#include "gc/shared/gcUtil.hpp" #include "gc/shared/gcUtil.hpp"
#include "oops/typeArrayOop.hpp"
#include "runtime/perfData.hpp" #include "runtime/perfData.hpp"
#include "runtime/vm_version.hpp" #include "runtime/vm_version.hpp"
@ -138,10 +137,7 @@ public:
inline HeapWord* allocate(size_t size); inline HeapWord* allocate(size_t size);
// Reserve space at the end of TLAB // Reserve space at the end of TLAB
static size_t end_reserve() { static size_t end_reserve();
int reserve_size = typeArrayOopDesc::header_size(T_INT);
return MAX2(reserve_size, _reserve_for_allocation_prefetch);
}
static size_t alignment_reserve() { return align_object_size(end_reserve()); } static size_t alignment_reserve() { return align_object_size(end_reserve()); }
static size_t alignment_reserve_in_bytes() { return alignment_reserve() * HeapWordSize; } static size_t alignment_reserve_in_bytes() { return alignment_reserve() * HeapWordSize; }