Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/lib-test/sun/hotspot/whitebox/CPUInfoTest.java
41149 views
1
/*
2
* Copyright (c) 2020, 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
26
* @library /test/lib /
27
*
28
* @build sun.hotspot.WhiteBox
29
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
30
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
31
* -XX:+WhiteBoxAPI
32
* CPUInfoTest
33
*/
34
35
import java.util.Set;
36
import java.util.List;
37
import jdk.test.lib.Platform;
38
import sun.hotspot.WhiteBox;
39
import sun.hotspot.cpuinfo.CPUInfo;
40
41
import static jdk.test.lib.Asserts.*;
42
43
public class CPUInfoTest {
44
static final WhiteBox WB = WhiteBox.getWhiteBox();
45
46
private static final Set<String> wellKnownCPUFeatures;
47
48
static {
49
if (Platform.isX86() || Platform.isX64()) {
50
// @formatter:off
51
// Checkstyle: stop
52
// See hotspot/cpu/x86/vm_version_x86.hpp for the list of supported features.
53
wellKnownCPUFeatures = Set.of(
54
"cx8", "cmov", "fxsr", "ht",
55
"mmx", "3dnowpref", "sse", "sse2",
56
"sse3", "ssse3", "sse4a", "sse4.1",
57
"sse4.2", "popcnt", "lzcnt", "tsc",
58
"tscinvbit", "tscinv", "avx", "avx2",
59
"aes", "erms", "clmul", "bmi1",
60
"bmi2", "rtm", "adx", "avx512f",
61
"avx512dq", "avx512pf", "avx512er", "avx512cd",
62
"avx512bw", "avx512vl", "sha", "fma",
63
"vzeroupper", "avx512_vpopcntdq", "avx512_vpclmulqdq", "avx512_vaes",
64
"avx512_vnni", "clflush", "clflushopt", "clwb",
65
"avx512_vbmi2", "avx512_vbmi", "hv"
66
);
67
// @formatter:on
68
// Checkstyle: resume
69
} else {
70
wellKnownCPUFeatures = null;
71
}
72
}
73
74
public static void main(String args[]) throws Throwable {
75
System.out.println("WB.getCPUFeatures(): \"" + WB.getCPUFeatures() + "\"");
76
77
String additionalCpuInfo = CPUInfo.getAdditionalCPUInfo();
78
assertTrue(additionalCpuInfo != null);
79
System.out.println("CPUInfo.getAdditionalCPUInfo(): \"" + additionalCpuInfo + "\"");
80
81
List<String> features = CPUInfo.getFeatures();
82
assertTrue(features != null);
83
System.out.println("CPUInfo.getFeatures(): " + features);
84
85
for (String feature : features) {
86
assertTrue(CPUInfo.hasFeature(feature), feature);
87
}
88
89
if (wellKnownCPUFeatures != null) {
90
System.out.println("Well-known CPU features: " + wellKnownCPUFeatures);
91
assertTrue(wellKnownCPUFeatures.containsAll(features), "not all features are known");
92
}
93
94
System.out.println("TEST PASSED");
95
}
96
}
97
98