Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java
40942 views
1
/*
2
* Copyright (c) 2014, 2020, 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
package gc.arguments;
25
26
/*
27
* @test TestG1ConcRefinementThreads
28
* @bug 8047976
29
* @requires vm.gc.G1
30
* @summary Tests argument processing for G1ConcRefinementThreads
31
* @library /test/lib
32
* @library /
33
* @modules java.base/jdk.internal.misc
34
* java.management
35
* @run driver gc.arguments.TestG1ConcRefinementThreads
36
*/
37
38
import jdk.test.lib.process.OutputAnalyzer;
39
import jdk.test.lib.process.ProcessTools;
40
import java.util.*;
41
import java.util.regex.*;
42
43
public class TestG1ConcRefinementThreads {
44
45
static final int AUTO_SELECT_THREADS_COUNT = -1;
46
static final int PASSED_THREADS_COUNT = 11;
47
48
public static void main(String args[]) throws Exception {
49
// default case
50
runG1ConcRefinementThreadsTest(
51
new String[]{}, // automatically selected
52
AUTO_SELECT_THREADS_COUNT /* use default setting */);
53
54
// zero setting case
55
runG1ConcRefinementThreadsTest(
56
new String[]{"-XX:G1ConcRefinementThreads=0"},
57
0);
58
59
// non-zero sestting case
60
runG1ConcRefinementThreadsTest(
61
new String[]{"-XX:G1ConcRefinementThreads="+Integer.toString(PASSED_THREADS_COUNT)},
62
PASSED_THREADS_COUNT);
63
}
64
65
private static void runG1ConcRefinementThreadsTest(String[] passedOpts,
66
int expectedValue) throws Exception {
67
List<String> vmOpts = new ArrayList<>();
68
if (passedOpts.length > 0) {
69
Collections.addAll(vmOpts, passedOpts);
70
}
71
Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version");
72
73
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts);
74
OutputAnalyzer output = new OutputAnalyzer(pb.start());
75
76
output.shouldHaveExitValue(0);
77
String stdout = output.getStdout();
78
checkG1ConcRefinementThreadsConsistency(stdout, expectedValue);
79
}
80
81
private static void checkG1ConcRefinementThreadsConsistency(String output, int expectedValue) {
82
int actualValue = getIntValue("G1ConcRefinementThreads", output);
83
84
if (expectedValue == AUTO_SELECT_THREADS_COUNT) {
85
// If expectedValue is automatically selected, set it same as ParallelGCThreads.
86
expectedValue = getIntValue("ParallelGCThreads", output);
87
}
88
89
if (expectedValue != actualValue) {
90
throw new RuntimeException(
91
"Actual G1ConcRefinementThreads(" + Integer.toString(actualValue)
92
+ ") is not equal to expected value(" + Integer.toString(expectedValue) + ")");
93
}
94
}
95
96
public static int getIntValue(String flag, String where) {
97
Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where);
98
if (!m.find()) {
99
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
100
}
101
String match = m.group();
102
return Integer.parseInt(match.substring(match.lastIndexOf(" ") + 1, match.length()));
103
}
104
}
105
106