Skip to content

Commit

Permalink
8278568: Consolidate filler objects
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, mli, ayang
  • Loading branch information
rkennke committed Dec 17, 2021
1 parent 6412d57 commit abab173
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 66 deletions.
26 changes: 4 additions & 22 deletions src/hotspot/share/gc/parallel/psPromotionLAB.cpp
Expand Up @@ -29,8 +29,6 @@
#include "memory/universe.hpp"
#include "oops/oop.inline.hpp"

size_t PSPromotionLAB::filler_header_size;

// This is the shared initialization code. It sets up the basic pointers,
// and allows enough extra space for a filler object. We call a virtual
// method, "lab_is_valid()" to handle the different asserts the old/young
Expand All @@ -45,19 +43,15 @@ void PSPromotionLAB::initialize(MemRegion lab) {
set_end(end);
set_top(bottom);

// Initialize after VM starts up because header_size depends on compressed
// oops.
filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));

// We can be initialized to a zero size!
if (free() > 0) {
if (ZapUnusedHeapArea) {
debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
}

// NOTE! We need to allow space for a filler object.
assert(lab.word_size() >= filler_header_size, "lab is too small");
end = end - filler_header_size;
assert(lab.word_size() >= CollectedHeap::min_dummy_object_size(), "lab is too small");
end = end - CollectedHeap::min_dummy_object_size();
set_end(end);

_state = needs_flush;
Expand All @@ -81,20 +75,8 @@ void PSPromotionLAB::flush() {

// PLAB's never allocate the last aligned_header_size
// so they can always fill with an array.
HeapWord* tlab_end = end() + filler_header_size;
typeArrayOop filler_oop = (typeArrayOop) cast_to_oop(top());
filler_oop->set_mark(markWord::prototype());
filler_oop->set_klass(Universe::intArrayKlassObj());
const size_t array_length =
pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));

#ifdef ASSERT
// Note that we actually DO NOT want to use the aligned header size!
HeapWord* elt_words = cast_from_oop<HeapWord*>(filler_oop) + typeArrayOopDesc::header_size(T_INT);
Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
#endif
HeapWord* tlab_end = end() + CollectedHeap::min_dummy_object_size();
CollectedHeap::fill_with_object(top(), tlab_end, trueInDebug);

set_bottom(NULL);
set_end(NULL);
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/parallel/psPromotionLAB.hpp
Expand Up @@ -39,8 +39,6 @@ class ObjectStartArray;

class PSPromotionLAB : public CHeapObj<mtGC> {
protected:
static size_t filler_header_size;

enum LabState {
needs_flush,
flushed,
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/gc/shared/collectedHeap.cpp
Expand Up @@ -493,10 +493,6 @@ void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool
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;
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/gc/shared/collectedHeap.hpp
Expand Up @@ -289,7 +289,10 @@ class CollectedHeap : public CHeapObj<mtInternal> {
}

virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap);
virtual size_t min_dummy_object_size() const;
static constexpr size_t min_dummy_object_size() {
return oopDesc::header_size();
}

size_t tlab_alloc_reserve() const;

// Some heaps may offer a contiguous region for shared non-blocking
Expand Down
32 changes: 0 additions & 32 deletions src/hotspot/share/gc/shared/space.cpp
Expand Up @@ -730,38 +730,6 @@ HeapWord* ContiguousSpace::par_allocate(size_t size) {
return par_allocate_impl(size);
}

void ContiguousSpace::allocate_temporary_filler(int factor) {
// allocate temporary type array decreasing free size with factor 'factor'
assert(factor >= 0, "just checking");
size_t size = pointer_delta(end(), top());

// if space is full, return
if (size == 0) return;

if (factor > 0) {
size -= size/factor;
}
size = align_object_size(size);

const size_t array_header_size = typeArrayOopDesc::header_size(T_INT);
if (size >= align_object_size(array_header_size)) {
size_t length = (size - array_header_size) * (HeapWordSize / sizeof(jint));
// allocate uninitialized int array
typeArrayOop t = (typeArrayOop) cast_to_oop(allocate(size));
assert(t != NULL, "allocation should succeed");
t->set_mark(markWord::prototype());
t->set_klass(Universe::intArrayKlassObj());
t->set_length((int)length);
} else {
assert(size == CollectedHeap::min_fill_size(),
"size for smallest fake object doesn't match");
instanceOop obj = (instanceOop) cast_to_oop(allocate(size));
obj->set_mark(markWord::prototype());
obj->set_klass_gap(0);
obj->set_klass(vmClasses::Object_klass());
}
}

void OffsetTableContigSpace::initialize_threshold() {
_offsets.initialize_threshold();
}
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/gc/shared/space.hpp
Expand Up @@ -532,10 +532,6 @@ class ContiguousSpace: public CompactibleSpace {

// Debugging
virtual void verify() const;

// Used to increase collection frequency. "factor" of 0 means entire
// space.
void allocate_temporary_filler(int factor);
};


Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/oop.hpp
Expand Up @@ -96,7 +96,7 @@ class oopDesc {
static inline void set_klass_gap(HeapWord* mem, int z);

// size of object header, aligned to platform wordSize
static int header_size() { return sizeof(oopDesc)/HeapWordSize; }
static constexpr int header_size() { return sizeof(oopDesc)/HeapWordSize; }

// Returns whether this is an instance of k or an instance of a subclass of k
inline bool is_a(Klass* k) const;
Expand Down

1 comment on commit abab173

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.