RFR: 8331098: [Aarch64] Fix crash in Arrays.equals() intrinsic with -CCP [v2]
Roman Kennke
rkennke at openjdk.org
Thu Apr 25 18:19:42 UTC 2024
On Thu, 25 Apr 2024 17:52:10 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> Roman Kennke has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Remove excess whitespace
>> - Avoid loading cnt2 on paths that don't need it
>
> src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 5730:
>
>> 5728: // main loop and don't need to compare it
>> 5729: // explicitely ahead of the loop.
>> 5730: cmp(cnt2, cnt1);
>
> Why do we need this? Surely if the base isn't required to be aligned, then it might be aligned. So why can't we use the not-aligned version in all cases?
The current implementation assumes that the base (first array element) is aligned. In this case, the array length is *not* aligned (8 bytes mark, word, 4 bytes compressed-Klass*, 4 bytes length), that is why in this case we compare the length ahead of the main loop. With uncompressed Klass* (8 bytes mark-word, 8 bytes Klass*, 4 bytes length, ...) or Lilliput (8 bytes mark-word/Klass*, 4 bytes length, ...), the base is only 4-bytes-aligned, but we can start at the length and still enter the main-loop at an 8 bytes aligned address. As a bonus, that also compares the lengths and we can save a few instructions/branches for that.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18948#discussion_r1579936795
More information about the hotspot-dev
mailing list