Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8359270

C2: alignment check should consider base offset when emitting arraycopy runtime call

XMLWordPrintable

      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

            fyang Fei Yang
            fyang Fei Yang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: