Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java
41153 views
1
/*
2
* Copyright (c) 2019, 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 TestOverloadCompileQueues
26
* @bug 8163511 8230402
27
* @summary Test overloading the C1 and C2 compile queues with tasks.
28
* @requires !vm.graal.enabled
29
* @run main/othervm/timeout=300 -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1
30
* compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
31
* @run main/othervm/timeout=300 -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2
32
* compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
33
*/
34
35
package compiler.classUnloading.methodUnloading;
36
37
import java.lang.reflect.Method;
38
import java.net.URL;
39
import java.net.URLClassLoader;
40
import java.util.Arrays;
41
42
public class TestOverloadCompileQueues {
43
public static final int ITERS = 500; // Increase for longer stress testing
44
public static final int ITERS_A = 1000; // Increase for longer stress testing
45
46
public static int iArr[] = new int[100];
47
48
// Some methods to fill up the compile queue
49
public static void test0() { }
50
public static void test1() { }
51
public static void test2() { }
52
public static void test3() { }
53
public static void test4() { }
54
public static void test5() { }
55
public static void test6() { }
56
public static void test7() { }
57
public static void test8() { }
58
public static void test9() { }
59
public static void test10() { }
60
public static void test11() { }
61
public static void test12() { }
62
public static void test13() { }
63
public static void test14() { }
64
public static void test15() { }
65
public static void test16() { }
66
public static void test17() { }
67
public static void test18() { }
68
public static void test19() { }
69
70
// More methods that do some more complex things. Therefore, the compiler needs to spend some more time compiling them.
71
// With 50 methods, a queue size of 10000 is also reached in the second run with TieredCompilation enabled.
72
public static void testA0() { Arrays.sort(iArr); }
73
public static void testA1() { Arrays.sort(iArr); }
74
public static void testA2() { Arrays.sort(iArr); }
75
public static void testA3() { Arrays.sort(iArr); }
76
public static void testA4() { Arrays.sort(iArr); }
77
public static void testA5() { Arrays.sort(iArr); }
78
public static void testA6() { Arrays.sort(iArr); }
79
public static void testA7() { Arrays.sort(iArr); }
80
public static void testA8() { Arrays.sort(iArr); }
81
public static void testA9() { Arrays.sort(iArr); }
82
public static void testA10() { Arrays.sort(iArr); }
83
public static void testA11() { Arrays.sort(iArr); }
84
public static void testA12() { Arrays.sort(iArr); }
85
public static void testA13() { Arrays.sort(iArr); }
86
public static void testA14() { Arrays.sort(iArr); }
87
public static void testA15() { Arrays.sort(iArr); }
88
public static void testA16() { Arrays.sort(iArr); }
89
public static void testA17() { Arrays.sort(iArr); }
90
public static void testA18() { Arrays.sort(iArr); }
91
public static void testA19() { Arrays.sort(iArr); }
92
public static void testA20() { Arrays.sort(iArr); }
93
public static void testA21() { Arrays.sort(iArr); }
94
public static void testA22() { Arrays.sort(iArr); }
95
public static void testA23() { Arrays.sort(iArr); }
96
public static void testA24() { Arrays.sort(iArr); }
97
public static void testA25() { Arrays.sort(iArr); }
98
public static void testA26() { Arrays.sort(iArr); }
99
public static void testA27() { Arrays.sort(iArr); }
100
public static void testA28() { Arrays.sort(iArr); }
101
public static void testA29() { Arrays.sort(iArr); }
102
public static void testA30() { Arrays.sort(iArr); }
103
public static void testA31() { Arrays.sort(iArr); }
104
public static void testA32() { Arrays.sort(iArr); }
105
public static void testA33() { Arrays.sort(iArr); }
106
public static void testA34() { Arrays.sort(iArr); }
107
public static void testA35() { Arrays.sort(iArr); }
108
public static void testA36() { Arrays.sort(iArr); }
109
public static void testA37() { Arrays.sort(iArr); }
110
public static void testA38() { Arrays.sort(iArr); }
111
public static void testA39() { Arrays.sort(iArr); }
112
public static void testA40() { Arrays.sort(iArr); }
113
public static void testA41() { Arrays.sort(iArr); }
114
public static void testA42() { Arrays.sort(iArr); }
115
public static void testA43() { Arrays.sort(iArr); }
116
public static void testA44() { Arrays.sort(iArr); }
117
public static void testA45() { Arrays.sort(iArr); }
118
public static void testA46() { Arrays.sort(iArr); }
119
public static void testA47() { Arrays.sort(iArr); }
120
public static void testA48() { Arrays.sort(iArr); }
121
public static void testA49() { Arrays.sort(iArr); }
122
123
public static void main(String[] args) throws Throwable {
124
run();
125
runA();
126
}
127
128
public static void run() throws Throwable {
129
Class<?> thisClass = TestOverloadCompileQueues.class;
130
ClassLoader defaultLoader = thisClass.getClassLoader();
131
URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();
132
133
for (int i = 0; i < ITERS; ++i) {
134
// Load test class with own class loader
135
URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());
136
Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);
137
138
// Execute all test methods to trigger compilation and fill up compile queue
139
for (int j = 1; j < 20; ++j) {
140
Method method = testClass.getDeclaredMethod("test" + j);
141
method.invoke(null);
142
method.invoke(null);
143
}
144
145
// Unload dead classes from ealier iterations
146
System.gc();
147
}
148
}
149
150
public static void runA() throws Throwable {
151
Class<?> thisClass = TestOverloadCompileQueues.class;
152
ClassLoader defaultLoader = thisClass.getClassLoader();
153
URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();
154
155
for (int i = 0; i < ITERS_A; ++i) {
156
// Load test class with own class loader
157
URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());
158
Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);
159
160
// Execute all test methods to trigger compilation and fill up compile queue
161
for (int j = 0; j < 50; ++j) {
162
Method method = testClass.getDeclaredMethod("testA" + j);
163
method.invoke(null);
164
method.invoke(null);
165
}
166
}
167
}
168
}
169
170