equal
deleted
inserted
replaced
144 public boolean isOsr() { |
144 public boolean isOsr() { |
145 return false; |
145 return false; |
146 } |
146 } |
147 |
147 |
148 protected int countCpuInstructions(byte[] nativeCode) { |
148 protected int countCpuInstructions(byte[] nativeCode) { |
|
149 return countCpuInstructions(nativeCode, instrMask, instrPattern); |
|
150 } |
|
151 |
|
152 public static int countCpuInstructions(byte[] nativeCode, byte[] instrMask, byte[] instrPattern) { |
149 int count = 0; |
153 int count = 0; |
150 int patternSize = Math.min(instrMask.length, instrPattern.length); |
154 int patternSize = Math.min(instrMask.length, instrPattern.length); |
151 boolean found; |
155 boolean found; |
152 Asserts.assertGreaterThan(patternSize, 0); |
156 Asserts.assertGreaterThan(patternSize, 0); |
153 for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) { |
157 for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) { |
181 |
185 |
182 protected String getVMFlag() { |
186 protected String getVMFlag() { |
183 return "UseBMI1Instructions"; |
187 return "UseBMI1Instructions"; |
184 } |
188 } |
185 } |
189 } |
|
190 |
|
191 abstract static class BmiTestCase_x64 extends BmiTestCase { |
|
192 protected byte[] instrMask_x64; |
|
193 protected byte[] instrPattern_x64; |
|
194 |
|
195 protected BmiTestCase_x64(Method method) { |
|
196 super(method); |
|
197 } |
|
198 |
|
199 protected int countCpuInstructions(byte[] nativeCode) { |
|
200 int cnt = super.countCpuInstructions(nativeCode); |
|
201 if (Platform.isX64()) { // on x64 platform the instruction we search for can be encoded in 2 different ways |
|
202 cnt += countCpuInstructions(nativeCode, instrMask_x64, instrPattern_x64); |
|
203 } |
|
204 return cnt; |
|
205 } |
|
206 } |
186 } |
207 } |