Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java
64474 views
1
/*
2
* Copyright Amazon.com Inc. 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 TestOnSpinWaitAArch64DefaultFlags
26
* @summary Check default values of '-XX:OnSpinWaitInst' and '-XX:OnSpinWaitInstCount' for AArch64 implementations.
27
* @bug 8277137
28
* @library /test/lib /
29
*
30
* @requires os.arch=="aarch64"
31
*
32
* @build sun.hotspot.WhiteBox
33
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
34
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35
* -XX:+WhiteBoxAPI
36
* compiler.onSpinWait.TestOnSpinWaitAArch64DefaultFlags
37
*/
38
39
package compiler.onSpinWait;
40
41
import java.util.Iterator;
42
import java.util.List;
43
import jdk.test.lib.process.OutputAnalyzer;
44
import jdk.test.lib.process.ProcessTools;
45
import sun.hotspot.cpuinfo.CPUInfo;
46
47
public class TestOnSpinWaitAArch64DefaultFlags {
48
private static boolean isCPUModelNeoverseN1(String cpuModel) {
49
return cpuModel.contains("0xd0c");
50
}
51
52
private static void checkFinalFlagsEqualTo(ProcessBuilder pb, String expectedOnSpinWaitInstValue, String expectedOnSpinWaitInstCountValue) throws Exception {
53
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
54
analyzer.shouldHaveExitValue(0);
55
56
Iterator<String> iter = analyzer.asLines().listIterator();
57
String line = null;
58
boolean hasExpectedOnSpinWaitInstValue = false;
59
boolean hasExpectedOnSpinWaitInstCountValue = false;
60
while (iter.hasNext()) {
61
line = iter.next();
62
if (!hasExpectedOnSpinWaitInstValue && line.contains("ccstr OnSpinWaitInst")) {
63
hasExpectedOnSpinWaitInstValue = line.contains("= " + expectedOnSpinWaitInstValue);
64
}
65
66
if (!hasExpectedOnSpinWaitInstCountValue && line.contains("uint OnSpinWaitInstCount")) {
67
hasExpectedOnSpinWaitInstCountValue = line.contains("= " + expectedOnSpinWaitInstCountValue);
68
}
69
}
70
if (!hasExpectedOnSpinWaitInstValue) {
71
System.out.println(analyzer.getOutput());
72
throw new RuntimeException("OnSpinWaitInst with the expected value '" + expectedOnSpinWaitInstValue + "' not found.");
73
}
74
if (!hasExpectedOnSpinWaitInstCountValue) {
75
System.out.println(analyzer.getOutput());
76
throw new RuntimeException("OnSpinWaitInstCount with the expected value '" + expectedOnSpinWaitInstCountValue + "' not found.");
77
}
78
}
79
80
public static void main(String[] args) throws Exception {
81
List<String> cpuFeatures = CPUInfo.getFeatures();
82
if (cpuFeatures.isEmpty()) {
83
System.out.println("Skip because no CPU features are available.");
84
return;
85
}
86
87
final String cpuModel = cpuFeatures.get(0);
88
89
if (isCPUModelNeoverseN1(cpuModel)) {
90
checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintFlagsFinal", "-version"),
91
"isb", "1");
92
checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:OnSpinWaitInstCount=2", "-XX:+PrintFlagsFinal", "-version"),
93
"isb", "2");
94
} else {
95
System.out.println("Skip because no defaults for CPU model: " + cpuModel);
96
}
97
}
98
}
99
100