# HG changeset patch # User iignatyev # Date 1548289540 28800 # Node ID 376f0e4e6fba84c66cd6892cc2e232a03414db24 # Parent df10c5cd5171e5e0e556d825a71abcf6853f105c 8158646: [jittester] generated tests may not compile by javac Reviewed-by: kvn diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/Makefile --- 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: diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/conf/default.properties --- 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 diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/AotTestGeneratorsFactory.java --- 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 apply(String[] input) { diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java --- 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", "---", "---", "---", "---"); diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java --- 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 preRunActions, String jtDriverOptions) { diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java --- 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 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); } diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TestsGenerator.java --- 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 preRunActions; protected final String jtDriverOptions; private static final String DISABLE_WARNINGS = "-XX:-PrintWarnings"; @@ -52,15 +53,19 @@ protected TestsGenerator(String suffix, Function 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") diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java --- 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 BUILTIN_TYPES = new ArrayList<>(); private static final List BUILTIN_INT_TYPES = new ArrayList<>(); private static final List BUILTIN_FP_TYPES = new ArrayList<>(); - private static final List REFERENCE_TYPES = new ArrayList<>(); + private static final List REFERENCE_TYPES = new ArrayList<>(); static { BUILTIN_INT_TYPES.add(BOOLEAN); @@ -99,7 +99,7 @@ return BUILTIN_FP_TYPES; } - protected static Collection getReferenceTypes() { + protected static Collection 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 isNotBasic = t -> t.getName().startsWith("Test_"); - TYPES.removeIf(isNotBasic); - REFERENCE_TYPES.removeIf(isNotBasic); + Predicate isNotBasic = s -> s.startsWith("Test_"); + Predicate isNotBasicType = t -> isNotBasic.test(t.getName()); + REFERENCE_TYPES.stream() + .map(TypeKlass::getChildrenNames) + .forEach(l -> l.removeIf(isNotBasic)); + TYPES.removeIf(isNotBasicType); + REFERENCE_TYPES.removeIf(isNotBasicType); } } diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java --- 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(); } diff -r df10c5cd5171 -r 376f0e4e6fba test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java --- 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 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 getAllChildren() { - TreeSet r = new TreeSet<>(); + TreeSet 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