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 forJDK-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.
Note: this was a suggestion by [~mhaessig], as an alternative solution for
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.
- relates to
-
JDK-8370405 C2: mismatched store from MergeStores wrongly scalarized in allocation elimination
-
- Resolved
-
-
JDK-8370936 C2 MergeStores: move process_for_merge_stores_igvn after allocation elimination
-
- Open
-