8335925: Serial: Move allocation API from Generation to subclasses
Reviewed-by: gli, kbarrett, iwalulya
This commit is contained in:
parent
66286b25a1
commit
41f784fe63
@ -572,11 +572,6 @@ HeapWord* DefNewGeneration::block_start(const void* p) const {
|
|||||||
return block_start_const(to(), p);
|
return block_start_const(to(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* DefNewGeneration::expand_and_allocate(size_t size, bool is_tlab) {
|
|
||||||
// We don't attempt to expand the young generation (but perhaps we should.)
|
|
||||||
return allocate(size, is_tlab);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DefNewGeneration::adjust_desired_tenuring_threshold() {
|
void DefNewGeneration::adjust_desired_tenuring_threshold() {
|
||||||
// Set the desired survivor size to half the real survivor space
|
// Set the desired survivor size to half the real survivor space
|
||||||
size_t const survivor_capacity = to()->capacity() / HeapWordSize;
|
size_t const survivor_capacity = to()->capacity() / HeapWordSize;
|
||||||
@ -865,7 +860,7 @@ const char* DefNewGeneration::name() const {
|
|||||||
return "def new generation";
|
return "def new generation";
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
|
HeapWord* DefNewGeneration::allocate(size_t word_size) {
|
||||||
// This is the slow-path allocation for the DefNewGeneration.
|
// This is the slow-path allocation for the DefNewGeneration.
|
||||||
// Most allocations are fast-path in compiled code.
|
// Most allocations are fast-path in compiled code.
|
||||||
// We try to allocate from the eden. If that works, we are happy.
|
// We try to allocate from the eden. If that works, we are happy.
|
||||||
@ -875,8 +870,7 @@ HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* DefNewGeneration::par_allocate(size_t word_size,
|
HeapWord* DefNewGeneration::par_allocate(size_t word_size) {
|
||||||
bool is_tlab) {
|
|
||||||
return eden()->par_allocate(word_size);
|
return eden()->par_allocate(word_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,9 +209,9 @@ class DefNewGeneration: public Generation {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* allocate(size_t word_size, bool is_tlab);
|
// Allocate requested size or return null; single-threaded and lock-free versions.
|
||||||
|
HeapWord* allocate(size_t word_size);
|
||||||
HeapWord* par_allocate(size_t word_size, bool is_tlab);
|
HeapWord* par_allocate(size_t word_size);
|
||||||
|
|
||||||
void gc_epilogue(bool full);
|
void gc_epilogue(bool full);
|
||||||
|
|
||||||
@ -227,8 +227,6 @@ class DefNewGeneration: public Generation {
|
|||||||
|
|
||||||
bool collect(bool clear_all_soft_refs);
|
bool collect(bool clear_all_soft_refs);
|
||||||
|
|
||||||
HeapWord* expand_and_allocate(size_t size, bool is_tlab);
|
|
||||||
|
|
||||||
oop copy_to_survivor_space(oop old);
|
oop copy_to_survivor_space(oop old);
|
||||||
uint tenuring_threshold() { return _tenuring_threshold; }
|
uint tenuring_threshold() { return _tenuring_threshold; }
|
||||||
|
|
||||||
|
@ -103,20 +103,6 @@ class Generation: public CHeapObj<mtGC> {
|
|||||||
return _reserved.contains(p);
|
return _reserved.contains(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate and returns a block of the requested size, or returns "null".
|
|
||||||
// Assumes the caller has done any necessary locking.
|
|
||||||
virtual HeapWord* allocate(size_t word_size, bool is_tlab) = 0;
|
|
||||||
|
|
||||||
// Like "allocate", but performs any necessary locking internally.
|
|
||||||
virtual HeapWord* par_allocate(size_t word_size, bool is_tlab) = 0;
|
|
||||||
|
|
||||||
// Perform a heap collection, attempting to create (at least) enough
|
|
||||||
// space to support an allocation of the given "word_size". If
|
|
||||||
// successful, perform the allocation and return the resulting
|
|
||||||
// "oop" (initializing the allocated block). If the allocation is
|
|
||||||
// still unsuccessful, return "null".
|
|
||||||
virtual HeapWord* expand_and_allocate(size_t word_size, bool is_tlab) = 0;
|
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
virtual const char* name() const = 0;
|
virtual const char* name() const = 0;
|
||||||
virtual const char* short_name() const = 0;
|
virtual const char* short_name() const = 0;
|
||||||
|
@ -156,7 +156,7 @@ void SerialHeap::safepoint_synchronize_end() {
|
|||||||
|
|
||||||
HeapWord* SerialHeap::allocate_loaded_archive_space(size_t word_size) {
|
HeapWord* SerialHeap::allocate_loaded_archive_space(size_t word_size) {
|
||||||
MutexLocker ml(Heap_lock);
|
MutexLocker ml(Heap_lock);
|
||||||
return old_gen()->allocate(word_size, false /* is_tlab */);
|
return old_gen()->allocate(word_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialHeap::complete_loaded_archive_space(MemRegion archive_space) {
|
void SerialHeap::complete_loaded_archive_space(MemRegion archive_space) {
|
||||||
@ -292,11 +292,12 @@ bool SerialHeap::should_try_older_generation_allocation(size_t word_size) const
|
|||||||
HeapWord* SerialHeap::expand_heap_and_allocate(size_t size, bool is_tlab) {
|
HeapWord* SerialHeap::expand_heap_and_allocate(size_t size, bool is_tlab) {
|
||||||
HeapWord* result = nullptr;
|
HeapWord* result = nullptr;
|
||||||
if (_old_gen->should_allocate(size, is_tlab)) {
|
if (_old_gen->should_allocate(size, is_tlab)) {
|
||||||
result = _old_gen->expand_and_allocate(size, is_tlab);
|
result = _old_gen->expand_and_allocate(size);
|
||||||
}
|
}
|
||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
if (_young_gen->should_allocate(size, is_tlab)) {
|
if (_young_gen->should_allocate(size, is_tlab)) {
|
||||||
result = _young_gen->expand_and_allocate(size, is_tlab);
|
// Young-gen is not expanded.
|
||||||
|
result = _young_gen->allocate(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(result == nullptr || is_in_reserved(result), "result not in heap");
|
assert(result == nullptr || is_in_reserved(result), "result not in heap");
|
||||||
@ -314,7 +315,7 @@ HeapWord* SerialHeap::mem_allocate_work(size_t size,
|
|||||||
// First allocation attempt is lock-free.
|
// First allocation attempt is lock-free.
|
||||||
DefNewGeneration *young = _young_gen;
|
DefNewGeneration *young = _young_gen;
|
||||||
if (young->should_allocate(size, is_tlab)) {
|
if (young->should_allocate(size, is_tlab)) {
|
||||||
result = young->par_allocate(size, is_tlab);
|
result = young->par_allocate(size);
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
assert(is_in_reserved(result), "result not in heap");
|
assert(is_in_reserved(result), "result not in heap");
|
||||||
return result;
|
return result;
|
||||||
@ -406,14 +407,14 @@ HeapWord* SerialHeap::attempt_allocation(size_t size,
|
|||||||
HeapWord* res = nullptr;
|
HeapWord* res = nullptr;
|
||||||
|
|
||||||
if (_young_gen->should_allocate(size, is_tlab)) {
|
if (_young_gen->should_allocate(size, is_tlab)) {
|
||||||
res = _young_gen->allocate(size, is_tlab);
|
res = _young_gen->allocate(size);
|
||||||
if (res != nullptr || first_only) {
|
if (res != nullptr || first_only) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_old_gen->should_allocate(size, is_tlab)) {
|
if (_old_gen->should_allocate(size, is_tlab)) {
|
||||||
res = _old_gen->allocate(size, is_tlab);
|
res = _old_gen->allocate(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -397,20 +397,19 @@ oop TenuredGeneration::allocate_for_promotion(oop obj, size_t obj_size) {
|
|||||||
#endif // #ifndef PRODUCT
|
#endif // #ifndef PRODUCT
|
||||||
|
|
||||||
// Allocate new object.
|
// Allocate new object.
|
||||||
HeapWord* result = allocate(obj_size, false);
|
HeapWord* result = allocate(obj_size);
|
||||||
if (result == nullptr) {
|
if (result == nullptr) {
|
||||||
// Promotion of obj into gen failed. Try to expand and allocate.
|
// Promotion of obj into gen failed. Try to expand and allocate.
|
||||||
result = expand_and_allocate(obj_size, false);
|
result = expand_and_allocate(obj_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cast_to_oop<HeapWord*>(result);
|
return cast_to_oop<HeapWord*>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord*
|
HeapWord*
|
||||||
TenuredGeneration::expand_and_allocate(size_t word_size, bool is_tlab) {
|
TenuredGeneration::expand_and_allocate(size_t word_size) {
|
||||||
assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
|
|
||||||
expand(word_size*HeapWordSize, _min_heap_delta_bytes);
|
expand(word_size*HeapWordSize, _min_heap_delta_bytes);
|
||||||
return allocate(word_size, is_tlab);
|
return allocate(word_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TenuredGeneration::assert_correct_size_change_locking() {
|
void TenuredGeneration::assert_correct_size_change_locking() {
|
||||||
|
@ -130,10 +130,12 @@ public:
|
|||||||
void complete_loaded_archive_space(MemRegion archive_space);
|
void complete_loaded_archive_space(MemRegion archive_space);
|
||||||
inline void update_for_block(HeapWord* start, HeapWord* end);
|
inline void update_for_block(HeapWord* start, HeapWord* end);
|
||||||
|
|
||||||
virtual inline HeapWord* allocate(size_t word_size, bool is_tlab);
|
// Allocate and returns a block of the requested size, or returns "null".
|
||||||
virtual inline HeapWord* par_allocate(size_t word_size, bool is_tlab);
|
// Assumes the caller has done any necessary locking.
|
||||||
|
inline HeapWord* allocate(size_t word_size);
|
||||||
|
|
||||||
HeapWord* expand_and_allocate(size_t size, bool is_tlab);
|
// Expand the old-gen then invoke allocate above.
|
||||||
|
HeapWord* expand_and_allocate(size_t size);
|
||||||
|
|
||||||
void gc_prologue();
|
void gc_prologue();
|
||||||
void gc_epilogue();
|
void gc_epilogue();
|
||||||
|
@ -48,9 +48,7 @@ inline void TenuredGeneration::update_for_block(HeapWord* start, HeapWord* end)
|
|||||||
_bts->update_for_block(start, end);
|
_bts->update_for_block(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* TenuredGeneration::allocate(size_t word_size,
|
HeapWord* TenuredGeneration::allocate(size_t word_size) {
|
||||||
bool is_tlab) {
|
|
||||||
assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
|
|
||||||
HeapWord* res = _the_space->allocate(word_size);
|
HeapWord* res = _the_space->allocate(word_size);
|
||||||
if (res != nullptr) {
|
if (res != nullptr) {
|
||||||
_bts->update_for_block(res, res + word_size);
|
_bts->update_for_block(res, res + word_size);
|
||||||
@ -58,14 +56,4 @@ HeapWord* TenuredGeneration::allocate(size_t word_size,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapWord* TenuredGeneration::par_allocate(size_t word_size,
|
|
||||||
bool is_tlab) {
|
|
||||||
assert(!is_tlab, "TenuredGeneration does not support TLAB allocation");
|
|
||||||
HeapWord* res = _the_space->par_allocate(word_size);
|
|
||||||
if (res != nullptr) {
|
|
||||||
_bts->update_for_block(res, res + word_size);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SHARE_GC_SERIAL_TENUREDGENERATION_INLINE_HPP
|
#endif // SHARE_GC_SERIAL_TENUREDGENERATION_INLINE_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user