Skip to content

Commit 5dbfae0

Browse files
committed
8255058: C1: assert(is_virtual()) failed: type check
Reviewed-by: neliasso, kvn
1 parent 4553fa0 commit 5dbfae0

File tree

2 files changed

+73
-3
lines changed

2 files changed

+73
-3
lines changed

src/hotspot/share/c1/c1_LinearScan.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,15 +1942,14 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, i
19421942
move_resolver.set_multiple_reads_allowed();
19431943

19441944
Constant* con = from_value->as_Constant();
1945-
if (con != NULL && !con->is_pinned()) {
1946-
// unpinned constants may have no register, so add mapping from constant to interval
1945+
if (con != NULL && (!con->is_pinned() || con->operand()->is_constant())) {
1946+
// Need a mapping from constant to interval if unpinned (may have no register) or if the operand is a constant (no register).
19471947
move_resolver.add_mapping(LIR_OprFact::value_type(con->type()), to_interval);
19481948
} else {
19491949
// search split child at the throwing op_id
19501950
Interval* from_interval = interval_at_op_id(from_value->operand()->vreg_number(), throwing_op_id);
19511951
move_resolver.add_mapping(from_interval, to_interval);
19521952
}
1953-
19541953
} else {
19551954
// no phi function, so use reg_num also for from_interval
19561955
// search split child at the throwing op_id
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2020, 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 8255058
27+
* @summary Add check in LinearScan::resolve_exception_edge for pinned constant that is not virtual which cannot be used to find an interval which
28+
resulted in an assertion error.
29+
* @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 -XX:CompileCommand=dontinline,compiler.c1.TestPinnedConstantExceptionEdge::dontInline
30+
* -XX:CompileCommand=compileonly,compiler.c1.TestPinnedConstantExceptionEdge::* compiler.c1.TestPinnedConstantExceptionEdge
31+
*/
32+
package compiler.c1;
33+
34+
public class TestPinnedConstantExceptionEdge {
35+
36+
public static long iFld = 0;
37+
public static boolean b1;
38+
public static boolean b2;
39+
40+
public static void test() {
41+
int x = 5;
42+
int y = 11;
43+
for (int i = 1; i < 8; i++) {
44+
for (int j = 1; j < 2; ++j) {
45+
if (b1) {
46+
try {
47+
y = (x / x);
48+
y = (500 / i);
49+
y = (-214 / i);
50+
} catch (ArithmeticException a_e) {}
51+
// Recursion too deep in UseCountComputer::uses_do and therefore constant 1 is pinned.
52+
iFld += (b1 ? 1 : 0) + (b2 ? 1 : 0) + 5 + 7 + 6 + 5 + y
53+
+ dontInline(7) + dontInline(5) + 8 + 8 + 9
54+
+ dontInline(3) + dontInline(3) + dontInline(4)
55+
+ dontInline(dontInline(5)) + dontInline(2);
56+
return;
57+
}
58+
}
59+
}
60+
}
61+
62+
// Not inlined
63+
public static int dontInline(int a) {
64+
return 0;
65+
}
66+
67+
public static void main(String[] strArr) {
68+
test();
69+
}
70+
}
71+

0 commit comments

Comments
 (0)