author | iignatyev |
Fri, 11 Apr 2014 00:34:51 +0400 | |
changeset 24003 | 372cef87666e |
child 25735 | 990d2378e01d |
permissions | -rw-r--r-- |
24003
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
1 |
/* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
4 |
* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
8 |
* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
14 |
* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
18 |
* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
22 |
* |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
23 |
*/ |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
24 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
25 |
import com.oracle.java.testlibrary.Asserts; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
26 |
import com.oracle.java.testlibrary.Platform; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
27 |
import com.oracle.java.testlibrary.Utils; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
28 |
import sun.hotspot.code.NMethod; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
29 |
import sun.hotspot.cpuinfo.CPUInfo; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
30 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
31 |
import java.lang.reflect.Executable; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
32 |
import java.lang.reflect.Method; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
33 |
import java.util.concurrent.Callable; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
34 |
import java.util.function.Function; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
35 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
36 |
public class BmiIntrinsicBase extends CompilerWhiteBoxTest { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
37 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
38 |
protected BmiIntrinsicBase(BmiTestCase testCase) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
39 |
super(testCase); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
40 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
41 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
42 |
public static void verifyTestCase(Function<Method, BmiTestCase> constructor, Method... methods) throws Exception { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
43 |
for (Method method : methods) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
44 |
new BmiIntrinsicBase(constructor.apply(method)).test(); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
45 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
46 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
47 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
48 |
@Override |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
49 |
protected void test() throws Exception { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
50 |
BmiTestCase bmiTestCase = (BmiTestCase) testCase; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
51 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
52 |
if (!(Platform.isX86() || Platform.isX64())) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
53 |
System.out.println("Unsupported platform, test SKIPPED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
54 |
return; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
55 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
56 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
57 |
if (!Platform.isServer()) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
58 |
System.out.println("Not server VM, test SKIPPED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
59 |
return; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
60 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
61 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
62 |
if (!CPUInfo.hasFeature(bmiTestCase.getCpuFlag())) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
63 |
System.out.println("Unsupported hardware, no required CPU flag " + bmiTestCase.getCpuFlag() + " , test SKIPPED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
64 |
return; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
65 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
66 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
67 |
if (!Boolean.valueOf(getVMOption(bmiTestCase.getVMFlag()))) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
68 |
System.out.println("VM flag " + bmiTestCase.getVMFlag() + " disabled, test SKIPPED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
69 |
return; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
70 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
71 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
72 |
System.out.println(testCase.name()); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
73 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
74 |
switch (MODE) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
75 |
case "compiled mode": |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
76 |
case "mixed mode": |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
77 |
if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
78 |
System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
79 |
return; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
80 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
81 |
deoptimize(); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
82 |
compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
83 |
break; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
84 |
case "interpreted mode": // test is not applicable in this mode; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
85 |
System.err.println("Warning: This test is not applicable in mode: " + MODE); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
86 |
break; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
87 |
default: |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
88 |
throw new AssertionError("Test bug, unknown VM mode: " + MODE); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
89 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
90 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
91 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
92 |
protected void compileAtLevelAndCheck(int level) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
93 |
WHITE_BOX.enqueueMethodForCompilation(method, level); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
94 |
waitBackgroundCompilation(); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
95 |
checkCompilation(method, level); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
96 |
checkEmittedCode(method); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
97 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
98 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
99 |
protected void checkCompilation(Executable executable, int level) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
100 |
if (!WHITE_BOX.isMethodCompiled(executable)) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
101 |
throw new AssertionError("Test bug, expected compilation (level): " + level + ", but not compiled" + WHITE_BOX.isMethodCompilable(executable, level)); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
102 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
103 |
final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
104 |
if (compilationLevel != level) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
105 |
throw new AssertionError("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
106 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
107 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
108 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
109 |
protected void checkEmittedCode(Executable executable) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
110 |
final byte[] nativeCode = NMethod.get(executable, false).insts; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
111 |
if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
112 |
throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode)); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
113 |
} else { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
114 |
System.out.println("CPU instructions found, PASSED"); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
115 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
116 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
117 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
118 |
abstract static class BmiTestCase implements CompilerWhiteBoxTest.TestCase { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
119 |
private final Method method; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
120 |
protected byte[] instrMask; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
121 |
protected byte[] instrPattern; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
122 |
protected boolean isLongOperation; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
123 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
124 |
public BmiTestCase(Method method) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
125 |
this.method = method; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
126 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
127 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
128 |
@Override |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
129 |
public String name() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
130 |
return method.toGenericString(); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
131 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
132 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
133 |
@Override |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
134 |
public Executable getExecutable() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
135 |
return method; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
136 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
137 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
138 |
@Override |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
139 |
public Callable<Integer> getCallable() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
140 |
return null; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
141 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
142 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
143 |
@Override |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
144 |
public boolean isOsr() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
145 |
return false; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
146 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
147 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
148 |
protected int countCpuInstructions(byte[] nativeCode) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
149 |
int count = 0; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
150 |
int patternSize = Math.min(instrMask.length, instrPattern.length); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
151 |
boolean found; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
152 |
Asserts.assertGreaterThan(patternSize, 0); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
153 |
for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
154 |
found = true; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
155 |
for (int j = 0; j < patternSize; j++) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
156 |
if ((nativeCode[i + j] & instrMask[j]) != instrPattern[j]) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
157 |
found = false; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
158 |
break; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
159 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
160 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
161 |
if (found) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
162 |
++count; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
163 |
i += patternSize - 1; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
164 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
165 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
166 |
return count; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
167 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
168 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
169 |
public boolean verifyPositive(byte[] nativeCode) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
170 |
final int cnt = countCpuInstructions(nativeCode); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
171 |
if (Platform.isX86()) { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
172 |
return cnt >= (isLongOperation ? 2 : 1); |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
173 |
} else { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
174 |
return Platform.isX64() && cnt >= 1; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
175 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
176 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
177 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
178 |
protected String getCpuFlag() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
179 |
return "bmi1"; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
180 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
181 |
|
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
182 |
protected String getVMFlag() { |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
183 |
return "UseBMI1Instructions"; |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
184 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
185 |
} |
372cef87666e
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
186 |
} |