Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java
64474 views
1
/*
2
* Copyright (c) 2018, 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
package gc.arguments;
25
26
/*
27
* @test TestParallelRefProc
28
* @summary Test defaults processing for -XX:+ParallelRefProcEnabled.
29
* @library /test/lib
30
* @library /
31
* @build sun.hotspot.WhiteBox
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
33
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.arguments.TestParallelRefProc
34
*/
35
36
import java.util.Arrays;
37
import java.util.ArrayList;
38
39
import jdk.test.lib.process.OutputAnalyzer;
40
41
import jtreg.SkippedException;
42
import sun.hotspot.gc.GC;
43
44
public class TestParallelRefProc {
45
46
public static void main(String args[]) throws Exception {
47
boolean noneGCSupported = true;
48
if (GC.Serial.isSupported()) {
49
noneGCSupported = false;
50
testFlag(new String[] { "-XX:+UseSerialGC" }, false);
51
}
52
if (GC.Parallel.isSupported()) {
53
noneGCSupported = false;
54
testFlag(new String[] { "-XX:+UseParallelGC", "-XX:ParallelGCThreads=1" }, false);
55
testFlag(new String[] { "-XX:+UseParallelGC", "-XX:ParallelGCThreads=2" }, true);
56
testFlag(new String[] { "-XX:+UseParallelGC", "-XX:-ParallelRefProcEnabled", "-XX:ParallelGCThreads=2" }, false);
57
}
58
if (GC.G1.isSupported()) {
59
noneGCSupported = false;
60
testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=1" }, false);
61
testFlag(new String[] { "-XX:+UseG1GC", "-XX:ParallelGCThreads=2" }, true);
62
testFlag(new String[] { "-XX:+UseG1GC", "-XX:-ParallelRefProcEnabled", "-XX:ParallelGCThreads=2" }, false);
63
}
64
if (noneGCSupported) {
65
throw new SkippedException("Skipping test because none of Serial/Parallel/G1 is supported.");
66
}
67
}
68
69
private static final String parallelRefProcEnabledPattern =
70
" *bool +ParallelRefProcEnabled *= *true +\\{product\\}";
71
72
private static final String parallelRefProcDisabledPattern =
73
" *bool +ParallelRefProcEnabled *= *false +\\{product\\}";
74
75
private static void testFlag(String[] args, boolean expectedTrue) throws Exception {
76
ArrayList<String> result = new ArrayList<String>();
77
result.addAll(Arrays.asList(args));
78
result.add("-XX:+PrintFlagsFinal");
79
result.add("-version");
80
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(result);
81
82
OutputAnalyzer output = new OutputAnalyzer(pb.start());
83
84
output.shouldHaveExitValue(0);
85
86
final String expectedPattern = expectedTrue ? parallelRefProcEnabledPattern : parallelRefProcDisabledPattern;
87
88
String value = output.firstMatch(expectedPattern);
89
if (value == null) {
90
throw new RuntimeException(
91
Arrays.toString(args) + " didn't set ParallelRefProcEnabled to " + expectedTrue + " as expected");
92
}
93
}
94
}
95
96