8283097: Parallel: Move filler object logic inside PSPromotionLAB::unallocate_object

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2022-03-21 16:21:30 +00:00
parent 19d34bdf99
commit f4f87284cb
3 changed files with 9 additions and 13 deletions

View File

@ -85,18 +85,19 @@ void PSPromotionLAB::flush() {
_state = flushed;
}
bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
void PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
assert(ParallelScavengeHeap::heap()->is_in(obj), "Object outside heap");
// If the object is inside this LAB, we just bump-down the `top` pointer.
// Otherwise, we overwrite it with a filler object.
if (contains(obj)) {
HeapWord* object_end = obj + obj_size;
assert(object_end == top(), "Not matching last allocation");
set_top(obj);
return true;
} else {
CollectedHeap::fill_with_object(obj, obj_size);
}
return false;
}
// Fill all remaining lab space with an unreachable object.

View File

@ -72,7 +72,7 @@ class PSPromotionLAB : public CHeapObj<mtGC> {
bool is_flushed() { return _state == flushed; }
bool unallocate_object(HeapWord* obj, size_t obj_size);
void unallocate_object(HeapWord* obj, size_t obj_size);
// Returns a subregion containing all objects in this space.
MemRegion used_region() { return MemRegion(bottom(), top()); }

View File

@ -290,15 +290,10 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
assert(o->is_forwarded(), "Object must be forwarded if the cas failed.");
assert(o->forwardee() == forwardee, "invariant");
// Try to deallocate the space. If it was directly allocated we cannot
// deallocate it, so we have to test. If the deallocation fails,
// overwrite with a filler object.
if (new_obj_is_tenured) {
if (!_old_lab.unallocate_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size)) {
CollectedHeap::fill_with_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size);
}
} else if (!_young_lab.unallocate_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size)) {
CollectedHeap::fill_with_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size);
_old_lab.unallocate_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size);
} else {
_young_lab.unallocate_object(cast_from_oop<HeapWord*>(new_obj), new_obj_size);
}
return forwardee;
}