changeset 25735:990d2378e01d

8049348: compiler/intrinsics/bmi/verifycode tests on lzcnt and tzcnt use incorrect assumption about REXB prefix usage Reviewed-by: kvn
author aaivanov
date Sat, 19 Jul 2014 00:33:37 +0400
parents 3f3faa33a4fa
children 6f35dbe32581
files hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java
diffstat 5 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java	Sat Jul 19 00:32:23 2014 +0400
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java	Sat Jul 19 00:33:37 2014 +0400
@@ -146,6 +146,10 @@
         }
 
         protected int countCpuInstructions(byte[] nativeCode) {
+            return countCpuInstructions(nativeCode, instrMask, instrPattern);
+        }
+
+        public static int countCpuInstructions(byte[] nativeCode, byte[] instrMask, byte[] instrPattern) {
             int count = 0;
             int patternSize = Math.min(instrMask.length, instrPattern.length);
             boolean found;
@@ -183,4 +187,21 @@
             return "UseBMI1Instructions";
         }
     }
+
+    abstract static class BmiTestCase_x64 extends BmiTestCase {
+        protected byte[] instrMask_x64;
+        protected byte[] instrPattern_x64;
+
+        protected BmiTestCase_x64(Method method) {
+            super(method);
+        }
+
+        protected int countCpuInstructions(byte[] nativeCode) {
+            int cnt = super.countCpuInstructions(nativeCode);
+            if (Platform.isX64()) { // on x64 platform the instruction we search for can be encoded in 2 different ways
+                cnt += countCpuInstructions(nativeCode, instrMask_x64, instrPattern_x64);
+            }
+            return cnt;
+        }
+    }
 }
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java	Sat Jul 19 00:32:23 2014 +0400
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java	Sat Jul 19 00:33:37 2014 +0400
@@ -33,12 +33,15 @@
 
 import java.lang.reflect.Method;
 
-public class LZcntTestI extends BmiIntrinsicBase.BmiTestCase {
+public class LZcntTestI extends BmiIntrinsicBase.BmiTestCase_x64 {
 
     protected LZcntTestI(Method method) {
         super(method);
         instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
         instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBD};
+
+        instrMask_x64 = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
+        instrPattern_x64 = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBD};
     }
 
     public static void main(String[] args) throws Exception {
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java	Sat Jul 19 00:32:23 2014 +0400
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java	Sat Jul 19 00:33:37 2014 +0400
@@ -31,8 +31,6 @@
  *                   -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountLeadingZerosInstruction LZcntTestL
  */
 
-import com.oracle.java.testlibrary.Platform;
-
 import java.lang.reflect.Method;
 
 public class LZcntTestL extends LZcntTestI {
@@ -40,10 +38,6 @@
     protected LZcntTestL(Method method) {
         super(method);
         isLongOperation = true;
-        if (Platform.isX64()) {
-            instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
-            instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBD};
-        }
     }
 
     public static void main(String[] args) throws Exception {
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java	Sat Jul 19 00:32:23 2014 +0400
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java	Sat Jul 19 00:33:37 2014 +0400
@@ -33,12 +33,15 @@
 
 import java.lang.reflect.Method;
 
-public class TZcntTestI extends BmiIntrinsicBase.BmiTestCase {
+public class TZcntTestI extends BmiIntrinsicBase.BmiTestCase_x64 {
 
     protected TZcntTestI(Method method) {
         super(method);
         instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
         instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBC};
+
+        instrMask_x64 = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
+        instrPattern_x64 = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBC};
     }
 
     public static void main(String[] args) throws Exception {
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java	Sat Jul 19 00:32:23 2014 +0400
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java	Sat Jul 19 00:33:37 2014 +0400
@@ -31,8 +31,6 @@
  *                   -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountTrailingZerosInstruction TZcntTestL
  */
 
-import com.oracle.java.testlibrary.Platform;
-
 import java.lang.reflect.Method;
 
 public class TZcntTestL extends TZcntTestI {
@@ -40,11 +38,6 @@
     protected TZcntTestL(Method method) {
         super(method);
         isLongOperation = true;
-        if (Platform.isX64()) {
-            instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
-            instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBC};
-        }
-        isLongOperation = true;
     }
 
     public static void main(String[] args) throws Exception {