Skip to content

Commit e7244c1

Browse files
committed
8278966: two microbenchmarks tests fail "assert(!jvms->method()->has_exception_handlers()) failed: no exception handler expected" after JDK-8275638
Reviewed-by: rbackman, vlivanov
1 parent b4b0328 commit e7244c1

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/hotspot/share/opto/callGenerator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ bool LateInlineMHCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms)
420420
// expression stacks which causes late inlining to break. The MH invoker is not expected to be called from a method wih
421421
// exception handlers. When there is no exception handler, GraphKit::builtin_throw() pops the stack which solves the issue
422422
// of late inlining with exceptions.
423-
assert(!jvms->method()->has_exception_handlers(), "no exception handler expected");
423+
assert(!jvms->method()->has_exception_handlers() ||
424+
(method()->intrinsic_id() != vmIntrinsics::_linkToVirtual &&
425+
method()->intrinsic_id() != vmIntrinsics::_linkToInterface), "no exception handler expected");
424426
// Even if inlining is not allowed, a virtual call can be strength-reduced to a direct call.
425427
bool allow_inline = C->inlining_incrementally();
426428
bool input_not_const = true;

test/hotspot/jtreg/compiler/exceptions/TestLateMHInlineExceptions.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* @test
26-
* @bug 8275638
26+
* @bug 8275638 8278966
2727
* @summary GraphKit::combine_exception_states fails with "matching stack sizes" assert
2828
*
2929
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestLateMHInlineExceptions::m
@@ -55,18 +55,37 @@ public static void main(String[] args) throws Throwable {
5555
}
5656
test4(test);
5757
test4(null);
58+
test5(test);
59+
try {
60+
test5(null);
61+
} catch (NullPointerException npe) {
62+
}
63+
test6(test);
64+
try {
65+
test6(null);
66+
} catch (NullPointerException npe) {
67+
}
5868
}
5969
}
6070

6171
void m() {
6272
}
6373

74+
static void nothing(Throwable t) {
75+
}
76+
6477
static final MethodHandle mh;
78+
static final MethodHandle mh_nothing;
79+
static final MethodHandle mh2;
80+
static final MethodHandle mh3;
6581

6682
static {
6783
MethodHandles.Lookup lookup = MethodHandles.lookup();
6884
try {
6985
mh = lookup.findVirtual(TestLateMHInlineExceptions.class, "m", MethodType.methodType(void.class));
86+
mh_nothing = lookup.findStatic(TestLateMHInlineExceptions.class, "nothing", MethodType.methodType(void.class, Throwable.class));
87+
mh2 = MethodHandles.tryFinally(mh, mh_nothing);
88+
mh3 = MethodHandles.catchException(mh, Throwable.class, mh_nothing);
7089
} catch (NoSuchMethodException e) {
7190
e.printStackTrace();
7291
throw new RuntimeException("Method handle lookup failed");
@@ -102,4 +121,12 @@ private static void test4(TestLateMHInlineExceptions test) throws Throwable {
102121
} catch (NullPointerException npe) {
103122
}
104123
}
124+
125+
private static void test5(TestLateMHInlineExceptions test) throws Throwable {
126+
mh2.invokeExact(test);
127+
}
128+
129+
private static void test6(TestLateMHInlineExceptions test) throws Throwable {
130+
mh3.invokeExact(test);
131+
}
105132
}

0 commit comments

Comments
 (0)