Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/exceptions/TestLateMHInlineExceptions.java
64474 views
1
/*
2
* Copyright (c) 2021, Red Hat, Inc. 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 8275638 8278966
27
* @summary GraphKit::combine_exception_states fails with "matching stack sizes" assert
28
*
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
33
*
34
*/
35
36
import java.lang.invoke.MethodHandle;
37
import java.lang.invoke.MethodHandles;
38
import java.lang.invoke.MethodType;
39
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++) {
44
test1(test);
45
try {
46
test1(null);
47
} catch (NullPointerException npe) {
48
}
49
test2(test);
50
test2(null);
51
test3(test);
52
try {
53
test3(null);
54
} catch (NullPointerException npe) {
55
}
56
test4(test);
57
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
}
68
}
69
}
70
71
void m() {
72
}
73
74
static void nothing(Throwable t) {
75
}
76
77
static final MethodHandle mh;
78
static final MethodHandle mh_nothing;
79
static final MethodHandle mh2;
80
static final MethodHandle mh3;
81
82
static {
83
MethodHandles.Lookup lookup = MethodHandles.lookup();
84
try {
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) {
90
e.printStackTrace();
91
throw new RuntimeException("Method handle lookup failed");
92
} catch (IllegalAccessException e) {
93
e.printStackTrace();
94
throw new RuntimeException("Method handle lookup failed");
95
}
96
}
97
98
private static void test1(TestLateMHInlineExceptions test) throws Throwable {
99
mh.invokeExact(test);
100
}
101
102
private static void test2(TestLateMHInlineExceptions test) throws Throwable {
103
try {
104
mh.invokeExact(test);
105
} catch (NullPointerException npe) {
106
}
107
}
108
109
private static void inlined(TestLateMHInlineExceptions test) throws Throwable {
110
mh.invokeExact(test);
111
}
112
113
114
private static void test3(TestLateMHInlineExceptions test) throws Throwable {
115
inlined(test);
116
}
117
118
private static void test4(TestLateMHInlineExceptions test) throws Throwable {
119
try {
120
inlined(test);
121
} catch (NullPointerException npe) {
122
}
123
}
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
}
132
}
133
134