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