Skip to content

Commit 852ea4b

Browse files
committed
8316687: [Lilliput/JDK21] Various cleanups
Reviewed-by: shade
1 parent 3816aee commit 852ea4b

14 files changed

+34
-41
lines changed

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register
198198

199199
if (len->is_valid()) {
200200
strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
201-
if (UseCompactObjectHeaders) {
202-
// With compact headers, arrays have a 32bit alignment gap after the length.
203-
assert(arrayOopDesc::length_offset_in_bytes() == 8, "check length offset");
204-
strw(zr, Address(obj, arrayOopDesc::length_offset_in_bytes() + sizeof(jint)));
205-
}
206201
} else if (UseCompressedClassPointers && !UseCompactObjectHeaders) {
207202
store_klass_gap(obj, zr);
208203
}

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4327,7 +4327,7 @@ void MacroAssembler::load_nklass_compact(Register dst, Register src) {
43274327
// Fetch displaced header
43284328
ldr(dst, Address(dst, OM_OFFSET_NO_MONITOR_VALUE_TAG(header)));
43294329

4330-
// Fast-path: shift and decode Klass*.
4330+
// Fast-path: shift to get narrowKlass.
43314331
bind(fast);
43324332
lsr(dst, dst, markWord::klass_shift);
43334333
}

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,7 @@ void TemplateTable::_new() {
35693569
// The object is initialized before the header. If the object size is
35703570
// zero, go directly to the header initialization.
35713571
if (UseCompactObjectHeaders) {
3572+
assert(is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong), "oop base offset must be 8-byte-aligned");
35723573
__ sub(r3, r3, oopDesc::base_offset_in_bytes());
35733574
} else {
35743575
__ sub(r3, r3, sizeof(oopDesc));
@@ -3578,12 +3579,8 @@ void TemplateTable::_new() {
35783579
// Initialize object fields
35793580
{
35803581
if (UseCompactObjectHeaders) {
3582+
assert(is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong), "oop base offset must be 8-byte-aligned");
35813583
__ add(r2, r0, oopDesc::base_offset_in_bytes());
3582-
if (!is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong)) {
3583-
__ strw(zr, Address(__ post(r2, BytesPerInt)));
3584-
__ sub(r3, r3, BytesPerInt);
3585-
__ cbz(r3, initialize_header);
3586-
}
35873584
} else {
35883585
__ add(r2, r0, sizeof(oopDesc));
35893586
}

src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
971971
op->tmp1()->as_register(),
972972
op->tmp2()->as_register(),
973973
op->tmp3()->as_register(),
974-
align_up(arrayOopDesc::header_size_in_bytes(), HeapWordSize) / HeapWordSize,
974+
arrayOopDesc::base_offset_in_bytes(op->type()),
975975
type2aelembytes(op->type()),
976976
op->klass()->as_register(),
977977
*op->stub()->entry());

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register
182182

183183
if (len->is_valid()) {
184184
movl(Address(obj, arrayOopDesc::length_offset_in_bytes()), len);
185-
#ifdef _LP64
186-
if (!is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerWord)) {
187-
assert(is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerInt), "must be 4-byte aligned");
188-
movl(Address(obj, arrayOopDesc::header_size_in_bytes()), 0);
189-
}
190-
#else
191-
assert(is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerInt), "must be 4-byte aligned");
192-
#endif
193185
}
194186
#ifdef _LP64
195187
else if (UseCompressedClassPointers && !UseCompactObjectHeaders) {
@@ -226,9 +218,8 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register
226218
assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0,
227219
"con_size_in_bytes is not multiple of alignment");
228220
const int hdr_size_in_bytes = instanceOopDesc::header_size() * HeapWordSize;
229-
if (UseCompactObjectHeaders) {
230-
assert(hdr_size_in_bytes == 8, "check object headers size");
231-
}
221+
assert(!UseCompactObjectHeaders || hdr_size_in_bytes == 8, "check object headers size");
222+
232223
initialize_header(obj, klass, noreg, t1, t2);
233224

234225
if (!(UseTLAB && ZeroTLAB && is_tlab_allocated)) {
@@ -296,12 +287,22 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1,
296287

297288
initialize_header(obj, klass, len, t1, t2);
298289

290+
// Clear leading 4 bytes, if necessary.
291+
// TODO: This could perhaps go into initialize_body() and also clear the leading 4 bytes
292+
// for non-array objects, thereby replacing the klass-gap clearing code in initialize_header().
293+
int base_offset = base_offset_in_bytes;
294+
#ifdef _LP64
295+
if (!is_aligned(base_offset, BytesPerWord)) {
296+
assert(is_aligned(base_offset, BytesPerInt), "must be 4-byte aligned");
297+
movl(Address(obj, base_offset), 0);
298+
base_offset += BytesPerInt;
299+
}
300+
#endif
301+
assert(is_aligned(base_offset, BytesPerWord), "must be word aligned");
302+
299303
// clear rest of allocated space
300304
const Register len_zero = len;
301-
// We align-up the header size to word-size, because we clear the
302-
// possible alignment gap in initialize_header().
303-
int hdr_size = align_up(base_offset_in_bytes, BytesPerWord);
304-
initialize_body(obj, arr_size, hdr_size, len_zero);
305+
initialize_body(obj, arr_size, base_offset, len_zero);
305306

306307
if (CURRENT_ENV->dtrace_alloc_probes()) {
307308
assert(obj == rax, "must be");

src/hotspot/cpu/x86/templateTable_x86.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4033,7 +4033,8 @@ void TemplateTable::_new() {
40334033
// The object is initialized before the header. If the object size is
40344034
// zero, go directly to the header initialization.
40354035
if (UseCompactObjectHeaders) {
4036-
__ decrement(rdx, align_up(oopDesc::base_offset_in_bytes(), BytesPerLong));
4036+
assert(is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong), "oop base offset must be 8-byte-aligned");
4037+
__ decrement(rdx, oopDesc::base_offset_in_bytes());
40374038
} else {
40384039
__ decrement(rdx, sizeof(oopDesc));
40394040
}
@@ -4059,7 +4060,8 @@ void TemplateTable::_new() {
40594060
{ Label loop;
40604061
__ bind(loop);
40614062
if (UseCompactObjectHeaders) {
4062-
int header_size = align_up(oopDesc::base_offset_in_bytes(), BytesPerLong);
4063+
assert(is_aligned(oopDesc::base_offset_in_bytes(), BytesPerLong), "oop base offset must be 8-byte-aligned");
4064+
int header_size = oopDesc::base_offset_in_bytes();
40634065
__ movptr(Address(rax, rdx, Address::times_8, header_size - 1*oopSize), rcx);
40644066
NOT_LP64(__ movptr(Address(rax, rdx, Address::times_8, header_size - 2*oopSize), rcx));
40654067
} else {

src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
254254
// Copy obj
255255
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(o), cast_from_oop<HeapWord*>(new_obj), new_obj_size);
256256

257+
// Parallel GC claims with a release - so other threads might access this object
258+
// after claiming and they should see the "completed" object.
257259
if (UseCompactObjectHeaders) {
258260
// The copy above is not atomic. Make sure we have seen the proper mark
259261
// and re-install it into the copy, so that Klass* is guaranteed to be correct.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ void CollectedHeap::set_gc_cause(GCCause::Cause v) {
402402
_gc_cause = v;
403403
}
404404

405-
// Should only be called with constants as argument
406-
// (will not constant fold otherwise)
407405
// Returns the header size in words aligned to the requirements of the
408406
// array object type.
409407
static int int_array_header_size() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,5 @@ void ContiguousSpace::oop_since_save_marks_iterate(OopClosureType* blk) {
183183

184184
set_saved_mark_word(p);
185185
}
186+
186187
#endif // SHARE_GC_SHARED_SPACE_INLINE_HPP

src/hotspot/share/gc/z/zObjArrayAllocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ oop ZObjArrayAllocator::initialize(HeapWord* mem) const {
7777
// Signal to the ZIterator that this is an invisible root, by setting
7878
// the mark word to "marked". Reset to prototype() after the clearing.
7979
if (UseCompactObjectHeaders) {
80-
oopDesc::release_set_mark(mem, _klass->prototype_header().set_marked());
80+
arrayOopDesc::release_set_mark(mem, _klass->prototype_header().set_marked());
8181
} else {
8282
arrayOopDesc::set_mark(mem, markWord::prototype().set_marked());
8383
arrayOopDesc::release_set_klass(mem, _klass);

0 commit comments

Comments
 (0)