--- old/test/testlibrary/jittester/Makefile 2016-05-12 04:23:53.806334858 +0300 +++ new/test/testlibrary/jittester/Makefile 2016-05-12 04:23:53.710334859 +0300 @@ -91,10 +91,10 @@ @echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST) compile_testlib: INIT - $(JAVAC) -XDignore.symbol.file -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) -source 1.8 + $(JAVAC) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR) COMPILE: INIT filelist compile_testlib - $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) -source 1.8 @filelist + $(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist filelist: $(SRC_FILES) @rm -f $@ @@ -104,7 +104,7 @@ $(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi) install: clean_testbase testgroup testroot copytestlibrary JAR cleantmp - $(JAVA) -jar $(DIST_JAR) $(APPLICATION_ARGS) + $(JAVA) -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS) clean_testbase: @rm -rf $(TESTBASE_DIR) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java 2016-05-12 04:23:57.466334829 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Automatic.java 2016-05-12 04:23:57.370334829 +0300 @@ -23,125 +23,165 @@ package jdk.test.lib.jittester; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import jdk.test.lib.jittester.IRNode; -import jdk.test.lib.jittester.ProductionParams; -import jdk.test.lib.jittester.SymbolTable; -import jdk.test.lib.jittester.TypeList; +import jdk.test.lib.Pair; import jdk.test.lib.jittester.factories.IRNodeBuilder; -import jdk.test.lib.jittester.TypesParser; +import jdk.test.lib.jittester.jtreg.Printer; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.visitors.JavaCodeVisitor; +import jdk.test.lib.jittester.utils.FixedTrees; import jdk.test.lib.jittester.utils.OptionResolver; import jdk.test.lib.jittester.utils.OptionResolver.Option; import jdk.test.lib.jittester.utils.PseudoRandom; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.LocalTime; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + public class Automatic { - public static final int minutesToWait = 3; + private static final int MINUTES_TO_WAIT = Integer.getInteger("jdk.test.lib.jittester", 3); + + static String getJtregHeader(String mainClass, boolean addCompile) { + String synopsis = "seed = '" + ProductionParams.seed.value() + "'" + + ", specificSeed = '" + PseudoRandom.getCurrentSeed() + "'"; + StringBuilder header = new StringBuilder(); + header.append("/*\n * @test\n * @summary ") + .append(synopsis) + .append(" \n* @library / ../\n"); + if (addCompile) { + header.append("\n * @compile ") + .append(mainClass) + .append(".java\n"); + } + header.append(" * @run build jdk.test.lib.jittester.jtreg.JitTesterDriver " + + "jdk.test.lib.jittester.jtreg.Printer\n") + .append(" * @run driver jdk.test.lib.jittester.jtreg.JitTesterDriver ") + .append(mainClass) + .append("\n */\n\n"); + if (ProductionParams.printHierarchy.value()) { + header.append("/*\n") + .append(Automatic.printHierarchy()) + .append("*/\n"); + } + return header.toString(); + } - private static String makeTestCase(String name) { + private static Pair generateIRTree(String name) { SymbolTable.removeAll(); TypeList.removeAll(); - StringBuilder resultVis = new StringBuilder(); - StringBuilder headerBuilder = new StringBuilder(); - try { - IRNodeBuilder builder = new IRNodeBuilder() - .setPrefix(name) - .setName(name) - .setLevel(0); - - JavaCodeVisitor vis = new JavaCodeVisitor(); - String synopsis = "seed = '" + ProductionParams.seed.value() + "'"; - String pathPrefix = ProductionParams.testbaseDir.value() - .replaceAll("([^/]+)", ".."); - headerBuilder - .append("/*\n") - .append(" * @test\n") - .append(" * @summary ") - .append(synopsis) - .append("\n") - .append(" * @compile ") - .append(name) - .append(".java\n") - .append(" * @run build jdk.test.lib.jittester.jtreg.JitTesterDriver\n") - .append(" * @run driver jdk.test.lib.jittester.jtreg.JitTesterDriver ") - .append(name) - .append("\n") - .append(" */\n\n"); - - - if (!ProductionParams.disableClasses.value()) { - long comlexityLimit = (long) (ProductionParams.complexityLimit.value() - * PseudoRandom.random()); - IRNode privateClasses = builder.setComplexityLimit(comlexityLimit) + + IRNodeBuilder builder = new IRNodeBuilder() + .setPrefix(name) + .setName(name) + .setLevel(0); + + Long complexityLimit = ProductionParams.complexityLimit.value(); + IRNode privateClasses = null; + if (!ProductionParams.disableClasses.value()) { + long privateClassComlexity = (long) (complexityLimit * PseudoRandom.random()); + try { + privateClasses = builder.setComplexityLimit(privateClassComlexity) .getClassDefinitionBlockFactory() .produce(); - if (privateClasses != null) { - resultVis.append(privateClasses.accept(vis)); - } + } catch (ProductionFailedException ex) { + ex.printStackTrace(System.out); } - long mainComplexityLimit = (long) (ProductionParams.complexityLimit.value() - * PseudoRandom.random()); - IRNode mainClass = builder.setComplexityLimit(mainComplexityLimit) + } + long mainClassComplexity = (long) (complexityLimit * PseudoRandom.random()); + IRNode mainClass = null; + try { + mainClass = builder.setComplexityLimit(mainClassComplexity) .getMainKlassFactory() .produce(); - resultVis.append(mainClass.accept(vis)); - - if (ProductionParams.printHierarchy.value()) { - headerBuilder - .append("/*\n") - .append(Automatic.printHierarchy()) - .append("*/\n"); - } - } catch (Exception e) { - e.printStackTrace(System.out); + TypeKlass aClass = new TypeKlass(name); + mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, true)); + mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, false)); + } catch (ProductionFailedException ex) { + ex.printStackTrace(System.out); } - return headerBuilder.append(resultVis).toString(); + return new Pair<>(mainClass, privateClasses); } private static void initializeTestGenerator(String[] params) { OptionResolver parser = new OptionResolver(); - Option propertyFileOpt = parser.addStringOption('p', "property-file", "", - "File to read properties from"); + Option propertyFileOpt = parser.addStringOption('p', "property-file", + "conf/default.properties", "File to read properties from"); ProductionParams.register(parser); parser.parse(params, propertyFileOpt); - jdk.test.lib.jittester.utils.PseudoRandom.reset(ProductionParams.seed.value()); - TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(), ProductionParams.excludeMethodsFile.value()); + PseudoRandom.reset(ProductionParams.seed.value()); + TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(), + ProductionParams.excludeMethodsFile.value()); + if (ProductionParams.specificSeed.isSet()) { + PseudoRandom.setCurrentSeed(ProductionParams.specificSeed.value()); + } } public static void main(String[] args) { initializeTestGenerator(args); int counter = 0; try { - String testbaseDir = ProductionParams.testbaseDir.value(); + Path testbaseDir = Paths.get(ProductionParams.testbaseDir.value()); + System.out.printf(" %13s | %8s | %8s | %8s |%n", "start time", "count", "generat", + "running"); + System.out.printf(" %13s | %8s | %8s | %8s |%n", "---", "---", "---","---"); + String path = getJavaPath(); + String javacPath = Paths.get(path, "javac").toString(); + String javaPath = Paths.get(path, "java").toString(); + + // compile Printer class first. A common one for all tests + ensureExisting(testbaseDir); + ProcessBuilder pbPrinter = new ProcessBuilder(javacPath, + Paths.get(testbaseDir.toString(), "jdk", "test", "lib", "jittester", + "jtreg", "Printer.java").toString()); + runProcess(pbPrinter, testbaseDir.resolve("Printer").toString()); do { double start = System.currentTimeMillis(); + System.out.print("[" + LocalTime.now() + "] |"); String name = "Test_" + counter; - generateTestFile(name); + Pair irTree = generateIRTree(name); + System.out.printf(" %8d |", counter); double generationTime = System.currentTimeMillis() - start; - String path = getJavaPath(); - ProcessBuilder pb = new ProcessBuilder(path + "javac", testbaseDir + "/" + name + ".java"); - runProcess(pb, testbaseDir + "/" + name); - - start = System.currentTimeMillis(); - pb = new ProcessBuilder(path + "java", "-Xint", "-cp", testbaseDir, name); - name = name + ".gold"; - runProcess(pb, testbaseDir + "/" + name); + System.out.printf(" %8.0f |", generationTime); + if (!ProductionParams.disableJavacodeGeneration.value()) { + JavaCodeGenerator generator = new JavaCodeGenerator(); + String javaFile = generator.apply(irTree.first, irTree.second); + ProcessBuilder pb = new ProcessBuilder(javacPath, "-cp", testbaseDir.toString() + + ":" + generator.getTestbase().toString(), javaFile); + runProcess(pb, generator.getTestbase().resolve(name).toString()); + start = System.currentTimeMillis(); + + // Run compiled class files + pb = new ProcessBuilder(javaPath, "-Xint", "-cp", testbaseDir.toString() + + ":" + generator.getTestbase().toString(), name); + String goldFile = name + ".gold"; + runProcess(pb, generator.getTestbase().resolve(goldFile).toString()); + } + + if (!ProductionParams.disableBytecodeGeneration.value()) { + ByteCodeGenerator generator = new ByteCodeGenerator(); + generator.apply(irTree.first, irTree.second); + generator.writeJtregBytecodeRunner(name); + // Run generated bytecode + ProcessBuilder pb = new ProcessBuilder(javaPath, "-Xint", "-Xverify", "-cp", + testbaseDir.toString() + ":" + generator.getTestbase().toString(), + name); + String goldFile = name + ".gold"; + start = System.currentTimeMillis(); + runProcess(pb, generator.getTestbase().resolve(goldFile).toString()); + } + double runningTime = System.currentTimeMillis() - start; - System.out.printf("%4d : generation time (ms) : %8.0f running time (ms) : %8.0f\n", - counter, generationTime, runningTime); - if (runningTime < TimeUnit.MINUTES.toMillis(minutesToWait)) - ++counter; + System.out.printf(" %8.0f |%n", runningTime); + if (runningTime < TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT)) { + ++counter; + } } while (counter < ProductionParams.numberOfTests.value()); } catch (IOException | InterruptedException ex) { - Logger.getLogger(Automatic.class.getName()).log(Level.SEVERE, null, ex); + ex.printStackTrace(); } } @@ -156,65 +196,47 @@ return ""; } - private static void runProcess(ProcessBuilder pb, String name) + private static int runProcess(ProcessBuilder pb, String name) throws IOException, InterruptedException { pb.redirectError(new File(name + ".err")); pb.redirectOutput(new File(name + ".out")); Process process = pb.start(); - if (process.waitFor(minutesToWait, TimeUnit.MINUTES)) { + if (process.waitFor(MINUTES_TO_WAIT, TimeUnit.MINUTES)) { try (FileWriter file = new FileWriter(name + ".exit")) { file.write(Integer.toString(process.exitValue())); } + return process.exitValue(); } else { process.destroyForcibly(); - } - TimeUnit.MILLISECONDS.sleep(300); - } - - private static void generateTestFile(String testName) { - String code = makeTestCase(testName); - String testbaseDir = ProductionParams.testbaseDir.value(); - String fileName = testbaseDir + "/" + testName + ".java"; - try (FileWriter file = new FileWriter(fileName)) { - file.write(code); - //file.close(); - } catch (IOException ex) { - Logger.getLogger(Automatic.class.getName()) - .log(Level.SEVERE, " Cannot write to file " + fileName, ex); + return -1; } } private static String printHierarchy() { - String r = "CLASS HIERARCHY:\n"; - for (Type t : TypeList.getAll()) { - if (t instanceof TypeKlass) { - TypeKlass k = (TypeKlass) t; - if (k.isAbstract()) { - r += "abstract "; - } - if (k.isFinal()) { - r += "final "; - } - if (k.isInterface()) { - r += "interface "; - } else { - r += "class "; - } - r += k.getName() + ": "; - HashSet parents = k.getParentsNames(); - if (parents != null) { - Iterator n = parents.iterator(); - int size = parents.size(); - for (int i = 0; n.hasNext() && i < size - 1; i++) { - r += n.next() + ", "; - } - if (n.hasNext()) { - r += n.next(); - } - } - r += "\n"; + return TypeList.getAll().stream() + .filter(t -> t instanceof TypeKlass) + .map(t -> typeDescription((TypeKlass) t)) + .collect(Collectors.joining("\n","CLASS HIERARCHY:\n", "\n")); + } + + private static String typeDescription(TypeKlass type) { + StringBuilder result = new StringBuilder(); + String parents = type.getParentsNames().stream().collect(Collectors.joining(",")); + result.append(type.isAbstract() ? "abstract " : "") + .append(type.isFinal() ? "final " : "") + .append(type.isInterface() ? "interface " : "class ") + .append(type.getName()) + .append(parents.isEmpty() ? "" : ": " + parents); + return result.toString(); + } + + static void ensureExisting(Path path) { + if (Files.notExists(path)) { + try { + Files.createDirectories(path); + } catch (IOException ex) { + ex.printStackTrace(); } } - return r; } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/BinaryOperator.java 2016-05-12 04:23:57.850334825 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/BinaryOperator.java 2016-05-12 04:23:57.782334826 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -26,12 +26,8 @@ import jdk.test.lib.jittester.visitors.Visitor; public class BinaryOperator extends Operator { - protected String operationCode; - protected Type resultType; - - public BinaryOperator(OperatorKind opKind, IRNode leftOperand, IRNode rightOperand) { - super(opKind.priority); - operationCode = opKind.text; + public BinaryOperator(OperatorKind opKind, Type resultType, IRNode leftOperand, IRNode rightOperand) { + super(opKind, resultType); addChild(leftOperand); addChild(rightOperand); } @@ -47,10 +43,6 @@ } } - public String getOperationCode() { - return operationCode; - } - @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Block.java 2016-05-12 04:23:58.114334823 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Block.java 2016-05-12 04:23:58.038334824 +0300 @@ -28,17 +28,12 @@ import jdk.test.lib.jittester.visitors.Visitor; public class Block extends IRNode { - private final Type returnType; - public Block(TypeKlass klass, Type returnType, List content, int level) { - setKlass(klass); + public Block(TypeKlass owner, Type returnType, List content, int level) { + super(returnType); + setOwner(owner); addChildren(content); this.level = level; - this.returnType = returnType; - } - - public Type getReturnType() { - return returnType; } protected int size() { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Break.java 2016-05-12 04:23:58.658334819 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Break.java 2016-05-12 04:23:58.570334820 +0300 @@ -27,6 +27,10 @@ public class Break extends IRNode { + public Break() { + super(TypeList.VOID); + } + @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/BuiltInType.java 2016-05-12 04:23:58.958334817 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/BuiltInType.java 2016-05-12 04:23:58.850334817 +0300 @@ -27,9 +27,9 @@ private static class BuiltInTypeCapacityHelper { - static String builtInTypes[] = {"boolean", "byte", "short", "char", "int", "long", "float", "double"}; + private static final String builtInTypes[] = {"boolean", "byte", "short", "char", "int", "long", "float", "double"}; - static private int getIndexFor(String typeName) { + private static int getIndexFor(String typeName) { for (int i = 0; i < builtInTypes.length; i++) { if (typeName.compareTo(builtInTypes[i]) == 0) { return i; @@ -38,7 +38,7 @@ return -1; } - static public int compare(String typeName1, String typeName2) { + public static int compare(String typeName1, String typeName2) { int i1 = getIndexFor(typeName1); int i2 = getIndexFor(typeName2); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/CastOperator.java 2016-05-12 04:23:59.298334814 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/CastOperator.java 2016-05-12 04:23:59.210334815 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -26,11 +26,9 @@ import jdk.test.lib.jittester.visitors.Visitor; public class CastOperator extends Operator { - private final Type resultType; public CastOperator(Type resultType, IRNode casted) { - super(13); - this.resultType = resultType; + super(null, 13, resultType); addChild(casted); } @@ -43,8 +41,4 @@ public T accept(Visitor v) { return v.visit(this); } - - public Type getResultType() { - return resultType; - } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/CatchBlock.java 2016-05-12 04:23:59.710334811 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/CatchBlock.java 2016-05-12 04:23:59.658334811 +0300 @@ -31,6 +31,7 @@ public final List throwables; public CatchBlock(IRNode body, List throwables, int level) { + super(body.getResultType()); this.level = level; this.throwables = Collections.unmodifiableList(throwables); addChild(body); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Continue.java 2016-05-12 04:24:00.070334808 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Continue.java 2016-05-12 04:23:59.994334808 +0300 @@ -27,6 +27,10 @@ public class Continue extends IRNode { + public Continue() { + super(TypeList.VOID); + } + @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Declaration.java 2016-05-12 04:24:00.310334806 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Declaration.java 2016-05-12 04:24:00.238334806 +0300 @@ -27,6 +27,7 @@ public class Declaration extends IRNode { public Declaration(IRNode declarationExpr) { + super(declarationExpr.getResultType()); addChild(declarationExpr); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/IRNode.java 2016-05-12 04:24:00.646334803 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/IRNode.java 2016-05-12 04:24:00.566334804 +0300 @@ -37,16 +37,26 @@ public abstract class IRNode { private IRNode parent; private final List children = new ArrayList<>(); - protected IRNode klass; + protected TypeKlass owner; protected int level; + private final Type resultType; + + protected IRNode(Type resultType) { + this.resultType = resultType; + } + + public Type getResultType() { + return resultType; + } + //TODO //private boolean isCFDeviation; public abstract T accept(Visitor v); - public void setKlass(TypeKlass klass) { - this.klass = klass; - if (Objects.isNull(klass)) { + public void setOwner(TypeKlass owner) { + this.owner = owner; + if (Objects.isNull(owner)) { System.out.println(getClass().getName() + " null"); for (StackTraceElement s : Thread.currentThread().getStackTrace()) { System.out.println(s.toString()); @@ -55,20 +65,17 @@ } public void addChild(IRNode child) { - children.add(child); - if (!Objects.isNull(child)) { + if (Objects.nonNull(child)) { + children.add(child); child.parent = this; } } public void addChildren(List ch) { - if (!Objects.isNull(ch)) { - children.addAll(ch); - for (IRNode c : ch) { - if (!Objects.isNull(c)) { - c.parent = this; - } - } + if (Objects.nonNull(ch)) { + ch.stream() + .filter(c -> c != null) + .forEach(this::addChild); } } @@ -80,8 +87,8 @@ return i < children.size() ? children.get(i) : null; } - public IRNode getKlass() { - return klass; + public TypeKlass getOwner() { + return owner; } public IRNode getParent() { @@ -90,7 +97,7 @@ public void setChild(int index, IRNode child) { children.set(index, child); - if (!Objects.isNull(child)) { + if (Objects.nonNull(child)) { child.parent = this; } } @@ -145,7 +152,7 @@ @Override public final String toString() { - throw new Error("Should be toJavaCode"); + return getName(); } public String getName() { @@ -154,7 +161,7 @@ public static long countDepth(Collection input) { return input.stream() - .filter(c -> !Objects.isNull(c)) + .filter(Objects::nonNull) .mapToLong(IRNode::countDepth) .max().orElse(0L); } @@ -166,7 +173,7 @@ public List getStackableLeaves() { List result = new ArrayList<>(); children.stream() - .filter(c -> !Objects.isNull(c)) + .filter(Objects::nonNull) .forEach(c -> { if (countDepth() == c.level && (c instanceof Block)) { result.add(c); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/If.java 2016-05-12 04:24:01.022334800 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/If.java 2016-05-12 04:24:00.930334801 +0300 @@ -30,9 +30,10 @@ CONDITION, THEN, ELSE, - }; + } - public If(IRNode condition, IRNode thenBlock, IRNode elseBlock, int level) { + public If(IRNode condition, Block thenBlock, Block elseBlock, int level) { + super(thenBlock.getResultType()); this.level = level; resizeUpChildren(IfPart.values().length); setChild(IfPart.CONDITION.ordinal(), condition); @@ -43,7 +44,7 @@ @Override public long complexity() { IRNode condition = getChild(IfPart.CONDITION.ordinal()); - IRNode thenBlock= getChild(IfPart.THEN.ordinal()); + IRNode thenBlock = getChild(IfPart.THEN.ordinal()); IRNode elseBlock = getChild(IfPart.ELSE.ordinal()); return (condition != null ? condition.complexity() : 0) + Math.max(thenBlock != null ? thenBlock.complexity() : 0, --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Initialization.java 2016-05-12 04:24:01.334334798 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Initialization.java 2016-05-12 04:24:01.250334798 +0300 @@ -26,20 +26,14 @@ import jdk.test.lib.jittester.visitors.Visitor; public abstract class Initialization extends IRNode { - protected VariableInfo variableInfo = new VariableInfo(); - - protected Initialization() { - } + private final VariableInfo variableInfo; protected Initialization(VariableInfo varInfo, IRNode initExpr) { + super(varInfo.type); variableInfo = varInfo; addChild(initExpr); } - public VariableInfo get() { - return variableInfo; - } - @Override public long complexity() { return getChild(0).complexity() + 1; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Literal.java 2016-05-12 04:24:01.898334793 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Literal.java 2016-05-12 04:24:01.830334794 +0300 @@ -27,11 +27,10 @@ public class Literal extends IRNode { public final Object value; - protected final Type resultType; public Literal(Object v, Type t) { + super(t); value = v; - resultType = t; } @Override @@ -44,10 +43,6 @@ return v.visit(this); } - public Type getResultType() { - return resultType; - } - public Object getValue() { return value; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/LocalVariable.java 2016-05-12 04:24:02.310334790 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/LocalVariable.java 2016-05-12 04:24:02.242334790 +0300 @@ -25,16 +25,9 @@ import jdk.test.lib.jittester.visitors.Visitor; -public class LocalVariable extends IRNode implements VariableBase { - private VariableInfo value = new VariableInfo(); - +public class LocalVariable extends VariableBase { public LocalVariable(VariableInfo value) { - this.value = value; - } - - @Override - public VariableInfo get() { - return value; + super(value); } @Override --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/NonStaticMemberVariable.java 2016-05-12 04:24:02.730334786 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/NonStaticMemberVariable.java 2016-05-12 04:24:02.670334787 +0300 @@ -25,20 +25,14 @@ import jdk.test.lib.jittester.visitors.Visitor; -public class NonStaticMemberVariable extends IRNode implements VariableBase { - private final VariableInfo value; +public class NonStaticMemberVariable extends VariableBase { public NonStaticMemberVariable(IRNode object, VariableInfo value) { - this.value = value; + super(value); addChild(object); } @Override - public VariableInfo get() { - return value; - } - - @Override public long complexity() { return getChild(0).complexity(); } @@ -47,8 +41,4 @@ public T accept(Visitor v) { return v.visit(this); } - - public VariableInfo getValue() { - return value; - } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Nothing.java 2016-05-12 04:24:03.022334784 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Nothing.java 2016-05-12 04:24:02.930334785 +0300 @@ -27,6 +27,10 @@ public class Nothing extends IRNode { + public Nothing() { + super(TypeList.VOID); + } + @Override public long complexity() { return 0; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Operator.java 2016-05-12 04:24:03.414334781 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Operator.java 2016-05-12 04:24:03.334334782 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -24,18 +24,28 @@ package jdk.test.lib.jittester; public abstract class Operator extends IRNode { - protected int operatorPriority; + protected final OperatorKind opKind; + private final int priority; public int getPriority() { - return operatorPriority; + return priority; + } + + public OperatorKind getOperationKind() { + return opKind; } public enum Order { LEFT, RIGHT - }; + } + + protected Operator(OperatorKind opKind, Type resultType) { + this(opKind, opKind.priority, resultType); + } - // This constructor is called to construct an IR-tree node. - protected Operator(int operatorPriority) { - this.operatorPriority = operatorPriority; + protected Operator(OperatorKind opKind, int operatorPriority, Type resultType) { + super(resultType); + this.opKind = opKind; + this.priority = operatorPriority; } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/OperatorKind.java 2016-05-12 04:24:03.734334778 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/OperatorKind.java 2016-05-12 04:24:03.646334779 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -25,58 +25,96 @@ // all unary and binary operator kinds public enum OperatorKind { - COMPOUND_ADD("+=", 1), - COMPOUND_SUB("-=", 1), - COMPOUND_MUL("*=", 1), - COMPOUND_DIV("-=", 1), - COMPOUND_MOD("%=", 1), - COMPOUND_AND("&=", 1), - COMPOUND_OR ("|=", 1), - COMPOUND_XOR("^=", 1), - COMPOUND_SHR(">>=", 1), - COMPOUND_SHL("<<=", 1), - COMPOUND_SAR(">>>=", 1), - ASSIGN ("=", 1), - OR ("||", 3), - BIT_OR ("|", 5), - BIT_XOR ("^", 6), - AND ("&&", 7), - BIT_AND ("&", 7), - EQ ("==", 8), - NE ("!=", 8), - GT (">", 9), - LT ("<", 9), - GE (">=", 9), - LE ("<=", 9), - SHR (">>", 10), - SHL ("<<", 10), - SAR (">>>", 10), - ADD ("+", 11), - STRADD ("+", 11), - SUB ("-", 11), - MUL ("*", 12), - DIV ("/", 12), - MOD ("%", 12), - NOT ("!", 14), - BIT_NOT ("~", 14), - UNARY_PLUS ("+", 14), - UNARY_MINUS ("-", 14), - PRE_DEC ("--", 15, true), - POST_DEC ("--", 15, false), - PRE_INC ("++", 16, true), - POST_INC ("++", 16, false), + /** a += b */ + COMPOUND_ADD(1), + /** a -= b */ + COMPOUND_SUB(1), + /** a *= b */ + COMPOUND_MUL(1), + /** a /= b */ + COMPOUND_DIV(1), + /** a %= b */ + COMPOUND_MOD(1), + /** a &= b */ + COMPOUND_AND(1), + /** a |= b */ + COMPOUND_OR (1), + /** a ^= b */ + COMPOUND_XOR(1), + /** a >>= b */ + COMPOUND_SHR(1), + /** a <<= b */ + COMPOUND_SHL(1), + /** a >>>= b */ + COMPOUND_SAR(1), + /** a = b */ + ASSIGN (1), + /** a || b */ + OR (3), + /** a | b */ + BIT_OR (5), + /** a ^ b */ + BIT_XOR (6), + /** a && b */ + AND (7), + /** a & b */ + BIT_AND (7), + /** a == b */ + EQ (8), + /** a != b */ + NE (8), + /** a > b */ + GT (9), + /** a < b */ + LT (9), + /** a >= b */ + GE (9), + /** a <= b */ + LE (9), + /** a >> b */ + SHR (10), + /** a << b */ + SHL (10), + /** a >>> b */ + SAR (10), + /** a + b */ + ADD (11), + /** a.toString() + b */ + STRADD (11), + /** a - b */ + SUB (11), + /** a * b */ + MUL (12), + /** a / b */ + DIV (12), + /** a % b */ + MOD (12), + /** !a */ + NOT (14), + /** ~a */ + BIT_NOT (14), + /** +a */ + UNARY_PLUS (14), + /** -a */ + UNARY_MINUS (14), + /** --a */ + PRE_DEC (15, true), + /** a-- */ + POST_DEC (15, false), + /** ++a */ + PRE_INC (16, true), + /** a++ */ + POST_INC (16, false), ; - public final String text; public final int priority; public final boolean isPrefix; // used for unary operators - private OperatorKind(String text, int priority) { - this(text, priority, true); + private OperatorKind(int priority) { + this(priority, true); } - private OperatorKind(String text, int priority, boolean isPrefix) { - this.text = text; + private OperatorKind(int priority, boolean isPrefix) { this.priority = priority; this.isPrefix = isPrefix; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/PrintVariables.java 2016-05-12 04:24:04.042334776 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/PrintVariables.java 2016-05-12 04:24:03.974334776 +0300 @@ -25,15 +25,16 @@ import java.util.ArrayList; import java.util.List; +import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.visitors.Visitor; public class PrintVariables extends IRNode { - private final String printerName; private final ArrayList vars; - public PrintVariables(String printerName, ArrayList vars, int level) { - this.printerName = printerName; - this.vars = vars; + public PrintVariables(TypeKlass owner, int level) { + super(TypeList.VOID); + this.owner = owner; + this.vars = SymbolTable.getAllCombined(owner, VariableInfo.class); this.level = level; } @@ -45,8 +46,4 @@ public List getVars() { return vars; } - - public String getPrinterName() { - return printerName; - } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java 2016-05-12 04:24:04.350334773 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionParams.java 2016-05-12 04:24:04.290334774 +0300 @@ -68,11 +68,14 @@ public static Option disableNestedBlocks = null; public static Option disableArrays = null; public static Option enableFinalizers = null; + public static Option disableBytecodeGeneration = null; + public static Option disableJavacodeGeneration = null; // workaraound: to reduce chance throwing ArrayIndexOutOfBoundsException public static Option chanceExpressionIndex = null; public static Option testbaseDir = null; public static Option numberOfTests = null; public static Option seed = null; + public static Option specificSeed = null; public static Option classesFile = null; public static Option excludeMethodsFile = null; @@ -117,11 +120,14 @@ disableNestedBlocks = optionResolver.addBooleanOption("disable-nested-blocks", "Disable generation of nested blocks"); disableArrays = optionResolver.addBooleanOption("disable-arrays", "Disable generation of arrays"); enableFinalizers = optionResolver.addBooleanOption("enable-finalizers", "Enable finalizers (for stress testing)"); + disableBytecodeGeneration = optionResolver.addBooleanOption("disable-bytecode-generation", "Disable generation of bytecode output"); + disableJavacodeGeneration = optionResolver.addBooleanOption("disable-javacode-generation", "Disable generation of java source code output"); chanceExpressionIndex = optionResolver.addIntegerOption("chance-expression-index", 0, "A non negative decimal integer used to restrict chane of generating expression in array index while creating or accessing by index"); testbaseDir = optionResolver.addStringOption("testbase-dir", ".", "Testbase dir"); numberOfTests = optionResolver.addIntegerOption('n', "number-of-tests", 0, "Number of test classes to generate"); seed = optionResolver.addStringOption("seed", "", "Random seed"); - classesFile = optionResolver.addStringOption('f', "classes-file", "", "File to read classes from"); - excludeMethodsFile = optionResolver.addStringOption('r', "exclude-methods-file", "", "File to read excluded methods from"); + specificSeed = optionResolver.addLongOption('z', "specificSeed", 0L, "A seed to be set for specific test generation(regular seed still needed for initialization)"); + classesFile = optionResolver.addStringOption('f', "classes-file", "conf/classes.lst", "File to read classes from"); + excludeMethodsFile = optionResolver.addStringOption('r', "exclude-methods-file", "conf/exclude.methods.lst", "File to read excluded methods from"); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Rule.java 2016-05-12 04:24:04.618334771 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Rule.java 2016-05-12 04:24:04.534334772 +0300 @@ -32,27 +32,26 @@ /** * The Rule. A helper to perform production. */ -public class Rule extends Factory implements Comparable { - private String name; +public class Rule extends Factory implements Comparable> { + private final String name; + private final TreeSet variants; private Integer limit = -1; @Override - public int compareTo(Rule rule) { + public int compareTo(Rule rule) { return name.compareTo(rule.name); } - private TreeSet variants; - public Rule(String name) { this.name = name; variants = new TreeSet<>(); } - public void add(String ruleName, Factory factory) { + public void add(String ruleName, Factory factory) { add(ruleName, factory, 1.0); } - public void add(String ruleName, Factory factory, double weight) { + public void add(String ruleName, Factory factory, double weight) { variants.add(new RuleEntry(ruleName, factory, weight)); } @@ -61,7 +60,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public T produce() throws ProductionFailedException { if (!variants.isEmpty()) { // Begin production. LinkedList rulesList = new LinkedList<>(variants); @@ -98,19 +97,19 @@ throw new ProductionFailedException(); } - private class RuleEntry extends Factory implements Comparable { + private class RuleEntry extends Factory implements Comparable { private final double weight; - private final Factory factory; + private final Factory factory; private final String name; - private RuleEntry(String name, Factory factory, double weight) { + private RuleEntry(String name, Factory factory, double weight) { this.name = name; this.weight = weight; this.factory = factory; } @Override - public IRNode produce() throws ProductionFailedException { + public T produce() throws ProductionFailedException { return factory.produce(); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Statement.java 2016-05-12 04:24:04.906334769 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Statement.java 2016-05-12 04:24:04.838334769 +0300 @@ -29,6 +29,7 @@ private final boolean needSemicolon; public Statement(IRNode statementBody, boolean needSemicolon) { + super(statementBody.getResultType()); this.needSemicolon = needSemicolon; addChild(statementBody); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/StaticMemberVariable.java 2016-05-12 04:24:05.198334767 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/StaticMemberVariable.java 2016-05-12 04:24:05.114334767 +0300 @@ -26,17 +26,11 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.visitors.Visitor; -public class StaticMemberVariable extends IRNode implements VariableBase { - private final VariableInfo varInfo; +public class StaticMemberVariable extends VariableBase { public StaticMemberVariable(TypeKlass owner, VariableInfo varInfo) { - setKlass(owner); - this.varInfo = varInfo; - } - - @Override - public VariableInfo get() { - return varInfo; + super(varInfo); + setOwner(owner); } @Override --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Switch.java 2016-05-12 04:24:05.530334764 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Switch.java 2016-05-12 04:24:05.450334765 +0300 @@ -30,6 +30,7 @@ private final int caseBlockIdx; public Switch(int level, List chldrn, int caseBlockIdx) { + super(chldrn.get(caseBlockIdx).getResultType()); this.level = level; addChildren(chldrn); this.caseBlockIdx = caseBlockIdx; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Symbol.java 2016-05-12 04:24:05.826334762 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Symbol.java 2016-05-12 04:24:05.754334762 +0300 @@ -29,7 +29,7 @@ public String name; public Type type; - public TypeKlass klass; + public TypeKlass owner; public static final int NONE = 0x00; public static final int PRIVATE = 0x01; public static final int DEFAULT = 0x02; @@ -47,16 +47,16 @@ this.name = name; } - public Symbol(String name, TypeKlass klass, Type type, int flags) { + public Symbol(String name, TypeKlass owner, Type type, int flags) { this.name = name; - this.klass = klass; + this.owner = owner; this.type = type; this.flags = flags; } protected Symbol(Symbol value) { this.name = value.name; - this.klass = value.klass; + this.owner = value.owner; this.type = value.type; this.flags = value.flags; } @@ -71,7 +71,7 @@ } try { Symbol s = (Symbol) o; - return klass.equals(s.klass) && name.equals(s.name); + return owner.equals(s.owner) && name.equals(s.name); } catch (Exception e) { return false; } @@ -110,4 +110,9 @@ public Symbol deepCopy() { return new Symbol(this); } + + + public TypeKlass getOwner() { + return owner; + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java 2016-05-12 04:24:06.142334759 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java 2016-05-12 04:24:06.058334760 +0300 @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Stack; +import java.util.stream.Collectors; import jdk.test.lib.jittester.types.TypeKlass; @@ -42,9 +43,8 @@ String classList = ProductionParams.addExternalSymbols.value(); if (classList.equals("all")) { - for (Type type : TypeList.getReferenceTypes()) { - type.exportSymbols(); - } + TypeList.getReferenceTypes() + .forEach(Type::exportSymbols); } else { String[] splittedList = classList.split(","); for (Type type : TypeList.getReferenceTypes()) { @@ -96,13 +96,9 @@ public static Collection get(Type type, Class classToCheck) { HashMap> vars = SYMBOL_STACK.peek(); if (vars.containsKey(type)) { - ArrayList result = new ArrayList<>(); - for (Symbol symbol : vars.get(type)) { - if (classToCheck.isInstance(symbol)) { - result.add(symbol); - } - } - return result; + return vars.get(type).stream() + .filter(classToCheck::isInstance) + .collect(Collectors.toList()); } return new ArrayList<>(); } @@ -113,7 +109,7 @@ if (vars.containsKey(type)) { ArrayList result = new ArrayList<>(); for (Symbol symbol : vars.get(type)) { - if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.klass)) { + if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.owner)) { result.add(symbol); } } @@ -150,7 +146,7 @@ for (Type type : SYMBOL_STACK.peek().keySet()) { ArrayList symbolsOfType = SYMBOL_STACK.peek().get(type); for (Symbol symbol : symbolsOfType) { - if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.klass)) { + if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.owner)) { if (!result.containsKey(type)) { result.put(type, new ArrayList<>()); } @@ -193,7 +189,7 @@ for (Type type : SYMBOL_STACK.peek().keySet()) { ArrayList symbolsOfType = SYMBOL_STACK.peek().get(type); for (Symbol symbol : symbolsOfType) { - if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.klass)) { + if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.owner)) { result.add(symbol); } } @@ -207,7 +203,7 @@ for (Type t : SYMBOL_STACK.peek().keySet()) { ArrayList symbolsOfType = SYMBOL_STACK.peek().get(t); for (Symbol symbol : symbolsOfType) { - if (typeKlass.equals(symbol.klass)) { + if (typeKlass.equals(symbol.owner)) { result.add(symbol); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/TernaryOperator.java 2016-05-12 04:24:06.434334757 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/TernaryOperator.java 2016-05-12 04:24:06.354334757 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -30,12 +30,11 @@ CONDITION, TRUE, FALSE, - }; + } //protected Production conditionalExpression, leftExpression, rightExpression; - protected Type resultType; public TernaryOperator(IRNode condition, IRNode trueBranch, IRNode falseBranch) { - super(2); + super(null, 2, trueBranch.getResultType()); resizeUpChildren(TernaryPart.values().length); setChild(TernaryPart.CONDITION.ordinal(), condition); setChild(TernaryPart.TRUE.ordinal(), trueBranch); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Throw.java 2016-05-12 04:24:06.706334755 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Throw.java 2016-05-12 04:24:06.638334755 +0300 @@ -27,6 +27,7 @@ public class Throw extends IRNode { public Throw(IRNode throwable) { + super(throwable.getResultType()); addChild(throwable); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/TryCatchBlock.java 2016-05-12 04:24:07.022334752 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/TryCatchBlock.java 2016-05-12 04:24:06.958334752 +0300 @@ -29,6 +29,7 @@ public class TryCatchBlock extends IRNode { public TryCatchBlock(IRNode body, IRNode finallyBlock, List catchBlocks, int level) { + super(body.getResultType()); this.level = level; addChild(body); addChild(finallyBlock); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/Type.java 2016-05-12 04:24:07.298334750 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/Type.java 2016-05-12 04:24:07.238334750 +0300 @@ -33,10 +33,16 @@ private final String typeName; protected Type(String typeName) { + super(null); this.typeName = typeName; } @Override + public Type getResultType() { + return this; + } + + @Override public boolean equals(Object t) { if (this == t) { return true; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java 2016-05-12 04:24:07.766334746 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeList.java 2016-05-12 04:24:07.670334747 +0300 @@ -27,19 +27,31 @@ import java.util.Collection; import java.util.List; import java.util.function.Predicate; -import jdk.test.lib.jittester.types.TypeArray; + import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.types.TypeChar; import jdk.test.lib.jittester.types.TypeDouble; import jdk.test.lib.jittester.types.TypeFloat; import jdk.test.lib.jittester.types.TypeInt; +import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.types.TypeShort; import jdk.test.lib.jittester.types.TypeVoid; public class TypeList { - private static final TypeVoid TYPE_VOID = new TypeVoid(); + public static final TypeVoid VOID = new TypeVoid(); + public static final TypeBoolean BOOLEAN = new TypeBoolean(); + public static final TypeByte BYTE = new TypeByte(); + public static final TypeChar CHAR = new TypeChar(); + public static final TypeShort SHORT = new TypeShort(); + public static final TypeInt INT = new TypeInt(); + public static final TypeLong LONG = new TypeLong(); + public static final TypeFloat FLOAT = new TypeFloat(); + public static final TypeDouble DOUBLE = new TypeDouble(); + public static final TypeKlass OBJECT = new TypeKlass("java.lang.Object"); + public static final TypeKlass STRING = new TypeKlass("java.lang.String", TypeKlass.FINAL); + private static final List TYPES = new ArrayList<>(); private static final List BUILTIN_TYPES = new ArrayList<>(); private static final List BUILTIN_INT_TYPES = new ArrayList<>(); @@ -47,14 +59,14 @@ private static final List REFERENCE_TYPES = new ArrayList<>(); static { - BUILTIN_INT_TYPES.add(new TypeBoolean()); - BUILTIN_INT_TYPES.add(new TypeByte()); - BUILTIN_INT_TYPES.add(new TypeChar()); - BUILTIN_INT_TYPES.add(new TypeShort()); - BUILTIN_INT_TYPES.add(new TypeInt()); - BUILTIN_INT_TYPES.add(new TypeLong()); - BUILTIN_FP_TYPES.add(new TypeFloat()); - BUILTIN_FP_TYPES.add(new TypeDouble()); + BUILTIN_INT_TYPES.add(BOOLEAN); + BUILTIN_INT_TYPES.add(BYTE); + BUILTIN_INT_TYPES.add(CHAR); + BUILTIN_INT_TYPES.add(SHORT); + BUILTIN_INT_TYPES.add(INT); + BUILTIN_INT_TYPES.add(LONG); + BUILTIN_FP_TYPES.add(FLOAT); + BUILTIN_FP_TYPES.add(DOUBLE); BUILTIN_TYPES.addAll(BUILTIN_INT_TYPES); BUILTIN_TYPES.addAll(BUILTIN_FP_TYPES); @@ -62,13 +74,13 @@ TYPES.addAll(BUILTIN_TYPES); if (!ProductionParams.disableArrays.value()) { - REFERENCE_TYPES.add(new TypeArray().produce()); TYPES.addAll(REFERENCE_TYPES); } - } - public static TypeVoid getVoid() { - return TYPE_VOID; + STRING.addParent(OBJECT.getName()); + STRING.setParent(OBJECT); + add(STRING); + add(OBJECT); } public static Collection getAll() { @@ -100,14 +112,14 @@ } public static boolean isBuiltIn(Type t) { - return isBuiltInInt(t) || isBuiltInFP(t); + return isBuiltInInt(t) || isBuiltInFP(t) || t.equals(VOID); } protected static boolean isIn(Type t) { return TYPES.contains(t); } - protected static boolean isReferenceType(Type t) { + public static boolean isReferenceType(Type t) { return REFERENCE_TYPES.contains(t); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypesParser.java 2016-05-12 04:24:08.122334743 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypesParser.java 2016-05-12 04:24:08.022334744 +0300 @@ -42,7 +42,6 @@ import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; /** * Class used for parsing included classes file and excluded methods file @@ -62,7 +61,7 @@ public static void parseTypesAndMethods(String klassesFileName, String exMethodsFileName) { Asserts.assertNotNull(klassesFileName, "Classes input file name is null"); Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty"); - Set> klasses = parseKlasses(klassesFileName); + List> klasses = parseKlasses(klassesFileName); Set methodsToExclude; if (exMethodsFileName != null && !exMethodsFileName.isEmpty()) { methodsToExclude = parseMethods(exMethodsFileName); @@ -119,15 +118,18 @@ } if (klass.isPrimitive()) { if (klass.equals(void.class)) { - type = new TypeVoid(); + type = TypeList.VOID; } else { type = TypeList.find(klass.getName()); } } else { int flags = getKlassFlags(klass); if (klass.isArray()) { - TypeKlass elementType - = new TypeKlass(klass.getCanonicalName().replaceAll("\\[\\]", ""), flags); + Class elementKlass = klass.getComponentType(); + while (elementKlass.isArray()) { + elementKlass = elementKlass.getComponentType(); + } + Type elementType = getType(elementKlass); int dim = getArrayClassDimension(klass); type = new TypeArray(elementType, dim); } else { @@ -138,10 +140,14 @@ type = new TypeKlass(canonicalName, flags); } Class parentKlass = klass.getSuperclass(); + TypeKlass typeKlass = (TypeKlass) type; if (parentKlass != null) { TypeKlass parentTypeKlass = (TypeKlass) getType(parentKlass); - ((TypeKlass) type).addParent(parentTypeKlass.getName()); - ((TypeKlass) type).setParent(parentTypeKlass); + typeKlass.addParent(parentTypeKlass.getName()); + typeKlass.setParent(parentTypeKlass); + } + for (Class iface : klass.getInterfaces()) { + typeKlass.addParent(getType(iface).getName()); } } TYPE_CACHE.put(klass, type); @@ -197,10 +203,10 @@ return flags; } - private static Set> parseKlasses(String klassesFileName) { + private static List> parseKlasses(String klassesFileName) { Asserts.assertNotNull(klassesFileName, "Classes input file name is null"); Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty"); - Set klassNamesSet = new HashSet<>(); + List klassNamesList = new ArrayList<>(); Path klassesFilePath = (new File(klassesFileName)).toPath(); try { Files.lines(klassesFilePath).forEach(line -> { @@ -211,20 +217,20 @@ String msg = String.format("Format of the classes input file \"%s\" is incorrect," + " line \"%s\" has wrong format", klassesFileName, line); Asserts.assertTrue(line.matches("\\w[\\w\\.$]*"), msg); - klassNamesSet.add(line.replaceAll(";", "")); + klassNamesList.add(line.replaceAll(";", "")); }); } catch (IOException ex) { throw new Error("Error reading klasses file", ex); } - Set> klassesSet = new HashSet<>(); - klassNamesSet.stream().forEach(klassName -> { + List> klassesList = new ArrayList<>(); + klassNamesList.stream().forEach(klassName -> { try { - klassesSet.add(Class.forName(klassName)); + klassesList.add(Class.forName(klassName)); } catch (ClassNotFoundException ex) { throw new Error("Unexpected exception while parsing klasses file", ex); } }); - return klassesSet; + return klassesList; } private static Set parseMethods(String methodsFileName) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/UnaryOperator.java 2016-05-12 04:24:08.502334740 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/UnaryOperator.java 2016-05-12 04:24:08.410334741 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -26,12 +26,8 @@ import jdk.test.lib.jittester.visitors.Visitor; public class UnaryOperator extends Operator { - protected OperatorKind opKind; - protected Type resultType; - public UnaryOperator(OperatorKind opKind, IRNode expression) { - super(opKind.priority); - this.opKind = opKind; + super(opKind, expression.getResultType()); addChild(expression); } @@ -49,8 +45,4 @@ public boolean isPrefix() { return opKind.isPrefix; } - - public String getOperatorText() { - return opKind.text; - } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableBase.java 2016-05-12 04:24:08.830334737 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableBase.java 2016-05-12 04:24:08.762334738 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -23,7 +23,14 @@ package jdk.test.lib.jittester; -public interface VariableBase { +public abstract class VariableBase extends IRNode { + private final VariableInfo variableInfo; + protected VariableBase(VariableInfo variableInfo) { + super(variableInfo.type); + this.variableInfo = variableInfo; + } - VariableInfo get(); + public VariableInfo getVariableInfo() { + return variableInfo; + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableDeclaration.java 2016-05-12 04:24:09.194334735 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableDeclaration.java 2016-05-12 04:24:09.118334735 +0300 @@ -26,9 +26,10 @@ import jdk.test.lib.jittester.visitors.Visitor; public class VariableDeclaration extends IRNode { - protected final VariableInfo variableInfo; + private final VariableInfo variableInfo; public VariableDeclaration(VariableInfo value) { + super(value.type); variableInfo = value; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableDeclarationBlock.java 2016-05-12 04:24:09.678334731 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableDeclarationBlock.java 2016-05-12 04:24:09.598334731 +0300 @@ -24,10 +24,12 @@ package jdk.test.lib.jittester; import java.util.ArrayList; + import jdk.test.lib.jittester.visitors.Visitor; public class VariableDeclarationBlock extends IRNode { - public VariableDeclarationBlock(ArrayList content, int level) { + public VariableDeclarationBlock(ArrayList content, int level) { + super(TypeList.VOID); addChildren(content); this.level = level; } @@ -40,10 +42,6 @@ .sum(); } - protected int size() { - return getChildren() != null ? getChildren().size() : 0; - } - @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableInfo.java 2016-05-12 04:24:09.998334728 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/VariableInfo.java 2016-05-12 04:24:09.918334729 +0300 @@ -55,4 +55,8 @@ public Symbol deepCopy() { return new VariableInfo(this); } + + public boolean isLocal() { + return (flags & LOCAL) != 0; + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayCreation.java 2016-05-12 04:24:10.366334725 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayCreation.java 2016-05-12 04:24:10.278334726 +0300 @@ -28,7 +28,6 @@ import java.util.stream.Collectors; import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.Literal; -import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.VariableDeclaration; import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.visitors.Visitor; @@ -39,6 +38,7 @@ private final List dims; public ArrayCreation(VariableDeclaration var, TypeArray array, ArrayList dimensionSizeExpressions) { + super(array); this.variable = var; this.array = array; addChildren(dimensionSizeExpressions); @@ -55,8 +55,8 @@ type.setDimentions(dims); } - public Type getArrayType() { - return array.type; + public TypeArray getArrayType() { + return array; } @Override --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayElement.java 2016-05-12 04:24:10.722334722 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayElement.java 2016-05-12 04:24:10.642334723 +0300 @@ -25,10 +25,12 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.visitors.Visitor; public class ArrayElement extends IRNode { public ArrayElement(IRNode array, ArrayList dimensionExpressions) { + super(((TypeArray) array.getResultType()).type); addChild(array); addChildren(dimensionExpressions); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayExtraction.java 2016-05-12 04:24:11.022334720 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/arrays/ArrayExtraction.java 2016-05-12 04:24:10.938334721 +0300 @@ -40,6 +40,7 @@ public class ArrayExtraction extends IRNode { private final List dims; public ArrayExtraction(IRNode array, ArrayList dimensionExpressions) { + super(array.getResultType()); addChild(array); addChildren(dimensionExpressions); if (array instanceof ArrayCreation) { @@ -56,7 +57,7 @@ } } else if (array instanceof LocalVariable) { LocalVariable loc = (LocalVariable) array; - TypeArray type = (TypeArray) loc.get().type; + TypeArray type = (TypeArray) loc.getVariableInfo().type; dims = type.getDims(); for (int i = dimensionExpressions.size(); i < type.dimensions; ++i) { dims.add(type.getDims().get(i)); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/ClassDefinitionBlock.java 2016-05-12 04:24:11.362334717 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/ClassDefinitionBlock.java 2016-05-12 04:24:11.286334718 +0300 @@ -25,10 +25,12 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.visitors.Visitor; public class ClassDefinitionBlock extends IRNode { public ClassDefinitionBlock(ArrayList content, int level) { + super(TypeList.VOID); this.level = level; addChildren(content); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/Interface.java 2016-05-12 04:24:11.782334714 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/Interface.java 2016-05-12 04:24:11.690334715 +0300 @@ -24,6 +24,7 @@ package jdk.test.lib.jittester.classes; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.visitors.Visitor; @@ -32,6 +33,7 @@ private TypeKlass parent = null; public Interface(TypeKlass parent, String name, int level, IRNode functionDeclaraionBlock) { + super(TypeList.find(functionDeclaraionBlock.getOwner().getName())); this.parent = parent; this.name = name; this.level = level; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/Klass.java 2016-05-12 04:24:12.634334707 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/Klass.java 2016-05-12 04:24:12.550334708 +0300 @@ -70,19 +70,21 @@ IRNode functionDefinitions, IRNode abstractFunctionRedefinitions, IRNode overridenFunctionRedefitions, IRNode functionDeclarations, IRNode printVariablesBlock) { + super(thisKlass); this.thisKlass = thisKlass; - klass = thisKlass; + owner = thisKlass; this.parentKlass = parent; this.interfaces = interfaces; this.name = name; this.level = level; - addChild(variableDeclarations); - addChild(constructorDefinitions); - addChild(abstractFunctionRedefinitions); - addChild(overridenFunctionRedefitions); - addChild(functionDefinitions); - addChild(functionDeclarations); - addChild(printVariablesBlock); + resizeUpChildren(KlassPart.values().length); + setChild(KlassPart.DATA_MEMBERS.ordinal(), variableDeclarations); + setChild(KlassPart.CONSTRUCTORS.ordinal(), constructorDefinitions); + setChild(KlassPart.REDEFINED_FUNCTIONS.ordinal(), abstractFunctionRedefinitions); + setChild(KlassPart.OVERRIDEN_FUNCTIONS.ordinal(), overridenFunctionRedefitions); + setChild(KlassPart.MEMBER_FUNCTIONS.ordinal(), functionDefinitions); + setChild(KlassPart.MEMBER_FUNCTIONS_DECLARATIONS.ordinal(), functionDeclarations); + setChild(KlassPart.PRINT_VARIABLES.ordinal(), printVariablesBlock); } @Override --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/MainKlass.java 2016-05-12 04:24:12.970334704 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/classes/MainKlass.java 2016-05-12 04:24:12.894334705 +0300 @@ -40,6 +40,7 @@ public MainKlass(String name, TypeKlass thisKlass, IRNode variableDeclarations, IRNode functionDefinitions, IRNode testFunction, IRNode printVariables) { + super(thisKlass); addChild(variableDeclarations); addChild(functionDefinitions); addChild(testFunction); @@ -64,4 +65,8 @@ public String getName() { return name; } + + public TypeKlass getThisKlass() { + return thisKlass; + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArgumentDeclarationFactory.java 2016-05-12 04:24:13.278334702 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArgumentDeclarationFactory.java 2016-05-12 04:24:13.210334702 +0300 @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class ArgumentDeclarationFactory extends Factory { +class ArgumentDeclarationFactory extends Factory { private final int argumentNumber; private final TypeKlass ownerClass; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArithmeticOperatorFactory.java 2016-05-12 04:24:13.614334699 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArithmeticOperatorFactory.java 2016-05-12 04:24:13.526334700 +0300 @@ -23,15 +23,15 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Operator; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.types.TypeKlass; -class ArithmeticOperatorFactory extends Factory { - private final Rule rule; +class ArithmeticOperatorFactory extends Factory { + private final Rule rule; ArithmeticOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException { @@ -42,7 +42,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(noconsts); - rule = new Rule("arithmetic"); + rule = new Rule<>("arithmetic"); rule.add("add", builder.setOperatorKind(OperatorKind.ADD).getBinaryOperatorFactory()); rule.add("sub", builder.setOperatorKind(OperatorKind.SUB).getBinaryOperatorFactory()); rule.add("mul", builder.setOperatorKind(OperatorKind.MUL).getBinaryOperatorFactory()); @@ -55,7 +55,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Operator produce() throws ProductionFailedException { return rule.produce(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayCreationFactory.java 2016-05-12 04:24:13.998334696 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayCreationFactory.java 2016-05-12 04:24:13.918334697 +0300 @@ -29,15 +29,14 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableDeclaration; import jdk.test.lib.jittester.arrays.ArrayCreation; import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeByte; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class ArrayCreationFactory extends SafeFactory { +class ArrayCreationFactory extends SafeFactory { private final long complexityLimit; private final int operatorLimit; private final Type resultType; @@ -56,16 +55,16 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected ArrayCreation sproduce() throws ProductionFailedException { if (resultType instanceof TypeArray) { TypeArray arrayResultType = (TypeArray) resultType; - if (arrayResultType.type.equals(new TypeVoid())) { + if (arrayResultType.type.equals(TypeList.VOID)) { arrayResultType = arrayResultType.produce(); } IRNodeBuilder builder = new IRNodeBuilder() .setComplexityLimit(complexityLimit) .setOwnerKlass(ownerClass) - .setResultType(new TypeByte()) + .setResultType(TypeList.BYTE) .setExceptionSafe(exceptionSafe) .setNoConsts(noconsts); double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100; @@ -77,14 +76,14 @@ .getExpressionFactory() .produce()); } else { - Literal dimension = (Literal)builder.getLiteralFactory().produce(); + Literal dimension = builder.getLiteralFactory().produce(); while (Integer.valueOf(dimension.getValue().toString()) < 1) { - dimension = (Literal)builder.getLiteralFactory().produce(); + dimension = builder.getLiteralFactory().produce(); } dims.add(dimension); } } - VariableDeclaration var = (VariableDeclaration) builder + VariableDeclaration var = builder .setOwnerKlass(ownerClass) .setResultType(arrayResultType) .setIsLocal(true) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayElementFactory.java 2016-05-12 04:24:14.418334693 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayElementFactory.java 2016-05-12 04:24:14.326334693 +0300 @@ -29,15 +29,15 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.arrays.ArrayCreation; import jdk.test.lib.jittester.arrays.ArrayElement; import jdk.test.lib.jittester.arrays.ArrayExtraction; import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.utils.PseudoRandom; -class ArrayElementFactory extends SafeFactory { +class ArrayElementFactory extends SafeFactory { private final long complexityLimit; private final int operatorLimit; private final Type resultType; @@ -56,7 +56,7 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected ArrayElement sproduce() throws ProductionFailedException { if (resultType instanceof TypeArray) { throw new ProductionFailedException(); } @@ -76,10 +76,10 @@ .setResultType(new TypeArray(resultType, dimensionsCount)) .getExpressionFactory() .produce(); - ExpressionFactory expressionFactory = builder + Factory expressionFactory = builder .setComplexityLimit(complexityPerDimension) .setOperatorLimit(operatorLimitPerDimension) - .setResultType(new TypeByte()) + .setResultType(TypeList.BYTE) .getExpressionFactory(); double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.; ArrayList perDimensionExpressions = new ArrayList<>(dimensionsCount); @@ -96,7 +96,7 @@ if (i < arrayExtraction.getDimsNumber()) dimLimit = arrayExtraction.getDim(i); } - perDimensionExpressions.add(new Literal(PseudoRandom.randomNotNegative(dimLimit), new TypeByte())); + perDimensionExpressions.add(new Literal((byte)PseudoRandom.randomNotNegative(dimLimit), TypeList.BYTE)); } } return new ArrayElement(arrayReturningExpression, perDimensionExpressions); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayExtractionFactory.java 2016-05-12 04:24:14.798334690 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ArrayExtractionFactory.java 2016-05-12 04:24:14.722334690 +0300 @@ -29,14 +29,14 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.arrays.ArrayCreation; import jdk.test.lib.jittester.arrays.ArrayExtraction; import jdk.test.lib.jittester.types.TypeArray; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.utils.PseudoRandom; -class ArrayExtractionFactory extends SafeFactory { +class ArrayExtractionFactory extends SafeFactory { private final long complexityLimit; private final int operatorLimit; private final Type resultType; @@ -55,7 +55,7 @@ } @Override - public IRNode sproduce() throws ProductionFailedException { + public ArrayExtraction sproduce() throws ProductionFailedException { if (resultType instanceof TypeArray) { TypeArray arrayType = (TypeArray) resultType; int delta = PseudoRandom.randomNotZero(ProductionParams.dimensionsLimit.value() @@ -79,7 +79,7 @@ double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.; for (int i = 0; i < delta; i++) { if (PseudoRandom.randomBoolean(chanceExpression)) { - perDimensionExpression.add(builder.setResultType(new TypeByte()) + perDimensionExpression.add(builder.setResultType(TypeList.BYTE) .setComplexityLimit(dimComplLimit) .setOperatorLimit(dimOpLimit) .getExpressionFactory() @@ -94,7 +94,7 @@ if (i < arrayExtraction.getDimsNumber()) dimLimit = arrayExtraction.getDim(i); } - perDimensionExpression.add(new Literal(PseudoRandom.randomNotNegative(dimLimit), new TypeByte())); + perDimensionExpression.add(new Literal((byte)PseudoRandom.randomNotNegative(dimLimit), TypeList.BYTE)); } } return new ArrayExtraction(arrayReturningExpression, perDimensionExpression); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorFactory.java 2016-05-12 04:24:15.098334687 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorFactory.java 2016-05-12 04:24:15.014334688 +0300 @@ -24,7 +24,8 @@ package jdk.test.lib.jittester.factories; import java.util.ArrayList; -import jdk.test.lib.jittester.IRNode; + +import jdk.test.lib.jittester.Operator; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; @@ -34,7 +35,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class AssignmentOperatorFactory extends Factory { +class AssignmentOperatorFactory extends Factory { private final int operatorLimit; private final long complexityLimit; private final Type resultType; @@ -42,8 +43,8 @@ private final boolean noconsts; private final TypeKlass ownerClass; - private Rule fillRule(Type resultType) throws ProductionFailedException { - Rule rule = new Rule("assignment"); + private Rule fillRule(Type resultType) throws ProductionFailedException { + Rule rule = new Rule<>("assignment"); IRNodeBuilder builder = new IRNodeBuilder() .setComplexityLimit(complexityLimit) .setOperatorLimit(operatorLimit) @@ -84,14 +85,14 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Operator produce() throws ProductionFailedException { if (resultType == null) { // if no result type is given - choose any. ArrayList allTypes = new ArrayList<>(TypeList.getAll()); PseudoRandom.shuffle(allTypes); for (Type type : allTypes) { SymbolTable.push(); try { - IRNode result = fillRule(type).produce(); + Operator result = fillRule(type).produce(); SymbolTable.merge(); return result; } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java 2016-05-12 04:24:15.466334684 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java 2016-05-12 04:24:15.374334685 +0300 @@ -31,8 +31,8 @@ import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableBase; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -49,7 +49,7 @@ } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, PseudoRandom.randomElement( TypeUtil.getImplicitlyCastable(TypeList.getAll(), resultType))); } @@ -68,23 +68,22 @@ .setOperatorLimit(leftOperatorLimit) .setResultType(leftOperandType) .setIsConstant(false); - Rule rule = new Rule("assignment"); + Rule rule = new Rule<>("assignment"); rule.add("initialized_nonconst_var", builder.setIsInitialized(true).getVariableFactory()); rule.add("uninitialized_nonconst_var", builder.setIsInitialized(false).getVariableFactory()); - IRNode leftOperandValue = rule.produce(); + VariableBase leftOperandValue = rule.produce(); IRNode rightOperandValue = builder.setComplexityLimit(rightComplexityLimit) .setOperatorLimit(rightOperatorLimit) .setResultType(rightOperandType) .getExpressionFactory() .produce(); try { - VariableBase v = (VariableBase) leftOperandValue; - if ((v.get().flags & VariableInfo.INITIALIZED) == 0) { - v.get().flags |= VariableInfo.INITIALIZED; + if ((leftOperandValue.getVariableInfo().flags & VariableInfo.INITIALIZED) == 0) { + leftOperandValue.getVariableInfo().flags |= VariableInfo.INITIALIZED; } } catch (Exception e) { throw new ProductionFailedException(e.getMessage()); } - return new BinaryOperator(opKind, leftOperandValue, rightOperandValue); + return new BinaryOperator(opKind, resultType, leftOperandValue, rightOperandValue); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java 2016-05-12 04:24:15.990334680 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java 2016-05-12 04:24:15.906334681 +0300 @@ -30,7 +30,6 @@ import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.utils.TypeUtil; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -47,18 +46,18 @@ // arithmetic for built-in types less capacious than "int" is not supported. if (TypeList.isBuiltIn(resultType)) { BuiltInType builtInType = (BuiltInType) resultType; - return builtInType.equals(new TypeInt()) || builtInType.isMoreCapaciousThan(new TypeInt()); + return builtInType.equals(TypeList.INT) || builtInType.isMoreCapaciousThan(TypeList.INT); } else { return false; } } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { Collection castableFromResultType = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType); // built-in types less capacious than int are automatically casted to int in arithmetic. final Type leftType = PseudoRandom.randomElement(castableFromResultType); - final Type rightType = resultType.equals(new TypeInt()) ? + final Type rightType = resultType.equals(TypeList.INT) ? PseudoRandom.randomElement(castableFromResultType) : resultType; //TODO: is there sense to swap them randomly as it was done in original code? return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java 2016-05-12 04:24:16.446334676 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java 2016-05-12 04:24:16.366334677 +0300 @@ -29,10 +29,7 @@ import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.utils.TypeUtil; -import jdk.test.lib.jittester.types.TypeBoolean; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.utils.PseudoRandom; import java.util.Collection; @@ -45,15 +42,15 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeInt()) || resultType.equals(new TypeLong()) || resultType.equals(new TypeBoolean()); + return resultType.equals(TypeList.INT) || resultType.equals(TypeList.LONG) || resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { Collection castableFromResult = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType); // built-in types less capacious than int are automatically casted to int in arithmetic. final Type leftType = PseudoRandom.randomElement(castableFromResult); - final Type rightType = resultType.equals(new TypeInt()) ? PseudoRandom.randomElement(castableFromResult) : resultType; + final Type rightType = resultType.equals(TypeList.INT) ? PseudoRandom.randomElement(castableFromResult) : resultType; //TODO: is there sense to swap them randomly as it was done in original code? return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryComparisonOperatorFactory.java 2016-05-12 04:24:16.926334673 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryComparisonOperatorFactory.java 2016-05-12 04:24:16.830334673 +0300 @@ -28,7 +28,6 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -43,13 +42,13 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeBoolean()); + return resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { final List builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn()); - builtInExceptBoolean.remove(new TypeBoolean()); + builtInExceptBoolean.remove(TypeList.BOOLEAN); return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean), PseudoRandom.randomElement(builtInExceptBoolean)); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryEqualityOperatorFactory.java 2016-05-12 04:24:17.282334670 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryEqualityOperatorFactory.java 2016-05-12 04:24:17.202334670 +0300 @@ -28,7 +28,6 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -43,13 +42,13 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeBoolean()); + return resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { final List builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn()); - builtInExceptBoolean.remove(new TypeBoolean()); + builtInExceptBoolean.remove(TypeList.BOOLEAN); return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean), PseudoRandom.randomElement(builtInExceptBoolean)); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryLogicOperatorFactory.java 2016-05-12 04:24:17.698334666 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryLogicOperatorFactory.java 2016-05-12 04:24:17.610334667 +0300 @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; -import jdk.test.lib.jittester.types.TypeBoolean; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -42,11 +42,11 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeBoolean()); + return resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, resultType); } @@ -81,6 +81,6 @@ } finally { SymbolTable.pop(); } - return new BinaryOperator(opKind, leftOperand, rightOperand); + return new BinaryOperator(opKind, resultType, leftOperand, rightOperand); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryOperatorFactory.java 2016-05-12 04:24:18.102334663 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryOperatorFactory.java 2016-05-12 04:24:18.026334664 +0300 @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -abstract class BinaryOperatorFactory extends OperatorFactory { +abstract class BinaryOperatorFactory extends OperatorFactory { protected final OperatorKind opKind; protected final Type resultType; protected final Type ownerClass; @@ -48,7 +48,7 @@ protected abstract boolean isApplicable(Type resultType); - protected abstract Pair generateTypes() throws ProductionFailedException; + protected abstract Pair generateTypes(); protected BinaryOperator generateProduction(Type leftType, Type rightType) throws ProductionFailedException { int leftOpLimit = (int) (PseudoRandom.random() * (operatorLimit - 1)); @@ -72,11 +72,11 @@ .setResultType(rightType) .getExpressionFactory() .produce(); - return new BinaryOperator(opKind, leftExpr, rightExpr); + return new BinaryOperator(opKind, resultType, leftExpr, rightExpr); } @Override - public final IRNode produce() throws ProductionFailedException { + public final BinaryOperator produce() throws ProductionFailedException { if (!isApplicable(resultType)) { //avoid implicit use of resultType.toString() throw new ProductionFailedException("Type " + resultType.getName() + " is not applicable by " + getClass().getName()); @@ -91,7 +91,7 @@ try { SymbolTable.push(); - IRNode p = generateProduction(types.first, types.second); + BinaryOperator p = generateProduction(types.first, types.second); SymbolTable.merge(); return p; } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java 2016-05-12 04:24:18.374334661 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java 2016-05-12 04:24:18.286334662 +0300 @@ -28,9 +28,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.utils.PseudoRandom; import jdk.test.lib.jittester.utils.TypeUtil; @@ -42,13 +40,13 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeInt()) || resultType.equals(new TypeLong()); + return resultType.equals(TypeList.INT) || resultType.equals(TypeList.LONG); } @Override - protected Pair generateTypes() throws ProductionFailedException { - Type leftType = resultType.equals(new TypeInt()) ? PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), resultType)) : resultType; - Type rightType = PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), new TypeLong())); + protected Pair generateTypes() { + Type leftType = resultType.equals(TypeList.INT) ? PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), resultType)) : resultType; + Type rightType = PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), TypeList.LONG)); return new Pair<>(leftType, rightType); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryStringPlusFactory.java 2016-05-12 04:24:18.730334658 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryStringPlusFactory.java 2016-05-12 04:24:18.542334660 +0300 @@ -38,11 +38,11 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(TypeList.find("java.lang.String")); - } + return resultType.equals(TypeList.STRING); + } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, resultType); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java 2016-05-12 04:24:18.994334656 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java 2016-05-12 04:24:18.934334657 +0300 @@ -23,7 +23,6 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; @@ -31,8 +30,6 @@ import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeInt; -import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.utils.PseudoRandom; class BitwiseInversionOperatorFactory extends UnaryOperatorFactory { @@ -43,12 +40,12 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeInt()) || resultType.equals(new TypeLong()); + return resultType.equals(TypeList.INT) || resultType.equals(TypeList.LONG); } @Override - protected Type generateType() throws ProductionFailedException { - if (resultType.equals(new TypeInt())) { + protected Type generateType() { + if (resultType.equals(TypeList.INT)) { return PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType)); } else { return resultType; @@ -56,7 +53,7 @@ } @Override - protected IRNode generateProduction(Type resultType) throws ProductionFailedException { + protected UnaryOperator generateProduction(Type resultType) throws ProductionFailedException { return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1) .setOperatorLimit(operatorLimit - 1) .setOwnerKlass((TypeKlass) ownerClass) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseOperatorFactory.java 2016-05-12 04:24:19.254334654 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseOperatorFactory.java 2016-05-12 04:24:19.194334654 +0300 @@ -23,15 +23,15 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Operator; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.types.TypeKlass; -class BitwiseOperatorFactory extends Factory { - private final Rule rule; +class BitwiseOperatorFactory extends Factory { + private final Rule rule; BitwiseOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException { @@ -42,7 +42,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(noconsts); - rule = new Rule("bitwise"); + rule = new Rule<>("bitwise"); rule.add("and", builder.setOperatorKind(OperatorKind.BIT_AND).getBinaryOperatorFactory()); rule.add("or", builder.setOperatorKind(OperatorKind.BIT_OR).getBinaryOperatorFactory()); rule.add("xor", builder.setOperatorKind(OperatorKind.BIT_XOR).getBinaryOperatorFactory()); @@ -53,7 +53,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Operator produce() throws ProductionFailedException { return rule.produce(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java 2016-05-12 04:24:19.506334652 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java 2016-05-12 04:24:19.426334653 +0300 @@ -38,13 +38,12 @@ import jdk.test.lib.jittester.loops.For; import jdk.test.lib.jittester.loops.While; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; import java.util.ArrayList; import java.util.List; -class BlockFactory extends Factory { +class BlockFactory extends Factory { private final Type returnType; private final long complexityLimit; private final int statementLimit; @@ -74,7 +73,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Block produce() throws ProductionFailedException { if (statementLimit > 0 && complexityLimit > 0) { List content = new ArrayList<>(); int slimit = PseudoRandom.randomNotZero(statementLimit); @@ -89,12 +88,12 @@ .setCanHaveContinues(canHaveContinues) .setExceptionSafe(false) .setNoConsts(false); - Rule rule; + Rule rule; SymbolTable.push(); for (int i = 0; i < slimit && climit > 0; ) { int subLimit = (int) (PseudoRandom.random() * (slimit - i - 1)); builder.setComplexityLimit((long) (PseudoRandom.random() * climit)); - rule = new Rule("block"); + rule = new Rule<>("block"); rule.add("statement", builder.getStatementFactory(), 5); if (!ProductionParams.disableVarsInBlock.value()) { rule.add("decl", builder.setIsLocal(true).getDeclarationFactory()); @@ -131,14 +130,14 @@ } } // Ok, if the block can end with break and continue. Generate the appropriate productions. - rule = new Rule("block_ending"); + rule = new Rule<>("block_ending"); if (canHaveBreaks && !subBlock) { rule.add("break", builder.getBreakFactory()); } if (canHaveContinues && !subBlock) { rule.add("continue", builder.getContinueFactory()); } - if (canHaveReturn && !subBlock && !returnType.equals(new TypeVoid())) { + if (canHaveReturn && !subBlock && !returnType.equals(TypeList.VOID)) { rule.add("return", builder.setComplexityLimit(climit).getReturnFactory()); } if (canHaveThrow && !subBlock) { @@ -166,7 +165,7 @@ throw new ProductionFailedException(); } - private void addControlFlowDeviation(Rule rule, IRNodeBuilder builder) { + private void addControlFlowDeviation(Rule rule, IRNodeBuilder builder) { if (!ProductionParams.disableIf.value()) { rule.add("if", builder.getIfFactory()); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BreakFactory.java 2016-05-12 04:24:19.802334650 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BreakFactory.java 2016-05-12 04:24:19.710334650 +0300 @@ -24,12 +24,11 @@ package jdk.test.lib.jittester.factories; import jdk.test.lib.jittester.Break; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; -class BreakFactory extends Factory { +class BreakFactory extends Factory { @Override - public IRNode produce() throws ProductionFailedException { + public Break produce() throws ProductionFailedException { return new Break(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java 2016-05-12 04:24:20.234334646 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CastOperatorFactory.java 2016-05-12 04:24:20.170334647 +0300 @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class CastOperatorFactory extends OperatorFactory { +class CastOperatorFactory extends OperatorFactory { private final Type resultType; private final Type ownerClass; @@ -45,12 +45,12 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public CastOperator produce() throws ProductionFailedException { ArrayList argType = new ArrayList<>(TypeList.getAll()); PseudoRandom.shuffle(argType); for (Type type : argType) { try { - ExpressionFactory expressionFactory = new IRNodeBuilder() + Factory expressionFactory = new IRNodeBuilder() .setComplexityLimit(complexityLimit - 1) .setOperatorLimit(operatorLimit - 1) .setOwnerKlass((TypeKlass) ownerClass) @@ -59,14 +59,11 @@ .setResultType(type) .getExpressionFactory(); SymbolTable.push(); - if (type.equals(resultType)) { - IRNode expr = expressionFactory.produce(); - SymbolTable.merge(); - return expr; - } else if ((!exceptionSafe || exceptionSafe && !(type instanceof TypeKlass)) - && type.canExplicitlyCastTo(resultType)) { + if (type.equals(resultType) || + ((!exceptionSafe || exceptionSafe && !(type instanceof TypeKlass)) + && type.canExplicitlyCastTo(resultType))) { // In safe mode we cannot explicitly cast an object, because it may throw. - IRNode castOperator = new CastOperator(resultType, expressionFactory.produce()); + CastOperator castOperator = new CastOperator(resultType, expressionFactory.produce()); SymbolTable.merge(); return castOperator; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-05-12 04:24:20.558334643 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ClassDefinitionBlockFactory.java 2016-05-12 04:24:20.478334644 +0300 @@ -38,7 +38,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class ClassDefinitionBlockFactory extends Factory { +class ClassDefinitionBlockFactory extends Factory { private final String prefix; private final long complexityLimit; private final int classesLimit; @@ -62,7 +62,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public ClassDefinitionBlock produce() throws ProductionFailedException { ArrayList content = new ArrayList<>(); int limit = (int) Math.ceil(PseudoRandom.random() * classesLimit); if (limit > 0) { @@ -74,9 +74,8 @@ .setComplexityLimit(classCompl); for (int i = 0; i < limit; i++) { try { - Rule rule = new Rule("class"); + Rule rule = new Rule<>("class"); rule.add("basic_class", builder.setName(prefix + "_Class_" + i) - .setPrinterName(prefix + ".Printer") .setMemberFunctionsLimit(memberFunctionsLimit) .getKlassFactory()); if (!ProductionParams.disableInterfaces.value()) { @@ -110,13 +109,12 @@ IRNode randomChild = childs.get(0); List leaves = randomChild.getStackableLeaves(); if (!leaves.isEmpty()) { - PseudoRandom.shuffle(leaves); - Block randomLeaf = (Block) leaves.get(0); - TypeKlass klass = (TypeKlass) randomChild.getKlass(); + Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size())); + TypeKlass owner = randomChild.getOwner(); int newLevel = randomLeaf.getLevel() + 1; - Type retType = randomLeaf.getReturnType(); + Type retType = randomLeaf.getResultType(); IRNodeBuilder b = new IRNodeBuilder() - .setOwnerKlass(klass) + .setOwnerKlass(owner) .setResultType(retType) .setComplexityLimit(complexityLimit) .setStatementLimit(statementLimit) @@ -137,7 +135,7 @@ .filter(c -> c instanceof Klass && c.countDepth() > maxDepth) .collect(Collectors.toList()); for (IRNode ch : childs) { - List leaves = null; + List leaves; do { long depth = Math.max(ch.countDepth(), maxDepth + 1); leaves = ch.getDeviantBlocks(depth); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java 2016-05-12 04:24:20.846334641 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java 2016-05-12 04:24:20.786334642 +0300 @@ -30,8 +30,8 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; +import jdk.test.lib.jittester.VariableBase; import jdk.test.lib.jittester.utils.TypeUtil; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -43,11 +43,11 @@ @Override protected boolean isApplicable(Type resultType) { - return TypeList.isBuiltIn(resultType) && !resultType.equals(new TypeBoolean()); + return TypeList.isBuiltIn(resultType) && !resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, PseudoRandom.randomElement( TypeUtil.getExplicitlyCastable(TypeList.getBuiltIn(), resultType))); } @@ -66,13 +66,13 @@ .setResultType(rightType) .getExpressionFactory() .produce(); - IRNode leftExpr = builder.setComplexityLimit(leftComplexityLimit) + VariableBase leftExpr = builder.setComplexityLimit(leftComplexityLimit) .setOperatorLimit(leftOperatorLimit) .setResultType(leftType) .setIsConstant(false) .setIsInitialized(true) .getVariableFactory() .produce(); - return new BinaryOperator(opKind, leftExpr, rightExpr); + return new BinaryOperator(opKind, resultType, leftExpr, rightExpr); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java 2016-05-12 04:24:21.182334638 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java 2016-05-12 04:24:21.086334639 +0300 @@ -46,7 +46,7 @@ } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, PseudoRandom.randomElement(TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType))); } @@ -71,6 +71,6 @@ .setResultType(rightType) .getExpressionFactory() .produce(); - return new BinaryOperator(opKind, leftExpr, rightExpr); + return new BinaryOperator(opKind, resultType, leftExpr, rightExpr); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java 2016-05-12 04:24:21.462334636 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java 2016-05-12 04:24:21.386334637 +0300 @@ -32,7 +32,6 @@ import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; class CompoundShiftAssignmentOperatorFactory extends BinaryOperatorFactory { @@ -43,11 +42,11 @@ @Override protected boolean isApplicable(Type resultType) { - return TypeList.isBuiltInInt(resultType) && !resultType.equals(new TypeBoolean()); + return TypeList.isBuiltInInt(resultType) && !resultType.equals(TypeList.BOOLEAN); } @Override - protected Pair generateTypes() throws ProductionFailedException { + protected Pair generateTypes() { return new Pair<>(resultType, PseudoRandom.randomElement( TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType))); } @@ -73,6 +72,6 @@ .setResultType(rightType) .getExpressionFactory() .produce(); - return new BinaryOperator(opKind, leftExpr, rightExpr); + return new BinaryOperator(opKind, resultType, leftExpr, rightExpr); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ConstructorDefinitionBlockFactory.java 2016-05-12 04:24:21.722334634 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ConstructorDefinitionBlockFactory.java 2016-05-12 04:24:21.650334635 +0300 @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class ConstructorDefinitionBlockFactory extends Factory { +class ConstructorDefinitionBlockFactory extends Factory { private final long complexityLimit; private final int statementLimit; private final int operatorLimit; @@ -53,7 +53,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public ConstructorDefinitionBlock produce() throws ProductionFailedException { IRNodeBuilder builder = new IRNodeBuilder() .setOwnerKlass(ownerClass) .setStatementLimit(statementLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ConstructorDefinitionFactory.java 2016-05-12 04:24:22.010334632 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ConstructorDefinitionFactory.java 2016-05-12 04:24:21.930334632 +0300 @@ -28,15 +28,15 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Symbol; import jdk.test.lib.jittester.SymbolTable; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.functions.ArgumentDeclaration; import jdk.test.lib.jittester.functions.ConstructorDefinition; import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class ConstructorDefinitionFactory extends Factory { +class ConstructorDefinitionFactory extends Factory { private final long complexityLimit; private final int statementLimit; private final int operatorLimit; @@ -55,7 +55,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public ConstructorDefinition produce() throws ProductionFailedException { int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit); ArrayList argumentsInfo = new ArrayList<>(argNumber); ArrayList argumentsDeclaration = new ArrayList<>(argNumber); @@ -90,7 +90,7 @@ } long blockComplLimit = (long) (PseudoRandom.random() * complexityLimit); try { - body = builder.setResultType(new TypeVoid()) + body = builder.setResultType(TypeList.VOID) .setComplexityLimit(blockComplLimit) .setStatementLimit(statementLimit) .setOperatorLimit(operatorLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ContinueFactory.java 2016-05-12 04:24:22.274334630 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ContinueFactory.java 2016-05-12 04:24:22.178334631 +0300 @@ -24,12 +24,11 @@ package jdk.test.lib.jittester.factories; import jdk.test.lib.jittester.Continue; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; -class ContinueFactory extends Factory { +class ContinueFactory extends Factory { @Override - public IRNode produce() throws ProductionFailedException { + public Continue produce() throws ProductionFailedException { return new Continue(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java 2016-05-12 04:24:22.534334628 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java 2016-05-12 04:24:22.470334628 +0300 @@ -24,20 +24,20 @@ package jdk.test.lib.jittester.factories; import java.util.List; + import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.LiteralInitializer; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableInfo; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.loops.CounterInitializer; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.utils.PseudoRandom; -class CounterInitializerFactory extends SafeFactory { +class CounterInitializerFactory extends SafeFactory { private final int counterValue; private final TypeKlass ownerClass; @@ -47,9 +47,9 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { - List types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt()); - types.add(new TypeInt()); + protected CounterInitializer sproduce() throws ProductionFailedException { + List types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), TypeList.INT); + types.add(TypeList.INT); final Type selectedType = PseudoRandom.randomElement(types); IRNode init = new LiteralInitializer(counterValue, selectedType); String resultName = "var_" + SymbolTable.getNextVariableNumber(); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterManipulatorFactory.java 2016-05-12 04:24:22.790334626 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterManipulatorFactory.java 2016-05-12 04:24:22.714334626 +0300 @@ -27,10 +27,11 @@ import jdk.test.lib.jittester.LocalVariable; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; +import jdk.test.lib.jittester.Statement; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.loops.CounterManipulator; -class CounterManipulatorFactory extends Factory { +class CounterManipulatorFactory extends Factory { private final LocalVariable counter; CounterManipulatorFactory(LocalVariable counter) { @@ -38,9 +39,9 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public CounterManipulator produce() throws ProductionFailedException { // We'll keep it simple for the time being.. IRNode manipulator = new UnaryOperator(OperatorKind.POST_DEC, counter); - return new CounterManipulator(manipulator); + return new CounterManipulator(new Statement(manipulator, false)); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/DeclarationFactory.java 2016-05-12 04:24:23.138334623 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/DeclarationFactory.java 2016-05-12 04:24:23.058334623 +0300 @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; -class DeclarationFactory extends Factory { +class DeclarationFactory extends Factory { private final int operatorLimit; private final long complexityLimit; private final boolean isLocal; @@ -48,29 +48,42 @@ } @Override - public IRNode produce() throws ProductionFailedException { - Rule rule = new Rule("declaration"); + public Declaration produce() throws ProductionFailedException { + Rule rule = new Rule<>("declaration"); IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass) - .setResultType(TypeList.getVoid()) + .setResultType(TypeList.VOID) .setIsLocal(isLocal) .setComplexityLimit(complexityLimit) .setOperatorLimit(operatorLimit) .setIsLocal(isLocal) .setExceptionSafe(exceptionSafe); - rule.add("decl", builder.setIsStatic(false).getVariableDeclarationFactory()); - rule.add("decl_and_init", builder.setIsConstant(false) - .setIsStatic(false).getVariableInitializationFactory()); + rule.add("decl", builder + .setIsStatic(false) + .getVariableDeclarationFactory()); + rule.add("decl_and_init", builder + .setIsConstant(false) + .setIsStatic(false) + .getVariableInitializationFactory()); if (!ProductionParams.disableFinalVariables.value()) { - rule.add("const_decl_and_init", builder.setIsConstant(true) - .setIsStatic(false).getVariableInitializationFactory()); + rule.add("const_decl_and_init", builder + .setIsConstant(true) + .setIsStatic(false) + .getVariableInitializationFactory()); } if (!isLocal && !ProductionParams.disableStatic.value()) { - rule.add("static_decl", builder.setIsStatic(true).getVariableDeclarationFactory()); - rule.add("static_decl_and_init", builder.setIsConstant(false) - .setIsStatic(true).getVariableInitializationFactory()); + rule.add("static_decl", builder + .setIsConstant(false) + .setIsStatic(true) + .getVariableDeclarationFactory()); + rule.add("static_decl_and_init", builder + .setIsConstant(false) + .setIsStatic(true) + .getVariableInitializationFactory()); if (!ProductionParams.disableFinalVariables.value()) { - rule.add("static_const_decl_and_init", builder.setIsConstant(true) - .setIsStatic(true).getVariableInitializationFactory()); + rule.add("static_const_decl_and_init", builder + .setIsConstant(true) + .setIsStatic(true) + .getVariableInitializationFactory()); } } return new Declaration(rule.produce()); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/DoWhileFactory.java 2016-05-12 04:24:23.434334620 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/DoWhileFactory.java 2016-05-12 04:24:23.342334621 +0300 @@ -23,21 +23,21 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; -import jdk.test.lib.jittester.Initialization; +import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; -import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.loops.DoWhile; import jdk.test.lib.jittester.loops.Loop; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.utils.PseudoRandom; -class DoWhileFactory extends SafeFactory { +import java.util.LinkedList; + +class DoWhileFactory extends SafeFactory { private final Loop loop; private final long complexityLimit; private final int statementLimit; @@ -62,7 +62,8 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected DoWhile sproduce() throws ProductionFailedException { + Block emptyBlock = new Block(ownerClass, returnType, new LinkedList<>(), level - 1); if (statementLimit > 0 && complexityLimit > 0) { long complexity = complexityLimit; // Loop header parameters @@ -89,7 +90,7 @@ .setResultType(returnType) .setOperatorLimit(operatorLimit); loop.initialization = builder.getCounterInitializerFactory(0).produce(); - IRNode header; + Block header; try { header = builder.setComplexityLimit(headerComplLimit) .setStatementLimit(headerStatementLimit) @@ -101,17 +102,17 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - header = new Nothing(); + header = emptyBlock; } // getChildren().set(DoWhile.DoWhilePart.HEADER.ordinal(), header); - LocalVariable counter = new LocalVariable(((Initialization) loop.initialization).get()); - Literal limiter = new Literal(Integer.valueOf((int) thisLoopIterLimit), new TypeInt()); + LocalVariable counter = new LocalVariable(loop.initialization.getVariableInfo()); + Literal limiter = new Literal((int) thisLoopIterLimit, TypeList.INT); loop.condition = builder.setComplexityLimit(condComplLimit) .setLocalVariable(counter) .getLoopingConditionFactory(limiter) .produce(); SymbolTable.push(); - IRNode body1; + Block body1; try { body1 = builder.setComplexityLimit(body1ComplLimit) .setStatementLimit(body1StatementLimit) @@ -123,11 +124,11 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body1 = new Nothing(); + body1 = emptyBlock; } // getChildren().set(DoWhile.DoWhilePart.BODY1.ordinal(), body1); loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce(); - IRNode body2; + Block body2; try { body2 = builder.setComplexityLimit(body2ComplLimit) .setStatementLimit(body2StatementLimit) @@ -139,7 +140,7 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body2 = new Nothing(); + body2 = emptyBlock; } // getChildren().set(DoWhile.DoWhilePart.BODY2.ordinal(), body2); SymbolTable.pop(); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ExpressionFactory.java 2016-05-12 04:24:23.678334618 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ExpressionFactory.java 2016-05-12 04:24:23.614334619 +0300 @@ -29,11 +29,11 @@ import jdk.test.lib.jittester.ProductionLimiter; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Rule; -import jdk.test.lib.jittester.Type;; +import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.types.TypeKlass; -class ExpressionFactory extends SafeFactory { - private final Rule rule; +class ExpressionFactory extends SafeFactory { + private final Rule rule; ExpressionFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException { @@ -44,7 +44,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(noconsts); - rule = new Rule("expression"); + rule = new Rule<>("expression"); if (!noconsts) { rule.add("literal", builder.getLiteralFactory()); rule.add("constant", builder.setIsConstant(true) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/Factory.java 2016-05-12 04:24:23.986334616 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/Factory.java 2016-05-12 04:24:23.910334617 +0300 @@ -26,6 +26,6 @@ import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; -public abstract class Factory { - public abstract IRNode produce() throws ProductionFailedException; +public abstract class Factory { + public abstract T produce() throws ProductionFailedException; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ForFactory.java 2016-05-12 04:24:24.350334613 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ForFactory.java 2016-05-12 04:24:24.262334614 +0300 @@ -23,22 +23,25 @@ package jdk.test.lib.jittester.factories; +import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.IRNode; -import jdk.test.lib.jittester.Initialization; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; +import jdk.test.lib.jittester.Statement; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.loops.For; import jdk.test.lib.jittester.loops.Loop; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.utils.PseudoRandom; -class ForFactory extends SafeFactory { +import java.util.LinkedList; + +class ForFactory extends SafeFactory { private final Loop loop; private final long complexityLimit; private final int statementLimit; @@ -46,7 +49,6 @@ private final TypeKlass ownerClass; private final Type returnType; private final int level; - private long thisLoopIterLimit = 0; private final boolean canHaveReturn; ForFactory(TypeKlass ownerClass, Type returnType, long complexityLimit, int statementLimit, @@ -62,7 +64,8 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected For sproduce() throws ProductionFailedException { + Block emptyBlock = new Block(ownerClass, returnType, new LinkedList<>(), level - 1); if (statementLimit <= 0 || complexityLimit <= 0) { throw new ProductionFailedException(); } @@ -81,7 +84,7 @@ long statement1ComplLimit = (long) (0.005 * complexity * PseudoRandom.random()); complexity -= statement1ComplLimit; // Loop body parameters - thisLoopIterLimit = (long) (0.0001 * complexity * PseudoRandom.random()); + long thisLoopIterLimit = (long) (0.0001 * complexity * PseudoRandom.random()); if (thisLoopIterLimit > Integer.MAX_VALUE || thisLoopIterLimit == 0) { throw new ProductionFailedException(); } @@ -100,7 +103,7 @@ int body3StatementLimit = PseudoRandom.randomNotZero((int) (statementLimit / 4.0)); // Production loop.initialization = builder.getCounterInitializerFactory(0).produce(); - IRNode header; + Block header; try { header = builder.setComplexityLimit(headerComplLimit) .setStatementLimit(headerStatementLimit) @@ -112,12 +115,12 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - header = new Nothing(); + header = emptyBlock; } SymbolTable.push(); IRNode statement1; try { - Rule rule = new Rule("statement1"); + Rule rule = new Rule<>("statement1"); builder.setComplexityLimit(statement1ComplLimit); rule.add("assignment", builder.getAssignmentOperatorFactory()); rule.add("function", builder.getFunctionFactory(), 0.1); @@ -129,20 +132,20 @@ } catch (ProductionFailedException e) { statement1 = new Nothing(); } - LocalVariable counter = new LocalVariable(((Initialization) loop.initialization).get()); - Literal limiter = new Literal(Integer.valueOf((int) thisLoopIterLimit), new TypeInt()); + LocalVariable counter = new LocalVariable(loop.initialization.getVariableInfo()); + Literal limiter = new Literal((int) thisLoopIterLimit, TypeList.INT); loop.condition = builder.setComplexityLimit(condComplLimit) .setLocalVariable(counter) .getLoopingConditionFactory(limiter) .produce(); IRNode statement2; try { - statement2 = builder.setComplexityLimit(statement2ComplLimit) + statement2 = builder.setComplexityLimit(statement2ComplLimit) .getAssignmentOperatorFactory().produce(); } catch (ProductionFailedException e) { statement2 = new Nothing(); } - IRNode body1; + Block body1; try { body1 = builder.setComplexityLimit(body1ComplLimit) .setStatementLimit(body1StatementLimit) @@ -154,10 +157,10 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body1 = new Nothing(); + body1 = emptyBlock; } loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce(); - IRNode body2; + Block body2; try { body2 = builder.setComplexityLimit(body2ComplLimit) .setStatementLimit(body2StatementLimit) @@ -169,9 +172,9 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body2 = new Nothing(); + body2 = emptyBlock; } - IRNode body3; + Block body3; try { body3 = builder.setComplexityLimit(body3ComplLimit) .setStatementLimit(body3StatementLimit) @@ -183,10 +186,13 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body3 = new Nothing(); + body3 = emptyBlock; } SymbolTable.pop(); - return new For(level, loop, thisLoopIterLimit, header, statement1, statement2, body1, + return new For(level, loop, thisLoopIterLimit, header, + new Statement(statement1, false), + new Statement(statement2, false), + body1, body2, body3); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDeclarationBlockFactory.java 2016-05-12 04:24:24.746334610 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDeclarationBlockFactory.java 2016-05-12 04:24:24.666334611 +0300 @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionDeclarationBlockFactory extends Factory { +class FunctionDeclarationBlockFactory extends Factory { private final int memberFunctionsLimit; private final int memberFunctionsArgLimit; private final int level; @@ -46,7 +46,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionDeclarationBlock produce() throws ProductionFailedException { ArrayList content = new ArrayList<>(); int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit); if (memFunLimit > 0) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDeclarationFactory.java 2016-05-12 04:24:25.018334608 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDeclarationFactory.java 2016-05-12 04:24:24.954334608 +0300 @@ -27,7 +27,6 @@ import java.util.Collection; import java.util.List; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Symbol; import jdk.test.lib.jittester.SymbolTable; @@ -39,10 +38,9 @@ import jdk.test.lib.jittester.functions.FunctionDefinition; import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionDeclarationFactory extends Factory { +class FunctionDeclarationFactory extends Factory { private final Type resultType; private final TypeKlass ownerClass; private final String name; @@ -59,11 +57,11 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionDeclaration produce() throws ProductionFailedException { Type resType = resultType; if (resType == null) { List types = new ArrayList<>(TypeList.getAll()); - types.add(new TypeVoid()); + types.add(TypeList.VOID); resType = PseudoRandom.randomElement(types); } int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDefinitionBlockFactory.java 2016-05-12 04:24:25.418334605 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDefinitionBlockFactory.java 2016-05-12 04:24:25.342334605 +0300 @@ -35,7 +35,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionDefinitionBlockFactory extends Factory { +class FunctionDefinitionBlockFactory extends Factory { private final long complexityLimit; private final int statementLimit; private final int operatorLimit; @@ -59,7 +59,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionDefinitionBlock produce() throws ProductionFailedException { ArrayList content = new ArrayList<>(); int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit); if (memFunLimit > 0) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDefinitionFactory.java 2016-05-12 04:24:25.718334602 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionDefinitionFactory.java 2016-05-12 04:24:25.650334603 +0300 @@ -28,6 +28,7 @@ import java.util.List; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Symbol; import jdk.test.lib.jittester.SymbolTable; @@ -37,11 +38,11 @@ import jdk.test.lib.jittester.functions.ArgumentDeclaration; import jdk.test.lib.jittester.functions.FunctionDefinition; import jdk.test.lib.jittester.functions.FunctionInfo; +import jdk.test.lib.jittester.functions.Return; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionDefinitionFactory extends Factory { +class FunctionDefinitionFactory extends Factory { private final Type resultType; private final String name; private final long complexityLimit; @@ -67,11 +68,11 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionDefinition produce() throws ProductionFailedException { Type resType = resultType; if (resType == null) { List types = new ArrayList<>(TypeList.getAll()); - types.add(new TypeVoid()); + types.add(TypeList.VOID); resType = PseudoRandom.randomElement(types); } int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit); @@ -86,7 +87,7 @@ ArrayList argumentsDeclaration = new ArrayList<>(argNumber); SymbolTable.push(); IRNode body; - IRNode returnNode; + Return returnNode; FunctionInfo functionInfo; try { IRNodeBuilder builder = new IRNodeBuilder().setArgumentType(ownerClass); @@ -127,13 +128,13 @@ .setCanHaveReturn(true) .getBlockFactory() .produce(); - if (!resType.equals(new TypeVoid())) { + if (!resType.equals(TypeList.VOID)) { returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit) .setExceptionSafe(false) .getReturnFactory() .produce(); } else { - returnNode = null; + returnNode = new Return(new Nothing()); } } finally { SymbolTable.pop(); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionFactory.java 2016-05-12 04:24:26.030334600 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionFactory.java 2016-05-12 04:24:25.962334600 +0300 @@ -37,7 +37,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionFactory extends SafeFactory { +class FunctionFactory extends SafeFactory { private final FunctionInfo functionInfo; private final int operatorLimit; private final long complexityLimit; @@ -55,7 +55,7 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected Function sproduce() throws ProductionFailedException { // Currently no function is exception-safe if (exceptionSafe) { throw new ProductionFailedException(); @@ -72,7 +72,7 @@ for (Symbol function : allFunctions) { FunctionInfo functionInfo = (FunctionInfo) function; // Don't try to construct abstract classes. - if (functionInfo.isConstructor() && functionInfo.klass.isAbstract()) { + if (functionInfo.isConstructor() && functionInfo.owner.isAbstract()) { continue; } // We don't call methods from the same class which are not final, because if we @@ -94,7 +94,7 @@ // If it's a local call.. or it's a call using some variable to some object of some type in our hierarchy boolean inHierarchy = false; - if (ownerClass.equals(functionInfo.klass) || (inHierarchy = klassHierarchy.contains(functionInfo.klass))) { + if (ownerClass.equals(functionInfo.owner) || (inHierarchy = klassHierarchy.contains(functionInfo.owner))) { if ((functionInfo.flags & FunctionInfo.FINAL) == 0 && (functionInfo.flags & FunctionInfo.STATIC) == 0 && (functionInfo.flags & FunctionInfo.NONRECURSIVE) == 0) { continue; @@ -121,7 +121,7 @@ // If there are function with a same name and same number of args, // then disable usage of foldable expressions in the args. boolean noconsts = false; - Collection allFuncsInKlass = SymbolTable.getAllCombined(functionInfo.klass, + Collection allFuncsInKlass = SymbolTable.getAllCombined(functionInfo.owner, FunctionInfo.class); for (Symbol s2 : allFuncsInKlass) { FunctionInfo i2 = (FunctionInfo) function; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionRedefinitionBlockFactory.java 2016-05-12 04:24:26.642334595 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionRedefinitionBlockFactory.java 2016-05-12 04:24:26.558334595 +0300 @@ -34,7 +34,7 @@ import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock; import jdk.test.lib.jittester.types.TypeKlass; -class FunctionRedefinitionBlockFactory extends Factory { +class FunctionRedefinitionBlockFactory extends Factory { private final int statementLimit; private final int operatorLimit; private final long complexityLimit; @@ -53,7 +53,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionRedefinitionBlock produce() throws ProductionFailedException { ArrayList content = new ArrayList<>(); if (functionSet.size() > 0) { long funcComplexity = complexityLimit / functionSet.size(); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionRedefinitionFactory.java 2016-05-12 04:24:27.010334592 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionRedefinitionFactory.java 2016-05-12 04:24:26.926334592 +0300 @@ -25,17 +25,19 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.functions.ArgumentDeclaration; -import jdk.test.lib.jittester.functions.FunctionDefinition; import jdk.test.lib.jittester.functions.FunctionInfo; +import jdk.test.lib.jittester.functions.FunctionRedefinition; +import jdk.test.lib.jittester.functions.Return; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class FunctionRedefinitionFactory extends Factory { +class FunctionRedefinitionFactory extends Factory { private final long complexityLimit; private final int statementLimit; private final int operatorLimit; @@ -47,14 +49,14 @@ long complexityLimit, int statementLimit, int operatorLimit, int level, int flags) { this.ownerClass = ownerClass; this.functionInfo = new FunctionInfo(functionInfo); // do deep coping - functionInfo.klass = ownerClass; // important! fix klass! + functionInfo.owner = ownerClass; // important! fix klass! if ((functionInfo.flags & FunctionInfo.STATIC) == 0) { functionInfo.argTypes.get(0).type = ownerClass; // redefine type of this } functionInfo.flags = flags; // apply new flags. // fix the type of class where the args would be declared for (VariableInfo varInfo : functionInfo.argTypes) { - varInfo.klass = ownerClass; + varInfo.owner = ownerClass; } this.complexityLimit = complexityLimit; this.statementLimit = statementLimit; @@ -63,14 +65,14 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public FunctionRedefinition produce() throws ProductionFailedException { ArrayList argumentsInfo = functionInfo.argTypes; SymbolTable.push(); IRNode body; - IRNode returnNode; + Return returnNode; ArrayList argumentsDeclaration; try { - if ((functionInfo.flags & FunctionInfo.STATIC) > 0) { + if (functionInfo.isStatic()) { argumentsDeclaration = new ArrayList<>(argumentsInfo.size()); for (VariableInfo varInfo : argumentsInfo) { argumentsDeclaration.add(new ArgumentDeclaration(varInfo)); @@ -98,13 +100,13 @@ .setCanHaveReturn(true) .getBlockFactory() .produce(); - if (!functionInfo.type.equals(new TypeVoid())) { + if (!functionInfo.type.equals(TypeList.VOID)) { returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit) .setExceptionSafe(false) .getReturnFactory() .produce(); } else { - returnNode = null; + returnNode = new Return(new Nothing()); } } catch (ProductionFailedException e) { SymbolTable.pop(); @@ -112,12 +114,12 @@ throw e; } SymbolTable.pop(); - if ((functionInfo.flags & FunctionInfo.STATIC) == 0) { + if (!functionInfo.isStatic()) { functionInfo.flags &= ~FunctionInfo.ABSTRACT; } // If it's all ok, add the function to the symbol table. SymbolTable.add(functionInfo); - return new FunctionDefinition(functionInfo, argumentsDeclaration, body, returnNode); + return new FunctionRedefinition(functionInfo, argumentsDeclaration, body, returnNode); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IRNodeBuilder.java 2016-05-12 04:24:27.398334589 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IRNodeBuilder.java 2016-05-12 04:24:27.310334589 +0300 @@ -25,14 +25,64 @@ import java.util.Collection; import java.util.Optional; + +import jdk.test.lib.jittester.BinaryOperator; +import jdk.test.lib.jittester.Block; +import jdk.test.lib.jittester.Break; +import jdk.test.lib.jittester.CastOperator; +import jdk.test.lib.jittester.Continue; +import jdk.test.lib.jittester.Declaration; +import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.If; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; +import jdk.test.lib.jittester.NonStaticMemberVariable; +import jdk.test.lib.jittester.Nothing; +import jdk.test.lib.jittester.Operator; import jdk.test.lib.jittester.OperatorKind; +import jdk.test.lib.jittester.PrintVariables; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; +import jdk.test.lib.jittester.Statement; +import jdk.test.lib.jittester.StaticMemberVariable; +import jdk.test.lib.jittester.Switch; import jdk.test.lib.jittester.Symbol; +import jdk.test.lib.jittester.TernaryOperator; +import jdk.test.lib.jittester.Throw; +import jdk.test.lib.jittester.TryCatchBlock; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; +import jdk.test.lib.jittester.UnaryOperator; +import jdk.test.lib.jittester.VariableBase; +import jdk.test.lib.jittester.VariableDeclaration; +import jdk.test.lib.jittester.VariableDeclarationBlock; +import jdk.test.lib.jittester.VariableInitialization; +import jdk.test.lib.jittester.arrays.ArrayCreation; +import jdk.test.lib.jittester.arrays.ArrayElement; +import jdk.test.lib.jittester.arrays.ArrayExtraction; +import jdk.test.lib.jittester.classes.ClassDefinitionBlock; +import jdk.test.lib.jittester.classes.Interface; +import jdk.test.lib.jittester.classes.Klass; +import jdk.test.lib.jittester.classes.MainKlass; +import jdk.test.lib.jittester.functions.ArgumentDeclaration; +import jdk.test.lib.jittester.functions.ConstructorDefinition; +import jdk.test.lib.jittester.functions.ConstructorDefinitionBlock; +import jdk.test.lib.jittester.functions.Function; +import jdk.test.lib.jittester.functions.FunctionDeclaration; +import jdk.test.lib.jittester.functions.FunctionDeclarationBlock; +import jdk.test.lib.jittester.functions.FunctionDefinition; +import jdk.test.lib.jittester.functions.FunctionDefinitionBlock; import jdk.test.lib.jittester.functions.FunctionInfo; +import jdk.test.lib.jittester.functions.FunctionRedefinition; +import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock; +import jdk.test.lib.jittester.functions.Return; +import jdk.test.lib.jittester.functions.StaticConstructorDefinition; +import jdk.test.lib.jittester.loops.CounterInitializer; +import jdk.test.lib.jittester.loops.CounterManipulator; +import jdk.test.lib.jittester.loops.DoWhile; +import jdk.test.lib.jittester.loops.For; +import jdk.test.lib.jittester.loops.LoopingCondition; +import jdk.test.lib.jittester.loops.While; import jdk.test.lib.jittester.types.TypeKlass; public class IRNodeBuilder { @@ -63,41 +113,40 @@ private Optional isConstant = Optional.empty(); private Optional isInitialized = Optional.empty(); private Optional name = Optional.empty(); - private Optional printerName = Optional.empty(); private Optional flags = Optional.empty(); private Optional functionInfo = Optional.empty(); private Optional semicolon = Optional.empty(); - public ArgumentDeclarationFactory getArgumentDeclarationFactory() { + public Factory getArgumentDeclarationFactory() { return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber()); } - public Factory getArithmeticOperatorFactory() throws ProductionFailedException { + public Factory getArithmeticOperatorFactory() throws ProductionFailedException { return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public ArrayCreationFactory getArrayCreationFactory() { + public Factory getArrayCreationFactory() { return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public ArrayElementFactory getArrayElementFactory() { + public Factory getArrayElementFactory() { return new ArrayElementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public ArrayExtractionFactory getArrayExtractionFactory() { + public Factory getArrayExtractionFactory() { return new ArrayExtractionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public AssignmentOperatorFactory getAssignmentOperatorFactory() { + public Factory getAssignmentOperatorFactory() { return new AssignmentOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts()); } - public BinaryOperatorFactory getBinaryOperatorFactory() throws ProductionFailedException { + public Factory getBinaryOperatorFactory() throws ProductionFailedException { OperatorKind o = getOperatorKind(); switch (o) { case ASSIGN: @@ -166,7 +215,7 @@ } } - public UnaryOperatorFactory getUnaryOperatorFactory() throws ProductionFailedException { + public Factory getUnaryOperatorFactory() throws ProductionFailedException { OperatorKind o = getOperatorKind(); switch (o) { case NOT: @@ -193,24 +242,24 @@ } } - public BlockFactory getBlockFactory() throws ProductionFailedException { + public Factory getBlockFactory() { return new BlockFactory(getOwnerClass(), getResultType(), getComplexityLimit(), - getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false), - canHaveBreaks.orElse(false), canHaveContinues.orElse(false), + getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false), + canHaveBreaks.orElse(false), canHaveContinues.orElse(false), canHaveReturn.orElse(false), canHaveReturn.orElse(false)); - //now 'throw' can be placed only in the same positions as 'return' + //now 'throw' can be placed only in the same positions as 'return' } - public BreakFactory getBreakFactory() { + public Factory getBreakFactory() { return new BreakFactory(); } - public CastOperatorFactory getCastOperatorFactory() { + public Factory getCastOperatorFactory() { return new CastOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public Factory getClassDefinitionBlockFactory() { + public Factory getClassDefinitionBlockFactory() { return new ClassDefinitionBlockFactory(getPrefix(), ProductionParams.classesLimit.value(), ProductionParams.memberFunctionsLimit.value(), @@ -221,7 +270,7 @@ getLevel()); } - public Factory getMainKlassFactory() { + public Factory getMainKlassFactory() { return new MainKlassFactory(getName(), getComplexityLimit(), ProductionParams.memberFunctionsLimit.value(), ProductionParams.memberFunctionsArgLimit.value(), @@ -230,200 +279,200 @@ ProductionParams.operatorLimit.value()); } - public ConstructorDefinitionBlockFactory getConstructorDefinitionBlockFactory() { + public Factory getConstructorDefinitionBlockFactory() { return new ConstructorDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), ProductionParams.memberFunctionsArgLimit.value(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel()); } - public ConstructorDefinitionFactory getConstructorDefinitionFactory() { + public Factory getConstructorDefinitionFactory() { return new ConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getMemberFunctionsArgLimit(), getLevel()); } - public ContinueFactory getContinueFactory() { + public Factory getContinueFactory() { return new ContinueFactory(); } - public CounterInitializerFactory getCounterInitializerFactory(int counterValue) { + public Factory getCounterInitializerFactory(int counterValue) { return new CounterInitializerFactory(getOwnerClass(), counterValue); } - public CounterManipulatorFactory getCounterManipulatorFactory() { + public Factory getCounterManipulatorFactory() { return new CounterManipulatorFactory(getLocalVariable()); } - public DeclarationFactory getDeclarationFactory() { + public Factory getDeclarationFactory() { return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(), - getIsLocal(), getExceptionSafe()); + getIsLocal(), getExceptionSafe()); } - public DoWhileFactory getDoWhileFactory() { + public Factory getDoWhileFactory() { return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); } - public WhileFactory getWhileFactory() { + public Factory getWhileFactory() { return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); } - public IfFactory getIfFactory() { + public Factory getIfFactory() { return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(), - getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(), + getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(), getCanHaveContinues(), getCanHaveReturn()); } - public ForFactory getForFactory() { + public Factory getForFactory() { return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); } - public SwitchFactory getSwitchFactory() { // TODO: switch is not used now + public Factory getSwitchFactory() { // TODO: switch is not used now return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn()); } - public ExpressionFactory getExpressionFactory() throws ProductionFailedException { + public Factory getExpressionFactory() throws ProductionFailedException { return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public FunctionDeclarationBlockFactory getFunctionDeclarationBlockFactory() { + public Factory getFunctionDeclarationBlockFactory() { return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getLevel()); } - public FunctionDeclarationFactory getFunctionDeclarationFactory() { - return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(null), + public Factory getFunctionDeclarationFactory() { + return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(TypeList.VOID), getMemberFunctionsArgLimit(), getFlags()); } - public FunctionDefinitionBlockFactory getFunctionDefinitionBlockFactory() { + public Factory getFunctionDefinitionBlockFactory() { return new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getFlags()); } - public FunctionDefinitionFactory getFunctionDefinitionFactory() { - return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(null), + public Factory getFunctionDefinitionFactory() { + return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(TypeList.VOID), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getMemberFunctionsArgLimit(), getLevel(), getFlags()); } - public FunctionFactory getFunctionFactory() { + public Factory getFunctionFactory() { return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), resultType.orElse(null), getExceptionSafe()); } - public FunctionRedefinitionBlockFactory getFunctionRedefinitionBlockFactory(Collection - functionSet) { + public Factory getFunctionRedefinitionBlockFactory(Collection + functionSet) { return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel()); } - public FunctionRedefinitionFactory getFunctionRedefinitionFactory() { + public Factory getFunctionRedefinitionFactory() { return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), getFlags()); } - public InterfaceFactory getInterfaceFactory() { + public Factory getInterfaceFactory() { return new InterfaceFactory(getName(), getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getLevel()); } - public KlassFactory getKlassFactory() { - return new KlassFactory(getName(), getPrinterName(), getComplexityLimit(), + public Factory getKlassFactory() { + return new KlassFactory(getName(), getComplexityLimit(), getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(), getOperatorLimit(), getLevel()); } - public LimitedExpressionFactory getLimitedExpressionFactory() throws ProductionFailedException { + public Factory getLimitedExpressionFactory() throws ProductionFailedException { return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public LiteralFactory getLiteralFactory() { + public Factory getLiteralFactory() { return new LiteralFactory(getResultType()); } - public LocalVariableFactory getLocalVariableFactory() { + public Factory getLocalVariableFactory() { return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags()); } - public LogicOperatorFactory getLogicOperatorFactory() throws ProductionFailedException { + public Factory getLogicOperatorFactory() throws ProductionFailedException { return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public LoopingConditionFactory getLoopingConditionFactory(Literal _limiter) { + public Factory getLoopingConditionFactory(Literal _limiter) { return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getLocalVariable(), _limiter); } - public NonStaticMemberVariableFactory getNonStaticMemberVariableFactory() { + public Factory getNonStaticMemberVariableFactory() { return new NonStaticMemberVariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), /*getVariableType()*/getResultType(), getFlags(), getExceptionSafe()); } - public NothingFactory getNothingFactory() { + public Factory getNothingFactory() { return new NothingFactory(); } - public PrintVariablesFactory getPrintVariablesFactory() { - return new PrintVariablesFactory(getPrinterName(), getOwnerClass(), getLevel()); + public Factory getPrintVariablesFactory() { + return new PrintVariablesFactory(getOwnerClass(), getLevel()); } - public ReturnFactory getReturnFactory() { + public Factory getReturnFactory() { return new ReturnFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe()); } - public ThrowFactory getThrowFactory() { + public Factory getThrowFactory() { return new ThrowFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe()); } - public StatementFactory getStatementFactory() { + public Factory getStatementFactory() { return new StatementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getExceptionSafe(), getNoConsts(), semicolon.orElse(true)); } - public StaticConstructorDefinitionFactory getStaticConstructorDefinitionFactory() { + public Factory getStaticConstructorDefinitionFactory() { return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel()); } - public StaticMemberVariableFactory getStaticMemberVariableFactory() { + public Factory getStaticMemberVariableFactory() { return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags()); } - public TernaryOperatorFactory getTernaryOperatorFactory() { + public Factory getTernaryOperatorFactory() { return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts()); } - public VariableDeclarationBlockFactory getVariableDeclarationBlockFactory() { + public Factory getVariableDeclarationBlockFactory() { return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(), getLevel(), getExceptionSafe()); } - public VariableDeclarationFactory getVariableDeclarationFactory() { + public Factory getVariableDeclarationFactory() { return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType()); } - public VariableFactory getVariableFactory() { + public Factory getVariableFactory() { return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), /*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts()); } - public VariableInitializationFactory getVariableInitializationFactory() { - return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(), - getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe()); + public Factory getVariableInitializationFactory() { + return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(), + getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe()); } - public TryCatchBlockFactory getTryCatchBlockFactory() { + public Factory getTryCatchBlockFactory() { return new TryCatchBlockFactory(getOwnerClass(), getResultType(), getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false), getCanHaveBreaks(), @@ -570,11 +619,6 @@ return this; } - public IRNodeBuilder setPrinterName(String value) { - printerName = Optional.of(value); - return this; - } - public IRNodeBuilder setSemicolon(boolean value) { semicolon = Optional.of(value); return this; @@ -698,9 +742,4 @@ return functionInfo.orElseThrow(() -> new IllegalArgumentException( "FunctionInfo wasn't set")); } - - private String getPrinterName() { - return printerName.orElseThrow(() -> new IllegalArgumentException( - "printerName wasn't set")); - } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IfFactory.java 2016-05-12 04:24:27.818334585 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IfFactory.java 2016-05-12 04:24:27.730334586 +0300 @@ -23,21 +23,22 @@ package jdk.test.lib.jittester.factories; +import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.If; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; -class IfFactory extends SafeFactory { - protected long complexityLimit; - protected int statementLimit; - protected int operatorLimit; - protected boolean canHaveBreaks; - protected boolean canHaveContinues; - protected boolean canHaveReturn; +class IfFactory extends SafeFactory { + protected final long complexityLimit; + protected final int statementLimit; + protected final int operatorLimit; + protected final boolean canHaveBreaks; + protected final boolean canHaveContinues; + protected final boolean canHaveReturn; protected final TypeKlass ownerClass; protected final Type returnType; protected final int level; @@ -57,7 +58,7 @@ } @Override - public IRNode sproduce() throws ProductionFailedException { + public If sproduce() throws ProductionFailedException { // resizeUpChildren(If.IfPart.values().length); if (statementLimit > 0 && complexityLimit > 0) { long conditionComplLimit = (long) (0.01 * PseudoRandom.random() * (complexityLimit - 1)); @@ -65,7 +66,7 @@ .setOwnerKlass(ownerClass) .setOperatorLimit(operatorLimit); IRNode condition = builder.setComplexityLimit(conditionComplLimit) - .setResultType(new TypeBoolean()) + .setResultType(TypeList.BOOLEAN) .setExceptionSafe(false) .setNoConsts(false) .getLimitedExpressionFactory() @@ -83,7 +84,7 @@ controlDeviation = PseudoRandom.randomBoolean() ? If.IfPart.THEN : If.IfPart.ELSE; } if (ifBlockLimit > 0 && ifBlockComplLimit > 0) { - IRNode thenBlock = null; + Block thenBlock; builder.setResultType(returnType) .setLevel(level) .setComplexityLimit(ifBlockComplLimit) @@ -104,7 +105,7 @@ .produce(); } // setChild(If.IfPart.THEN.ordinal(), thenBlock); - IRNode elseBlock = null; + Block elseBlock = null; if (elseBlockLimit > 0 && elseBlockComplLimit > 0) { builder.setComplexityLimit(elseBlockComplLimit) .setStatementLimit(elseBlockLimit); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IncDecOperatorFactory.java 2016-05-12 04:24:28.174334582 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/IncDecOperatorFactory.java 2016-05-12 04:24:28.082334583 +0300 @@ -23,14 +23,12 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeBoolean; class IncDecOperatorFactory extends UnaryOperatorFactory { IncDecOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit, @@ -40,11 +38,11 @@ @Override protected boolean isApplicable(Type resultType) { - return TypeList.isBuiltInInt(resultType) && !resultType.equals(new TypeBoolean()); + return TypeList.isBuiltInInt(resultType) && !resultType.equals(TypeList.BOOLEAN); } @Override - protected IRNode generateProduction(Type l) throws ProductionFailedException { + protected UnaryOperator generateProduction(Type l) throws ProductionFailedException { return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1) .setOperatorLimit(operatorLimit - 1) .setOwnerKlass((TypeKlass) ownerClass) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/InterfaceFactory.java 2016-05-12 04:24:28.734334578 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/InterfaceFactory.java 2016-05-12 04:24:28.646334579 +0300 @@ -37,7 +37,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class InterfaceFactory extends Factory { +class InterfaceFactory extends Factory { private final String name; private final int memberFunctionsLimit; private final int memberFunctionsArgLimit; @@ -52,7 +52,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Interface produce() throws ProductionFailedException { TypeKlass thisKlass; // Do we want to inherit something? if (!ProductionParams.disableInheritance.value()) { @@ -76,7 +76,7 @@ parent.addChild(name); for (Symbol symbol : SymbolTable.getAllCombined(parent, FunctionInfo.class)) { FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy(); - functionInfo.klass = thisKlass; + functionInfo.owner = thisKlass; functionInfo.argTypes.get(0).type = thisKlass; SymbolTable.add(functionInfo); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/KlassFactory.java 2016-05-12 04:24:29.190334574 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/KlassFactory.java 2016-05-12 04:24:29.102334575 +0300 @@ -42,9 +42,8 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class KlassFactory extends Factory { +class KlassFactory extends Factory { private final String name; - private final String printerName; private final long complexityLimit; private final int statementsInFunctionLimit; private final int operatorLimit; @@ -55,11 +54,10 @@ private TypeKlass parent; private int memberFunctionsLimit; - KlassFactory(String name, String printerName, long complexityLimit, + KlassFactory(String name, long complexityLimit, int memberFunctionsLimit, int memberFunctionsArgLimit, int statementsInFunctionLimit, int operatorLimit, int level) { this.name = name; - this.printerName = printerName; this.complexityLimit = complexityLimit; this.memberFunctionsLimit = memberFunctionsLimit; this.memberFunctionsArgLimit = memberFunctionsArgLimit; @@ -70,7 +68,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Klass produce() throws ProductionFailedException { HashSet abstractSet = new HashSet<>(); HashSet overrideSet = new HashSet<>(); thisKlass = new TypeKlass(name); @@ -135,15 +133,11 @@ SymbolTable.remove(symbol); } } else { - parent = (TypeKlass) TypeList.find("java.lang.Object"); + parent = TypeList.OBJECT; thisKlass.addParent(parent.getName()); thisKlass.setParent(parent); parent.addChild(name); } - // Just don't print it. It's assumed that we at least are inherited from Object. - if (parent.getName().equals("java.lang.Object")) { - parent = null; - } SymbolTable.add(new VariableInfo("this", thisKlass, thisKlass, VariableInfo.FINAL | VariableInfo.LOCAL | VariableInfo.INITIALIZED)); IRNode variableDeclarations = null; @@ -152,8 +146,7 @@ IRNode functionDeclarations = null; IRNode abstractFunctionsRedefinitions = null; IRNode overridenFunctionsRedefinitions = null; - IRNodeBuilder builder = new IRNodeBuilder().setPrinterName(printerName) - .setOwnerKlass(thisKlass) + IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(thisKlass) .setExceptionSafe(true); try { builder.setLevel(level + 1) @@ -227,7 +220,7 @@ } } if (probableParents.isEmpty()) { - parent = (TypeKlass) TypeList.find("java.lang.Object"); + parent = TypeList.OBJECT; } else { parent = (TypeKlass) PseudoRandom.randomElement(probableParents); } @@ -246,7 +239,7 @@ functionInfo.argTypes.get(0).type = thisKlass; } } - symbolCopy.klass = thisKlass; + symbolCopy.owner = thisKlass; SymbolTable.add(symbolCopy); } } @@ -276,10 +269,9 @@ interfaces.add(iface); iface.addChild(name); thisKlass.addParent(iface.getName()); - thisKlass.setParent(iface); for (Symbol symbol : SymbolTable.getAllCombined(iface, FunctionInfo.class)) { FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy(); - functionInfo.klass = thisKlass; + functionInfo.owner = thisKlass; functionInfo.argTypes.get(0).type = thisKlass; SymbolTable.add(functionInfo); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java 2016-05-12 04:24:29.734334570 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LiteralFactory.java 2016-05-12 04:24:29.646334571 +0300 @@ -23,23 +23,16 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.types.TypeBoolean; -import jdk.test.lib.jittester.types.TypeByte; -import jdk.test.lib.jittester.types.TypeChar; -import jdk.test.lib.jittester.types.TypeDouble; -import jdk.test.lib.jittester.types.TypeFloat; -import jdk.test.lib.jittester.types.TypeInt; -import jdk.test.lib.jittester.types.TypeLong; -import jdk.test.lib.jittester.types.TypeShort; import jdk.test.lib.jittester.utils.PseudoRandom; -class LiteralFactory extends Factory { +import java.util.Locale; + +class LiteralFactory extends Factory { protected final Type resultType; LiteralFactory(Type resultType) { @@ -47,31 +40,39 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Literal produce() throws ProductionFailedException { Literal literal; - if (resultType.equals(new TypeBoolean())) { - literal = new Literal(PseudoRandom.randomBoolean(), new TypeBoolean()); - } else if (resultType.equals(new TypeChar())) { - literal = new Literal((char) ((char) (PseudoRandom.random() * ('z' - 'A')) + 'A'), new TypeChar()); - } else if (resultType.equals(new TypeInt())) { - literal = new Literal((int) (PseudoRandom.random() * Integer.MAX_VALUE), new TypeInt()); - } else if (resultType.equals(new TypeLong())) { - literal = new Literal((long) (PseudoRandom.random() * Long.MAX_VALUE), new TypeLong()); - } else if (resultType.equals(new TypeFloat())) { - literal = new Literal((float) (PseudoRandom.random() * Float.MAX_VALUE), new TypeFloat()); - } else if (resultType.equals(new TypeDouble())) { - literal = new Literal(PseudoRandom.random() * Double.MAX_VALUE, new TypeDouble()); - } else if (resultType.equals(new TypeByte())) { - literal = new Literal((byte)(PseudoRandom.random() * Byte.MAX_VALUE),new TypeByte()); - } else if (resultType.equals(new TypeShort())) { - literal = new Literal((short)(PseudoRandom.random() * Short.MAX_VALUE), new TypeShort()); - } else if (resultType.equals(TypeList.find("java.lang.String"))) { + if (resultType.equals(TypeList.BOOLEAN)) { + literal = new Literal(PseudoRandom.randomBoolean(), TypeList.BOOLEAN); + } else if (resultType.equals(TypeList.CHAR)) { + literal = new Literal((char) ((char) (PseudoRandom.random() * ('z' - 'A')) + 'A'), TypeList.CHAR); + } else if (resultType.equals(TypeList.INT)) { + literal = new Literal((int) (PseudoRandom.random() * Integer.MAX_VALUE), TypeList.INT); + } else if (resultType.equals(TypeList.LONG)) { + literal = new Literal((long) (PseudoRandom.random() * Long.MAX_VALUE), TypeList.LONG); + } else if (resultType.equals(TypeList.FLOAT)) { + literal = new Literal(new Float(String.format( + (Locale) null, + "%." + ProductionParams.floatingPointPrecision.value() + "EF", + (float) PseudoRandom.random() * Float.MAX_VALUE)), + TypeList.FLOAT); + } else if (resultType.equals(TypeList.DOUBLE)) { + literal = new Literal(new Double(String.format( + (Locale) null, + "%." + 2 * ProductionParams.floatingPointPrecision.value() + "E", + PseudoRandom.random() * Double.MAX_VALUE)), + TypeList.DOUBLE); + } else if (resultType.equals(TypeList.BYTE)) { + literal = new Literal((byte)(PseudoRandom.random() * Byte.MAX_VALUE), TypeList.BYTE); + } else if (resultType.equals(TypeList.SHORT)) { + literal = new Literal((short)(PseudoRandom.random() * Short.MAX_VALUE), TypeList.SHORT); + } else if (resultType.equals(TypeList.STRING)) { int size = (int) (PseudoRandom.random() * ProductionParams.stringLiteralSizeLimit.value()); byte[] str = new byte[size]; for (int i = 0; i < size; i++) { str[i] = (byte) ((int) (('z' - 'a') * PseudoRandom.random()) + 'a'); } - literal = new Literal("\"" + new String(str) + "\"", TypeList.find("java.lang.String")); + literal = new Literal(new String(str), TypeList.STRING); } else { throw new ProductionFailedException(); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LocalVariableFactory.java 2016-05-12 04:24:30.098334567 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LocalVariableFactory.java 2016-05-12 04:24:30.010334568 +0300 @@ -24,7 +24,7 @@ package jdk.test.lib.jittester.factories; import java.util.ArrayList; -import jdk.test.lib.jittester.IRNode; + import jdk.test.lib.jittester.LocalVariable; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Symbol; @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.utils.PseudoRandom; -class LocalVariableFactory extends Factory { +class LocalVariableFactory extends Factory { private final Type type; private final int flags; @@ -43,7 +43,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public LocalVariable produce() throws ProductionFailedException { // Get the variables of the requested type from SymbolTable ArrayList allVariables = new ArrayList<>(SymbolTable.get(type, VariableInfo.class)); if (!allVariables.isEmpty()) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LogicOperatorFactory.java 2016-05-12 04:24:30.662334563 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LogicOperatorFactory.java 2016-05-12 04:24:30.570334563 +0300 @@ -23,15 +23,15 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Operator; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.types.TypeKlass; -class LogicOperatorFactory extends Factory { - private final Rule rule; +class LogicOperatorFactory extends Factory { + private final Rule rule; LogicOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException { @@ -42,7 +42,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(noconsts); - rule = new Rule("arithmetic"); + rule = new Rule<>("arithmetic"); rule.add("land", builder.setOperatorKind(OperatorKind.AND).getBinaryOperatorFactory()); rule.add("lor", builder.setOperatorKind(OperatorKind.OR).getBinaryOperatorFactory()); rule.add("greater", builder.setOperatorKind(OperatorKind.GT).getBinaryOperatorFactory()); @@ -55,7 +55,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Operator produce() throws ProductionFailedException { return rule.produce(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LogicalInversionOperatorFactory.java 2016-05-12 04:24:30.966334560 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LogicalInversionOperatorFactory.java 2016-05-12 04:24:30.890334561 +0300 @@ -23,12 +23,11 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.UnaryOperator; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; class LogicalInversionOperatorFactory extends UnaryOperatorFactory { @@ -39,11 +38,11 @@ @Override protected boolean isApplicable(Type resultType) { - return resultType.equals(new TypeBoolean()); + return resultType.equals(TypeList.BOOLEAN); } @Override - protected IRNode generateProduction(Type resultType) throws ProductionFailedException { + protected UnaryOperator generateProduction(Type resultType) throws ProductionFailedException { return new UnaryOperator(opKind, new ExpressionFactory(complexityLimit - 1, operatorLimit - 1, (TypeKlass) ownerClass, resultType, exceptionSafe, noconsts).produce()); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LoopingConditionFactory.java 2016-05-12 04:24:31.310334557 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/LoopingConditionFactory.java 2016-05-12 04:24:31.226334558 +0300 @@ -29,12 +29,12 @@ import jdk.test.lib.jittester.LocalVariable; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.loops.LoopingCondition; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; -class LoopingConditionFactory extends Factory { +class LoopingConditionFactory extends Factory { private final LocalVariable counter; private final Literal limiter; private final int operatorLimit; @@ -51,11 +51,11 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public LoopingCondition produce() throws ProductionFailedException { IRNode leftExpression = null; IRNode rightExpression = null; - LimitedExpressionFactory exprFactory = new IRNodeBuilder() - .setResultType(new TypeBoolean()) + Factory exprFactory = new IRNodeBuilder() + .setResultType(TypeList.BOOLEAN) .setComplexityLimit((complexityLimit - 1) / 2) .setOperatorLimit((operatorLimit - 1) / 2) .setOwnerKlass(ownerClass) @@ -75,10 +75,10 @@ // Just as a temporary solution we'll assume that the counter is monotonically increasing. // And use counter < n condition to limit the loop. // In future we may introduce other equivalent relations as well. - IRNode condition = new BinaryOperator(OperatorKind.LT, counter, limiter); - condition = (rightExpression != null) ? new BinaryOperator(OperatorKind.AND, condition, + BinaryOperator condition = new BinaryOperator(OperatorKind.LT, TypeList.BOOLEAN, counter, limiter); + condition = (rightExpression != null) ? new BinaryOperator(OperatorKind.AND, TypeList.BOOLEAN, condition, rightExpression) : condition; - condition = (leftExpression != null) ? new BinaryOperator(OperatorKind.AND, leftExpression, + condition = (leftExpression != null) ? new BinaryOperator(OperatorKind.AND, TypeList.BOOLEAN, leftExpression, condition) : condition; return new LoopingCondition(condition); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/MainKlassFactory.java 2016-05-12 04:24:31.878334553 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/MainKlassFactory.java 2016-05-12 04:24:31.702334554 +0300 @@ -38,10 +38,9 @@ import jdk.test.lib.jittester.classes.MainKlass; import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class MainKlassFactory extends Factory { +class MainKlassFactory extends Factory { private final String name; private final long complexityLimit; private final int statementsInTestFunctionLimit; @@ -64,8 +63,8 @@ } @Override - public IRNode produce() throws ProductionFailedException { - TypeKlass parent = (TypeKlass) TypeList.find("java.lang.Object"); + public MainKlass produce() throws ProductionFailedException { + TypeKlass parent = TypeList.OBJECT; thisKlass = new TypeKlass(name); thisKlass.addParent(parent.getName()); thisKlass.setParent(parent); @@ -80,8 +79,7 @@ .setMemberFunctionsArgLimit(memberFunctionsArgLimit) .setStatementLimit(statementsInFunctionLimit) .setLevel(1) - .setExceptionSafe(true) - .setPrinterName("Printer"); + .setExceptionSafe(true); IRNode variableDeclarations = builder .setComplexityLimit((long) (complexityLimit * 0.05)) .getVariableDeclarationBlockFactory().produce(); @@ -93,7 +91,7 @@ .getFunctionDefinitionBlockFactory() .produce(); } - IRNode testFunction = builder.setResultType(new TypeVoid()) + IRNode testFunction = builder.setResultType(TypeList.VOID) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInTestFunctionLimit) .getBlockFactory() @@ -109,6 +107,7 @@ childs.add(printVariables); ensureMinDepth(childs, builder); ensureMaxDepth(childs); + TypeList.add(thisKlass); return new MainKlass(name, thisKlass, variableDeclarations, functionDefinitions, testFunction, printVariables); } @@ -119,7 +118,7 @@ .filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth) .collect(Collectors.toList()); for (IRNode child : filtered) { - List leaves = null; + List leaves; do { long depth = Math.max(child.countDepth(), maxDepth + 1); leaves = child.getDeviantBlocks(depth); @@ -138,16 +137,14 @@ private void addMoreChildren(List childs, int minDepth, IRNodeBuilder builder) throws ProductionFailedException { while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) { - PseudoRandom.shuffle(childs); - IRNode randomChild = childs.get(0); + IRNode randomChild = childs.get(PseudoRandom.randomNotNegative(childs.size())); List leaves = randomChild.getStackableLeaves(); if (!leaves.isEmpty()) { - PseudoRandom.shuffle(leaves); - Block randomLeaf = (Block) leaves.get(0); - TypeKlass klass = (TypeKlass) randomChild.getKlass(); + Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size())); + TypeKlass owner = randomChild.getOwner(); int newLevel = randomLeaf.getLevel() + 1; - Type retType = randomLeaf.getReturnType(); - IRNode newBlock = builder.setOwnerKlass(klass) + Type retType = randomLeaf.getResultType(); + IRNode newBlock = builder.setOwnerKlass(owner) .setResultType(retType) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInFunctionLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/NonStaticMemberVariableFactory.java 2016-05-12 04:24:32.474334548 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/NonStaticMemberVariableFactory.java 2016-05-12 04:24:32.258334550 +0300 @@ -34,7 +34,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class NonStaticMemberVariableFactory extends Factory { +class NonStaticMemberVariableFactory extends Factory { private final Type type; private final int flags; private final long complexityLimit; @@ -53,7 +53,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public NonStaticMemberVariable produce() throws ProductionFailedException { // Get the variables of the requested type from SymbolTable ArrayList variables = new ArrayList<>(SymbolTable.get(type, VariableInfo.class)); if (!variables.isEmpty()) { @@ -70,7 +70,7 @@ && (varInfo.flags & VariableInfo.STATIC) == 0 && (varInfo.flags & VariableInfo.LOCAL) == 0) { try { - IRNode object = builder.setResultType(varInfo.klass) + IRNode object = builder.setResultType(varInfo.owner) .getExpressionFactory().produce(); return new NonStaticMemberVariable(object, varInfo); } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/NothingFactory.java 2016-05-12 04:24:32.750334546 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/NothingFactory.java 2016-05-12 04:24:32.670334546 +0300 @@ -26,7 +26,7 @@ import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; -public class NothingFactory extends Factory { +public class NothingFactory extends Factory { @Override public Nothing produce() throws ProductionFailedException { return new Nothing(); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/OperatorFactory.java 2016-05-12 04:24:33.042334543 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/OperatorFactory.java 2016-05-12 04:24:32.962334544 +0300 @@ -23,12 +23,14 @@ package jdk.test.lib.jittester.factories; -public abstract class OperatorFactory extends Factory { - protected long complexityLimit; - protected boolean exceptionSafe; - protected boolean noconsts; +import jdk.test.lib.jittester.Operator; + +public abstract class OperatorFactory extends Factory { + protected final long complexityLimit; + protected final boolean exceptionSafe; + protected final boolean noconsts; + protected final int operatorPriority; protected int operatorLimit; - protected int operatorPriority; protected OperatorFactory(int operatorPriority, long complexityLimit, int operatorLimit, boolean exceptionSafe, boolean noconsts) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/PrintVariablesFactory.java 2016-05-12 04:24:33.386334541 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/PrintVariablesFactory.java 2016-05-12 04:24:33.290334541 +0300 @@ -23,27 +23,21 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.PrintVariables; import jdk.test.lib.jittester.ProductionFailedException; -import jdk.test.lib.jittester.SymbolTable; -import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.types.TypeKlass; -class PrintVariablesFactory extends Factory { - private final String printerName; +class PrintVariablesFactory extends Factory { private final TypeKlass ownerClass; private final int level; - PrintVariablesFactory(String printerName, TypeKlass ownerClass, int level) { - this.printerName = printerName; + PrintVariablesFactory(TypeKlass ownerClass, int level) { this.ownerClass = ownerClass; this.level = level; } @Override - public IRNode produce() throws ProductionFailedException { - return new PrintVariables(printerName, SymbolTable.getAllCombined(ownerClass, - VariableInfo.class), level); + public PrintVariables produce() throws ProductionFailedException { + return new PrintVariables(ownerClass, level); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ReturnFactory.java 2016-05-12 04:24:33.762334538 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ReturnFactory.java 2016-05-12 04:24:33.690334538 +0300 @@ -23,13 +23,12 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.functions.Return; import jdk.test.lib.jittester.types.TypeKlass; -class ReturnFactory extends SafeFactory { +class ReturnFactory extends SafeFactory { private final long complexityLimit; private final int operatorLimit; private final Type resultType; @@ -46,7 +45,7 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected Return sproduce() throws ProductionFailedException { return new Return(new IRNodeBuilder().setComplexityLimit(complexityLimit - 1) .setOperatorLimit(operatorLimit - 1) .setOwnerKlass(ownerClass) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SafeFactory.java 2016-05-12 04:24:34.062334535 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SafeFactory.java 2016-05-12 04:24:33.998334536 +0300 @@ -27,14 +27,14 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; -public abstract class SafeFactory extends Factory { - protected abstract IRNode sproduce() throws ProductionFailedException; +public abstract class SafeFactory extends Factory { + protected abstract T sproduce() throws ProductionFailedException; @Override - public IRNode produce() throws ProductionFailedException { + public T produce() throws ProductionFailedException { try { SymbolTable.push(); - IRNode p = sproduce(); + T p = sproduce(); SymbolTable.merge(); return p; } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StatementFactory.java 2016-05-12 04:24:34.458334532 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StatementFactory.java 2016-05-12 04:24:34.374334533 +0300 @@ -32,15 +32,15 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class StatementFactory extends Factory { - private final Rule rule; +class StatementFactory extends Factory { + private final Rule rule; private final boolean needSemicolon; StatementFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, boolean exceptionSafe, boolean noconsts, boolean needSemicolon ){ this.needSemicolon = needSemicolon; - rule = new Rule("statement"); + rule = new Rule<>("statement"); IRNodeBuilder builder = new IRNodeBuilder() .setComplexityLimit(complexityLimit) .setOperatorLimit(operatorLimit) @@ -54,7 +54,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public Statement produce() throws ProductionFailedException { ProductionLimiter.setLimit(); try { return new Statement(rule.produce(), needSemicolon); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StaticConstructorDefinitionFactory.java 2016-05-12 04:24:35.006334528 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StaticConstructorDefinitionFactory.java 2016-05-12 04:24:34.902334529 +0300 @@ -26,13 +26,13 @@ import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.functions.StaticConstructorDefinition; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; -class StaticConstructorDefinitionFactory extends Factory { +class StaticConstructorDefinitionFactory extends Factory { private final long complexityLimit; private final int statementLimit; private final int operatorLimit; @@ -49,7 +49,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public StaticConstructorDefinition produce() throws ProductionFailedException { SymbolTable.push(); IRNode body; try { @@ -57,7 +57,7 @@ long complLimit = (long) (PseudoRandom.random() * complexityLimit); body = new IRNodeBuilder() .setOwnerKlass(ownerClass) - .setResultType(new TypeVoid()) + .setResultType(TypeList.VOID) .setComplexityLimit(complLimit) .setStatementLimit(statementLimit) .setOperatorLimit(operatorLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StaticMemberVariableFactory.java 2016-05-12 04:24:35.630334523 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/StaticMemberVariableFactory.java 2016-05-12 04:24:35.498334524 +0300 @@ -24,7 +24,7 @@ package jdk.test.lib.jittester.factories; import java.util.ArrayList; -import jdk.test.lib.jittester.IRNode; + import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.StaticMemberVariable; import jdk.test.lib.jittester.Symbol; @@ -34,7 +34,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class StaticMemberVariableFactory extends Factory { +class StaticMemberVariableFactory extends Factory { private final Type type; private final int flags; private final Type ownerClass; @@ -46,7 +46,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public StaticMemberVariable produce() throws ProductionFailedException { // Get the variables of the requested type from SymbolTable ArrayList variables = new ArrayList<>(SymbolTable.get(type, VariableInfo.class)); if (!variables.isEmpty()) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java 2016-05-12 04:24:36.358334517 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java 2016-05-12 04:24:36.222334518 +0300 @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; + import jdk.test.lib.jittester.BuiltInType; import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.Literal; @@ -34,21 +35,18 @@ import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Switch; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeByte; -import jdk.test.lib.jittester.types.TypeChar; -import jdk.test.lib.jittester.types.TypeInt; -import jdk.test.lib.jittester.types.TypeShort; import jdk.test.lib.jittester.utils.PseudoRandom; -class SwitchFactory extends SafeFactory { - private int caseBlockIdx; - protected long complexityLimit; - protected int statementLimit, operatorLimit; - private boolean canHaveReturn = false; +class SwitchFactory extends SafeFactory { + private final int statementLimit; + private final int operatorLimit; + private final boolean canHaveReturn; private final TypeKlass ownerClass; private final int level; + private final long complexityLimit; SwitchFactory(TypeKlass ownerClass, long complexityLimit, int statementLimit, int operatorLimit, int level, boolean canHaveReturn) { @@ -61,13 +59,13 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected Switch sproduce() throws ProductionFailedException { if (statementLimit > 0 && complexityLimit > 0) { List switchTypes = new ArrayList<>(); - switchTypes.add(new TypeChar()); - switchTypes.add(new TypeByte()); - switchTypes.add(new TypeShort()); - switchTypes.add(new TypeInt()); + switchTypes.add(TypeList.CHAR); + switchTypes.add(TypeList.BYTE); + switchTypes.add(TypeList.SHORT); + switchTypes.add(TypeList.INT); PseudoRandom.shuffle(switchTypes); IRNodeBuilder builder = new IRNodeBuilder() .setOwnerKlass(ownerClass) @@ -95,8 +93,8 @@ .produce(); accumulatedComplexity += currentComplexityLimit; List caseTypes = new ArrayList<>(); - caseTypes.add(new TypeByte()); - caseTypes.add(new TypeChar()); + caseTypes.add(TypeList.BYTE); + caseTypes.add(TypeList.CHAR); caseTypes = new ArrayList<>(TypeUtil.getLessCapaciousOrEqualThan(caseTypes, (BuiltInType) type)); if (PseudoRandom.randomBoolean()) { // "default" @@ -104,7 +102,7 @@ * (statementLimit - accumulatedStatements)); currentComplexityLimit = (long) (PseudoRandom.random() * (complexityLimit - accumulatedComplexity)); - caseConsts.add(null); + caseConsts.add(new Nothing()); caseBlocks.add(builder.setComplexityLimit(currentComplexityLimit) .setStatementLimit(currentStatementsLimit) .setLevel(level + 1) @@ -128,7 +126,7 @@ if (tryCount >= 10) { continue MAIN_LOOP; } - Literal literal = (Literal) builder.setResultType(caseTypes.get(0)) + Literal literal = builder.setResultType(caseTypes.get(0)) .getLiteralFactory().produce(); int value = 0; if (literal.value instanceof Integer) { @@ -149,7 +147,7 @@ break; } } - Rule rule = new Rule("case_block"); + Rule rule = new Rule<>("case_block"); rule.add("block", builder.setComplexityLimit(currentComplexityLimit) .setStatementLimit(currentStatementsLimit) .setLevel(level) @@ -170,7 +168,7 @@ } PseudoRandom.shuffle(caseConsts); List accum = new ArrayList<>(); - caseBlockIdx = 1 + caseConsts.size(); + int caseBlockIdx = 1 + caseConsts.size(); accum.add(switchExp); for (int i = 1; i < caseBlockIdx; ++i) { accum.add(caseConsts.get(i - 1)); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java 2016-05-12 04:24:40.414334484 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java 2016-05-12 04:24:40.074334487 +0300 @@ -23,21 +23,18 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.Pair; import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.TernaryOperator; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; -class TernaryOperatorFactory extends OperatorFactory { - protected final Type resultType; - protected final TypeKlass ownerClass; +class TernaryOperatorFactory extends OperatorFactory { + private final Type resultType; + private final TypeKlass ownerClass; TernaryOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe, boolean noconsts) { @@ -46,15 +43,7 @@ this.ownerClass = ownerClass; } - private Pair generateTypes() { - Pair types = new Pair<>(resultType, PseudoRandom.randomElement( - TypeUtil.getImplicitlyCastable(TypeList.getAll(), resultType))); - if (PseudoRandom.randomBoolean()) - types = new Pair<>(types.second, types.first); - return types; - } - - private IRNode generateProduction(Type conditionType, Type leftType, Type rightType) throws ProductionFailedException { + private TernaryOperator generateProduction() throws ProductionFailedException { int leftOpLimit = (int) (PseudoRandom.random() * 0.3 * (operatorLimit - 1)); int rightOpLimit = (int) (PseudoRandom.random() * 0.3 * (operatorLimit - 1)); int condOpLimit = operatorLimit - 1 - leftOpLimit - rightOpLimit; @@ -69,7 +58,7 @@ .setExceptionSafe(exceptionSafe); IRNode conditionalExp = builder.setComplexityLimit(condComplLimit) .setOperatorLimit(condOpLimit) - .setResultType(conditionType) + .setResultType(TypeList.BOOLEAN) .setNoConsts(noconsts) .getExpressionFactory() .produce(); @@ -79,7 +68,7 @@ try { leftExp = builder.setComplexityLimit(leftComplLimit) .setOperatorLimit(leftOpLimit) - .setResultType(leftType) + .setResultType(resultType) .setNoConsts(false) .getExpressionFactory() .produce(); @@ -91,7 +80,7 @@ try { rightExp = builder.setComplexityLimit(rightComplLimit) .setOperatorLimit(rightOpLimit) - .setResultType(rightType) + .setResultType(resultType) .setNoConsts(false) .getExpressionFactory() .produce(); @@ -102,16 +91,10 @@ } @Override - public IRNode produce() throws ProductionFailedException { - Pair types; - try { - types = generateTypes(); - } catch (RuntimeException ex) { - throw new ProductionFailedException(ex.getMessage()); - } + public TernaryOperator produce() throws ProductionFailedException { try { SymbolTable.push(); - IRNode result = generateProduction(new TypeBoolean(), types.first, types.second); + TernaryOperator result = generateProduction(); SymbolTable.merge(); return result; } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ThrowFactory.java 2016-05-12 04:24:41.234334478 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/ThrowFactory.java 2016-05-12 04:24:41.142334479 +0300 @@ -30,8 +30,8 @@ import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.types.TypeKlass; -class ThrowFactory extends SafeFactory { - private final Rule rule; +class ThrowFactory extends SafeFactory { + private final Rule rule; ThrowFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean exceptionSafe) { @@ -42,7 +42,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(false); - rule = new Rule("throw"); + rule = new Rule<>("throw"); rule.add("constant", b.setIsConstant(true).setIsInitialized(true).getVariableFactory()); rule.add("variable", b.setIsConstant(false).setIsInitialized(true).getVariableFactory()); @@ -51,7 +51,7 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected Throw sproduce() throws ProductionFailedException { return new Throw(rule.produce()); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java 2016-05-12 04:24:41.610334475 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java 2016-05-12 04:24:41.498334476 +0300 @@ -25,8 +25,9 @@ import java.util.ArrayList; import java.util.List; + +import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.CatchBlock; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.TryCatchBlock; import jdk.test.lib.jittester.Type; @@ -35,7 +36,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class TryCatchBlockFactory extends Factory { +class TryCatchBlockFactory extends Factory { private final static double CATCH_SELECTION_COEF = 0.1d; private final Type returnType; private final long complexityLimit; @@ -64,7 +65,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public TryCatchBlock produce() throws ProductionFailedException { if (complexityLimit < 1 || statementLimit < 1) { throw new ProductionFailedException(); } @@ -77,7 +78,7 @@ .setCanHaveReturn(canHaveReturn) .setCanHaveContinues(canHaveContinues) .setCanHaveBreaks(canHaveBreaks); - IRNode body = getBlock(builder, 0.6); + Block body = getBlock(builder, 0.6); int catchBlocksCount = (int) (CATCH_SELECTION_COEF * PseudoRandom.random() * uncheckedThrowables.size()); List catchBlocks = new ArrayList<>(); @@ -92,7 +93,7 @@ catchBlocks.add(new CatchBlock(getBlock(builder, 0.3/catchBlocksCount), whatToCatch, level)); } - IRNode finallyBody = PseudoRandom.randomBoolean() || catchBlocksCount == 0 ? getBlock(builder, 0.1) : null; + Block finallyBody = PseudoRandom.randomBoolean() || catchBlocksCount == 0 ? getBlock(builder, 0.1) : null; return new TryCatchBlock(body, finallyBody, catchBlocks, level); } @@ -106,7 +107,7 @@ return selected; } - private IRNode getBlock(IRNodeBuilder builder, double weight) + private Block getBlock(IRNodeBuilder builder, double weight) throws ProductionFailedException { long actualComplexityLim = (long) (weight * PseudoRandom.random() * complexityLimit); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryOperatorFactory.java 2016-05-12 04:24:42.182334470 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryOperatorFactory.java 2016-05-12 04:24:42.050334471 +0300 @@ -23,13 +23,13 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.UnaryOperator; -public abstract class UnaryOperatorFactory extends OperatorFactory { +public abstract class UnaryOperatorFactory extends OperatorFactory { protected final OperatorKind opKind; protected final Type resultType; protected final Type ownerClass; @@ -42,16 +42,16 @@ this.ownerClass = ownerClass; } - protected Type generateType() throws ProductionFailedException { + protected Type generateType() { return resultType; } - protected abstract IRNode generateProduction(Type type) throws ProductionFailedException; + protected abstract UnaryOperator generateProduction(Type type) throws ProductionFailedException; protected abstract boolean isApplicable(Type resultType); @Override - public IRNode produce() throws ProductionFailedException { + public UnaryOperator produce() throws ProductionFailedException { if (!isApplicable(resultType)) { //avoid implicit use of resultType.toString() throw new ProductionFailedException("Type " + resultType.getName() @@ -65,7 +65,7 @@ } try { SymbolTable.push(); - IRNode result = generateProduction(type); + UnaryOperator result = generateProduction(type); SymbolTable.merge(); return result; } catch (ProductionFailedException e) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java 2016-05-12 04:24:42.542334467 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java 2016-05-12 04:24:42.466334468 +0300 @@ -24,15 +24,12 @@ package jdk.test.lib.jittester.factories; import jdk.test.lib.jittester.BuiltInType; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; -import jdk.test.lib.jittester.types.TypeBoolean; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; @@ -44,16 +41,16 @@ @Override protected boolean isApplicable(Type resultType) { - if (!TypeList.isBuiltIn(resultType) || resultType.equals(new TypeBoolean())) { + if (!TypeList.isBuiltIn(resultType) || resultType.equals(TypeList.BOOLEAN)) { return false; } BuiltInType resType = (BuiltInType) resultType; - return resType.equals(new TypeInt()) || resType.isMoreCapaciousThan(new TypeInt()); + return resType.equals(TypeList.INT) || resType.isMoreCapaciousThan(TypeList.INT); } @Override - protected Type generateType() throws ProductionFailedException { - if (resultType.equals(new TypeInt())) { + protected Type generateType() { + if (resultType.equals(TypeList.INT)) { return PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType)); } else { return resultType; @@ -61,7 +58,7 @@ } @Override - protected IRNode generateProduction(Type type) throws ProductionFailedException { + protected UnaryOperator generateProduction(Type type) throws ProductionFailedException { return new UnaryOperator(opKind, new IRNodeBuilder() .setComplexityLimit(complexityLimit) .setOperatorLimit(operatorLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableDeclarationBlockFactory.java 2016-05-12 04:24:42.966334464 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableDeclarationBlockFactory.java 2016-05-12 04:24:42.866334465 +0300 @@ -24,14 +24,15 @@ package jdk.test.lib.jittester.factories; import java.util.ArrayList; -import jdk.test.lib.jittester.IRNode; + +import jdk.test.lib.jittester.Declaration; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.VariableDeclarationBlock; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class VariableDeclarationBlockFactory extends Factory { +class VariableDeclarationBlockFactory extends Factory { private final long complexityLimit; private final int operatorLimit; private final boolean exceptionSafe; @@ -48,10 +49,10 @@ } @Override - public IRNode produce() throws ProductionFailedException { - ArrayList content = new ArrayList<>(); + public VariableDeclarationBlock produce() throws ProductionFailedException { + ArrayList content = new ArrayList<>(); int limit = (int) Math.ceil(PseudoRandom.random() * ProductionParams.dataMemberLimit.value()); - DeclarationFactory declFactory = new IRNodeBuilder() + Factory declFactory = new IRNodeBuilder() .setOwnerKlass(ownerClass) .setComplexityLimit(complexityLimit) .setOperatorLimit(operatorLimit) --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableDeclarationFactory.java 2016-05-12 04:24:43.390334460 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableDeclarationFactory.java 2016-05-12 04:24:43.306334461 +0300 @@ -24,7 +24,7 @@ package jdk.test.lib.jittester.factories; import java.util.LinkedList; -import jdk.test.lib.jittester.IRNode; + import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; @@ -34,10 +34,10 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class VariableDeclarationFactory extends Factory { - protected final boolean isStatic; - protected final boolean isLocal; - protected final TypeKlass ownerClass; +class VariableDeclarationFactory extends Factory { + private final boolean isStatic; + private final boolean isLocal; + private final TypeKlass ownerClass; private Type resultType; VariableDeclarationFactory(TypeKlass ownerClass, boolean isStatic, boolean isLocal, Type resultType) { @@ -48,8 +48,8 @@ } @Override - public IRNode produce() throws ProductionFailedException { - if (resultType == TypeList.getVoid()) { + public VariableDeclaration produce() throws ProductionFailedException { + if (resultType.equals(TypeList.VOID)) { LinkedList types = new LinkedList<>(TypeList.getAll()); PseudoRandom.shuffle(types); if (types.isEmpty()) { --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableFactory.java 2016-05-12 04:24:43.950334456 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableFactory.java 2016-05-12 04:24:43.858334457 +0300 @@ -23,15 +23,15 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.VariableBase; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.types.TypeKlass; -class VariableFactory extends Factory { - private final Rule rule; +class VariableFactory extends Factory { + private final Rule rule; VariableFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType, boolean constant, boolean initialized, boolean exceptionSafe, boolean noconsts) { @@ -42,7 +42,7 @@ if (initialized) { flags |= VariableInfo.INITIALIZED; } - rule = new Rule("variable"); + rule = new Rule<>("variable"); IRNodeBuilder b = new IRNodeBuilder().setResultType(resultType) .setFlags(flags) .setComplexityLimit(complexityLimit) @@ -55,7 +55,7 @@ } @Override - public IRNode produce() throws ProductionFailedException { + public VariableBase produce() throws ProductionFailedException { return rule.produce(); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableInitializationFactory.java 2016-05-12 04:24:44.342334453 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/VariableInitializationFactory.java 2016-05-12 04:24:44.258334454 +0300 @@ -37,7 +37,7 @@ import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; -class VariableInitializationFactory extends SafeFactory { +class VariableInitializationFactory extends SafeFactory { private final int operatorLimit; private final long complexityLimit; private final boolean constant; @@ -58,7 +58,7 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected VariableInitialization sproduce() throws ProductionFailedException { LinkedList types = new LinkedList<>(TypeList.getAll()); PseudoRandom.shuffle(types); if (types.isEmpty()) { @@ -71,7 +71,7 @@ .setResultType(resultType) .setExceptionSafe(exceptionSafe) .setNoConsts(false); - Rule rule = new Rule("initializer"); + Rule rule = new Rule<>("initializer"); rule.add("literal_initializer", b.getLiteralFactory()); if (!ProductionParams.disableExprInInit.value()) { rule.add("expression", b.getLimitedExpressionFactory()); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/WhileFactory.java 2016-05-12 04:24:44.698334450 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/WhileFactory.java 2016-05-12 04:24:44.594334451 +0300 @@ -23,21 +23,21 @@ package jdk.test.lib.jittester.factories; -import jdk.test.lib.jittester.IRNode; -import jdk.test.lib.jittester.Initialization; +import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; -import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.loops.Loop; import jdk.test.lib.jittester.loops.While; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.utils.PseudoRandom; -class WhileFactory extends SafeFactory { +import java.util.LinkedList; + +class WhileFactory extends SafeFactory { private final Loop loop; private final long complexityLimit; private final int statementLimit; @@ -61,7 +61,8 @@ } @Override - protected IRNode sproduce() throws ProductionFailedException { + protected While sproduce() throws ProductionFailedException { + Block emptyBlock = new Block(ownerClass, returnType, new LinkedList<>(), level - 1); if (statementLimit <= 0 || complexityLimit <= 0) { throw new ProductionFailedException(); } @@ -91,7 +92,7 @@ .setResultType(returnType) .setOperatorLimit(operatorLimit); loop.initialization = builder.getCounterInitializerFactory(0).produce(); - IRNode header; + Block header; try { header = builder.setComplexityLimit(headerComplLimit) .setStatementLimit(headerStatementLimit) @@ -103,15 +104,15 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - header = new Nothing(); + header = emptyBlock; } - LocalVariable counter = new LocalVariable(((Initialization) loop.initialization).get()); - Literal limiter = new Literal(Integer.valueOf((int) thisLoopIterLimit), new TypeInt()); + LocalVariable counter = new LocalVariable(loop.initialization.getVariableInfo()); + Literal limiter = new Literal((int) thisLoopIterLimit, TypeList.INT); loop.condition = builder.setComplexityLimit(condComplLimit) .setLocalVariable(counter) .getLoopingConditionFactory(limiter) .produce(); - IRNode body1; + Block body1; SymbolTable.push(); try { body1 = builder.setComplexityLimit(body1ComplLimit) @@ -124,10 +125,10 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body1 = new Nothing(); + body1 = emptyBlock; } loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce(); - IRNode body2; + Block body2; try { body2 = builder.setComplexityLimit(body2ComplLimit) .setStatementLimit(body2StatementLimit) @@ -139,9 +140,9 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body2 = new Nothing(); + body2 = emptyBlock; } - IRNode body3; + Block body3; try { body3 = builder.setComplexityLimit(body3ComplLimit) .setStatementLimit(body3StatementLimit) @@ -153,7 +154,7 @@ .getBlockFactory() .produce(); } catch (ProductionFailedException e) { - body3 = new Nothing(); + body3 = emptyBlock; } SymbolTable.pop(); return new While(level, loop, thisLoopIterLimit, header, body1, body2, body3); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ArgumentDeclaration.java 2016-05-12 04:24:45.162334446 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ArgumentDeclaration.java 2016-05-12 04:24:45.070334447 +0300 @@ -28,9 +28,10 @@ import jdk.test.lib.jittester.visitors.Visitor; public class ArgumentDeclaration extends IRNode { - public VariableInfo variableInfo; + public final VariableInfo variableInfo; public ArgumentDeclaration(VariableInfo variableInfo) { + super(variableInfo.type); this.variableInfo = variableInfo; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ConstructorDefinition.java 2016-05-12 04:24:45.514334443 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ConstructorDefinition.java 2016-05-12 04:24:45.422334444 +0300 @@ -32,7 +32,9 @@ public ConstructorDefinition(FunctionInfo functionInfo, ArrayList argumentsDeclaration, IRNode body) { + super(functionInfo.type); this.functionInfo = functionInfo; + this.owner = functionInfo.owner; addChild(body); addChildren(argumentsDeclaration); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ConstructorDefinitionBlock.java 2016-05-12 04:24:45.990334440 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/ConstructorDefinitionBlock.java 2016-05-12 04:24:45.850334441 +0300 @@ -25,10 +25,12 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.visitors.Visitor; public class ConstructorDefinitionBlock extends IRNode { public ConstructorDefinitionBlock(ArrayList content, int level) { + super(TypeList.VOID); this.level = level; addChildren(content); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/Function.java 2016-05-12 04:24:46.678334434 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/Function.java 2016-05-12 04:24:46.570334435 +0300 @@ -36,7 +36,8 @@ private FunctionInfo functionInfo = new FunctionInfo(); public Function(TypeKlass ownerClass, FunctionInfo functionInfo, List args) { - setKlass(ownerClass); + super(functionInfo.type); + setOwner(ownerClass); this.functionInfo = functionInfo; addChildren(args); } @@ -48,14 +49,14 @@ argsComplexity += child.complexity(); } long funcComplexity = functionInfo.complexity; - TypeKlass typeKlass = (TypeKlass) this.klass; + TypeKlass typeKlass = this.owner; if (functionInfo.isConstructor()) { // Sum complexities of all default constructors of parent classes for (TypeKlass parent : typeKlass.getAllParents()) { Collection parentFuncs = SymbolTable.getAllCombined(parent, FunctionInfo.class); for (Symbol f : parentFuncs) { FunctionInfo c = (FunctionInfo) f; - if (c.name.equals(c.klass.getName()) && c.argTypes.isEmpty()) { + if (c.name.equals(c.owner.getName()) && c.argTypes.isEmpty()) { funcComplexity += c.complexity; } } @@ -66,7 +67,7 @@ for (TypeKlass child : typeKlass.getAllChildren()) { Collection childFuncs = SymbolTable.getAllCombined(child, FunctionInfo.class); for (Symbol childFunc : childFuncs) { - if (((FunctionInfo) childFunc).equals(functionInfo)) { + if (childFunc.equals(functionInfo)) { funcComplexity = Math.max(funcComplexity, ((FunctionInfo) childFunc).complexity); } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDeclaration.java 2016-05-12 04:24:47.214334430 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDeclaration.java 2016-05-12 04:24:47.118334431 +0300 @@ -32,7 +32,9 @@ public FunctionDeclaration(FunctionInfo functionInfo, ArrayList argumentsDeclaration) { + super(functionInfo.type); this.functionInfo = functionInfo; + this.owner = functionInfo.owner; addChildren(argumentsDeclaration); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDeclarationBlock.java 2016-05-12 04:24:47.658334426 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDeclarationBlock.java 2016-05-12 04:24:47.574334427 +0300 @@ -25,12 +25,14 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.visitors.Visitor; public class FunctionDeclarationBlock extends IRNode { public FunctionDeclarationBlock(TypeKlass ownerClass, ArrayList content, int level) { - setKlass(ownerClass); + super(TypeList.VOID); + setOwner(ownerClass); this.level = level; addChildren(content); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDefinition.java 2016-05-12 04:24:48.038334423 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDefinition.java 2016-05-12 04:24:47.926334424 +0300 @@ -23,9 +23,10 @@ package jdk.test.lib.jittester.functions; -import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; +import java.util.List; + import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.Symbol; import jdk.test.lib.jittester.SymbolTable; @@ -36,8 +37,10 @@ private final FunctionInfo functionInfo; public FunctionDefinition(FunctionInfo functionInfo, - ArrayList argumentsDeclaration, IRNode body, IRNode ret) { + List argumentsDeclaration, IRNode body, Return ret) { + super(functionInfo.type); this.functionInfo = functionInfo; + this.owner = functionInfo.owner; addChild(body); addChild(ret); addChildren(argumentsDeclaration); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDefinitionBlock.java 2016-05-12 04:24:48.470334420 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionDefinitionBlock.java 2016-05-12 04:24:48.386334420 +0300 @@ -25,12 +25,14 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.visitors.Visitor; public class FunctionDefinitionBlock extends IRNode { public FunctionDefinitionBlock(ArrayList content, int level, TypeKlass ownerClass) { - setKlass(ownerClass); + super(TypeList.VOID); + setOwner(ownerClass); addChildren(content); this.level = level; } @@ -44,10 +46,6 @@ return complexity; } - protected int size() { - return getChildren() != null ? getChildren().size() : 0; - } - @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionInfo.java 2016-05-12 04:24:48.930334416 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionInfo.java 2016-05-12 04:24:48.842334417 +0300 @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Arrays; + import jdk.test.lib.jittester.Symbol; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.VariableInfo; @@ -89,7 +90,7 @@ try { FunctionInfo f = (FunctionInfo) o; - return klass.equals(f.klass) && hasEqualSignature(o); + return owner.equals(f.owner) && hasEqualSignature(o); } catch (Exception e) { } return false; @@ -117,7 +118,7 @@ } public boolean isConstructor() { - return name.equals(klass.getName()); + return name.equals(owner.getName()); } @Override --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionRedefinition.java 2016-05-12 04:24:49.698334410 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionRedefinition.java 2016-05-12 04:24:49.378334413 +0300 @@ -23,16 +23,19 @@ package jdk.test.lib.jittester.functions; -import java.util.ArrayList; +import java.util.List; + import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.visitors.Visitor; public class FunctionRedefinition extends IRNode { private final FunctionInfo functionInfo; - protected FunctionRedefinition(FunctionInfo functionInfo, - ArrayList argumentsDeclaration, IRNode body, IRNode ret) { + public FunctionRedefinition(FunctionInfo functionInfo, + List argumentsDeclaration, IRNode body, Return ret) { + super(functionInfo.type); this.functionInfo = functionInfo; + this.owner = functionInfo.owner; addChild(body); addChild(ret); addChildren(argumentsDeclaration); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionRedefinitionBlock.java 2016-05-12 04:24:50.074334407 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/FunctionRedefinitionBlock.java 2016-05-12 04:24:50.002334408 +0300 @@ -25,10 +25,12 @@ import java.util.ArrayList; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.visitors.Visitor; public class FunctionRedefinitionBlock extends IRNode { public FunctionRedefinitionBlock(ArrayList content, int level) { + super(TypeList.VOID); this.level = level; addChildren(content); } @@ -42,10 +44,6 @@ return complexity; } - protected int size() { - return getChildren() != null ? getChildren().size() : 0; - } - @Override public T accept(Visitor v) { return v.visit(this); --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/Return.java 2016-05-12 04:24:50.570334403 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/Return.java 2016-05-12 04:24:50.470334404 +0300 @@ -30,6 +30,7 @@ private final IRNode returnExpression; public Return(IRNode returnExpression) { + super(returnExpression.getResultType()); this.returnExpression = returnExpression; addChild(returnExpression); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/StaticConstructorDefinition.java 2016-05-12 04:24:51.082334399 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/functions/StaticConstructorDefinition.java 2016-05-12 04:24:50.982334400 +0300 @@ -28,6 +28,8 @@ public class StaticConstructorDefinition extends IRNode { public StaticConstructorDefinition(IRNode body) { + super(body.getResultType()); + this.owner = body.getOwner(); addChild(body); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/CounterManipulator.java 2016-05-12 04:24:51.614334395 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/CounterManipulator.java 2016-05-12 04:24:51.518334395 +0300 @@ -25,6 +25,7 @@ import jdk.test.lib.jittester.IRNode; import jdk.test.lib.jittester.LocalVariable; +import jdk.test.lib.jittester.Statement; import jdk.test.lib.jittester.visitors.Visitor; /* @@ -36,7 +37,8 @@ public class CounterManipulator extends IRNode { LocalVariable counter; - public CounterManipulator(IRNode manipulator) { + public CounterManipulator(Statement manipulator) { + super(manipulator.getResultType()); addChild(manipulator); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/DoWhile.java 2016-05-12 04:24:52.846334385 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/DoWhile.java 2016-05-12 04:24:52.642334386 +0300 @@ -42,7 +42,7 @@ HEADER, BODY1, BODY2, - }; + } private final Loop loop; // header; [subblock] // do { @@ -52,8 +52,9 @@ // } while(condition); private long thisLoopIterLimit = 0; - public DoWhile(int level, Loop loop, long thisLoopIterLimit, IRNode header, - IRNode body1, IRNode body2) { + public DoWhile(int level, Loop loop, long thisLoopIterLimit, Block header, + Block body1, Block body2) { + super(body1.getResultType()); this.level = level; this.loop = loop; this.thisLoopIterLimit = thisLoopIterLimit; @@ -85,13 +86,12 @@ IRNode header = getChildren().get(DoWhilePart.HEADER.ordinal()); List siblings = getParent().getChildren(); int index = siblings.indexOf(this); + siblings.set(index++, loop.initialization); if (header instanceof Block) { - siblings.remove(this); siblings.addAll(index, header.getChildren()); } else { - siblings.set(index, header); + siblings.add(index, header); } - siblings.add(index + header.getChildren().size(), loop.initialization); return true; } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/For.java 2016-05-12 04:24:53.906334376 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/For.java 2016-05-12 04:24:53.714334378 +0300 @@ -26,6 +26,7 @@ import java.util.List; import jdk.test.lib.jittester.Block; import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Statement; import jdk.test.lib.jittester.visitors.Visitor; public class For extends IRNode { @@ -45,7 +46,7 @@ BODY1, BODY2, BODY3, - }; + } private final Loop loop; // header; // [subblock] @@ -57,8 +58,9 @@ // } private long thisLoopIterLimit = 0; public For(int level, Loop loop, long thisLoopIterLimit, - IRNode header, IRNode statement1, - IRNode statement2, IRNode body1, IRNode body2, IRNode body3) { + Block header, Statement statement1, + Statement statement2, Block body1, Block body2, Block body3) { + super(body1.getResultType()); this.level = level; this.loop = loop; this.thisLoopIterLimit = thisLoopIterLimit; @@ -100,13 +102,12 @@ IRNode header = getChildren().get(ForPart.HEADER.ordinal()); List siblings = getParent().getChildren(); int index = siblings.indexOf(this); + siblings.set(index++, loop.initialization); if (header instanceof Block) { - siblings.remove(this); siblings.addAll(index, header.getChildren()); } else { - siblings.set(index, header); + siblings.add(index, header); } - siblings.add(index + header.getChildren().size(), loop.initialization); return true; } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/Loop.java 2016-05-12 04:24:54.806334369 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/Loop.java 2016-05-12 04:24:54.642334370 +0300 @@ -23,11 +23,10 @@ package jdk.test.lib.jittester.loops; -import jdk.test.lib.jittester.IRNode; // Just a structure to hold the values needed to handle basic loop production public class Loop { - public IRNode initialization; - public IRNode condition; - public IRNode manipulator; + public CounterInitializer initialization; + public LoopingCondition condition; + public CounterManipulator manipulator; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/LoopingCondition.java 2016-05-12 04:24:55.230334366 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/LoopingCondition.java 2016-05-12 04:24:55.134334366 +0300 @@ -30,6 +30,7 @@ private final IRNode condition; public LoopingCondition(IRNode condition) { + super(condition.getResultType()); this.condition = condition; addChild(condition); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/While.java 2016-05-12 04:24:55.454334364 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/loops/While.java 2016-05-12 04:24:55.398334364 +0300 @@ -38,7 +38,7 @@ BODY1, BODY2, BODY3, - }; + } private final Loop loop; // int counter = x; @@ -51,8 +51,9 @@ // } private final long thisLoopIterLimit; - public While(int level, Loop loop, long thisLoopIterLimit, IRNode header, - IRNode body1, IRNode body2, IRNode body3) { + public While(int level, Loop loop, long thisLoopIterLimit, Block header, + Block body1, Block body2, Block body3) { + super(body1.getResultType()); this.loop = loop; this.level = level; this.thisLoopIterLimit = thisLoopIterLimit; @@ -88,13 +89,12 @@ IRNode header = getChildren().get(WhilePart.HEADER.ordinal()); List siblings = getParent().getChildren(); int index = siblings.indexOf(this); + siblings.set(index++, loop.initialization); if (header instanceof Block) { - siblings.remove(this); siblings.addAll(index, header.getChildren()); } else { - siblings.set(index, header); + siblings.add(index, header); } - siblings.add(index + header.getChildren().size(), loop.initialization); return true; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeArray.java 2016-05-12 04:24:56.738334354 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeArray.java 2016-05-12 04:24:56.658334354 +0300 @@ -26,6 +26,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; @@ -47,26 +50,29 @@ public final int dimensions; private List dims = new ArrayList<>(); - public TypeArray() { - this(new TypeVoid(), 0); - } - public TypeArray(Type type, int dimensions) { super("Array", TypeKlass.FINAL); - addParent("java.lang.Object"); - setParent((TypeKlass) TypeList.find("java.lang.Object")); + addParent(TypeList.OBJECT.getName()); + setParent(TypeList.OBJECT); this.type = type; this.dimensions = dimensions; } + public String getName() { + String dimString = Stream.generate(() -> "[]") + .limit(dimensions) + .collect(Collectors.joining()); + return type.getName() + dimString; + } + @Override protected void exportSymbols() { - SymbolTable.add(new VariableInfo("length", this, new TypeInt(), VariableInfo.PUBLIC | VariableInfo.FINAL)); + SymbolTable.add(new VariableInfo("length", this, TypeList.INT, VariableInfo.PUBLIC | VariableInfo.FINAL)); } @Override public boolean equals(Object t) { - if (this == t) { + if (this == t) { return true; } if (t == null || !(t instanceof TypeArray)) { @@ -95,8 +101,7 @@ @Override public int compareTo(Type t) { - int r = 0; - r = super.compareTo(t); + int r = super.compareTo(t); if (r == 0) { try { TypeArray a = (TypeArray) t; --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java 2016-05-12 04:24:56.998334351 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/types/TypeKlass.java 2016-05-12 04:24:56.934334352 +0300 @@ -33,24 +33,27 @@ import jdk.test.lib.jittester.TypeList; public class TypeKlass extends Type { - - private TypeKlass parent; - private HashSet parentsList; - private HashSet childrenList; + private TypeKlass parentKlass; + private final HashSet parentsList; + private final HashSet childrenList; private final HashSet symbolsSet; + private int flags; + public static final int NONE = 0x00; public static final int FINAL = 0x01; public static final int INTERFACE = 0x02; public static final int ABSTRACT = 0x04; - private int flags = NONE; + public TypeKlass(String name) { - this(name, 0); + this(name, NONE); } public TypeKlass(String name, int flags) { super(name); this.flags = flags; + parentsList = new HashSet<>(); + childrenList = new HashSet<>(); symbolsSet = new HashSet<>(); } @@ -76,39 +79,27 @@ @Override protected void exportSymbols() { - symbolsSet.stream().forEach(symbol -> { - SymbolTable.add(symbol); - }); + symbolsSet.stream().forEach(SymbolTable::add); } public void setParent(TypeKlass p) { - parent = p; + parentKlass = p; } public void addParent(String p) { - if (parentsList == null) { - parentsList = new HashSet<>(); - } parentsList.add(p); } public void addChild(String c) { - if (childrenList == null) { - childrenList = new HashSet<>(); - } childrenList.add(c); } protected void removeParent(String p) { - if (parentsList != null) { - parentsList.remove(p); - } + parentsList.remove(p); } protected void removeChild(String c) { - if (childrenList != null) { - childrenList.remove(c); - } + childrenList.remove(c); } public HashSet getParentsNames() { @@ -131,37 +122,27 @@ public TreeSet getAllParents() { TreeSet result = new TreeSet<>(); - if (parentsList != null) { - for (String parentName : parentsList) { - Type _parentKlass = TypeList.find(new TypeKlass(parentName)); - if (_parentKlass != null) { - try { - TypeKlass parentKlass = (TypeKlass) _parentKlass; - result.add(parentKlass); - result.addAll(parentKlass.getAllParents()); - } catch (Exception e) { - } - } - } - } + parentsList.stream() + .map(TypeList::find) + .filter(parentKlass -> parentKlass != null) + .map(parentKlass -> (TypeKlass) parentKlass) + .forEach(parentKlass -> { + result.add(parentKlass); + result.addAll(parentKlass.getAllParents()); + }); return result; } public TreeSet getAllChildren() { TreeSet r = new TreeSet<>(); - if (childrenList != null) { - for (String childName : childrenList) { - Type _childKlass = TypeList.find(new TypeKlass(childName)); - if (_childKlass != null) { - try { - TypeKlass childKlass = (TypeKlass) _childKlass; - r.add(childKlass); - r.addAll(childKlass.getAllChildren()); - } catch (Exception e) { - } - } - } - } + childrenList.stream() + .map(TypeList::find) + .filter(childKlass -> childKlass != null) + .map(childKlass -> (TypeKlass) childKlass) + .forEach(childKlass -> { + r.add(childKlass); + r.addAll(childKlass.getAllChildren()); + }); return r; } @@ -179,8 +160,11 @@ // we cannot guarantee that no exception will occur. @Override public boolean canExplicitlyCastTo(Type t) { + if (equals(t)) { + return true; + } if (t instanceof TypeKlass && !ProductionParams.disableDowncasts.value()) { - return equals(t) || getAllChildren().contains(t); + return getAllChildren().contains(t); } return false; @@ -205,4 +189,8 @@ public boolean isInterface() { return (flags & INTERFACE) > 0; } + + public TypeKlass getParent() { + return parentKlass; + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java 2016-05-12 04:24:57.962334344 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/OptionResolver.java 2016-05-12 04:24:57.842334345 +0300 @@ -166,11 +166,10 @@ } public abstract class Option { - - Character shortName; - String longName; - protected T defaultValue; - protected String description; + protected final Character shortName; + protected final String longName; + protected final T defaultValue; + protected final String description; public Option(Character shortName, String longName, T defaultValue, String description) { this.shortName = shortName; @@ -200,6 +199,10 @@ return (T) values.getOrDefault(this, defaultValue); } + public boolean isSet() { + return values.containsKey(this); + } + public boolean isFlag() { return false; } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/PseudoRandom.java 2016-05-12 04:24:58.210334342 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/PseudoRandom.java 2016-05-12 04:24:58.146334342 +0300 @@ -23,18 +23,31 @@ package jdk.test.lib.jittester.utils; +import java.lang.reflect.Field; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; /** * This class is used for any random generation operations. */ public class PseudoRandom { - private static java.util.Random random = null; + private static Random random = null; + private static final Field SEED_FIELD; + + static { + try { + SEED_FIELD = Random.class.getDeclaredField("seed"); + SEED_FIELD.setAccessible(true); + } catch (ReflectiveOperationException roe) { + throw new Error("Can't get seed field: " + roe, roe); + } + } public static void reset(String seed) { if (seed == null || seed.length() == 0) { @@ -71,9 +84,9 @@ Collections.shuffle(list, random); } - public static byte randomNotNegative(byte limit) { - byte result = (byte) (limit * random.nextDouble()); - return (byte)Math.abs(result); + public static int randomNotNegative(int limit) { + int result = (int) (limit * random.nextDouble()); + return Math.abs(result); } public static T randomElement(Collection collection) { @@ -103,4 +116,21 @@ throw new NoSuchElementException("Empty, no element can be randomly selected"); return array[random.nextInt(array.length)]; } + + public static long getCurrentSeed() { + try { + return ((AtomicLong)SEED_FIELD.get(random)).get(); + } catch (ReflectiveOperationException roe) { + throw new Error("Can't get seed: " + roe, roe); + } + } + + public static void setCurrentSeed(long seed) { + try { + AtomicLong seedObject = (AtomicLong)SEED_FIELD.get(random); + seedObject.set(seed); + } catch (ReflectiveOperationException roe) { + throw new Error("Can't set seed: " + roe, roe); + } + } } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/JavaCodeVisitor.java 2016-05-12 04:24:58.662334338 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/JavaCodeVisitor.java 2016-05-12 04:24:58.590334339 +0300 @@ -23,8 +23,6 @@ package jdk.test.lib.jittester.visitors; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Objects; @@ -41,10 +39,10 @@ import jdk.test.lib.jittester.Initialization; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; -import jdk.test.lib.jittester.LogicOperator; import jdk.test.lib.jittester.NonStaticMemberVariable; import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.Operator; +import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.PrintVariables; import jdk.test.lib.jittester.ProductionParams; import jdk.test.lib.jittester.Statement; @@ -89,13 +87,8 @@ import jdk.test.lib.jittester.loops.LoopingCondition; import jdk.test.lib.jittester.loops.While; import jdk.test.lib.jittester.types.TypeArray; -import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.types.TypeKlass; -import jdk.test.lib.jittester.types.TypeChar; -import jdk.test.lib.jittester.types.TypeDouble; -import jdk.test.lib.jittester.types.TypeFloat; -import jdk.test.lib.jittester.types.TypeLong; -import jdk.test.lib.jittester.types.TypeShort; +import jdk.test.lib.jittester.utils.FixedTrees; import jdk.test.lib.jittester.utils.PrintingUtils; public class JavaCodeVisitor implements Visitor { @@ -128,7 +121,91 @@ return attrs; } - public String expressionToJavaCode(Operator t, IRNode p, Operator.Order o) { + private String operatorToJaveCode(OperatorKind operationKind) { + switch (operationKind) { + case COMPOUND_ADD: + return "+="; + case COMPOUND_SUB: + return "-="; + case COMPOUND_MUL: + return "*="; + case COMPOUND_DIV: + return "/="; + case COMPOUND_MOD: + return "%="; + case COMPOUND_AND: + return "&="; + case COMPOUND_OR: + return "|="; + case COMPOUND_XOR: + return "^="; + case COMPOUND_SHR: + return ">>="; + case COMPOUND_SHL: + return "<<="; + case COMPOUND_SAR: + return ">>>="; + case ASSIGN: + return "="; + case OR: + return "||"; + case BIT_OR: + return "|"; + case BIT_XOR: + return "^"; + case AND: + return "&&"; + case BIT_AND: + return "&"; + case EQ: + return "=="; + case NE: + return "!="; + case GT: + return ">"; + case LT: + return "<"; + case GE: + return ">="; + case LE: + return "<="; + case SHR: + return ">>"; + case SHL: + return "<<"; + case SAR: + return ">>>"; + case ADD: + case STRADD: + return "+"; + case SUB: + return "-"; + case MUL: + return "*"; + case DIV: + return "/"; + case MOD: + return "%"; + case NOT: + return "!"; + case BIT_NOT: + return "~"; + case UNARY_PLUS: + return "+"; + case UNARY_MINUS: + return "-"; + case PRE_DEC: + case POST_DEC: + return "--"; + case PRE_INC: + case POST_INC: + return "++"; + default: + throw new IllegalArgumentException("Unkown operator kind " + operationKind); + } + } + + private String expressionToJavaCode(Operator t, IRNode p, Operator.Order o) { String result; try { if ((o == Operator.Order.LEFT && ((Operator) p).getPriority() < t.getPriority()) @@ -151,8 +228,8 @@ @Override public String visit(ArrayCreation node) { - Type arrayType = node.getArrayType(); - String type = arrayType.accept(this); + Type arrayElemType = node.getArrayType().type; + String type = arrayElemType.accept(this); String name = node.getVariable().getName(); StringBuilder code = new StringBuilder() .append(node.getVariable().accept(this)) @@ -165,7 +242,7 @@ .map(p -> p.accept(this)) .collect(Collectors.joining("][", "[", "]"))); code.append(";\n"); - if (!TypeList.isBuiltIn(arrayType)) { + if (!TypeList.isBuiltIn(arrayElemType)) { code.append(PrintingUtils.align(node.getParent().getLevel())) .append("java.util.Arrays.fill(") .append(name) @@ -220,7 +297,7 @@ return "null"; } return expressionToJavaCode(node, left, Operator.Order.LEFT) - + " " + node.getOperationCode() + " " + + " " + operatorToJaveCode(node.getOperationKind()) + " " + expressionToJavaCode(node, right, Operator.Order.RIGHT); } @@ -320,7 +397,7 @@ @Override public String visit(CounterInitializer node) { - VariableInfo vi = node.get(); + VariableInfo vi = node.getVariableInfo(); return vi.type.accept(this) + " " + vi.name + " = " + node.getChild(0).accept(this)+ ";"; } @@ -407,8 +484,8 @@ + ")"; String prefix = ""; if (value.isStatic()) { - if(!node.getKlass().equals(value.klass)) { - prefix = value.klass.getName() + "."; + if(!node.getOwner().equals(value.owner)) { + prefix = value.owner.getName() + "."; } } else if (value.isConstructor()) { prefix = "new "; @@ -434,7 +511,7 @@ .collect(Collectors.joining(", ")); FunctionInfo functionInfo = node.getFunctionInfo(); - return (functionInfo.klass.isInterface() ? "" : "abstract ") + return (functionInfo.owner.isInterface() ? "" : "abstract ") + funcAttributes(functionInfo) + functionInfo.type.accept(this)+ " " + functionInfo.name + "(" + args + ");"; } @@ -464,7 +541,7 @@ + PrintingUtils.align(node.getLevel() + 1) + "{\n" + body.accept(this) + (ret != null ? PrintingUtils.align(node.getLevel() + 2) + ret.accept(this) + "\n" : "") - + PrintingUtils.align(node.getLevel() + 1) + "}"; + + PrintingUtils.align(node.getLevel() + 1) + "}\n"; } @Override @@ -483,6 +560,7 @@ @Override public String visit(FunctionRedefinition node) { String args = node.getChildren().stream() + .skip(2) .map(c -> c.accept(this)) .collect(Collectors.joining(", ")); @@ -490,10 +568,10 @@ IRNode ret = node.getChild(1); int level = node.getLevel(); FunctionInfo functionInfo = node.getFunctionInfo(); - return funcAttributes(functionInfo) + functionInfo.type + " " + functionInfo.name + "(" + args + ")" + "\n" + return funcAttributes(functionInfo) + functionInfo.type.accept(this) + " " + functionInfo.name + "(" + args + ")" + "\n" + PrintingUtils.align(level + 1) + "{\n" - + body - + (ret != null ? PrintingUtils.align(level + 2) + ret + "\n" : "") + + body.accept(this) + + (ret != null ? PrintingUtils.align(level + 2) + ret.accept(this) + "\n" : "") + PrintingUtils.align(level + 1) + "}"; } @@ -551,10 +629,11 @@ + (thisKlass.isFinal() ? "final " : "") + (thisKlass.isAbstract() ? "abstract " : "") + "class " + node.getName() - + (node.getParentKlass()!= null ? " extends " + node.getParentKlass().getName() : ""); + + (node.getParentKlass() != null && !node.getParentKlass().equals(TypeList.OBJECT) + ? " extends " + node.getParentKlass().getName() : ""); List interfaces = node.getInterfaces(); r += interfaces.stream() - .map(c -> c.getName()) + .map(Type::getName) .collect(Collectors.joining(", ", (interfaces.isEmpty() ? "" : " implements "), "")); IRNode dataMembers = node.getChild(Klass.KlassPart.DATA_MEMBERS.ordinal()); IRNode constructors = node.getChild(Klass.KlassPart.CONSTRUCTORS.ordinal()); @@ -570,10 +649,7 @@ + (overridenFunctions != null ? (overridenFunctions.accept(this)+ "\n") : "") + (memberFunctionDecls != null ? (memberFunctionDecls.accept(this)+ "\n") : "") + (memberFunctions != null ? (memberFunctions.accept(this)+ "\n") : "") - + " public String toString()\n" - + " {\n" + printVariables.accept(this) - + " }\n" + "}\n"; return r; } @@ -582,43 +658,42 @@ public String visit(Literal node) { Type resultType = node.getResultType(); Object value = node.getValue(); - if (resultType.equals(new TypeLong())) { + if (resultType.equals(TypeList.LONG)) { return value.toString() + "L"; } - if (resultType.equals(new TypeFloat())) { + if (resultType.equals(TypeList.FLOAT)) { return String.format((Locale) null, - "%." + ProductionParams.floatingPointPrecision.value() + "EF", + "%EF", Double.parseDouble(value.toString())); } - if (resultType.equals(new TypeDouble())) { + if (resultType.equals(TypeList.DOUBLE)) { return String.format((Locale) null, - "%." + 2 * ProductionParams.floatingPointPrecision.value() + "E", + "%E", Double.parseDouble(value.toString())); } - if (resultType.equals(new TypeChar())) { - if (((Character) value).charValue() == '\\') { + if (resultType.equals(TypeList.CHAR)) { + if ((Character) value == '\\') { return "\'" + "\\\\" + "\'"; } else { return "\'" + value.toString() + "\'"; } } - if (resultType.equals(new TypeShort())) { + if (resultType.equals(TypeList.SHORT)) { return "(short) " + value.toString(); } - if (resultType.equals(new TypeByte())) { + if (resultType.equals(TypeList.BYTE)) { return "(byte) " + value.toString(); } + if (resultType.equals(TypeList.STRING)) { + // TOOD handle other non-printable + return "\"" + value.toString().replace("\n", "\\n") + "\""; + } return value.toString(); } @Override public String visit(LocalVariable node) { - return node.get().name; - } - - @Override - public String visit(LogicOperator node) { - throw new UnsupportedOperationException("Not supported yet."); + return node.getVariableInfo().name; } @Override @@ -633,182 +708,16 @@ IRNode memberFunctions = node.getChild(MainKlass.MainKlassPart.MEMBER_FUNCTIONS.ordinal()); IRNode testFunction = node.getChild(MainKlass.MainKlassPart.TEST_FUNCTION.ordinal()); IRNode printVariables = node.getChild(MainKlass.MainKlassPart.PRINT_VARIABLES.ordinal()); - String executeFunction = " public static String execute()\n" - + " {\n" - + " try {\n" - + " " + name + " t = new " + name + "();\n" - + " try { t.test(); }\n" - + " catch(Throwable e) { }\n" - + " try { return t.toString(); }\n" - + " catch (Throwable e) { return \"Error during result conversion to String\"; }\n" - + " } catch (Throwable e) { return \"Error during test execution\"; }\n" - + " }\n"; - String mainFunction = " public static void main(String[] args)\n" - + " {\n" - + " try {\n" - + " " + name + " t = new " + name + "();\n" - + " try {\n" - + " for (int i = 0; i < 150000; ++i) {\n" - + " t.test();\n" - + " }\n" - + " }\n" - + " catch(Throwable e) { e.printStackTrace(); }\n" - + " try { System.out.println(t); }\n" - + " catch(Throwable e) { e.printStackTrace();}\n" - + " } catch (Throwable e) { e.printStackTrace(); }\n" - + " }\n"; - String printerClass = " static class Printer\n" - + " {\n" - + " public static String print(boolean arg) { return String.valueOf(arg); }\n" - + " public static String print(byte arg) { return String.valueOf(arg); }\n" - + " public static String print(short arg) { return String.valueOf(arg); }\n" - + " public static String print(char arg) { return String.valueOf((int)arg); }\n" - + " public static String print(int arg) { return String.valueOf(arg); }\n" - + " public static String print(long arg) { return String.valueOf(arg); }\n" - + " public static String print(float arg) { return String.valueOf(arg); }\n" - + " public static String print(double arg) { return String.valueOf(arg); }\n" - + "\n" - + "\n" - + " public static String print(Object arg)\n" - + " {\n" - + " return print_r(new java.util.Stack(), arg);\n" - + " }\n" - + "\n" - + " private static String print_r(java.util.Stack visitedObjects, Object arg)\n" - + " {\n" - + " String result = \"\";\n" - + " if (arg == null)\n" - + " result += \"null\";\n" - + " else\n" - + " if (arg.getClass().isArray())\n" - + " {\n" - + " for (int i = 0; i < visitedObjects.size(); i++)\n" - + " if (visitedObjects.elementAt(i) == arg) return \"\";\n" - + "\n" - + " visitedObjects.push(arg);\n" - + "\n" - + " final String delimiter = \", \";\n" - + " result += \"[\";\n" - + "\n" - + " if (arg instanceof Object[])\n" - + " {\n" - + " Object[] array = (Object[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print_r(visitedObjects, array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof boolean[])\n" - + " {\n" - + " boolean[] array = (boolean[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof byte[])\n" - + " {\n" - + " byte[] array = (byte[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof short[])\n" - + " {\n" - + " short[] array = (short[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof char[])\n" - + " {\n" - + " char[] array = (char[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof int[])\n" - + " {\n" - + " int[] array = (int[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof long[])\n" - + " {\n" - + " long[] array = (long[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof float[])\n" - + " {\n" - + " float[] array = (float[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + " else\n" - + " if (arg instanceof double[])\n" - + " {\n" - + " double[] array = (double[]) arg;\n" - + " for (int i = 0; i < array.length; i++)\n" - + " {\n" - + " result += print(array[i]);\n" - + " if (i < array.length - 1) result += delimiter;\n" - + " }\n" - + " }\n" - + "\n" - + " result += \"]\";\n" - + " visitedObjects.pop();\n" - + "\n" - + " } else\n" - + " {\n" - + " result += arg.toString();\n" - + " }\n" - + "\n" - + " return result;\n" - + " }\n" - + " }\n"; return (ProductionParams.enableStrictFP.value() ? "strictfp " : "") + "public class " + name + " {\n" + dataMembers.accept(this)+ "\n" + (memberFunctions != null ? memberFunctions.accept(this): "") + "\n" - + executeFunction - + "\n" - + mainFunction - + "\n" + " private void test()\n" + " {\n" + testFunction.accept(this) + " }" + addComplexityInfo(testFunction) + "\n" - + " public String toString()\n" - + " {\n" + printVariables.accept(this) - + " }\n" - + printerClass + "}\n\n"; } @@ -816,7 +725,7 @@ public String visit(NonStaticMemberVariable node) { IRNode object = node.getChild(0); String objectString = object.accept(this); - VariableInfo value = node.getValue(); + VariableInfo value = node.getVariableInfo(); if (objectString.equals("this")) { return value.name; } else { @@ -835,38 +744,7 @@ @Override public String visit(PrintVariables node) { - int level = node.getLevel(); - List vars = node.getVars(); - StringBuilder result = new StringBuilder() - .append(PrintingUtils.align(level)) - .append("String result = \"[\\n\";\n"); - if (!vars.isEmpty()) { - for (int i = 0; i < vars.size(); i++) { - Symbol v = vars.get(i); - result.append(PrintingUtils.align(level)) - .append("result += \"").append(v.klass.getName()) - .append(".") - .append(v.name) - .append(" = \"; ") - .append("result += ") - .append(node.getPrinterName()) - .append(".print(") - .append(v.name) - .append(");\n") - .append(PrintingUtils.align(level)); - if (i < vars.size() - 1) { - result.append("result += \"\\n\";"); - } else { - result.append("result += \"\";"); - } - result.append("\n"); - } - } - result.append(PrintingUtils.align(level)) - .append("result += \"\\n]\";\n") - .append(PrintingUtils.align(level)) - .append("return result;\n"); - return result.toString(); + return FixedTrees.printVariablesAsFunction(node).accept(this); } @Override @@ -894,12 +772,12 @@ @Override public String visit(StaticMemberVariable node) { - IRNode klass = node.getKlass(); - VariableInfo value = node.get(); - if (klass.equals(value.klass)) { - return value.name; + IRNode owner = node.getOwner(); + VariableInfo info = node.getVariableInfo(); + if (owner.equals(info.owner)) { + return info.name; } else { - return value.klass.getName() + "." + value.name; + return info.owner.getName() + "." + info.name; } } @@ -910,10 +788,10 @@ String cases = ""; for (int i = 0; i < caseBlockIdx - 1; ++i) { cases += PrintingUtils.align(level + 1); - if (node.getChild(i + 1) != null) { - cases += "case " + node.getChild(i + 1).accept(this)+ ":\n"; - } else { + if (node.getChild(i + 1) instanceof Nothing) { cases += "default:\n"; + } else { + cases += "case " + node.getChild(i + 1).accept(this)+ ":\n"; } cases += node.getChild(i + caseBlockIdx).accept(this)+ "\n"; @@ -955,11 +833,13 @@ public String visit(UnaryOperator node) { IRNode exp = node.getChild(0); if (node.isPrefix()) { - return node.getOperatorText() + (exp instanceof Operator ? " " : "") + return operatorToJaveCode(node.getOperationKind()) + + (exp instanceof Operator ? " " : "") + expressionToJavaCode(node, exp, Operator.Order.LEFT); } else { return expressionToJavaCode(node, exp, Operator.Order.RIGHT) - + (exp instanceof Operator ? " " : "") + node.getOperatorText(); + + (exp instanceof Operator ? " " : "") + + operatorToJaveCode(node.getOperationKind()); } } @@ -1024,14 +904,18 @@ int level = node.getLevel(); result.append("try {\n") .append(body.accept(this)).append("\n") - .append(PrintingUtils.align(level)).append("}\n"); + .append(PrintingUtils.align(level)) + .append("}\n"); for (int i = 2; i < childs.size(); i++) { result.append(childs.get(i).accept(this)); } if (finallyBody != null) { - result.append(PrintingUtils.align(level)).append("finally {\n") - .append(finallyBody.accept(this)).append("\n") - .append(PrintingUtils.align(level)).append("}\n"); + String finallyContent = finallyBody.accept(this); + if (!finallyContent.isEmpty()) { + result.append(PrintingUtils.align(level)).append("finally {\n") + .append(finallyContent).append("\n") + .append(PrintingUtils.align(level)).append("}\n"); + } } return result.toString(); } --- old/test/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/Visitor.java 2016-05-12 04:24:58.922334336 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/Visitor.java 2016-05-12 04:24:58.858334337 +0300 @@ -34,7 +34,6 @@ import jdk.test.lib.jittester.Initialization; import jdk.test.lib.jittester.Literal; import jdk.test.lib.jittester.LocalVariable; -import jdk.test.lib.jittester.LogicOperator; import jdk.test.lib.jittester.NonStaticMemberVariable; import jdk.test.lib.jittester.Nothing; import jdk.test.lib.jittester.PrintVariables; @@ -106,7 +105,6 @@ T visit(Klass node); T visit(Literal node); T visit(LocalVariable node); - T visit(LogicOperator node); T visit(LoopingCondition node); T visit(MainKlass node); T visit(NonStaticMemberVariable node); --- /dev/null 2016-05-10 17:52:27.219330981 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/ByteCodeGenerator.java 2016-05-12 04:24:59.186334334 +0300 @@ -0,0 +1,96 @@ +/* + * 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 jdk.test.lib.jittester; + +import jdk.test.lib.jittester.visitors.ByteCodeVisitor; + +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.function.BiFunction; + +/** + * Generates class files from bytecode + */ +class ByteCodeGenerator implements BiFunction { + private final Path testbase = Paths.get(ProductionParams.testbaseDir.value(), + "bytecode_tests"); + + public void writeJtregBytecodeRunner(String name) { + try (FileWriter file = new FileWriter(testbase.resolve(name + ".java").toFile())) { + file.write(Automatic.getJtregHeader(name, false)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public String apply(IRNode mainClass, IRNode privateClasses) { + Automatic.ensureExisting(testbase); + try { + ByteCodeVisitor vis = new ByteCodeVisitor(); + if (privateClasses != null) { + privateClasses.accept(vis); + } + mainClass.accept(vis); + + Path mainClassPath = testbase.resolve(mainClass.getName() + ".class"); + writeToClassFile(mainClassPath, vis.getByteCode(mainClass.getName())); + if (privateClasses != null) { + privateClasses.getChildren().forEach(c -> { + String name = c.getName(); + Path classPath = testbase.resolve(name + ".class"); + writeToClassFile(classPath, vis.getByteCode(name)); + }); + } + return mainClassPath.toString(); + } catch (Throwable t) { + Path errFile = testbase.resolve(mainClass.getName() + ".err"); + try (PrintWriter pw = new PrintWriter(Files.newOutputStream(errFile, + StandardOpenOption.CREATE_NEW))) { + t.printStackTrace(pw); + } catch (IOException e) { + t.printStackTrace(); + throw new Error("can't write error to error file " + errFile, e); + } + return null; + } + } + + public Path getTestbase() { + return testbase; + } + + private void writeToClassFile(Path path, byte[] bytecode) { + try (FileOutputStream file = new FileOutputStream(path.toString())) { + file.write(bytecode); + } catch (IOException ex) { + ex.printStackTrace(); + } + } +} --- /dev/null 2016-05-10 17:52:27.219330981 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/JavaCodeGenerator.java 2016-05-12 04:25:00.006334327 +0300 @@ -0,0 +1,70 @@ +/* + * 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 jdk.test.lib.jittester; + +import jdk.test.lib.jittester.visitors.JavaCodeVisitor; + +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.BiFunction; + +/** + * Generates class files from java source code + */ +class JavaCodeGenerator implements BiFunction { + private final Path testbase = Paths.get(ProductionParams.testbaseDir.value(), "java_tests"); + + private String generateJavaCode(IRNode mainClass, IRNode privateClasses) { + StringBuilder code = new StringBuilder(); + JavaCodeVisitor vis = new JavaCodeVisitor(); + + code.append(Automatic.getJtregHeader(mainClass.getName(), true)); + if (privateClasses != null) { + code.append(privateClasses.accept(vis)); + } + code.append(mainClass.accept(vis)); + + return code.toString(); + } + + public Path getTestbase() { + return testbase; + } + + @Override + public String apply(IRNode mainClass, IRNode privateClasses) { + String code = generateJavaCode(mainClass, privateClasses); + Automatic.ensureExisting(testbase); + Path fileName = testbase.resolve(mainClass.getName() + ".java"); + try (FileWriter file = new FileWriter(fileName.toFile())) { + file.write(code); + return fileName.toString(); + } catch (IOException ex) { + ex.printStackTrace(); + } + return ""; + } +} --- /dev/null 2016-05-10 17:52:27.219330981 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/Printer.java 2016-05-12 04:25:00.338334325 +0300 @@ -0,0 +1,165 @@ +/* + * 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 jdk.test.lib.jittester.jtreg; + +import java.util.Stack; + +public class Printer { + + public static String print(boolean arg) { + return String.valueOf(arg); + } + + public static String print(byte arg) { + return String.valueOf(arg); + } + + public static String print(short arg) { + return String.valueOf(arg); + } + + public static String print(char arg) { + return String.valueOf((int) arg); + } + + public static String print(int arg) { + return String.valueOf(arg); + } + + public static String print(long arg) { + return String.valueOf(arg); + } + + public static String print(float arg) { + return String.valueOf(arg); + } + + public static String print(double arg) { + return String.valueOf(arg); + } + + public static String print(Object arg) { + return print_r(new Stack<>(), arg); + } + + private static String print_r(Stack visitedObjects, Object arg) { + String result = ""; + if (arg == null) { + result += "null"; + } else if (arg.getClass().isArray()) { + for (int i = 0; i < visitedObjects.size(); i++) { + if (visitedObjects.elementAt(i) == arg) { + return ""; + } + } + + visitedObjects.push(arg); + + final String delimiter = ", "; + result += "["; + + if (arg instanceof Object[]) { + Object[] array = (Object[]) arg; + for (int i = 0; i < array.length; i++) { + result += print_r(visitedObjects, array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof boolean[]) { + boolean[] array = (boolean[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof byte[]) { + byte[] array = (byte[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof short[]) { + short[] array = (short[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof char[]) { + char[] array = (char[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof int[]) { + int[] array = (int[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof long[]) { + long[] array = (long[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof float[]) { + float[] array = (float[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } else if (arg instanceof double[]) { + double[] array = (double[]) arg; + for (int i = 0; i < array.length; i++) { + result += print(array[i]); + if (i < array.length - 1) { + result += delimiter; + } + } + } + + result += "]"; + visitedObjects.pop(); + + } else { + result += arg.toString(); + } + + return result; + } +} --- /dev/null 2016-05-10 17:52:27.219330981 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/FixedTrees.java 2016-05-12 04:25:00.674334322 +0300 @@ -0,0 +1,213 @@ +/* + * 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 jdk.test.lib.jittester.utils; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import jdk.test.lib.jittester.BinaryOperator; +import jdk.test.lib.jittester.Block; +import jdk.test.lib.jittester.CatchBlock; +import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.Literal; +import jdk.test.lib.jittester.LocalVariable; +import jdk.test.lib.jittester.NonStaticMemberVariable; +import jdk.test.lib.jittester.Nothing; +import jdk.test.lib.jittester.Operator; +import jdk.test.lib.jittester.OperatorKind; +import jdk.test.lib.jittester.PrintVariables; +import jdk.test.lib.jittester.ProductionFailedException; +import jdk.test.lib.jittester.Statement; +import jdk.test.lib.jittester.StaticMemberVariable; +import jdk.test.lib.jittester.Symbol; +import jdk.test.lib.jittester.TryCatchBlock; +import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; +import jdk.test.lib.jittester.VariableInfo; +import jdk.test.lib.jittester.VariableInitialization; +import jdk.test.lib.jittester.functions.ArgumentDeclaration; +import jdk.test.lib.jittester.functions.Function; +import jdk.test.lib.jittester.functions.FunctionDefinition; +import jdk.test.lib.jittester.functions.FunctionInfo; +import jdk.test.lib.jittester.functions.Return; +import jdk.test.lib.jittester.jtreg.Printer; +import jdk.test.lib.jittester.loops.CounterInitializer; +import jdk.test.lib.jittester.loops.CounterManipulator; +import jdk.test.lib.jittester.loops.For; +import jdk.test.lib.jittester.loops.Loop; +import jdk.test.lib.jittester.loops.LoopingCondition; +import jdk.test.lib.jittester.types.TypeArray; +import jdk.test.lib.jittester.types.TypeKlass; + +public class FixedTrees { + public static FunctionDefinition printVariablesAsFunction(PrintVariables node) { + TypeKlass owner = node.getOwner(); + + ArrayList nodes = new ArrayList<>(); + + VariableInfo resultInfo = new VariableInfo("result", node.getOwner(), TypeList.STRING, VariableInfo.LOCAL); + nodes.add(new Statement(new VariableInitialization(resultInfo, new Literal("[", TypeList.STRING)), true)); + LocalVariable resultVar = new LocalVariable(resultInfo); + + List vars = node.getVars(); + + TypeKlass printerKlass = new TypeKlass(Printer.class.getName()); + Literal EOL = new Literal("\n", TypeList.STRING); + VariableInfo thisInfo = new VariableInfo("this", node.getOwner(), + node.getOwner(), VariableInfo.LOCAL | VariableInfo.INITIALIZED); + + LocalVariable thisVar = new LocalVariable(thisInfo); + + for (int i = 0; i < vars.size(); i++) { + Symbol v = vars.get(i); + nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, + new Literal(v.owner.getName() + "." + v.name + " = ", TypeList.STRING)), true)); + VariableInfo argInfo = new VariableInfo("arg", printerKlass, + v.type instanceof TypeKlass ? TypeList.OBJECT : v.type, + VariableInfo.LOCAL | VariableInfo.INITIALIZED); + FunctionInfo printInfo = new FunctionInfo("print", printerKlass, + TypeList.STRING, 0, FunctionInfo.PUBLIC | FunctionInfo.STATIC, argInfo); + Function call = new Function(owner, printInfo, null); + VariableInfo varInfo = new VariableInfo(v.name, v.owner, v.type, v.flags); + if (v.isStatic()) { + call.addChild(new StaticMemberVariable(v.owner, varInfo)); + } else { + call.addChild(new NonStaticMemberVariable(thisVar, varInfo)); + } + nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, + call), true)); + if (i < vars.size() - 1) { + nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, + EOL), true)); + } + } + nodes.add(new Statement( + new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, new Literal("]\n", TypeList.STRING)), + true)); + + Block block = new Block(node.getOwner(), TypeList.STRING, nodes, 1); + FunctionInfo toStringInfo = new FunctionInfo("toString", owner, TypeList.STRING, 0L, FunctionInfo.PUBLIC, thisInfo); + return new FunctionDefinition(toStringInfo, new ArrayList<>(), block, new Return(resultVar)); + } + public static FunctionDefinition generateMainOrExecuteMethod(TypeKlass owner, boolean isMain) { + Nothing nothing = new Nothing(); + ArrayList testCallNodeContent = new ArrayList<>(); + VariableInfo tInfo = new VariableInfo("t", owner, owner, VariableInfo.LOCAL); + LocalVariable tVar = new LocalVariable(tInfo); + Function testCallNode = new Function(owner, new FunctionInfo("test", owner, TypeList.VOID, + 0L, FunctionInfo.PRIVATE, tInfo), null); + testCallNode.addChild(tVar); + testCallNodeContent.add(new Statement(testCallNode, true)); + // { t.test(); } + Block testCallNodeBlock = new Block(owner, TypeList.VOID, testCallNodeContent, 4); + + IRNode tryNode = testCallNodeBlock; + if (isMain) { + VariableInfo iInfo = new VariableInfo("i", owner, TypeList.INT, VariableInfo.LOCAL); + LocalVariable iVar = new LocalVariable(iInfo); + Operator increaseCounter = new BinaryOperator(OperatorKind.ASSIGN, TypeList.INT, + iVar, + new BinaryOperator(OperatorKind.ADD, TypeList.INT, + iVar, new Literal(1, TypeList.INT))); + Loop loop = new Loop(); + Block emptyBlock = new Block(owner, TypeList.VOID, new LinkedList<>(), 3); + loop.initialization = new CounterInitializer(iInfo, new Literal(0, TypeList.INT)); + loop.manipulator = new CounterManipulator(new Statement(increaseCounter, false)); + loop.condition = new LoopingCondition(new BinaryOperator(OperatorKind.LT, TypeList.BOOLEAN, iVar, + new Literal(150000, TypeList.INT))); + For forNode = new For(4, loop, 150000, emptyBlock, new Statement(nothing, false), + new Statement(nothing, false), testCallNodeBlock, emptyBlock, emptyBlock); + tryNode = forNode; + } + + FunctionInfo constrInfo = new FunctionInfo(owner.getName(), owner, owner, 0, FunctionInfo.PUBLIC); + Function testConstructor = new Function(owner, constrInfo, null); + // Test t = new Test() + VariableInitialization testInit = new VariableInitialization(tInfo, testConstructor); + + TypeKlass throwableKlass = new TypeKlass("java.lang.Throwable"); + List throwables = new ArrayList<>(); + throwables.add(throwableKlass); + + VariableInfo exInfo = new VariableInfo("ex", owner, throwableKlass, + VariableInfo.LOCAL | VariableInfo.INITIALIZED); + FunctionInfo printStackTraceInfo = new FunctionInfo("printStackTrace", throwableKlass, + TypeList.VOID, 0, FunctionInfo.PUBLIC, exInfo); + Function printStackTraceCall = new Function(throwableKlass, printStackTraceInfo, null); + printStackTraceCall.addChild(new LocalVariable(exInfo)); + ArrayList printStackTraceCallBlockContent = new ArrayList<>(); + // { ex.printStackTrace(); } + printStackTraceCallBlockContent.add(new Statement(printStackTraceCall, true)); + + Block printStackTraceCallBlock = new Block(owner, TypeList.VOID, printStackTraceCallBlockContent, 3); + List catchBlocks1 = new ArrayList<>(); + catchBlocks1.add(new CatchBlock(printStackTraceCallBlock, throwables, 3)); + List catchBlocks2 = new ArrayList<>(); + catchBlocks2.add(new CatchBlock(printStackTraceCallBlock, throwables, 3)); + List catchBlocks3 = new ArrayList<>(); + catchBlocks3.add(new CatchBlock(printStackTraceCallBlock, throwables, 2)); + + TryCatchBlock tryCatch1 = new TryCatchBlock(tryNode, nothing, catchBlocks1, 3); + TypeKlass printStreamKlass = new TypeKlass("java.io.PrintStream"); + TypeKlass systemKlass = new TypeKlass("java.lang.System"); + FunctionInfo systemOutPrintlnInfo = new FunctionInfo("println", printStreamKlass, + TypeList.VOID, 0, FunctionInfo.PUBLIC, + new VariableInfo("this", owner, printStreamKlass, VariableInfo.LOCAL | VariableInfo.INITIALIZED), + new VariableInfo("t", owner, TypeList.OBJECT, + VariableInfo.LOCAL | VariableInfo.INITIALIZED)); + List printlnArgs = new ArrayList<>(); + VariableInfo systemOutInfo = new VariableInfo("out", systemKlass, printStreamKlass, + VariableInfo.STATIC | VariableInfo.PUBLIC); + StaticMemberVariable systemOutVar = new StaticMemberVariable(owner, systemOutInfo); + printlnArgs.add(systemOutVar); + printlnArgs.add(tVar); + Function println = new Function(printStreamKlass, systemOutPrintlnInfo, printlnArgs); + ArrayList printlnBlockContent = new ArrayList<>(); + printlnBlockContent.add(new Statement(println, true)); + Block printlnBlock = new Block(owner, TypeList.VOID, printlnBlockContent, 3); + TryCatchBlock tryCatch2 = new TryCatchBlock(printlnBlock, nothing, catchBlocks2, 3); + + List mainTryCatchBlockContent = new ArrayList<>(); + mainTryCatchBlockContent.add(new Statement(testInit, true)); + mainTryCatchBlockContent.add(tryCatch1); + mainTryCatchBlockContent.add(tryCatch2); + Block mainTryCatchBlock = new Block(owner, TypeList.VOID, mainTryCatchBlockContent, 2); + TryCatchBlock mainTryCatch = new TryCatchBlock(mainTryCatchBlock, nothing, catchBlocks3, 2); + ArrayList bodyContent = new ArrayList<>(); + bodyContent.add(mainTryCatch); + Block funcBody = new Block(owner, TypeList.VOID, bodyContent, 1); + + // static main(String[] args)V or static execute()V + VariableInfo mainArgs = new VariableInfo("args", owner, + new TypeArray(TypeList.STRING, 1), VariableInfo.LOCAL); + FunctionInfo fInfo = isMain + ? new FunctionInfo("main", owner, TypeList.VOID, 0, FunctionInfo.PUBLIC | FunctionInfo.STATIC, mainArgs) + : new FunctionInfo("execute", owner, TypeList.VOID, 0, FunctionInfo.PUBLIC | FunctionInfo.STATIC); + ArrayList argDecl = new ArrayList<>(); + if (isMain) { + argDecl.add(new ArgumentDeclaration(mainArgs)); + } + return new FunctionDefinition(fInfo, argDecl, funcBody, new Return(nothing)); + } +} --- /dev/null 2016-05-10 17:52:27.219330981 +0300 +++ new/test/testlibrary/jittester/src/jdk/test/lib/jittester/visitors/ByteCodeVisitor.java 2016-05-12 04:25:00.886334320 +0300 @@ -0,0 +1,1831 @@ +/* + * 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 jdk.test.lib.jittester.visitors; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashMap; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.FieldVisitor; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.test.lib.Pair; +import jdk.test.lib.jittester.BinaryOperator; +import jdk.test.lib.jittester.Block; +import jdk.test.lib.jittester.BuiltInType; +import jdk.test.lib.jittester.Break; +import jdk.test.lib.jittester.CastOperator; +import jdk.test.lib.jittester.CatchBlock; +import jdk.test.lib.jittester.Continue; +import jdk.test.lib.jittester.Declaration; +import jdk.test.lib.jittester.IRNode; +import jdk.test.lib.jittester.If; +import jdk.test.lib.jittester.Initialization; +import jdk.test.lib.jittester.Literal; +import jdk.test.lib.jittester.LocalVariable; +import jdk.test.lib.jittester.NonStaticMemberVariable; +import jdk.test.lib.jittester.Nothing; +import jdk.test.lib.jittester.Operator; +import jdk.test.lib.jittester.OperatorKind; +import jdk.test.lib.jittester.PrintVariables; +import jdk.test.lib.jittester.ProductionParams; +import jdk.test.lib.jittester.Statement; +import jdk.test.lib.jittester.StaticMemberVariable; +import jdk.test.lib.jittester.Switch; +import jdk.test.lib.jittester.Symbol; +import jdk.test.lib.jittester.TernaryOperator; +import jdk.test.lib.jittester.Throw; +import jdk.test.lib.jittester.TryCatchBlock; +import jdk.test.lib.jittester.Type; +import jdk.test.lib.jittester.TypeList; +import jdk.test.lib.jittester.UnaryOperator; +import jdk.test.lib.jittester.VariableBase; +import jdk.test.lib.jittester.VariableDeclaration; +import jdk.test.lib.jittester.VariableDeclarationBlock; +import jdk.test.lib.jittester.VariableInfo; +import jdk.test.lib.jittester.VariableInitialization; +import jdk.test.lib.jittester.arrays.ArrayCreation; +import jdk.test.lib.jittester.arrays.ArrayElement; +import jdk.test.lib.jittester.arrays.ArrayExtraction; +import jdk.test.lib.jittester.classes.ClassDefinitionBlock; +import jdk.test.lib.jittester.classes.Interface; +import jdk.test.lib.jittester.classes.Klass; +import jdk.test.lib.jittester.classes.MainKlass; +import jdk.test.lib.jittester.functions.ArgumentDeclaration; +import jdk.test.lib.jittester.functions.ConstructorDefinition; +import jdk.test.lib.jittester.functions.ConstructorDefinitionBlock; +import jdk.test.lib.jittester.functions.Function; +import jdk.test.lib.jittester.functions.FunctionDeclaration; +import jdk.test.lib.jittester.functions.FunctionDeclarationBlock; +import jdk.test.lib.jittester.functions.FunctionDefinition; +import jdk.test.lib.jittester.functions.FunctionDefinitionBlock; +import jdk.test.lib.jittester.functions.FunctionInfo; +import jdk.test.lib.jittester.functions.FunctionRedefinition; +import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock; +import jdk.test.lib.jittester.functions.Return; +import jdk.test.lib.jittester.functions.StaticConstructorDefinition; +import jdk.test.lib.jittester.loops.CounterInitializer; +import jdk.test.lib.jittester.loops.CounterManipulator; +import jdk.test.lib.jittester.loops.DoWhile; +import jdk.test.lib.jittester.loops.For; +import jdk.test.lib.jittester.loops.Loop; +import jdk.test.lib.jittester.loops.LoopingCondition; +import jdk.test.lib.jittester.loops.While; +import jdk.test.lib.jittester.types.TypeArray; +import jdk.test.lib.jittester.types.TypeKlass; +import jdk.test.lib.jittester.utils.FixedTrees; +import jdk.test.lib.jittester.utils.PseudoRandom; + +public class ByteCodeVisitor implements Visitor { + private final GeneratedClassesContext context = new GeneratedClassesContext(); + private final byte[] EMPTY_BYTE_ARRAY = new byte[0]; + private final int CLASS_WRITER_FLAGS = ContextDependedClassWriter.COMPUTE_MAXS | ContextDependedClassWriter.COMPUTE_FRAMES; + private final HashMap classWriters = new HashMap<>(); + private MethodVisitor currentMV; + private TypeKlass currentClass; + private final LocalVariablesTable locals = new LocalVariablesTable(); + private final Deque