Skip to content

Commit 34ebed7

Browse files
author
duke
committedJul 19, 2024
Automatic merge of jdk:master into master
2 parents 888d962 + 10982fe commit 34ebed7

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed
 

‎src/hotspot/share/opto/callGenerator.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ bool LateInlineMHCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms)
432432
assert(!input_not_const, "sanity"); // shouldn't have been scheduled for inlining in the first place
433433

434434
if (cg != nullptr) {
435+
if (!allow_inline && (C->print_inlining() || C->print_intrinsics())) {
436+
C->print_inlining(cg->method(), jvms->depth()-1, call_node()->jvms()->bci(), InliningResult::FAILURE,
437+
"late method handle call resolution");
438+
}
435439
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining");
436440
_inline_cg = cg;
437441
C->dec_number_of_mh_late_inlines();
@@ -555,7 +559,7 @@ bool LateInlineVirtualCallGenerator::do_late_inline_check(Compile* C, JVMState*
555559

556560
if (cg != nullptr) {
557561
if (!allow_inline && (C->print_inlining() || C->print_intrinsics())) {
558-
C->print_inlining(method(), jvms->depth()-1, call_node()->jvms()->bci(), InliningResult::FAILURE,
562+
C->print_inlining(cg->method(), jvms->depth()-1, call_node()->jvms()->bci(), InliningResult::FAILURE,
559563
"late call devirtualization");
560564
}
561565
assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline || StressIncrementalInlining, "we're doing late inlining");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2024, Red Hat and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8335843
27+
* @summary C2 hits assert(_print_inlining_stream->size() > 0) failed: missing inlining msg
28+
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-BackgroundCompilation -XX:+PrintCompilation -XX:+PrintInlining TestPrintInliningLateMHCall
29+
*/
30+
31+
import java.lang.invoke.MethodHandle;
32+
import java.lang.invoke.MethodHandles;
33+
import java.lang.invoke.MethodType;
34+
35+
public class TestPrintInliningLateMHCall {
36+
static final MethodHandle mh1;
37+
static MethodHandle mh2;
38+
39+
static {
40+
try {
41+
MethodHandles.Lookup lookup = MethodHandles.lookup();
42+
mh1 = lookup.findStatic(TestPrintInliningLateMHCall.class, "lateResolved", MethodType.methodType(void.class));
43+
mh2 = mh1;
44+
} catch (NoSuchMethodException | IllegalAccessException e) {
45+
e.printStackTrace();
46+
throw new RuntimeException("Method handle lookup failed");
47+
}
48+
}
49+
50+
public static void main(String[] args) throws Throwable {
51+
for (int i = 0; i < 20_000; i++) {
52+
testHelper(0);
53+
testHelper(10);
54+
test();
55+
}
56+
}
57+
58+
private static void testHelper(int i) throws Throwable {
59+
MethodHandle mh = null;
60+
if (i == 10) {
61+
mh = mh1;
62+
} else {
63+
mh = mh2;
64+
}
65+
mh.invokeExact();
66+
}
67+
68+
private static void test() throws Throwable {
69+
int i;
70+
for (i = 0; i < 10; i++) {
71+
72+
}
73+
testHelper(i);
74+
}
75+
76+
private static void lateResolved() {
77+
// noop
78+
}
79+
}

‎test/hotspot/jtreg/compiler/print/TestPrintInliningLateVirtualCall.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public static void main(String[] args) {
4444
private static void testHelper(int i) {
4545
A a;
4646
if (i == 10) {
47-
a = fieldA;
48-
} else if (i > 10) {
4947
a = fieldB;
48+
} else if (i > 10) {
49+
a = fieldA;
5050
} else {
5151
a = fieldC;
5252
}

0 commit comments

Comments
 (0)
Please sign in to comment.