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

Daniel Lundén dlunden at openjdk.org
Tue Mar 26 14:40:51 UTC 2024


> 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/18472/files
  - new: https://git.openjdk.org/jdk/pull/18472/files/47cfe37d..2fe44dda

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18472&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18472&range=00-01

  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/18472.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18472/head:pull/18472

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


More information about the hotspot-compiler-dev mailing list