JDK-8348853 : Fold layout helper check for objects implementing non-array interfaces
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 25
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-01-28
  • Updated: 2025-04-14
  • Resolved: 2025-04-09
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.
JDK 25
25 b18Fixed
Related Reports
Relates :  
Relates :  
Description
C2 will fold the layout helper load if it can determine that the object is not an array. Currently, this does not work for an object that implements a "non-array" interface, i.e. an interface that is not 'Serializable' and not 'Cloneable':
https://github.com/openjdk/jdk/blob/c33c1cfe7349ac657cd7bf54861227709d3c8f1b/src/hotspot/share/opto/memnode.cpp#L2215-L2223

This is probably an oversight from JDK-8297933 that now causes issues like the one described in JDK-8348631 where data is folded but control is not.

The fix should also undo the change to 'LibraryCallKit::generate_array_guard_common':
https://github.com/openjdk/jdk/pull/23331
Comments
Changeset: a1d566ce Branch: master Author: Marc Chevalier <mchevalier@openjdk.org> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2025-04-09 09:28:36 +0000 URL: https://git.openjdk.org/jdk/commit/a1d566ce4b0315591ece489347c5d1c253f06be9
09-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/24245 Date: 2025-03-26 09:16:17 +0000
26-03-2025

Yes, this issue is only about C2. The layout helper content did not change but JDK-8297933 made C2's type system smarter when interfaces are involved. In some cases like JDK-8348631, the corresponding layout helper checks could also be folded.
29-01-2025

Is it issue only in C2? There are several places in VM which relies on layout helper to detect array object. It is bug if it does not work anymore.
28-01-2025