JDK-8228361 : [lworld] Optimize the substitutability check in C2
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: repo-valhalla
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-07-18
  • Updated: 2025-12-18
  • Resolved: 2025-12-18
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
repo-valhallaFixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
We currently always allocate when performing acmp on inline types and delegate to ValueBootstrapMethods::isSubstitutable() if the klasses are equal. We should try to check for substitutability at compile time or even emit optimized code for the substitutability check (for example, directly compare memory if there are no oop fields).

With all the branching in Parse::do_acmp, we should also make sure that profile information is correctly used to set branch probabilities (Tobias: I checked while working on JDK-8325417 but we should double-check and maybe add an IR framework test to verify that the traps are at the correct branch. TestAcmpWithUnstableIf could be used/converted, TestLWorldProfiling already contains some tests for acmp profiling).

ValueBootstrapMethods::isSubstitutable() is currently special cased in the JIT to avoid recursion. Should it use unsafe for pointer comparison?

The runtime call to isSubstitutable might end up with both arguments referring to the same inline type. We should remove it in that case.
Comments
A pull request was submitted for review. Branch: lworld URL: https://git.openjdk.org/valhalla/pull/1823 Date: 2025-12-18 07:31:30 +0000
18-12-2025

Eric's prototype: https://github.com/openjdk/valhalla/pull/910
13-08-2025

See tests marked with "// TODO 8228361".
25-08-2021

See discussion in https://github.com/openjdk/valhalla/pull/185 , in particular: https://github.com/openjdk/valhalla/pull/185#issuecomment-696313869 for comments on improving the current implementation and use of profile data
09-10-2020