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

C2 Allocation Elimination: handle some mismatched accesses to arrays

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 26
    • hotspot

      Currently, we don't handle mismatched stores. But for arrays, it could be useful to also eliminate some allocations of arrays that have mismatched stores. For example via Unsafe, or MemorySegment.

      Note: this was a suggestion by [~mhaessig], as an alternative solution for JDK-8370405:
      https://github.com/openjdk/jdk/pull/27997#pullrequestreview-3392451330
      https://github.com/openjdk/jdk/pull/27997#issuecomment-3460642090

      We have to be very careful and write a lot of tests for this.

      This could also be an alternative for JDK-8370936.

      Basic idea:

      Imagine we have an int-array, where we currently only allow StoreI that are exactly aligned to an int-element.
      We could now use Unsafe or MemorySegment to do StoreL over two int-elements. That produces a mismatched StoreL that prevents allocation elimination.

      Harder cases, maybe not worth it: where array elements are only partially overlapped by a store. E.g. StoreB to an int-element.

            Unassigned Unassigned
            epeter Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: