Skip to content

Commit abab173

Browse files
committedDec 17, 2021
8278568: Consolidate filler objects
Reviewed-by: tschatzl, mli, ayang
1 parent 6412d57 commit abab173

File tree

7 files changed

+9
-66
lines changed

7 files changed

+9
-66
lines changed
 

‎src/hotspot/share/gc/parallel/psPromotionLAB.cpp

+4-22
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include "memory/universe.hpp"
3030
#include "oops/oop.inline.hpp"
3131

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

48-
// Initialize after VM starts up because header_size depends on compressed
49-
// oops.
50-
filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
51-
5246
// We can be initialized to a zero size!
5347
if (free() > 0) {
5448
if (ZapUnusedHeapArea) {
5549
debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
5650
}
5751

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

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

8276
// PLAB's never allocate the last aligned_header_size
8377
// so they can always fill with an array.
84-
HeapWord* tlab_end = end() + filler_header_size;
85-
typeArrayOop filler_oop = (typeArrayOop) cast_to_oop(top());
86-
filler_oop->set_mark(markWord::prototype());
87-
filler_oop->set_klass(Universe::intArrayKlassObj());
88-
const size_t array_length =
89-
pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
90-
assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
91-
filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
92-
93-
#ifdef ASSERT
94-
// Note that we actually DO NOT want to use the aligned header size!
95-
HeapWord* elt_words = cast_from_oop<HeapWord*>(filler_oop) + typeArrayOopDesc::header_size(T_INT);
96-
Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
97-
#endif
78+
HeapWord* tlab_end = end() + CollectedHeap::min_dummy_object_size();
79+
CollectedHeap::fill_with_object(top(), tlab_end, trueInDebug);
9880

9981
set_bottom(NULL);
10082
set_end(NULL);

‎src/hotspot/share/gc/parallel/psPromotionLAB.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class ObjectStartArray;
3939

4040
class PSPromotionLAB : public CHeapObj<mtGC> {
4141
protected:
42-
static size_t filler_header_size;
43-
4442
enum LabState {
4543
needs_flush,
4644
flushed,

‎src/hotspot/share/gc/shared/collectedHeap.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,6 @@ void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool
493493
CollectedHeap::fill_with_object(start, end, zap);
494494
}
495495

496-
size_t CollectedHeap::min_dummy_object_size() const {
497-
return oopDesc::header_size();
498-
}
499-
500496
size_t CollectedHeap::tlab_alloc_reserve() const {
501497
size_t min_size = min_dummy_object_size();
502498
return min_size > (size_t)MinObjAlignment ? align_object_size(min_size) : 0;

‎src/hotspot/share/gc/shared/collectedHeap.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ class CollectedHeap : public CHeapObj<mtInternal> {
289289
}
290290

291291
virtual void fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap);
292-
virtual size_t min_dummy_object_size() const;
292+
static constexpr size_t min_dummy_object_size() {
293+
return oopDesc::header_size();
294+
}
295+
293296
size_t tlab_alloc_reserve() const;
294297

295298
// Some heaps may offer a contiguous region for shared non-blocking

‎src/hotspot/share/gc/shared/space.cpp

-32
Original file line numberDiff line numberDiff line change
@@ -730,38 +730,6 @@ HeapWord* ContiguousSpace::par_allocate(size_t size) {
730730
return par_allocate_impl(size);
731731
}
732732

733-
void ContiguousSpace::allocate_temporary_filler(int factor) {
734-
// allocate temporary type array decreasing free size with factor 'factor'
735-
assert(factor >= 0, "just checking");
736-
size_t size = pointer_delta(end(), top());
737-
738-
// if space is full, return
739-
if (size == 0) return;
740-
741-
if (factor > 0) {
742-
size -= size/factor;
743-
}
744-
size = align_object_size(size);
745-
746-
const size_t array_header_size = typeArrayOopDesc::header_size(T_INT);
747-
if (size >= align_object_size(array_header_size)) {
748-
size_t length = (size - array_header_size) * (HeapWordSize / sizeof(jint));
749-
// allocate uninitialized int array
750-
typeArrayOop t = (typeArrayOop) cast_to_oop(allocate(size));
751-
assert(t != NULL, "allocation should succeed");
752-
t->set_mark(markWord::prototype());
753-
t->set_klass(Universe::intArrayKlassObj());
754-
t->set_length((int)length);
755-
} else {
756-
assert(size == CollectedHeap::min_fill_size(),
757-
"size for smallest fake object doesn't match");
758-
instanceOop obj = (instanceOop) cast_to_oop(allocate(size));
759-
obj->set_mark(markWord::prototype());
760-
obj->set_klass_gap(0);
761-
obj->set_klass(vmClasses::Object_klass());
762-
}
763-
}
764-
765733
void OffsetTableContigSpace::initialize_threshold() {
766734
_offsets.initialize_threshold();
767735
}

‎src/hotspot/share/gc/shared/space.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,6 @@ class ContiguousSpace: public CompactibleSpace {
532532

533533
// Debugging
534534
virtual void verify() const;
535-
536-
// Used to increase collection frequency. "factor" of 0 means entire
537-
// space.
538-
void allocate_temporary_filler(int factor);
539535
};
540536

541537

‎src/hotspot/share/oops/oop.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class oopDesc {
9696
static inline void set_klass_gap(HeapWord* mem, int z);
9797

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

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

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Dec 17, 2021

@openjdk-notifier[bot]
Please sign in to comment.