changeset 12503:2577c6ced18e

8170918: Remove shell script from test/compiler/c2/cr7200264/TestIntVect.java Reviewed-by: kvn
author bmoloden
date Wed, 21 Dec 2016 15:01:01 +0300
parents 9cd4389354c0
children f92932a08d08
files test/TEST.ROOT test/compiler/c2/cr7200264/Test7200264.sh test/compiler/c2/cr7200264/TestDriver.java test/compiler/c2/cr7200264/TestIntVect.java test/compiler/c2/cr7200264/TestSSE2IntVect.java test/compiler/c2/cr7200264/TestSSE4IntVect.java
diffstat 6 files changed, 159 insertions(+), 141 deletions(-) [+]
line wrap: on
line diff
--- a/test/TEST.ROOT	Fri Dec 23 15:09:03 2016 +0000
+++ b/test/TEST.ROOT	Wed Dec 21 15:01:01 2016 +0300
@@ -46,6 +46,7 @@
     vm.gc.Parallel \
     vm.gc.ConcMarkSweep \
     vm.jvmci \
+    vm.cpu.features \
     vm.debug
 
 # Tests using jtreg 4.2 b04 features
--- a/test/compiler/c2/cr7200264/Test7200264.sh	Fri Dec 23 15:09:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-# 
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-# 
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-# 
-# 
-
-## some tests require path to find test source dir
-if [ "${TESTSRC}" = "" ]
-then
-  TESTSRC=${PWD}
-  echo "TESTSRC not set.  Using "${TESTSRC}" as default"
-fi
-echo "TESTSRC=${TESTSRC}"
-## Adding common setup Variables for running shell tests.
-. ${TESTSRC}/../../../test_env.sh
-
-${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -Xinternalversion | sed 's/amd64/x86/' | grep "x86" | grep "Server VM" | grep "debug"
-
-# Only test fastdebug Server VM on x86
-if [ $? != 0 ]
-then
-    echo "Test Passed"
-    exit 0
-fi
-
-# grep for support integer multiply vectors (cpu with SSE4.1)
-${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -XX:+PrintMiscellaneous -XX:+Verbose -version | grep "cores per cpu" | grep "sse4.1"
-
-if [ $? != 0 ]
-then
-    SSE=2
-else
-    SSE=4
-fi
-
-cp ${TESTSRC}${FS}TestIntVect.java .
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} -d . TestIntVect.java
-
-# CICompilerCount must be at least 2 with -TieredCompilation
-${TESTJAVA}${FS}bin${FS}java ${TESTOPTS} -Xbatch -XX:-TieredCompilation  \
-        -XX:CICompilerCount=2 -XX:+PrintCompilation -XX:+TraceNewVectors \
-        compiler.c2.cr7200264.TestIntVect > test.out 2>&1
-
-COUNT=`grep AddVI test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 4 ]
-then
-    echo "Test Failed: AddVI $COUNT < 4"
-    exit 1
-fi
-
-# AddVI is generated for test_subc
-COUNT=`grep SubVI test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 4 ]
-then
-    echo "Test Failed: SubVI $COUNT < 4"
-    exit 1
-fi
-
-# MulVI is only supported with SSE4.1.
-if [ $SSE -gt 3 ]
-then
-# LShiftVI+SubVI is generated for test_mulc
-COUNT=`grep MulVI test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 2 ]
-then
-    echo "Test Failed: MulVI $COUNT < 2"
-    exit 1
-fi
-fi
-
-COUNT=`grep AndV test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 3 ]
-then
-    echo "Test Failed: AndV $COUNT < 3"
-    exit 1
-fi
-
-COUNT=`grep OrV test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 3 ]
-then
-    echo "Test Failed: OrV $COUNT < 3"
-    exit 1
-fi
-
-COUNT=`grep XorV test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 3 ]
-then
-    echo "Test Failed: XorV $COUNT < 3"
-    exit 1
-fi
-
-# LShiftVI+SubVI is generated for test_mulc
-COUNT=`grep LShiftVI test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 5 ]
-then
-    echo "Test Failed: LShiftVI $COUNT < 5"
-    exit 1
-fi
-
-COUNT=`grep RShiftVI test.out | sed '/URShiftVI/d' | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 3 ]
-then
-    echo "Test Failed: RShiftVI $COUNT < 3"
-    exit 1
-fi
-
-COUNT=`grep URShiftVI test.out | wc -l | awk '{print $1}'`
-if [ $COUNT -lt 3 ]
-then
-    echo "Test Failed: URShiftVI $COUNT < 3"
-    exit 1
-fi
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/c2/cr7200264/TestDriver.java	Wed Dec 21 15:01:01 2016 +0300
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.c2.cr7200264;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class TestDriver {
+    private final Map<String, Long> expectedVectorizationNumbers
+            = new HashMap<>();
+
+    public void addExpectedVectorization(String v, long num) {
+        expectedVectorizationNumbers.put(v, num);
+    }
+
+    public void run() throws Throwable {
+        verifyVectorizationNumber(executeApplication());
+    }
+
+    private List<String> executeApplication() throws Throwable {
+        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvmAllArgs(
+            "-Xbatch",
+            "-XX:-TieredCompilation",
+            "-XX:+PrintCompilation",
+            "-XX:+TraceNewVectors",
+            TestIntVect.class.getName());
+        outputAnalyzer.shouldHaveExitValue(0);
+        return outputAnalyzer.asLines();
+    }
+
+    private void verifyVectorizationNumber(List<String> vectorizationLog) {
+        for (Map.Entry<String, Long> entry : expectedVectorizationNumbers.entrySet()) {
+            String v = "\t" + entry.getKey();
+            long actualNum = vectorizationLog.stream()
+                    .filter(s -> s.contains(v)).count();
+            long expectedNum = entry.getValue();
+            Asserts.assertGTE(actualNum, expectedNum,
+                              "Unexpected " + entry.getKey() + " number");
+        }
+    }
+}
--- a/test/compiler/c2/cr7200264/TestIntVect.java	Fri Dec 23 15:09:03 2016 +0000
+++ b/test/compiler/c2/cr7200264/TestIntVect.java	Wed Dec 21 15:01:01 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,14 +21,6 @@
  * questions.
  */
 
-/**
- * @test
- * @bug 7200264
- * @summary 7192963 changes disabled shift vectors
- *
- * @run shell Test7200264.sh
- */
-
 package compiler.c2.cr7200264;
 /*
  * Copy of test/compiler/6340864/TestIntVect.java without performance tests.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/c2/cr7200264/TestSSE2IntVect.java	Wed Dec 21 15:01:01 2016 +0300
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7200264
+ * @summary 7192963 changes disabled shift vectors
+ * @requires vm.cpu.features ~= ".*sse2.*" & vm.debug & vm.flavor == "server"
+ * @library /test/lib /
+ * @run driver compiler.c2.cr7200264.TestSSE2IntVect
+ */
+
+package compiler.c2.cr7200264;
+
+public class TestSSE2IntVect {
+    public static void main(String[] args) throws Throwable {
+        TestDriver test = new TestDriver();
+        test.addExpectedVectorization("AddVI", 4);
+        test.addExpectedVectorization("SubVI", 4);
+        test.addExpectedVectorization("AndV", 3);
+        test.addExpectedVectorization("OrV", 3);
+        test.addExpectedVectorization("XorV", 3);
+        test.addExpectedVectorization("LShiftVI", 5);
+        test.addExpectedVectorization("RShiftVI", 3);
+        test.addExpectedVectorization("URShiftVI", 3);
+        test.run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compiler/c2/cr7200264/TestSSE4IntVect.java	Wed Dec 21 15:01:01 2016 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7200264
+ * @summary 7192963 changes disabled shift vectors
+ * @requires vm.cpu.features ~= ".*sse4\\.1.*" & vm.debug & vm.flavor == "server"
+ * @library /test/lib /
+ * @run driver compiler.c2.cr7200264.TestSSE4IntVect
+ */
+
+package compiler.c2.cr7200264;
+
+public class TestSSE4IntVect {
+    public static void main(String[] args) throws Throwable {
+        TestDriver test = new TestDriver();
+        test.addExpectedVectorization("MulVI", 2);
+        test.run();
+    }
+}