Mercurial > hg > truffle
annotate test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java @ 18730:61739e1b2296
Added one more reference to the CHANGELOG.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 19 Dec 2014 21:27:32 +0100 |
parents | 72558bacada3 |
children |
rev | line source |
---|---|
17868
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
1 /* |
72558bacada3
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. |
72558bacada3
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. |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
4 * |
72558bacada3
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 |
72558bacada3
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 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
8 * |
72558bacada3
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 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
72558bacada3
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 |
72558bacada3
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 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
13 * accompanied this code). |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
14 * |
72558bacada3
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 |
72558bacada3
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, |
72558bacada3
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. |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
18 * |
72558bacada3
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 |
72558bacada3
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 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
21 * questions. |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
22 * |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
23 */ |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
24 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
25 import com.oracle.java.testlibrary.Asserts; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
26 import com.oracle.java.testlibrary.Platform; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
27 import com.oracle.java.testlibrary.Utils; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
28 import sun.hotspot.code.NMethod; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
29 import sun.hotspot.cpuinfo.CPUInfo; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
30 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
31 import java.lang.reflect.Executable; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
32 import java.lang.reflect.Method; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
33 import java.util.concurrent.Callable; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
34 import java.util.function.Function; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
35 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
36 public class BmiIntrinsicBase extends CompilerWhiteBoxTest { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
37 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
38 protected BmiIntrinsicBase(BmiTestCase testCase) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
39 super(testCase); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
40 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
41 |
72558bacada3
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 { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
43 for (Method method : methods) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
44 new BmiIntrinsicBase(constructor.apply(method)).test(); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
45 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
46 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
47 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
48 @Override |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
49 protected void test() throws Exception { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
50 BmiTestCase bmiTestCase = (BmiTestCase) testCase; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
51 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
52 if (!(Platform.isX86() || Platform.isX64())) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
53 System.out.println("Unsupported platform, test SKIPPED"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
54 return; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
55 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
56 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
57 if (!Platform.isServer()) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
58 System.out.println("Not server VM, test SKIPPED"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
59 return; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
60 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
61 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
62 if (!CPUInfo.hasFeature(bmiTestCase.getCpuFlag())) { |
72558bacada3
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"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
64 return; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
65 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
66 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
67 if (!Boolean.valueOf(getVMOption(bmiTestCase.getVMFlag()))) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
68 System.out.println("VM flag " + bmiTestCase.getVMFlag() + " disabled, test SKIPPED"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
69 return; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
70 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
71 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
72 System.out.println(testCase.name()); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
73 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
74 switch (MODE) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
75 case "compiled mode": |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
76 case "mixed mode": |
72558bacada3
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) { |
72558bacada3
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"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
79 return; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
80 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
81 deoptimize(); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
82 compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
83 break; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
84 case "interpreted mode": // test is not applicable in this mode; |
72558bacada3
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); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
86 break; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
87 default: |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
88 throw new AssertionError("Test bug, unknown VM mode: " + MODE); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
89 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
90 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
91 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
92 protected void compileAtLevelAndCheck(int level) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
93 WHITE_BOX.enqueueMethodForCompilation(method, level); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
94 waitBackgroundCompilation(); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
95 checkCompilation(method, level); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
96 checkEmittedCode(method); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
97 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
98 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
99 protected void checkCompilation(Executable executable, int level) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
100 if (!WHITE_BOX.isMethodCompiled(executable)) { |
72558bacada3
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)); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
102 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
103 final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
104 if (compilationLevel != level) { |
72558bacada3
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); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
106 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
107 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
108 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
109 protected void checkEmittedCode(Executable executable) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
110 final byte[] nativeCode = NMethod.get(executable, false).insts; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
111 if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) { |
72558bacada3
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)); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
113 } else { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
114 System.out.println("CPU instructions found, PASSED"); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
115 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
116 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
117 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
118 abstract static class BmiTestCase implements CompilerWhiteBoxTest.TestCase { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
119 private final Method method; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
120 protected byte[] instrMask; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
121 protected byte[] instrPattern; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
122 protected boolean isLongOperation; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
123 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
124 public BmiTestCase(Method method) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
125 this.method = method; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
126 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
127 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
128 @Override |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
129 public String name() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
130 return method.toGenericString(); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
131 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
132 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
133 @Override |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
134 public Executable getExecutable() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
135 return method; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
136 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
137 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
138 @Override |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
139 public Callable<Integer> getCallable() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
140 return null; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
141 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
142 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
143 @Override |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
144 public boolean isOsr() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
145 return false; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
146 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
147 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
148 protected int countCpuInstructions(byte[] nativeCode) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
149 int count = 0; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
150 int patternSize = Math.min(instrMask.length, instrPattern.length); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
151 boolean found; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
152 Asserts.assertGreaterThan(patternSize, 0); |
72558bacada3
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++) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
154 found = true; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
155 for (int j = 0; j < patternSize; j++) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
156 if ((nativeCode[i + j] & instrMask[j]) != instrPattern[j]) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
157 found = false; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
158 break; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
159 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
160 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
161 if (found) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
162 ++count; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
163 i += patternSize - 1; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
164 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
165 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
166 return count; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
167 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
168 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
169 public boolean verifyPositive(byte[] nativeCode) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
170 final int cnt = countCpuInstructions(nativeCode); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
171 if (Platform.isX86()) { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
172 return cnt >= (isLongOperation ? 2 : 1); |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
173 } else { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
174 return Platform.isX64() && cnt >= 1; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
175 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
176 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
177 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
178 protected String getCpuFlag() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
179 return "bmi1"; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
180 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
181 |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
182 protected String getVMFlag() { |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
183 return "UseBMI1Instructions"; |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
184 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
185 } |
72558bacada3
8038953: Add sanity tests for BMI1 and LZCNT instructions
iignatyev
parents:
diff
changeset
|
186 } |