-
Bug
-
Resolution: Unresolved
-
P4
-
25, 26
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
- links to
-
Review(master) openjdk/jdk/25765