JDK-8371122 : C2 Allocation Elimination: handle some mismatched accesses to arrays
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 26
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-11-03
  • Updated: 2025-11-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
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.