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

Roman Kennke rkennke at openjdk.org
Tue Jan 31 11:34:05 UTC 2023


On Tue, 24 Jan 2023 18:29:35 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Move filler_array_min_size() into inline header file
>
> 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.

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

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


More information about the hotspot-dev mailing list