-
Bug
-
Resolution: Fixed
-
P4
-
25, 26, repo-lilliput-21
-
b04
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8361111 | 25.0.1 | Fei Yang | P4 | Resolved | Fixed | master |
There are four callsites of `StubRoutines::select_arraycopy_function` in C2 shared code where we emit arraycopy runtime calls [1-4].
Three of them [2-4] missed base offset when calculation alignment for both source and destination array addresses. Seems they assume
a base offset of 8 bytes, which is not always true. Base offset becomes 4 bytes under either `-XX:+UseCompactObjectHeaders` or
`-XX:-UseCompressedClassPointers`. And `StubRoutines::select_arraycopy_function` selects the right arraycopy runtime based on this alignment.
As a result, it sees an incorrect `aligned` param and thus a wrong arraycopy runtime call is selected. This is causing performance regressions
(like Dacapo spring) on linux-riscv64 platforms where misaligned memory access is very slow.
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/macroArrayCopy.cpp#L341
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/library_call.cpp#L1584
[3] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/library_call.cpp#L1666
[4] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/stringopts.cpp#L1481
Three of them [2-4] missed base offset when calculation alignment for both source and destination array addresses. Seems they assume
a base offset of 8 bytes, which is not always true. Base offset becomes 4 bytes under either `-XX:+UseCompactObjectHeaders` or
`-XX:-UseCompressedClassPointers`. And `StubRoutines::select_arraycopy_function` selects the right arraycopy runtime based on this alignment.
As a result, it sees an incorrect `aligned` param and thus a wrong arraycopy runtime call is selected. This is causing performance regressions
(like Dacapo spring) on linux-riscv64 platforms where misaligned memory access is very slow.
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/macroArrayCopy.cpp#L341
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/library_call.cpp#L1584
[3] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/library_call.cpp#L1666
[4] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/stringopts.cpp#L1481
- backported by
-
JDK-8361111 C2: alignment check should consider base offset when emitting arraycopy runtime call
-
- Resolved
-
- links to
-
Commit(master) openjdk/jdk25u/26d99e04
-
Commit(master) openjdk/jdk/6b439391
-
Review(master) openjdk/jdk25u/6
-
Review(master) openjdk/jdk/25765