2
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
* @bug 8275638 8278966
27
* @summary GraphKit::combine_exception_states fails with "matching stack sizes" assert
29
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestLateMHInlineExceptions::m
30
* -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline TestLateMHInlineExceptions
31
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacements -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline
32
* TestLateMHInlineExceptions
36
import java.lang.invoke.MethodHandle;
37
import java.lang.invoke.MethodHandles;
38
import java.lang.invoke.MethodType;
40
public class TestLateMHInlineExceptions {
41
public static void main(String[] args) throws Throwable {
42
TestLateMHInlineExceptions test = new TestLateMHInlineExceptions();
43
for (int i = 0; i < 20_000; i++) {
47
} catch (NullPointerException npe) {
54
} catch (NullPointerException npe) {
61
} catch (NullPointerException npe) {
66
} catch (NullPointerException npe) {
74
static void nothing(Throwable t) {
77
static final MethodHandle mh;
78
static final MethodHandle mh_nothing;
79
static final MethodHandle mh2;
80
static final MethodHandle mh3;
83
MethodHandles.Lookup lookup = MethodHandles.lookup();
85
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);
89
} catch (NoSuchMethodException e) {
91
throw new RuntimeException("Method handle lookup failed");
92
} catch (IllegalAccessException e) {
94
throw new RuntimeException("Method handle lookup failed");
98
private static void test1(TestLateMHInlineExceptions test) throws Throwable {
102
private static void test2(TestLateMHInlineExceptions test) throws Throwable {
104
mh.invokeExact(test);
105
} catch (NullPointerException npe) {
109
private static void inlined(TestLateMHInlineExceptions test) throws Throwable {
110
mh.invokeExact(test);
114
private static void test3(TestLateMHInlineExceptions test) throws Throwable {
118
private static void test4(TestLateMHInlineExceptions test) throws Throwable {
121
} catch (NullPointerException npe) {
125
private static void test5(TestLateMHInlineExceptions test) throws Throwable {
126
mh2.invokeExact(test);
129
private static void test6(TestLateMHInlineExceptions test) throws Throwable {
130
mh3.invokeExact(test);