RFR: 8331098: [Aarch64] Fix crash in Arrays.equals() intrinsic with -CCP [v2]

Andrew Haley aph at openjdk.org
Fri Apr 26 08:54:37 UTC 2024


On Thu, 25 Apr 2024 18:16:49 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> 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.

So what we're saying here is not so much that the base is not aligned, but that the length _is_?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18948#discussion_r1580703823


More information about the hotspot-dev mailing list