changeset 54594:376f0e4e6fba

8158646: [jittester] generated tests may not compile by javac Reviewed-by: kvn
author iignatyev
date Wed, 23 Jan 2019 16:25:40 -0800
parents df10c5cd5171
children 8fd43dacaef7
files test/hotspot/jtreg/testlibrary/jittester/Makefile test/hotspot/jtreg/testlibrary/jittester/conf/default.properties test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/AotTestGeneratorsFactory.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java
diffstat 10 files changed, 58 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/testlibrary/jittester/Makefile	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/Makefile	Wed Jan 23 16:25:40 2019 -0800
@@ -83,9 +83,9 @@
 
 .PHONY: cleantmp
 
-all: JAR
+all: $(DIST_JAR)
 
-JAR: INIT COMPILE manifest
+$(DIST_JAR): INIT COMPILE manifest
 	$(JAR) cfm $(DIST_JAR) $(MANIFEST) -C $(CLASSES_DIR) .
 
 manifest:
@@ -107,7 +107,7 @@
 INIT: $(DIST_DIR)
 	$(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi)
 
-install: clean_testbase testgroup testroot copytestlibrary copyaot JAR cleantmp
+install: clean_testbase testgroup testroot copytestlibrary copyaot $(DIST_JAR) cleantmp
 	$(JAVA) --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS)
 
 clean_testbase:
--- a/test/hotspot/jtreg/testlibrary/jittester/conf/default.properties	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/conf/default.properties	Wed Jan 23 16:25:40 2019 -0800
@@ -1,6 +1,6 @@
 seed=SEED2
 number-of-tests=1000
-testbase-dir=ws/hotspot/test
+testbase-dir=testbase
 fp-precision=7
 min-cfg-depth=5
 max-cfg-depth=5
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/AotTestGeneratorsFactory.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/AotTestGeneratorsFactory.java	Wed Jan 23 16:25:40 2019 -0800
@@ -32,7 +32,7 @@
     private static final String AOT_COMPILER_BUILD_ACTION
             = "@build compiler.aot.AotCompiler";
     private static final String AOT_COMPILER_RUN_ACTION_PREFIX
-            = "@run driver compiler.aot.AotCompiler -libname aottest.so -class ";
+            = "@run driver compiler.aot.AotCompiler -extraopt -Xmixed -libname aottest.so -class ";
 
     @Override
     public List<TestsGenerator> apply(String[] input) {
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java	Wed Jan 23 16:25:40 2019 -0800
@@ -110,6 +110,7 @@
     public static void main(String[] args) {
         initializeTestGenerator(args);
         int counter = 0;
+        System.out.printf("Generating %d tests...%n",  ProductionParams.numberOfTests.value());
         System.out.printf(" %13s | %8s | %8s | %8s |%n", "start time", "count", "generat",
                 "running");
         System.out.printf(" %13s | %8s | %8s | %8s |%n", "---", "---", "---", "---");
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java	Wed Jan 23 16:25:40 2019 -0800
@@ -39,7 +39,7 @@
     private static final String DEFAULT_SUFFIX = "bytecode_tests";
 
     ByteCodeGenerator() {
-        super(DEFAULT_SUFFIX);
+        super(DEFAULT_SUFFIX, s -> new String[0], "-Xcomp");
     }
 
     ByteCodeGenerator(String suffix, Function<String, String[]> preRunActions, String jtDriverOptions) {
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java	Wed Jan 23 16:25:40 2019 -0800
@@ -34,7 +34,7 @@
     private static final String DEFAULT_SUFFIX = "java_tests";
 
     JavaCodeGenerator() {
-        this(DEFAULT_SUFFIX, JavaCodeGenerator::generatePrerunAction, "");
+        this(DEFAULT_SUFFIX, JavaCodeGenerator::generatePrerunAction, "-Xcomp");
     }
 
     JavaCodeGenerator(String prefix, Function<String, String[]> preRunActions, String jtDriverOptions) {
@@ -64,13 +64,16 @@
     }
 
     private void compileJavaFile(String mainClassName) {
-        String classPath = getRoot().resolve(generatorDir)
-                                    .toAbsolutePath()
-                                    .toString();
-        ProcessBuilder pb = new ProcessBuilder(JAVAC, "-cp", classPath,
+        String classPath = tmpDir.toString();
+        ProcessBuilder pb = new ProcessBuilder(JAVAC,
+                "-d", classPath,
+                "-cp", classPath,
                 generatorDir.resolve(mainClassName + ".java").toString());
         try {
-            runProcess(pb, generatorDir.resolve(mainClassName).toString());
+            int r = runProcess(pb, tmpDir.resolve(mainClassName + ".javac").toString());
+            if (r != 0) {
+                throw new Error("Can't compile sources, exit code = " + r);
+            }
         } catch (IOException | InterruptedException e) {
             throw new Error("Can't compile sources ", e);
         }
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java	Wed Jan 23 16:25:40 2019 -0800
@@ -42,6 +42,7 @@
     protected static final String JAVAC = Paths.get(JAVA_BIN, "javac").toString();
     protected static final String JAVA = Paths.get(JAVA_BIN, "java").toString();
     protected final Path generatorDir;
+    protected final Path tmpDir;
     protected final Function<String, String[]> preRunActions;
     protected final String jtDriverOptions;
     private static final String DISABLE_WARNINGS = "-XX:-PrintWarnings";
@@ -52,15 +53,19 @@
 
     protected TestsGenerator(String suffix, Function<String, String[]> preRunActions,
             String jtDriverOptions) {
-        generatorDir = getRoot().resolve(suffix);
+        generatorDir = getRoot().resolve(suffix).toAbsolutePath();
+        try {
+            tmpDir = Files.createTempDirectory(suffix).toAbsolutePath();
+        } catch (IOException e) {
+            throw new Error("Can't get a tmp dir for " + suffix, e);
+        }
         this.preRunActions = preRunActions;
         this.jtDriverOptions = jtDriverOptions;
     }
 
     protected void generateGoldenOut(String mainClassName) {
-        String classPath = getRoot().resolve(generatorDir)
-                                    .toAbsolutePath()
-                                    .toString();
+        String classPath = tmpDir.toString() + File.pathSeparator
+                + generatorDir.toString();
         ProcessBuilder pb = new ProcessBuilder(JAVA, "-Xint", DISABLE_WARNINGS, "-Xverify",
                 "-cp", classPath, mainClassName);
         String goldFile = mainClassName + ".gold";
@@ -89,9 +94,10 @@
         return -1;
     }
 
-    protected static void compilePrinter() {
+    protected void compilePrinter() {
         Path root = getRoot();
         ProcessBuilder pbPrinter = new ProcessBuilder(JAVAC,
+                "-d", tmpDir.toString(),
                 root.resolve("jdk")
                     .resolve("test")
                     .resolve("lib")
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java	Wed Jan 23 16:25:40 2019 -0800
@@ -23,11 +23,6 @@
 
 package jdk.test.lib.jittester;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.function.Predicate;
-
 import jdk.test.lib.jittester.types.TypeBoolean;
 import jdk.test.lib.jittester.types.TypeByte;
 import jdk.test.lib.jittester.types.TypeChar;
@@ -39,6 +34,11 @@
 import jdk.test.lib.jittester.types.TypeShort;
 import jdk.test.lib.jittester.types.TypeVoid;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.function.Predicate;
+
 public class TypeList {
     public static final TypeVoid VOID = new TypeVoid();
     public static final TypeBoolean BOOLEAN = new TypeBoolean();
@@ -56,7 +56,7 @@
     private static final List<Type> BUILTIN_TYPES = new ArrayList<>();
     private static final List<Type> BUILTIN_INT_TYPES = new ArrayList<>();
     private static final List<Type> BUILTIN_FP_TYPES = new ArrayList<>();
-    private static final List<Type> REFERENCE_TYPES = new ArrayList<>();
+    private static final List<TypeKlass> REFERENCE_TYPES = new ArrayList<>();
 
     static {
         BUILTIN_INT_TYPES.add(BOOLEAN);
@@ -99,7 +99,7 @@
         return BUILTIN_FP_TYPES;
     }
 
-    protected static Collection<Type> getReferenceTypes() {
+    protected static Collection<TypeKlass> getReferenceTypes() {
         return REFERENCE_TYPES;
     }
 
@@ -148,7 +148,7 @@
         return null;
     }
 
-    public static void add(Type t) {
+    public static void add(TypeKlass t) {
         REFERENCE_TYPES.add(t);
         TYPES.add(t);
     }
@@ -159,8 +159,12 @@
     }
 
     public static void removeAll() {
-        Predicate<? super Type> isNotBasic = t -> t.getName().startsWith("Test_");
-        TYPES.removeIf(isNotBasic);
-        REFERENCE_TYPES.removeIf(isNotBasic);
+        Predicate<? super String> isNotBasic = s -> s.startsWith("Test_");
+        Predicate<? super Type> isNotBasicType = t -> isNotBasic.test(t.getName());
+        REFERENCE_TYPES.stream()
+                       .map(TypeKlass::getChildrenNames)
+                       .forEach(l -> l.removeIf(isNotBasic));
+        TYPES.removeIf(isNotBasicType);
+        REFERENCE_TYPES.removeIf(isNotBasicType);
     }
 }
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java	Wed Jan 23 16:25:40 2019 -0800
@@ -67,7 +67,7 @@
                     SymbolTable.merge();
                     return castOperator;
                 }
-                throw new ProductionFailedException();
+                SymbolTable.pop();
             } catch (ProductionFailedException e) {
                 SymbolTable.pop();
             }
--- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java	Thu Jan 24 00:43:22 2019 +0100
+++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java	Wed Jan 23 16:25:40 2019 -0800
@@ -25,6 +25,7 @@
 
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.TreeSet;
 import jdk.test.lib.jittester.ProductionParams;
 import jdk.test.lib.jittester.Symbol;
@@ -124,26 +125,28 @@
         TreeSet<TypeKlass> result = new TreeSet<>();
         parentsList.stream()
                 .map(TypeList::find)
-                .filter(parentKlass -> parentKlass != null)
-                .map(parentKlass -> (TypeKlass) parentKlass)
-                .forEach(parentKlass -> {
-                    result.add(parentKlass);
-                    result.addAll(parentKlass.getAllParents());
+                .filter(Objects::nonNull)
+                .map(k -> (TypeKlass) k)
+                .forEach(k -> {
+                    if (result.add(k)) {
+                        result.addAll(k.getAllParents());
+                    }
         });
         return result;
     }
 
     public TreeSet<TypeKlass> getAllChildren() {
-        TreeSet<TypeKlass> r = new TreeSet<>();
+        TreeSet<TypeKlass> result = new TreeSet<>();
         childrenList.stream()
                 .map(TypeList::find)
-                .filter(childKlass -> childKlass != null)
-                .map(childKlass -> (TypeKlass) childKlass)
-                .forEach(childKlass -> {
-                    r.add(childKlass);
-                    r.addAll(childKlass.getAllChildren());
+                .filter(Objects::nonNull)
+                .map(k -> (TypeKlass) k)
+                .forEach(k -> {
+                    if (result.add(k)) {
+                        result.addAll(k.getAllChildren());
+                    }
         });
-        return r;
+        return result;
     }
 
     @Override