Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java
41152 views
1
/*
2
* Copyright (c) 2014, 2021, 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 CheckCompileThresholdScaling
26
* @bug 8059604
27
* @summary Add CompileThresholdScaling flag to control when methods are first compiled (with +/-TieredCompilation)
28
* @library /test/lib
29
* @requires vm.flagless
30
* @modules java.base/jdk.internal.misc
31
* java.management
32
*
33
* @run driver compiler.arguments.CheckCompileThresholdScaling
34
*/
35
36
package compiler.arguments;
37
38
import jdk.test.lib.process.OutputAnalyzer;
39
import jdk.test.lib.process.ProcessTools;
40
41
public class CheckCompileThresholdScaling {
42
43
// The flag CompileThresholdScaling scales compilation thresholds
44
// in the following way:
45
//
46
// - if CompileThresholdScaling==1.0, the default threshold values
47
// are used;
48
//
49
// - if CompileThresholdScaling>1.0, threshold values are scaled
50
// up (e.g., CompileThresholdScalingPercentage=1.2 scales up
51
// thresholds by a factor of 1.2X);
52
//
53
// - if CompileThresholdScaling<1.0, threshold values are scaled
54
// down;
55
//
56
// - if CompileThresholdScaling==0, compilation is disabled
57
// (equivalent to using -Xint).
58
//
59
// With tiered compilation enabled, the values of the following
60
// flags are changed:
61
//
62
// Tier0InvokeNotifyFreqLog, Tier0BackedgeNotifyFreqLog,
63
// Tier3InvocationThreshold, Tier3MinInvocationThreshold,
64
// Tier3CompileThreshold, Tier3BackEdgeThreshold,
65
// Tier2InvokeNotifyFreqLog, Tier2BackedgeNotifyFreqLog,
66
// Tier3InvokeNotifyFreqLog, Tier3BackedgeNotifyFreqLog,
67
// Tier23InlineeNotifyFreqLog, Tier4InvocationThreshold,
68
// Tier4MinInvocationThreshold, Tier4CompileThreshold,
69
// Tier4BackEdgeThreshold
70
//
71
// With tiered compilation disabled the value of CompileThreshold
72
// is scaled.
73
private static final String[][] NON_TIERED_ARGUMENTS = {
74
{
75
"-XX:-TieredCompilation",
76
"-XX:+PrintFlagsFinal",
77
"-XX:CompileThreshold=1000",
78
"-version"
79
},
80
{
81
"-XX:-TieredCompilation",
82
"-XX:+PrintFlagsFinal",
83
"-XX:CompileThreshold=1000",
84
"-XX:CompileThresholdScaling=1.25",
85
"-version"
86
},
87
{
88
"-XX:-TieredCompilation",
89
"-XX:+PrintFlagsFinal",
90
"-XX:CompileThreshold=1000",
91
"-XX:CompileThresholdScaling=0.75",
92
"-version"
93
},
94
{
95
"-XX:-TieredCompilation",
96
"-XX:+PrintFlagsFinal",
97
"-XX:CompileThreshold=1000",
98
"-XX:CompileThresholdScaling=0.0",
99
"-version"
100
},
101
{
102
"-XX:-TieredCompilation",
103
"-XX:+PrintFlagsFinal",
104
"-XX:CompileThreshold=0",
105
"-XX:CompileThresholdScaling=0.75",
106
"-version"
107
}
108
109
};
110
111
private static final String[][] NON_TIERED_EXPECTED_OUTPUTS = {
112
{
113
"intx CompileThreshold = 1000 {pd product} {command line}",
114
"double CompileThresholdScaling = 1.000000 {product} {default}"
115
},
116
{
117
"intx CompileThreshold = 1250 {pd product} {command line, ergonomic}",
118
"double CompileThresholdScaling = 1.250000 {product} {command line}"
119
},
120
{
121
"intx CompileThreshold = 750 {pd product} {command line, ergonomic}",
122
"double CompileThresholdScaling = 0.750000 {product} {command line}"
123
},
124
{
125
"intx CompileThreshold = 1000 {pd product} {command line}",
126
"double CompileThresholdScaling = 0.000000 {product} {command line}",
127
"interpreted mode"
128
},
129
{
130
"intx CompileThreshold = 0 {pd product} {command line}",
131
"double CompileThresholdScaling = 0.750000 {product} {command line}",
132
"interpreted mode"
133
}
134
};
135
136
private static final String[][] TIERED_ARGUMENTS = {
137
{
138
"-XX:+TieredCompilation",
139
"-XX:+PrintFlagsFinal",
140
"-XX:Tier0InvokeNotifyFreqLog=7",
141
"-XX:Tier0BackedgeNotifyFreqLog=10",
142
"-XX:Tier3InvocationThreshold=200",
143
"-XX:Tier3MinInvocationThreshold=100",
144
"-XX:Tier3CompileThreshold=2000",
145
"-XX:Tier3BackEdgeThreshold=60000",
146
"-XX:Tier2InvokeNotifyFreqLog=11",
147
"-XX:Tier2BackedgeNotifyFreqLog=14",
148
"-XX:Tier3InvokeNotifyFreqLog=10",
149
"-XX:Tier3BackedgeNotifyFreqLog=13",
150
"-XX:Tier23InlineeNotifyFreqLog=20",
151
"-XX:Tier4InvocationThreshold=5000",
152
"-XX:Tier4MinInvocationThreshold=600",
153
"-XX:Tier4CompileThreshold=15000",
154
"-XX:Tier4BackEdgeThreshold=40000",
155
"-version"
156
},
157
{
158
"-XX:+TieredCompilation",
159
"-XX:+PrintFlagsFinal",
160
"-XX:Tier0InvokeNotifyFreqLog=7",
161
"-XX:Tier0BackedgeNotifyFreqLog=10",
162
"-XX:Tier3InvocationThreshold=200",
163
"-XX:Tier3MinInvocationThreshold=100",
164
"-XX:Tier3CompileThreshold=2000",
165
"-XX:Tier3BackEdgeThreshold=60000",
166
"-XX:Tier2InvokeNotifyFreqLog=11",
167
"-XX:Tier2BackedgeNotifyFreqLog=14",
168
"-XX:Tier3InvokeNotifyFreqLog=10",
169
"-XX:Tier3BackedgeNotifyFreqLog=13",
170
"-XX:Tier23InlineeNotifyFreqLog=20",
171
"-XX:Tier4InvocationThreshold=5000",
172
"-XX:Tier4MinInvocationThreshold=600",
173
"-XX:Tier4CompileThreshold=15000",
174
"-XX:Tier4BackEdgeThreshold=40000",
175
"-XX:CompileThresholdScaling=0.75",
176
"-version"
177
},
178
{
179
"-XX:+TieredCompilation",
180
"-XX:+PrintFlagsFinal",
181
"-XX:Tier0InvokeNotifyFreqLog=7",
182
"-XX:Tier0BackedgeNotifyFreqLog=10",
183
"-XX:Tier3InvocationThreshold=200",
184
"-XX:Tier3MinInvocationThreshold=100",
185
"-XX:Tier3CompileThreshold=2000",
186
"-XX:Tier3BackEdgeThreshold=60000",
187
"-XX:Tier2InvokeNotifyFreqLog=11",
188
"-XX:Tier2BackedgeNotifyFreqLog=14",
189
"-XX:Tier3InvokeNotifyFreqLog=10",
190
"-XX:Tier3BackedgeNotifyFreqLog=13",
191
"-XX:Tier23InlineeNotifyFreqLog=20",
192
"-XX:Tier4InvocationThreshold=5000",
193
"-XX:Tier4MinInvocationThreshold=600",
194
"-XX:Tier4CompileThreshold=15000",
195
"-XX:Tier4BackEdgeThreshold=40000",
196
"-XX:CompileThresholdScaling=1.25",
197
"-version"
198
},
199
{
200
"-XX:+TieredCompilation",
201
"-XX:+PrintFlagsFinal",
202
"-XX:Tier0InvokeNotifyFreqLog=7",
203
"-XX:Tier0BackedgeNotifyFreqLog=10",
204
"-XX:Tier3InvocationThreshold=200",
205
"-XX:Tier3MinInvocationThreshold=100",
206
"-XX:Tier3CompileThreshold=2000",
207
"-XX:Tier3BackEdgeThreshold=60000",
208
"-XX:Tier2InvokeNotifyFreqLog=11",
209
"-XX:Tier2BackedgeNotifyFreqLog=14",
210
"-XX:Tier3InvokeNotifyFreqLog=10",
211
"-XX:Tier3BackedgeNotifyFreqLog=13",
212
"-XX:Tier23InlineeNotifyFreqLog=20",
213
"-XX:Tier4InvocationThreshold=5000",
214
"-XX:Tier4MinInvocationThreshold=600",
215
"-XX:Tier4CompileThreshold=15000",
216
"-XX:Tier4BackEdgeThreshold=40000",
217
"-XX:CompileThresholdScaling=2.0",
218
"-version"
219
},
220
{
221
"-XX:+TieredCompilation",
222
"-XX:+PrintFlagsFinal",
223
"-XX:Tier0InvokeNotifyFreqLog=7",
224
"-XX:Tier0BackedgeNotifyFreqLog=10",
225
"-XX:Tier3InvocationThreshold=200",
226
"-XX:Tier3MinInvocationThreshold=100",
227
"-XX:Tier3CompileThreshold=2000",
228
"-XX:Tier3BackEdgeThreshold=60000",
229
"-XX:Tier2InvokeNotifyFreqLog=11",
230
"-XX:Tier2BackedgeNotifyFreqLog=14",
231
"-XX:Tier3InvokeNotifyFreqLog=10",
232
"-XX:Tier3BackedgeNotifyFreqLog=13",
233
"-XX:Tier23InlineeNotifyFreqLog=20",
234
"-XX:Tier4InvocationThreshold=5000",
235
"-XX:Tier4MinInvocationThreshold=600",
236
"-XX:Tier4CompileThreshold=15000",
237
"-XX:Tier4BackEdgeThreshold=40000",
238
"-XX:CompileThresholdScaling=0.0",
239
"-version"
240
}
241
};
242
243
private static final String[][] TIERED_EXPECTED_OUTPUTS = {
244
{
245
"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line}",
246
"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line}",
247
"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line}",
248
"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line}",
249
"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line}",
250
"intx Tier3BackEdgeThreshold = 60000 {product} {command line}",
251
"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line}",
252
"intx Tier3CompileThreshold = 2000 {product} {command line}",
253
"intx Tier3InvocationThreshold = 200 {product} {command line}",
254
"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line}",
255
"intx Tier3MinInvocationThreshold = 100 {product} {command line}",
256
"intx Tier4BackEdgeThreshold = 40000 {product} {command line}",
257
"intx Tier4CompileThreshold = 15000 {product} {command line}",
258
"intx Tier4InvocationThreshold = 5000 {product} {command line}",
259
"intx Tier4MinInvocationThreshold = 600 {product} {command line}",
260
"double CompileThresholdScaling = 1.000000 {product} {default}"
261
},
262
{
263
"intx Tier0BackedgeNotifyFreqLog = 9 {product} {command line, ergonomic}",
264
"intx Tier0InvokeNotifyFreqLog = 6 {product} {command line, ergonomic}",
265
"intx Tier23InlineeNotifyFreqLog = 19 {product} {command line, ergonomic}",
266
"intx Tier2BackedgeNotifyFreqLog = 13 {product} {command line, ergonomic}",
267
"intx Tier2InvokeNotifyFreqLog = 10 {product} {command line, ergonomic}",
268
"intx Tier3BackEdgeThreshold = 45000 {product} {command line, ergonomic}",
269
"intx Tier3BackedgeNotifyFreqLog = 12 {product} {command line, ergonomic}",
270
"intx Tier3CompileThreshold = 1500 {product} {command line, ergonomic}",
271
"intx Tier3InvocationThreshold = 150 {product} {command line, ergonomic}",
272
"intx Tier3InvokeNotifyFreqLog = 9 {product} {command line, ergonomic}",
273
"intx Tier3MinInvocationThreshold = 75 {product} {command line, ergonomic}",
274
"intx Tier4BackEdgeThreshold = 30000 {product} {command line, ergonomic}",
275
"intx Tier4CompileThreshold = 11250 {product} {command line, ergonomic}",
276
"intx Tier4InvocationThreshold = 3750 {product} {command line, ergonomic}",
277
"intx Tier4MinInvocationThreshold = 450 {product} {command line, ergonomic}",
278
"double CompileThresholdScaling = 0.750000 {product} {command line}"
279
},
280
{
281
"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line, ergonomic}",
282
"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line, ergonomic}",
283
"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line, ergonomic}",
284
"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line, ergonomic}",
285
"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line, ergonomic}",
286
"intx Tier3BackEdgeThreshold = 75000 {product} {command line, ergonomic}",
287
"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line, ergonomic}",
288
"intx Tier3CompileThreshold = 2500 {product} {command line, ergonomic}",
289
"intx Tier3InvocationThreshold = 250 {product} {command line, ergonomic}",
290
"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line, ergonomic}",
291
"intx Tier3MinInvocationThreshold = 125 {product} {command line, ergonomic}",
292
"intx Tier4BackEdgeThreshold = 50000 {product} {command line, ergonomic}",
293
"intx Tier4CompileThreshold = 18750 {product} {command line, ergonomic}",
294
"intx Tier4InvocationThreshold = 6250 {product} {command line, ergonomic}",
295
"intx Tier4MinInvocationThreshold = 750 {product} {command line, ergonomic}",
296
"double CompileThresholdScaling = 1.250000 {product} {command line}"
297
},
298
{
299
"intx Tier0BackedgeNotifyFreqLog = 11 {product} {command line, ergonomic}",
300
"intx Tier0InvokeNotifyFreqLog = 8 {product} {command line, ergonomic}",
301
"intx Tier23InlineeNotifyFreqLog = 21 {product} {command line, ergonomic}",
302
"intx Tier2BackedgeNotifyFreqLog = 15 {product} {command line, ergonomic}",
303
"intx Tier2InvokeNotifyFreqLog = 12 {product} {command line, ergonomic}",
304
"intx Tier3BackEdgeThreshold = 120000 {product} {command line, ergonomic}",
305
"intx Tier3BackedgeNotifyFreqLog = 14 {product} {command line, ergonomic}",
306
"intx Tier3CompileThreshold = 4000 {product} {command line, ergonomic}",
307
"intx Tier3InvocationThreshold = 400 {product} {command line, ergonomic}",
308
"intx Tier3InvokeNotifyFreqLog = 11 {product} {command line, ergonomic}",
309
"intx Tier3MinInvocationThreshold = 200 {product} {command line, ergonomic}",
310
"intx Tier4BackEdgeThreshold = 80000 {product} {command line, ergonomic}",
311
"intx Tier4CompileThreshold = 30000 {product} {command line, ergonomic}",
312
"intx Tier4InvocationThreshold = 10000 {product} {command line, ergonomic}",
313
"intx Tier4MinInvocationThreshold = 1200 {product} {command line, ergonomic}",
314
"double CompileThresholdScaling = 2.000000 {product} {command line}"
315
},
316
{
317
"intx Tier0BackedgeNotifyFreqLog = 10 {product} {command line}",
318
"intx Tier0InvokeNotifyFreqLog = 7 {product} {command line}",
319
"intx Tier23InlineeNotifyFreqLog = 20 {product} {command line}",
320
"intx Tier2BackedgeNotifyFreqLog = 14 {product} {command line}",
321
"intx Tier2InvokeNotifyFreqLog = 11 {product} {command line}",
322
"intx Tier3BackEdgeThreshold = 60000 {product} {command line}",
323
"intx Tier3BackedgeNotifyFreqLog = 13 {product} {command line}",
324
"intx Tier3CompileThreshold = 2000 {product} {command line}",
325
"intx Tier3InvocationThreshold = 200 {product} {command line}",
326
"intx Tier3InvokeNotifyFreqLog = 10 {product} {command line}",
327
"intx Tier3MinInvocationThreshold = 100 {product} {command line}",
328
"intx Tier4BackEdgeThreshold = 40000 {product} {command line}",
329
"intx Tier4CompileThreshold = 15000 {product} {command line}",
330
"intx Tier4InvocationThreshold = 5000 {product} {command line}",
331
"intx Tier4MinInvocationThreshold = 600 {product} {command line}",
332
"double CompileThresholdScaling = 0.000000 {product} {command line}",
333
"interpreted mode"
334
}
335
};
336
337
private static void verifyValidOption(String[] arguments, String[] expected_outputs, boolean tiered) throws Exception {
338
ProcessBuilder pb;
339
OutputAnalyzer out;
340
341
pb = ProcessTools.createJavaProcessBuilder(arguments);
342
out = new OutputAnalyzer(pb.start());
343
344
try {
345
for (String expected_output : expected_outputs) {
346
out.shouldContain(expected_output);
347
}
348
out.shouldHaveExitValue(0);
349
} catch (RuntimeException e) {
350
// Check if tiered compilation is available in this JVM
351
// Version. Throw exception only if it is available.
352
if (!(tiered && out.getOutput().contains("-XX:+TieredCompilation not supported in this VM"))) {
353
throw new RuntimeException(e);
354
}
355
}
356
}
357
358
public static void main(String[] args) throws Exception {
359
360
if (NON_TIERED_ARGUMENTS.length != NON_TIERED_EXPECTED_OUTPUTS.length) {
361
throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in non-tiered mode of operation does not match.");
362
}
363
364
if (TIERED_ARGUMENTS.length != TIERED_EXPECTED_OUTPUTS.length) {
365
throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs in tiered mode of operation.");
366
}
367
368
// Check if thresholds are scaled properly in non-tiered mode of operation
369
for (int i = 0; i < NON_TIERED_ARGUMENTS.length; i++) {
370
verifyValidOption(NON_TIERED_ARGUMENTS[i], NON_TIERED_EXPECTED_OUTPUTS[i], false);
371
}
372
373
// Check if thresholds are scaled properly in tiered mode of operation
374
for (int i = 0; i < TIERED_ARGUMENTS.length; i++) {
375
verifyValidOption(TIERED_ARGUMENTS[i], TIERED_EXPECTED_OUTPUTS[i], true);
376
}
377
}
378
}
379
380