Skip to content

Commit 2fe7ae9

Browse files
committed
8381362: C2: assert(_late_inlines.length() == 0 || IncrementalInlineMH || IncrementalInlineVirtual) failed: not empty
Reviewed-by: qamai, vlivanov
1 parent 6b6f299 commit 2fe7ae9

2 files changed

Lines changed: 147 additions & 2 deletions

File tree

src/hotspot/share/opto/compile.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,14 +2584,13 @@ void Compile::Optimize() {
25842584

25852585
assert(igvn._worklist.size() == 0, "not empty");
25862586

2587-
assert(_late_inlines.length() == 0 || IncrementalInlineMH || IncrementalInlineVirtual, "not empty");
2588-
25892587
if (_late_inlines.length() > 0) {
25902588
// More opportunities to optimize virtual and MH calls.
25912589
// Though it's maybe too late to perform inlining, strength-reducing them to direct calls is still an option.
25922590
process_late_inline_calls_no_inline(igvn);
25932591
if (failing()) return;
25942592
}
2593+
assert(_late_inlines.length() == 0, "late inline queue must be drained");
25952594
} // (End scope of igvn; run destructor if necessary for asserts.)
25962595

25972596
check_no_dead_use();
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* Copyright (c) 2026, Oracle 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 8381362
27+
* @summary Verify no crash for vector late-inline queue draining when MH/virtual late inlining is disabled
28+
* @modules jdk.incubator.vector
29+
* @run main/othervm -Xcomp
30+
* -XX:-IncrementalInlineVirtual -XX:-IncrementalInlineMH -XX:-UseInlineCaches
31+
* ${test.main.class} vector
32+
*/
33+
34+
/*
35+
* @test
36+
* @bug 8381362
37+
* @summary Verify no crash for non-vector late-inline queue draining when MH/virtual late inlining is disabled
38+
* @modules jdk.incubator.vector
39+
* @run main/othervm -Xcomp
40+
* -XX:-IncrementalInlineVirtual -XX:-IncrementalInlineMH -XX:-UseInlineCaches
41+
* -XX:LiveNodeCountInliningCutoff=50
42+
* -XX:CompileCommand=compileonly,${test.main.class}::nonVector*
43+
* -XX:CompileCommand=delayinline,${test.main.class}::lateInline*
44+
* ${test.main.class} nonvector
45+
*/
46+
47+
package compiler.inlining;
48+
49+
import jdk.incubator.vector.*;
50+
import java.lang.invoke.VarHandle;
51+
52+
public class LateInlineQueueDrainTest {
53+
private static final int SIZE = 60_000;
54+
private static int sink;
55+
56+
public static void main(String[] args) {
57+
sink = 0;
58+
if (args.length != 1) {
59+
throw new RuntimeException("Expected one argument: vector|nonvector");
60+
}
61+
switch (args[0]) {
62+
case "vector":
63+
vectorWorkload();
64+
break;
65+
case "nonvector":
66+
nonVectorWorkload();
67+
break;
68+
default:
69+
throw new RuntimeException("Unknown mode: " + args[0]);
70+
}
71+
System.out.println("PASS " + args[0] + " " + sink);
72+
}
73+
74+
private static void vectorWorkload() {
75+
char[] a = new char[SIZE];
76+
char[] b = new char[SIZE];
77+
for (int i = 0; i < SIZE; i++) {
78+
a[i] = (char) i;
79+
b[i] = (char) i;
80+
}
81+
vectorKernel(a);
82+
}
83+
84+
private static void vectorKernel(char[] arr) {
85+
FloatVector lcFloatVec2 = null;
86+
FloatVector lcFloatVec1 = null;
87+
float[] lcFloatArr1 = new float[100];
88+
float[] lcFloatArr2 = new float[100];
89+
float[] lcFloatArr3 = new float[100];
90+
Object Obj = new Object();
91+
for (int i = 0; i < lcFloatArr1.length; i++) {
92+
lcFloatArr1[i] = (((float) i) * 1.5F) + 7.89F;
93+
}
94+
for (int i = 0; i < lcFloatArr2.length; i++) {
95+
lcFloatArr2[i] = (((float) i) * 1.5F) + 7.89F;
96+
}
97+
for (int i = 0; i < lcFloatArr3.length; i++) {
98+
lcFloatArr3[i] = (((float) i) * 1.5F) + 7.89F;
99+
}
100+
for (int i = 0; i < 50; i++) {
101+
VarHandle.fullFence();
102+
synchronized (Obj) {
103+
try {
104+
Obj.wait(1);
105+
} catch (InterruptedException ex) {
106+
}
107+
}
108+
VarHandle.fullFence();
109+
if ((((int) (lcFloatArr1[0])) % 3) < 1) {
110+
lcFloatVec1 = ((FloatVector) (VectorShuffle.iota(FloatVector.SPECIES_PREFERRED, 0, 14, true).toVector()));
111+
} else {
112+
lcFloatVec1 = FloatVector.fromArray(FloatVector.SPECIES_PREFERRED, lcFloatArr2, 14);
113+
}
114+
lcFloatVec1 = FloatVector.fromArray(FloatVector.SPECIES_PREFERRED, lcFloatArr3, 14);
115+
lcFloatVec2 = lcFloatVec1.add(lcFloatVec1);
116+
lcFloatVec2.intoArray(lcFloatArr1, 14);
117+
synchronized (Obj) {
118+
try {
119+
Obj.wait(1);
120+
} catch (InterruptedException ex) {
121+
}
122+
}
123+
}
124+
}
125+
126+
private static void nonVectorWorkload() {
127+
int r = 0;
128+
for (int i = 0; i < 200_000; i++) {
129+
r += nonVectorKernel(100);
130+
}
131+
sink += r;
132+
}
133+
134+
private static int nonVectorKernel(int n) {
135+
int s = 0;
136+
for (int i = 0; i < n; i++) {
137+
lateInline(i);
138+
s += i;
139+
}
140+
return s;
141+
}
142+
143+
private static void lateInline(int x) {
144+
sink += x;
145+
}
146+
}

0 commit comments

Comments
 (0)