RFR: 8323682: C2: guard check is not generated in Arrays.copyOfRange intrinsic when allocation is eliminated by EA [v2]

Vladimir Kozlov kvn at openjdk.org
Tue Mar 26 16:02:23 UTC 2024


On Tue, 26 Mar 2024 14:40:51 GMT, Daniel Lundén <dlunden at openjdk.org> wrote:

>> The library intrinsic `_copyOfRange` does not add a guard for start indices that are larger than the length of the source arrays. Macro expansion of `ArrayCopy` nodes later adds such a guard, but in certain situations escape analysis may result in removing the `ArrayCopy` node before it is expanded. The result is incorrect behavior of the compiled program (as the missing guard may have relevant side effects, such as throwing an exception).
>> 
>> ### Changeset
>> 
>> - Add the missing guard (start index <= source array length).
>> - Add a regression test.
>> 
>> ### Testing
>> 
>> - [GitHub Actions](https://github.com/dlunde/jdk/actions/runs/8388044152)
>> - tier1 to tier5 on windows-x64, linux-x64, linux-aarch64, macosx-x64, and macosx-aarch64.
>
> Daniel Lundén has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Readd negative end check

Looks good.

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

Marked as reviewed by kvn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/18472#pullrequestreview-1960906906


More information about the hotspot-compiler-dev mailing list