JDK-8320237 : C2: late inlining of method handle invoke causes duplicate lines in PrintInlining output
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 22
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-11-16
  • Updated: 2024-04-04
  • Resolved: 2024-02-06
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 23
23 b09Fixed
Related Reports
Relates :  
Description
I noticed this:

@ 19   java.lang.invoke.MethodHandle::invokeBasic(L)V (0 bytes)   failed to inline: receiver not constant
@ 19   java.lang.invoke.LambdaForm$DMH/0x000000000f081000::invokeStatic (21 bytes)   force inline by annotation

with the test case of JDK-8319764 that is method invoke at parse time is not constant (first line of the output) and then it's found constant and inlined (second line of the output). We don't want the first line if inlining ends up succeeding. This:

diff --git a/src/hotspot/share/opto/callGenerator.cpp b/src/hotspot/share/opto/callGenerator.cpp
index 971c37e6b45..e5da4e96b67 100644
--- a/src/hotspot/share/opto/callGenerator.cpp
+++ b/src/hotspot/share/opto/callGenerator.cpp
@@ -684,6 +684,7 @@ void CallGenerator::do_late_inline_helper() {
       C->print_inlining_update_delayed(this);
       return;
     }
+    C->print_inlining_update_delayed(this);
 
     // Setup default node notes to be picked up by the inlining
     Node_Notes* old_nn = C->node_notes_at(call->_idx);

appears to fix it. I believe this used to work so a test case would be nice to prevent a regression. I also think I saw the same behavior with late inlining of a virtual call.
Comments
Changeset: 51d7169b Author: Kangcheng Xu <kxu@openjdk.org> Committer: Roland Westrelin <roland@openjdk.org> Date: 2024-02-06 14:37:41 +0000 URL: https://git.openjdk.org/jdk/commit/51d7169bd9c6f57999d9f93da301672c1a115e71
06-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17147 Date: 2023-12-18 15:28:47 +0000
08-01-2024

ILW = Redundant output with PrintInlining, rare with -XX:+PrintInlining, no workaround = LLH = P5
17-11-2023