Skip to content

Commit

Permalink
Move alignment-gap-clearing into allocate_array() (aarch64)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkennke committed Aug 17, 2023
1 parent 7ac06da commit 7418fab
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register

if (len->is_valid()) {
strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
if (!is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerWord)) {
assert(is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerInt), "must be 4-byte aligned");
strw(zr, Address(obj, arrayOopDesc::header_size_in_bytes()));
}
} else if (UseCompressedClassPointers) {
store_klass_gap(obj, zr);
}
Expand Down Expand Up @@ -296,11 +292,19 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1,

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

// Clear leading 4 bytes, if necessary.
// TODO: This could perhaps go into initialize_body() and also clear the leading 4 bytes
// for non-array objects, thereby replacing the klass-gap clearing code in initialize_header().
int base_offset = base_offset_in_bytes;
if (!is_aligned(base_offset, BytesPerWord)) {
assert(is_aligned(base_offset, BytesPerInt), "must be 4-byte aligned");
strw(zr, Address(obj, base_offset));
base_offset += BytesPerInt;
}
assert(is_aligned(base_offset, BytesPerWord), "must be word-aligned");

// clear rest of allocated space
// We align-up the header size to word-size, because we clear the
// possible alignment gap in initialize_header().
int hdr_size = align_up(base_offset_in_bytes, BytesPerWord);
initialize_body(obj, arr_size, hdr_size, t1, t2);
initialize_body(obj, arr_size, base_offset, t1, t2);
if (Compilation::current()->bailed_out()) {
return;
}
Expand Down

0 comments on commit 7418fab

Please sign in to comment.