RFR: 8139457: Array bases are aligned at HeapWord granularity [v15]

Aleksey Shipilev shade at openjdk.org
Mon Feb 13 16:50:39 UTC 2023


On Tue, 31 Jan 2023 11:31:27 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> src/hotspot/share/opto/runtime.cpp line 312:
>> 
>>> 310:     BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
>>> 311:     size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type);
>>> 312:     assert(is_aligned(hs_bytes, BytesPerInt), "must be 4 byte aligned");
>> 
>> This assert is misplaced, should be in the `if` block below? Otherwise checking for HeapWordSize alignment after assert-checking for BytesPerInt seems rather odd: the check is guaranteed to pass if assert does not fire.
>
> This assert checks int-alignment of the base offset (in bytes). This is always expected. Subsequently, we check if the base offset is 8-byte aligned, and if it is not, then we make it so. After that correction, we assert 8-byte-alignment. I believe it is correct as it is.

Right, I misread this one, sorry.

-------------

PR: https://git.openjdk.org/jdk/pull/11044


More information about the hotspot-dev mailing list