Mercurial > hg > truffle
annotate test/testlibrary/whitebox/sun/hotspot/cpuinfo/CPUInfo.java @ 18847:cff8333119b4
fixed eclipseformat issues
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Jan 2015 20:43:38 +0100 |
parents | a48e16541e6b |
children |
rev | line source |
---|---|
17778
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
1 /* |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
4 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
8 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
13 * accompanied this code). |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
14 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
18 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
21 * questions. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
22 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
23 */ |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
24 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
25 package sun.hotspot.cpuinfo; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
26 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
27 import java.util.List; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
28 import java.util.ArrayList; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
29 import java.util.Arrays; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
30 import java.util.Collections; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
31 import java.util.regex.Pattern; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
32 import java.util.regex.Matcher; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
33 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
34 import sun.hotspot.WhiteBox; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
35 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
36 /** |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
37 * Information about CPU on test box. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
38 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
39 * CPUInfo uses WhiteBox to gather information, |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
40 * so WhiteBox class should be added to bootclasspath |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
41 * and option -XX:+WhiteBoxAPI should expclicetly |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
42 * specified on command line. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
43 */ |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
44 public class CPUInfo { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
45 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
46 private static final List<String> features; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
47 private static final String additionalCPUInfo; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
48 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
49 static { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
50 WhiteBox wb = WhiteBox.getWhiteBox(); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
51 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
52 Pattern additionalCPUInfoRE = |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
53 Pattern.compile("([^(]*\\([^)]*\\)[^,]*),\\s*"); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
54 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
55 String cpuFeaturesString = wb.getCPUFeatures(); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
56 Matcher matcher = additionalCPUInfoRE.matcher(cpuFeaturesString); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
57 if (matcher.find()) { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
58 additionalCPUInfo = matcher.group(1); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
59 } else { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
60 additionalCPUInfo = ""; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
61 } |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
62 String splittedFeatures[] = matcher.replaceAll("").split("(, )| "); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
63 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
64 features = Collections.unmodifiableList(Arrays. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
65 asList(splittedFeatures)); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
66 } |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
67 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
68 /** |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
69 * Get additional information about CPU. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
70 * For example, on X86 in will be family/model/stepping |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
71 * and number of cores. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
72 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
73 * @return additional CPU info |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
74 */ |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
75 public static String getAdditionalCPUInfo() { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
76 return additionalCPUInfo; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
77 } |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
78 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
79 /** |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
80 * Get all known features supported by CPU. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
81 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
82 * @return unmodifiable list with names of all known features |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
83 * supported by CPU. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
84 */ |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
85 public static List<String> getFeatures() { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
86 return features; |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
87 } |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
88 |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
89 /** |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
90 * Check if some feature is supported by CPU. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
91 * |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
92 * @param feature Name of feature to be tested. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
93 * @return <b>true</b> if tested feature is supported by CPU. |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
94 */ |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
95 public static boolean hasFeature(String feature) { |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
96 return features.contains(feature.toLowerCase()); |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
97 } |
a48e16541e6b
8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
98 } |