Skip to content

Commit

Permalink
8255058: C1: assert(is_virtual()) failed: type check
Browse files Browse the repository at this point in the history
Reviewed-by: neliasso, kvn
  • Loading branch information
chhagedorn committed Nov 17, 2020
1 parent 4553fa0 commit 5dbfae0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/share/c1/c1_LinearScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,15 +1942,14 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, i
move_resolver.set_multiple_reads_allowed();

Constant* con = from_value->as_Constant();
if (con != NULL && !con->is_pinned()) {
// unpinned constants may have no register, so add mapping from constant to interval
if (con != NULL && (!con->is_pinned() || con->operand()->is_constant())) {
// Need a mapping from constant to interval if unpinned (may have no register) or if the operand is a constant (no register).
move_resolver.add_mapping(LIR_OprFact::value_type(con->type()), to_interval);
} else {
// search split child at the throwing op_id
Interval* from_interval = interval_at_op_id(from_value->operand()->vreg_number(), throwing_op_id);
move_resolver.add_mapping(from_interval, to_interval);
}

} else {
// no phi function, so use reg_num also for from_interval
// search split child at the throwing op_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8255058
* @summary Add check in LinearScan::resolve_exception_edge for pinned constant that is not virtual which cannot be used to find an interval which
resulted in an assertion error.
* @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 -XX:CompileCommand=dontinline,compiler.c1.TestPinnedConstantExceptionEdge::dontInline
* -XX:CompileCommand=compileonly,compiler.c1.TestPinnedConstantExceptionEdge::* compiler.c1.TestPinnedConstantExceptionEdge
*/
package compiler.c1;

public class TestPinnedConstantExceptionEdge {

public static long iFld = 0;
public static boolean b1;
public static boolean b2;

public static void test() {
int x = 5;
int y = 11;
for (int i = 1; i < 8; i++) {
for (int j = 1; j < 2; ++j) {
if (b1) {
try {
y = (x / x);
y = (500 / i);
y = (-214 / i);
} catch (ArithmeticException a_e) {}
// Recursion too deep in UseCountComputer::uses_do and therefore constant 1 is pinned.
iFld += (b1 ? 1 : 0) + (b2 ? 1 : 0) + 5 + 7 + 6 + 5 + y
+ dontInline(7) + dontInline(5) + 8 + 8 + 9
+ dontInline(3) + dontInline(3) + dontInline(4)
+ dontInline(dontInline(5)) + dontInline(2);
return;
}
}
}
}

// Not inlined
public static int dontInline(int a) {
return 0;
}

public static void main(String[] strArr) {
test();
}
}

0 comments on commit 5dbfae0

Please sign in to comment.