Merge
This commit is contained in:
commit
6fd77565f4
@ -91,10 +91,10 @@ manifest:
|
|||||||
@echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST)
|
@echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST)
|
||||||
|
|
||||||
compile_testlib: INIT
|
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
|
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)
|
filelist: $(SRC_FILES)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
@ -104,7 +104,7 @@ INIT: $(DIST_DIR)
|
|||||||
$(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi)
|
$(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi)
|
||||||
|
|
||||||
install: clean_testbase testgroup testroot copytestlibrary JAR cleantmp
|
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:
|
clean_testbase:
|
||||||
@rm -rf $(TESTBASE_DIR)
|
@rm -rf $(TESTBASE_DIR)
|
||||||
|
@ -23,125 +23,165 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester;
|
package jdk.test.lib.jittester;
|
||||||
|
|
||||||
import java.io.File;
|
import jdk.test.lib.Pair;
|
||||||
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.jittester.factories.IRNodeBuilder;
|
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.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;
|
||||||
import jdk.test.lib.jittester.utils.OptionResolver.Option;
|
import jdk.test.lib.jittester.utils.OptionResolver.Option;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
public class Automatic {
|
import java.io.File;
|
||||||
public static final int minutesToWait = 3;
|
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;
|
||||||
|
|
||||||
private static String makeTestCase(String name) {
|
public class Automatic {
|
||||||
|
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 Pair<IRNode, IRNode> generateIRTree(String name) {
|
||||||
SymbolTable.removeAll();
|
SymbolTable.removeAll();
|
||||||
TypeList.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();
|
IRNodeBuilder builder = new IRNodeBuilder()
|
||||||
String synopsis = "seed = '" + ProductionParams.seed.value() + "'";
|
.setPrefix(name)
|
||||||
String pathPrefix = ProductionParams.testbaseDir.value()
|
.setName(name)
|
||||||
.replaceAll("([^/]+)", "..");
|
.setLevel(0);
|
||||||
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");
|
|
||||||
|
|
||||||
|
Long complexityLimit = ProductionParams.complexityLimit.value();
|
||||||
if (!ProductionParams.disableClasses.value()) {
|
IRNode privateClasses = null;
|
||||||
long comlexityLimit = (long) (ProductionParams.complexityLimit.value()
|
if (!ProductionParams.disableClasses.value()) {
|
||||||
* PseudoRandom.random());
|
long privateClassComlexity = (long) (complexityLimit * PseudoRandom.random());
|
||||||
IRNode privateClasses = builder.setComplexityLimit(comlexityLimit)
|
try {
|
||||||
|
privateClasses = builder.setComplexityLimit(privateClassComlexity)
|
||||||
.getClassDefinitionBlockFactory()
|
.getClassDefinitionBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
if (privateClasses != null) {
|
} catch (ProductionFailedException ex) {
|
||||||
resultVis.append(privateClasses.accept(vis));
|
ex.printStackTrace(System.out);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
long mainComplexityLimit = (long) (ProductionParams.complexityLimit.value()
|
}
|
||||||
* PseudoRandom.random());
|
long mainClassComplexity = (long) (complexityLimit * PseudoRandom.random());
|
||||||
IRNode mainClass = builder.setComplexityLimit(mainComplexityLimit)
|
IRNode mainClass = null;
|
||||||
|
try {
|
||||||
|
mainClass = builder.setComplexityLimit(mainClassComplexity)
|
||||||
.getMainKlassFactory()
|
.getMainKlassFactory()
|
||||||
.produce();
|
.produce();
|
||||||
resultVis.append(mainClass.accept(vis));
|
TypeKlass aClass = new TypeKlass(name);
|
||||||
|
mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, true));
|
||||||
if (ProductionParams.printHierarchy.value()) {
|
mainClass.getChild(1).addChild(FixedTrees.generateMainOrExecuteMethod(aClass, false));
|
||||||
headerBuilder
|
} catch (ProductionFailedException ex) {
|
||||||
.append("/*\n")
|
ex.printStackTrace(System.out);
|
||||||
.append(Automatic.printHierarchy())
|
|
||||||
.append("*/\n");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace(System.out);
|
|
||||||
}
|
}
|
||||||
return headerBuilder.append(resultVis).toString();
|
return new Pair<>(mainClass, privateClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTestGenerator(String[] params) {
|
private static void initializeTestGenerator(String[] params) {
|
||||||
OptionResolver parser = new OptionResolver();
|
OptionResolver parser = new OptionResolver();
|
||||||
Option<String> propertyFileOpt = parser.addStringOption('p', "property-file", "",
|
Option<String> propertyFileOpt = parser.addStringOption('p', "property-file",
|
||||||
"File to read properties from");
|
"conf/default.properties", "File to read properties from");
|
||||||
ProductionParams.register(parser);
|
ProductionParams.register(parser);
|
||||||
parser.parse(params, propertyFileOpt);
|
parser.parse(params, propertyFileOpt);
|
||||||
jdk.test.lib.jittester.utils.PseudoRandom.reset(ProductionParams.seed.value());
|
PseudoRandom.reset(ProductionParams.seed.value());
|
||||||
TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(), ProductionParams.excludeMethodsFile.value());
|
TypesParser.parseTypesAndMethods(ProductionParams.classesFile.value(),
|
||||||
|
ProductionParams.excludeMethodsFile.value());
|
||||||
|
if (ProductionParams.specificSeed.isSet()) {
|
||||||
|
PseudoRandom.setCurrentSeed(ProductionParams.specificSeed.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
initializeTestGenerator(args);
|
initializeTestGenerator(args);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
try {
|
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 {
|
do {
|
||||||
double start = System.currentTimeMillis();
|
double start = System.currentTimeMillis();
|
||||||
|
System.out.print("[" + LocalTime.now() + "] |");
|
||||||
String name = "Test_" + counter;
|
String name = "Test_" + counter;
|
||||||
generateTestFile(name);
|
Pair<IRNode, IRNode> irTree = generateIRTree(name);
|
||||||
|
System.out.printf(" %8d |", counter);
|
||||||
double generationTime = System.currentTimeMillis() - start;
|
double generationTime = System.currentTimeMillis() - start;
|
||||||
String path = getJavaPath();
|
System.out.printf(" %8.0f |", generationTime);
|
||||||
ProcessBuilder pb = new ProcessBuilder(path + "javac", testbaseDir + "/" + name + ".java");
|
if (!ProductionParams.disableJavacodeGeneration.value()) {
|
||||||
runProcess(pb, testbaseDir + "/" + name);
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
|
||||||
pb = new ProcessBuilder(path + "java", "-Xint", "-cp", testbaseDir, name);
|
|
||||||
name = name + ".gold";
|
|
||||||
runProcess(pb, testbaseDir + "/" + name);
|
|
||||||
double runningTime = System.currentTimeMillis() - start;
|
double runningTime = System.currentTimeMillis() - start;
|
||||||
System.out.printf("%4d : generation time (ms) : %8.0f running time (ms) : %8.0f\n",
|
System.out.printf(" %8.0f |%n", runningTime);
|
||||||
counter, generationTime, runningTime);
|
if (runningTime < TimeUnit.MINUTES.toMillis(MINUTES_TO_WAIT)) {
|
||||||
if (runningTime < TimeUnit.MINUTES.toMillis(minutesToWait))
|
++counter;
|
||||||
++counter;
|
}
|
||||||
} while (counter < ProductionParams.numberOfTests.value());
|
} while (counter < ProductionParams.numberOfTests.value());
|
||||||
} catch (IOException | InterruptedException ex) {
|
} catch (IOException | InterruptedException ex) {
|
||||||
Logger.getLogger(Automatic.class.getName()).log(Level.SEVERE, null, ex);
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,65 +196,47 @@ public class Automatic {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runProcess(ProcessBuilder pb, String name)
|
private static int runProcess(ProcessBuilder pb, String name)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
pb.redirectError(new File(name + ".err"));
|
pb.redirectError(new File(name + ".err"));
|
||||||
pb.redirectOutput(new File(name + ".out"));
|
pb.redirectOutput(new File(name + ".out"));
|
||||||
Process process = pb.start();
|
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")) {
|
try (FileWriter file = new FileWriter(name + ".exit")) {
|
||||||
file.write(Integer.toString(process.exitValue()));
|
file.write(Integer.toString(process.exitValue()));
|
||||||
}
|
}
|
||||||
|
return process.exitValue();
|
||||||
} else {
|
} else {
|
||||||
process.destroyForcibly();
|
process.destroyForcibly();
|
||||||
}
|
return -1;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String printHierarchy() {
|
private static String printHierarchy() {
|
||||||
String r = "CLASS HIERARCHY:\n";
|
return TypeList.getAll().stream()
|
||||||
for (Type t : TypeList.getAll()) {
|
.filter(t -> t instanceof TypeKlass)
|
||||||
if (t instanceof TypeKlass) {
|
.map(t -> typeDescription((TypeKlass) t))
|
||||||
TypeKlass k = (TypeKlass) t;
|
.collect(Collectors.joining("\n","CLASS HIERARCHY:\n", "\n"));
|
||||||
if (k.isAbstract()) {
|
}
|
||||||
r += "abstract ";
|
|
||||||
}
|
private static String typeDescription(TypeKlass type) {
|
||||||
if (k.isFinal()) {
|
StringBuilder result = new StringBuilder();
|
||||||
r += "final ";
|
String parents = type.getParentsNames().stream().collect(Collectors.joining(","));
|
||||||
}
|
result.append(type.isAbstract() ? "abstract " : "")
|
||||||
if (k.isInterface()) {
|
.append(type.isFinal() ? "final " : "")
|
||||||
r += "interface ";
|
.append(type.isInterface() ? "interface " : "class ")
|
||||||
} else {
|
.append(type.getName())
|
||||||
r += "class ";
|
.append(parents.isEmpty() ? "" : ": " + parents);
|
||||||
}
|
return result.toString();
|
||||||
r += k.getName() + ": ";
|
}
|
||||||
HashSet<String> parents = k.getParentsNames();
|
|
||||||
if (parents != null) {
|
static void ensureExisting(Path path) {
|
||||||
Iterator<String> n = parents.iterator();
|
if (Files.notExists(path)) {
|
||||||
int size = parents.size();
|
try {
|
||||||
for (int i = 0; n.hasNext() && i < size - 1; i++) {
|
Files.createDirectories(path);
|
||||||
r += n.next() + ", ";
|
} catch (IOException ex) {
|
||||||
}
|
ex.printStackTrace();
|
||||||
if (n.hasNext()) {
|
|
||||||
r += n.next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r += "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,12 +26,8 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class BinaryOperator extends Operator {
|
public class BinaryOperator extends Operator {
|
||||||
protected String operationCode;
|
public BinaryOperator(OperatorKind opKind, Type resultType, IRNode leftOperand, IRNode rightOperand) {
|
||||||
protected Type resultType;
|
super(opKind, resultType);
|
||||||
|
|
||||||
public BinaryOperator(OperatorKind opKind, IRNode leftOperand, IRNode rightOperand) {
|
|
||||||
super(opKind.priority);
|
|
||||||
operationCode = opKind.text;
|
|
||||||
addChild(leftOperand);
|
addChild(leftOperand);
|
||||||
addChild(rightOperand);
|
addChild(rightOperand);
|
||||||
}
|
}
|
||||||
@ -47,10 +43,6 @@ public class BinaryOperator extends Operator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOperationCode() {
|
|
||||||
return operationCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
|
@ -28,17 +28,12 @@ import jdk.test.lib.jittester.types.TypeKlass;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class Block extends IRNode {
|
public class Block extends IRNode {
|
||||||
private final Type returnType;
|
|
||||||
|
|
||||||
public Block(TypeKlass klass, Type returnType, List<IRNode> content, int level) {
|
public Block(TypeKlass owner, Type returnType, List<? extends IRNode> content, int level) {
|
||||||
setKlass(klass);
|
super(returnType);
|
||||||
|
setOwner(owner);
|
||||||
addChildren(content);
|
addChildren(content);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.returnType = returnType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getReturnType() {
|
|
||||||
return returnType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int size() {
|
protected int size() {
|
||||||
|
@ -27,6 +27,10 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Break extends IRNode {
|
public class Break extends IRNode {
|
||||||
|
|
||||||
|
public Break() {
|
||||||
|
super(TypeList.VOID);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
|
@ -27,9 +27,9 @@ public abstract class BuiltInType extends Type {
|
|||||||
|
|
||||||
private static class BuiltInTypeCapacityHelper {
|
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++) {
|
for (int i = 0; i < builtInTypes.length; i++) {
|
||||||
if (typeName.compareTo(builtInTypes[i]) == 0) {
|
if (typeName.compareTo(builtInTypes[i]) == 0) {
|
||||||
return i;
|
return i;
|
||||||
@ -38,7 +38,7 @@ public abstract class BuiltInType extends Type {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public int compare(String typeName1, String typeName2) {
|
public static int compare(String typeName1, String typeName2) {
|
||||||
int i1 = getIndexFor(typeName1);
|
int i1 = getIndexFor(typeName1);
|
||||||
int i2 = getIndexFor(typeName2);
|
int i2 = getIndexFor(typeName2);
|
||||||
|
|
||||||
|
@ -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<IRNode, IRNode, String> {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,11 +26,9 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class CastOperator extends Operator {
|
public class CastOperator extends Operator {
|
||||||
private final Type resultType;
|
|
||||||
|
|
||||||
public CastOperator(Type resultType, IRNode casted) {
|
public CastOperator(Type resultType, IRNode casted) {
|
||||||
super(13);
|
super(null, 13, resultType);
|
||||||
this.resultType = resultType;
|
|
||||||
addChild(casted);
|
addChild(casted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +41,4 @@ public class CastOperator extends Operator {
|
|||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getResultType() {
|
|
||||||
return resultType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public class CatchBlock extends IRNode {
|
|||||||
public final List<Type> throwables;
|
public final List<Type> throwables;
|
||||||
|
|
||||||
public CatchBlock(IRNode body, List<Type> throwables, int level) {
|
public CatchBlock(IRNode body, List<Type> throwables, int level) {
|
||||||
|
super(body.getResultType());
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.throwables = Collections.unmodifiableList(throwables);
|
this.throwables = Collections.unmodifiableList(throwables);
|
||||||
addChild(body);
|
addChild(body);
|
||||||
|
@ -27,6 +27,10 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Continue extends IRNode {
|
public class Continue extends IRNode {
|
||||||
|
|
||||||
|
public Continue() {
|
||||||
|
super(TypeList.VOID);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
|
@ -27,6 +27,7 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Declaration extends IRNode {
|
public class Declaration extends IRNode {
|
||||||
public Declaration(IRNode declarationExpr) {
|
public Declaration(IRNode declarationExpr) {
|
||||||
|
super(declarationExpr.getResultType());
|
||||||
addChild(declarationExpr);
|
addChild(declarationExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,16 +37,26 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
public abstract class IRNode {
|
public abstract class IRNode {
|
||||||
private IRNode parent;
|
private IRNode parent;
|
||||||
private final List<IRNode> children = new ArrayList<>();
|
private final List<IRNode> children = new ArrayList<>();
|
||||||
protected IRNode klass;
|
protected TypeKlass owner;
|
||||||
protected int level;
|
protected int level;
|
||||||
|
private final Type resultType;
|
||||||
|
|
||||||
|
protected IRNode(Type resultType) {
|
||||||
|
this.resultType = resultType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getResultType() {
|
||||||
|
return resultType;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//private boolean isCFDeviation;
|
//private boolean isCFDeviation;
|
||||||
|
|
||||||
public abstract <T> T accept(Visitor<T> v);
|
public abstract <T> T accept(Visitor<T> v);
|
||||||
|
|
||||||
public void setKlass(TypeKlass klass) {
|
public void setOwner(TypeKlass owner) {
|
||||||
this.klass = klass;
|
this.owner = owner;
|
||||||
if (Objects.isNull(klass)) {
|
if (Objects.isNull(owner)) {
|
||||||
System.out.println(getClass().getName() + " null");
|
System.out.println(getClass().getName() + " null");
|
||||||
for (StackTraceElement s : Thread.currentThread().getStackTrace()) {
|
for (StackTraceElement s : Thread.currentThread().getStackTrace()) {
|
||||||
System.out.println(s.toString());
|
System.out.println(s.toString());
|
||||||
@ -55,20 +65,17 @@ public abstract class IRNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(IRNode child) {
|
public void addChild(IRNode child) {
|
||||||
children.add(child);
|
if (Objects.nonNull(child)) {
|
||||||
if (!Objects.isNull(child)) {
|
children.add(child);
|
||||||
child.parent = this;
|
child.parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChildren(List<? extends IRNode> ch) {
|
public void addChildren(List<? extends IRNode> ch) {
|
||||||
if (!Objects.isNull(ch)) {
|
if (Objects.nonNull(ch)) {
|
||||||
children.addAll(ch);
|
ch.stream()
|
||||||
for (IRNode c : ch) {
|
.filter(c -> c != null)
|
||||||
if (!Objects.isNull(c)) {
|
.forEach(this::addChild);
|
||||||
c.parent = this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +87,8 @@ public abstract class IRNode {
|
|||||||
return i < children.size() ? children.get(i) : null;
|
return i < children.size() ? children.get(i) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRNode getKlass() {
|
public TypeKlass getOwner() {
|
||||||
return klass;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRNode getParent() {
|
public IRNode getParent() {
|
||||||
@ -90,7 +97,7 @@ public abstract class IRNode {
|
|||||||
|
|
||||||
public void setChild(int index, IRNode child) {
|
public void setChild(int index, IRNode child) {
|
||||||
children.set(index, child);
|
children.set(index, child);
|
||||||
if (!Objects.isNull(child)) {
|
if (Objects.nonNull(child)) {
|
||||||
child.parent = this;
|
child.parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +152,7 @@ public abstract class IRNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
throw new Error("Should be toJavaCode");
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -154,7 +161,7 @@ public abstract class IRNode {
|
|||||||
|
|
||||||
public static long countDepth(Collection<IRNode> input) {
|
public static long countDepth(Collection<IRNode> input) {
|
||||||
return input.stream()
|
return input.stream()
|
||||||
.filter(c -> !Objects.isNull(c))
|
.filter(Objects::nonNull)
|
||||||
.mapToLong(IRNode::countDepth)
|
.mapToLong(IRNode::countDepth)
|
||||||
.max().orElse(0L);
|
.max().orElse(0L);
|
||||||
}
|
}
|
||||||
@ -166,7 +173,7 @@ public abstract class IRNode {
|
|||||||
public List<IRNode> getStackableLeaves() {
|
public List<IRNode> getStackableLeaves() {
|
||||||
List<IRNode> result = new ArrayList<>();
|
List<IRNode> result = new ArrayList<>();
|
||||||
children.stream()
|
children.stream()
|
||||||
.filter(c -> !Objects.isNull(c))
|
.filter(Objects::nonNull)
|
||||||
.forEach(c -> {
|
.forEach(c -> {
|
||||||
if (countDepth() == c.level && (c instanceof Block)) {
|
if (countDepth() == c.level && (c instanceof Block)) {
|
||||||
result.add(c);
|
result.add(c);
|
||||||
|
@ -30,9 +30,10 @@ public class If extends IRNode {
|
|||||||
CONDITION,
|
CONDITION,
|
||||||
THEN,
|
THEN,
|
||||||
ELSE,
|
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;
|
this.level = level;
|
||||||
resizeUpChildren(IfPart.values().length);
|
resizeUpChildren(IfPart.values().length);
|
||||||
setChild(IfPart.CONDITION.ordinal(), condition);
|
setChild(IfPart.CONDITION.ordinal(), condition);
|
||||||
@ -43,7 +44,7 @@ public class If extends IRNode {
|
|||||||
@Override
|
@Override
|
||||||
public long complexity() {
|
public long complexity() {
|
||||||
IRNode condition = getChild(IfPart.CONDITION.ordinal());
|
IRNode condition = getChild(IfPart.CONDITION.ordinal());
|
||||||
IRNode thenBlock= getChild(IfPart.THEN.ordinal());
|
IRNode thenBlock = getChild(IfPart.THEN.ordinal());
|
||||||
IRNode elseBlock = getChild(IfPart.ELSE.ordinal());
|
IRNode elseBlock = getChild(IfPart.ELSE.ordinal());
|
||||||
return (condition != null ? condition.complexity() : 0)
|
return (condition != null ? condition.complexity() : 0)
|
||||||
+ Math.max(thenBlock != null ? thenBlock.complexity() : 0,
|
+ Math.max(thenBlock != null ? thenBlock.complexity() : 0,
|
||||||
|
@ -26,20 +26,14 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public abstract class Initialization extends IRNode {
|
public abstract class Initialization extends IRNode {
|
||||||
protected VariableInfo variableInfo = new VariableInfo();
|
private final VariableInfo variableInfo;
|
||||||
|
|
||||||
protected Initialization() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Initialization(VariableInfo varInfo, IRNode initExpr) {
|
protected Initialization(VariableInfo varInfo, IRNode initExpr) {
|
||||||
|
super(varInfo.type);
|
||||||
variableInfo = varInfo;
|
variableInfo = varInfo;
|
||||||
addChild(initExpr);
|
addChild(initExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableInfo get() {
|
|
||||||
return variableInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long complexity() {
|
public long complexity() {
|
||||||
return getChild(0).complexity() + 1;
|
return getChild(0).complexity() + 1;
|
||||||
|
@ -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<IRNode, IRNode, String> {
|
||||||
|
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 "";
|
||||||
|
}
|
||||||
|
}
|
@ -27,11 +27,10 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Literal extends IRNode {
|
public class Literal extends IRNode {
|
||||||
public final Object value;
|
public final Object value;
|
||||||
protected final Type resultType;
|
|
||||||
|
|
||||||
public Literal(Object v, Type t) {
|
public Literal(Object v, Type t) {
|
||||||
|
super(t);
|
||||||
value = v;
|
value = v;
|
||||||
resultType = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,10 +43,6 @@ public class Literal extends IRNode {
|
|||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getResultType() {
|
|
||||||
return resultType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,9 @@ package jdk.test.lib.jittester;
|
|||||||
|
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class LocalVariable extends IRNode implements VariableBase {
|
public class LocalVariable extends VariableBase {
|
||||||
private VariableInfo value = new VariableInfo();
|
|
||||||
|
|
||||||
public LocalVariable(VariableInfo value) {
|
public LocalVariable(VariableInfo value) {
|
||||||
this.value = value;
|
super(value);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VariableInfo get() {
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jdk.test.lib.jittester;
|
|
||||||
|
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
|
||||||
|
|
||||||
public class LogicOperator extends IRNode {
|
|
||||||
|
|
||||||
protected LogicOperator() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public<T> T accept(Visitor<T> v) {
|
|
||||||
return v.visit(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,19 +25,13 @@ package jdk.test.lib.jittester;
|
|||||||
|
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class NonStaticMemberVariable extends IRNode implements VariableBase {
|
public class NonStaticMemberVariable extends VariableBase {
|
||||||
private final VariableInfo value;
|
|
||||||
|
|
||||||
public NonStaticMemberVariable(IRNode object, VariableInfo value) {
|
public NonStaticMemberVariable(IRNode object, VariableInfo value) {
|
||||||
this.value = value;
|
super(value);
|
||||||
addChild(object);
|
addChild(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VariableInfo get() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long complexity() {
|
public long complexity() {
|
||||||
return getChild(0).complexity();
|
return getChild(0).complexity();
|
||||||
@ -47,8 +41,4 @@ public class NonStaticMemberVariable extends IRNode implements VariableBase {
|
|||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableInfo getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Nothing extends IRNode {
|
public class Nothing extends IRNode {
|
||||||
|
|
||||||
|
public Nothing() {
|
||||||
|
super(TypeList.VOID);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long complexity() {
|
public long complexity() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,18 +24,28 @@
|
|||||||
package jdk.test.lib.jittester;
|
package jdk.test.lib.jittester;
|
||||||
|
|
||||||
public abstract class Operator extends IRNode {
|
public abstract class Operator extends IRNode {
|
||||||
protected int operatorPriority;
|
protected final OperatorKind opKind;
|
||||||
|
private final int priority;
|
||||||
|
|
||||||
public int getPriority() {
|
public int getPriority() {
|
||||||
return operatorPriority;
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperatorKind getOperationKind() {
|
||||||
|
return opKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Order {
|
public enum Order {
|
||||||
LEFT, RIGHT
|
LEFT, RIGHT
|
||||||
};
|
}
|
||||||
|
|
||||||
// This constructor is called to construct an IR-tree node.
|
protected Operator(OperatorKind opKind, Type resultType) {
|
||||||
protected Operator(int operatorPriority) {
|
this(opKind, opKind.priority, resultType);
|
||||||
this.operatorPriority = operatorPriority;
|
}
|
||||||
|
|
||||||
|
protected Operator(OperatorKind opKind, int operatorPriority, Type resultType) {
|
||||||
|
super(resultType);
|
||||||
|
this.opKind = opKind;
|
||||||
|
this.priority = operatorPriority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,58 +25,96 @@ package jdk.test.lib.jittester;
|
|||||||
|
|
||||||
// all unary and binary operator kinds
|
// all unary and binary operator kinds
|
||||||
public enum OperatorKind {
|
public enum OperatorKind {
|
||||||
COMPOUND_ADD("+=", 1),
|
/** a += b */
|
||||||
COMPOUND_SUB("-=", 1),
|
COMPOUND_ADD(1),
|
||||||
COMPOUND_MUL("*=", 1),
|
/** a -= b */
|
||||||
COMPOUND_DIV("-=", 1),
|
COMPOUND_SUB(1),
|
||||||
COMPOUND_MOD("%=", 1),
|
/** a *= b */
|
||||||
COMPOUND_AND("&=", 1),
|
COMPOUND_MUL(1),
|
||||||
COMPOUND_OR ("|=", 1),
|
/** a /= b */
|
||||||
COMPOUND_XOR("^=", 1),
|
COMPOUND_DIV(1),
|
||||||
COMPOUND_SHR(">>=", 1),
|
/** a %= b */
|
||||||
COMPOUND_SHL("<<=", 1),
|
COMPOUND_MOD(1),
|
||||||
COMPOUND_SAR(">>>=", 1),
|
/** a &= b */
|
||||||
ASSIGN ("=", 1),
|
COMPOUND_AND(1),
|
||||||
OR ("||", 3),
|
/** a |= b */
|
||||||
BIT_OR ("|", 5),
|
COMPOUND_OR (1),
|
||||||
BIT_XOR ("^", 6),
|
/** a ^= b */
|
||||||
AND ("&&", 7),
|
COMPOUND_XOR(1),
|
||||||
BIT_AND ("&", 7),
|
/** a >>= b */
|
||||||
EQ ("==", 8),
|
COMPOUND_SHR(1),
|
||||||
NE ("!=", 8),
|
/** a <<= b */
|
||||||
GT (">", 9),
|
COMPOUND_SHL(1),
|
||||||
LT ("<", 9),
|
/** a >>>= b */
|
||||||
GE (">=", 9),
|
COMPOUND_SAR(1),
|
||||||
LE ("<=", 9),
|
/** a = b */
|
||||||
SHR (">>", 10),
|
ASSIGN (1),
|
||||||
SHL ("<<", 10),
|
/** a || b */
|
||||||
SAR (">>>", 10),
|
OR (3),
|
||||||
ADD ("+", 11),
|
/** a | b */
|
||||||
STRADD ("+", 11),
|
BIT_OR (5),
|
||||||
SUB ("-", 11),
|
/** a ^ b */
|
||||||
MUL ("*", 12),
|
BIT_XOR (6),
|
||||||
DIV ("/", 12),
|
/** a && b */
|
||||||
MOD ("%", 12),
|
AND (7),
|
||||||
NOT ("!", 14),
|
/** a & b */
|
||||||
BIT_NOT ("~", 14),
|
BIT_AND (7),
|
||||||
UNARY_PLUS ("+", 14),
|
/** a == b */
|
||||||
UNARY_MINUS ("-", 14),
|
EQ (8),
|
||||||
PRE_DEC ("--", 15, true),
|
/** a != b */
|
||||||
POST_DEC ("--", 15, false),
|
NE (8),
|
||||||
PRE_INC ("++", 16, true),
|
/** a > b */
|
||||||
POST_INC ("++", 16, false),
|
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 int priority;
|
||||||
public final boolean isPrefix; // used for unary operators
|
public final boolean isPrefix; // used for unary operators
|
||||||
|
|
||||||
private OperatorKind(String text, int priority) {
|
private OperatorKind(int priority) {
|
||||||
this(text, priority, true);
|
this(priority, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OperatorKind(String text, int priority, boolean isPrefix) {
|
private OperatorKind(int priority, boolean isPrefix) {
|
||||||
this.text = text;
|
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.isPrefix = isPrefix;
|
this.isPrefix = isPrefix;
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,16 @@ package jdk.test.lib.jittester;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class PrintVariables extends IRNode {
|
public class PrintVariables extends IRNode {
|
||||||
private final String printerName;
|
|
||||||
private final ArrayList<Symbol> vars;
|
private final ArrayList<Symbol> vars;
|
||||||
|
|
||||||
public PrintVariables(String printerName, ArrayList<Symbol> vars, int level) {
|
public PrintVariables(TypeKlass owner, int level) {
|
||||||
this.printerName = printerName;
|
super(TypeList.VOID);
|
||||||
this.vars = vars;
|
this.owner = owner;
|
||||||
|
this.vars = SymbolTable.getAllCombined(owner, VariableInfo.class);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +46,4 @@ public class PrintVariables extends IRNode {
|
|||||||
public List<Symbol> getVars() {
|
public List<Symbol> getVars() {
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrinterName() {
|
|
||||||
return printerName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,14 @@ public class ProductionParams {
|
|||||||
public static Option<Boolean> disableNestedBlocks = null;
|
public static Option<Boolean> disableNestedBlocks = null;
|
||||||
public static Option<Boolean> disableArrays = null;
|
public static Option<Boolean> disableArrays = null;
|
||||||
public static Option<Boolean> enableFinalizers = null;
|
public static Option<Boolean> enableFinalizers = null;
|
||||||
|
public static Option<Boolean> disableBytecodeGeneration = null;
|
||||||
|
public static Option<Boolean> disableJavacodeGeneration = null;
|
||||||
// workaraound: to reduce chance throwing ArrayIndexOutOfBoundsException
|
// workaraound: to reduce chance throwing ArrayIndexOutOfBoundsException
|
||||||
public static Option<Integer> chanceExpressionIndex = null;
|
public static Option<Integer> chanceExpressionIndex = null;
|
||||||
public static Option<String> testbaseDir = null;
|
public static Option<String> testbaseDir = null;
|
||||||
public static Option<Integer> numberOfTests = null;
|
public static Option<Integer> numberOfTests = null;
|
||||||
public static Option<String> seed = null;
|
public static Option<String> seed = null;
|
||||||
|
public static Option<Long> specificSeed = null;
|
||||||
public static Option<String> classesFile = null;
|
public static Option<String> classesFile = null;
|
||||||
public static Option<String> excludeMethodsFile = null;
|
public static Option<String> excludeMethodsFile = null;
|
||||||
|
|
||||||
@ -117,11 +120,14 @@ public class ProductionParams {
|
|||||||
disableNestedBlocks = optionResolver.addBooleanOption("disable-nested-blocks", "Disable generation of nested blocks");
|
disableNestedBlocks = optionResolver.addBooleanOption("disable-nested-blocks", "Disable generation of nested blocks");
|
||||||
disableArrays = optionResolver.addBooleanOption("disable-arrays", "Disable generation of arrays");
|
disableArrays = optionResolver.addBooleanOption("disable-arrays", "Disable generation of arrays");
|
||||||
enableFinalizers = optionResolver.addBooleanOption("enable-finalizers", "Enable finalizers (for stress testing)");
|
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");
|
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");
|
testbaseDir = optionResolver.addStringOption("testbase-dir", ".", "Testbase dir");
|
||||||
numberOfTests = optionResolver.addIntegerOption('n', "number-of-tests", 0, "Number of test classes to generate");
|
numberOfTests = optionResolver.addIntegerOption('n', "number-of-tests", 0, "Number of test classes to generate");
|
||||||
seed = optionResolver.addStringOption("seed", "", "Random seed");
|
seed = optionResolver.addStringOption("seed", "", "Random seed");
|
||||||
classesFile = optionResolver.addStringOption('f', "classes-file", "", "File to read classes from");
|
specificSeed = optionResolver.addLongOption('z', "specificSeed", 0L, "A seed to be set for specific test generation(regular seed still needed for initialization)");
|
||||||
excludeMethodsFile = optionResolver.addStringOption('r', "exclude-methods-file", "", "File to read excluded methods from");
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,27 +32,26 @@ import jdk.test.lib.jittester.utils.PseudoRandom;
|
|||||||
/**
|
/**
|
||||||
* The Rule. A helper to perform production.
|
* The Rule. A helper to perform production.
|
||||||
*/
|
*/
|
||||||
public class Rule extends Factory implements Comparable<Rule> {
|
public class Rule<T extends IRNode> extends Factory<T> implements Comparable<Rule<T>> {
|
||||||
private String name;
|
private final String name;
|
||||||
|
private final TreeSet<RuleEntry> variants;
|
||||||
private Integer limit = -1;
|
private Integer limit = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Rule rule) {
|
public int compareTo(Rule<T> rule) {
|
||||||
return name.compareTo(rule.name);
|
return name.compareTo(rule.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeSet<RuleEntry> variants;
|
|
||||||
|
|
||||||
public Rule(String name) {
|
public Rule(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
variants = new TreeSet<>();
|
variants = new TreeSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String ruleName, Factory factory) {
|
public void add(String ruleName, Factory<? extends T> factory) {
|
||||||
add(ruleName, factory, 1.0);
|
add(ruleName, factory, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String ruleName, Factory factory, double weight) {
|
public void add(String ruleName, Factory<? extends T> factory, double weight) {
|
||||||
variants.add(new RuleEntry(ruleName, factory, weight));
|
variants.add(new RuleEntry(ruleName, factory, weight));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ public class Rule extends Factory implements Comparable<Rule> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public T produce() throws ProductionFailedException {
|
||||||
if (!variants.isEmpty()) {
|
if (!variants.isEmpty()) {
|
||||||
// Begin production.
|
// Begin production.
|
||||||
LinkedList<RuleEntry> rulesList = new LinkedList<>(variants);
|
LinkedList<RuleEntry> rulesList = new LinkedList<>(variants);
|
||||||
@ -98,19 +97,19 @@ public class Rule extends Factory implements Comparable<Rule> {
|
|||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RuleEntry extends Factory implements Comparable<RuleEntry> {
|
private class RuleEntry extends Factory<T> implements Comparable<RuleEntry> {
|
||||||
private final double weight;
|
private final double weight;
|
||||||
private final Factory factory;
|
private final Factory<? extends T> factory;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private RuleEntry(String name, Factory factory, double weight) {
|
private RuleEntry(String name, Factory<? extends T> factory, double weight) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public T produce() throws ProductionFailedException {
|
||||||
return factory.produce();
|
return factory.produce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ public class Statement extends IRNode {
|
|||||||
private final boolean needSemicolon;
|
private final boolean needSemicolon;
|
||||||
|
|
||||||
public Statement(IRNode statementBody, boolean needSemicolon) {
|
public Statement(IRNode statementBody, boolean needSemicolon) {
|
||||||
|
super(statementBody.getResultType());
|
||||||
this.needSemicolon = needSemicolon;
|
this.needSemicolon = needSemicolon;
|
||||||
addChild(statementBody);
|
addChild(statementBody);
|
||||||
}
|
}
|
||||||
|
@ -26,17 +26,11 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class StaticMemberVariable extends IRNode implements VariableBase {
|
public class StaticMemberVariable extends VariableBase {
|
||||||
private final VariableInfo varInfo;
|
|
||||||
|
|
||||||
public StaticMemberVariable(TypeKlass owner, VariableInfo varInfo) {
|
public StaticMemberVariable(TypeKlass owner, VariableInfo varInfo) {
|
||||||
setKlass(owner);
|
super(varInfo);
|
||||||
this.varInfo = varInfo;
|
setOwner(owner);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VariableInfo get() {
|
|
||||||
return varInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,6 +30,7 @@ public class Switch extends IRNode {
|
|||||||
private final int caseBlockIdx;
|
private final int caseBlockIdx;
|
||||||
|
|
||||||
public Switch(int level, List<IRNode> chldrn, int caseBlockIdx) {
|
public Switch(int level, List<IRNode> chldrn, int caseBlockIdx) {
|
||||||
|
super(chldrn.get(caseBlockIdx).getResultType());
|
||||||
this.level = level;
|
this.level = level;
|
||||||
addChildren(chldrn);
|
addChildren(chldrn);
|
||||||
this.caseBlockIdx = caseBlockIdx;
|
this.caseBlockIdx = caseBlockIdx;
|
||||||
|
@ -29,7 +29,7 @@ public class Symbol {
|
|||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Type type;
|
public Type type;
|
||||||
public TypeKlass klass;
|
public TypeKlass owner;
|
||||||
public static final int NONE = 0x00;
|
public static final int NONE = 0x00;
|
||||||
public static final int PRIVATE = 0x01;
|
public static final int PRIVATE = 0x01;
|
||||||
public static final int DEFAULT = 0x02;
|
public static final int DEFAULT = 0x02;
|
||||||
@ -47,16 +47,16 @@ public class Symbol {
|
|||||||
this.name = name;
|
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.name = name;
|
||||||
this.klass = klass;
|
this.owner = owner;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Symbol(Symbol value) {
|
protected Symbol(Symbol value) {
|
||||||
this.name = value.name;
|
this.name = value.name;
|
||||||
this.klass = value.klass;
|
this.owner = value.owner;
|
||||||
this.type = value.type;
|
this.type = value.type;
|
||||||
this.flags = value.flags;
|
this.flags = value.flags;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ public class Symbol {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Symbol s = (Symbol) o;
|
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) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -110,4 +110,9 @@ public class Symbol {
|
|||||||
public Symbol deepCopy() {
|
public Symbol deepCopy() {
|
||||||
return new Symbol(this);
|
return new Symbol(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TypeKlass getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
|
|
||||||
@ -42,9 +43,8 @@ public class SymbolTable {
|
|||||||
|
|
||||||
String classList = ProductionParams.addExternalSymbols.value();
|
String classList = ProductionParams.addExternalSymbols.value();
|
||||||
if (classList.equals("all")) {
|
if (classList.equals("all")) {
|
||||||
for (Type type : TypeList.getReferenceTypes()) {
|
TypeList.getReferenceTypes()
|
||||||
type.exportSymbols();
|
.forEach(Type::exportSymbols);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String[] splittedList = classList.split(",");
|
String[] splittedList = classList.split(",");
|
||||||
for (Type type : TypeList.getReferenceTypes()) {
|
for (Type type : TypeList.getReferenceTypes()) {
|
||||||
@ -96,13 +96,9 @@ public class SymbolTable {
|
|||||||
public static Collection<Symbol> get(Type type, Class<?> classToCheck) {
|
public static Collection<Symbol> get(Type type, Class<?> classToCheck) {
|
||||||
HashMap<Type, ArrayList<Symbol>> vars = SYMBOL_STACK.peek();
|
HashMap<Type, ArrayList<Symbol>> vars = SYMBOL_STACK.peek();
|
||||||
if (vars.containsKey(type)) {
|
if (vars.containsKey(type)) {
|
||||||
ArrayList<Symbol> result = new ArrayList<>();
|
return vars.get(type).stream()
|
||||||
for (Symbol symbol : vars.get(type)) {
|
.filter(classToCheck::isInstance)
|
||||||
if (classToCheck.isInstance(symbol)) {
|
.collect(Collectors.toList());
|
||||||
result.add(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -113,7 +109,7 @@ public class SymbolTable {
|
|||||||
if (vars.containsKey(type)) {
|
if (vars.containsKey(type)) {
|
||||||
ArrayList<Symbol> result = new ArrayList<>();
|
ArrayList<Symbol> result = new ArrayList<>();
|
||||||
for (Symbol symbol : vars.get(type)) {
|
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);
|
result.add(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +146,7 @@ public class SymbolTable {
|
|||||||
for (Type type : SYMBOL_STACK.peek().keySet()) {
|
for (Type type : SYMBOL_STACK.peek().keySet()) {
|
||||||
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(type);
|
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(type);
|
||||||
for (Symbol symbol : symbolsOfType) {
|
for (Symbol symbol : symbolsOfType) {
|
||||||
if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.klass)) {
|
if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.owner)) {
|
||||||
if (!result.containsKey(type)) {
|
if (!result.containsKey(type)) {
|
||||||
result.put(type, new ArrayList<>());
|
result.put(type, new ArrayList<>());
|
||||||
}
|
}
|
||||||
@ -193,7 +189,7 @@ public class SymbolTable {
|
|||||||
for (Type type : SYMBOL_STACK.peek().keySet()) {
|
for (Type type : SYMBOL_STACK.peek().keySet()) {
|
||||||
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(type);
|
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(type);
|
||||||
for (Symbol symbol : symbolsOfType) {
|
for (Symbol symbol : symbolsOfType) {
|
||||||
if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.klass)) {
|
if (classToCheck.isInstance(symbol) && typeKlass.equals(symbol.owner)) {
|
||||||
result.add(symbol);
|
result.add(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +203,7 @@ public class SymbolTable {
|
|||||||
for (Type t : SYMBOL_STACK.peek().keySet()) {
|
for (Type t : SYMBOL_STACK.peek().keySet()) {
|
||||||
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(t);
|
ArrayList<Symbol> symbolsOfType = SYMBOL_STACK.peek().get(t);
|
||||||
for (Symbol symbol : symbolsOfType) {
|
for (Symbol symbol : symbolsOfType) {
|
||||||
if (typeKlass.equals(symbol.klass)) {
|
if (typeKlass.equals(symbol.owner)) {
|
||||||
result.add(symbol);
|
result.add(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -30,12 +30,11 @@ public class TernaryOperator extends Operator {
|
|||||||
CONDITION,
|
CONDITION,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
FALSE,
|
||||||
};
|
}
|
||||||
//protected Production conditionalExpression, leftExpression, rightExpression;
|
//protected Production conditionalExpression, leftExpression, rightExpression;
|
||||||
protected Type resultType;
|
|
||||||
|
|
||||||
public TernaryOperator(IRNode condition, IRNode trueBranch, IRNode falseBranch) {
|
public TernaryOperator(IRNode condition, IRNode trueBranch, IRNode falseBranch) {
|
||||||
super(2);
|
super(null, 2, trueBranch.getResultType());
|
||||||
resizeUpChildren(TernaryPart.values().length);
|
resizeUpChildren(TernaryPart.values().length);
|
||||||
setChild(TernaryPart.CONDITION.ordinal(), condition);
|
setChild(TernaryPart.CONDITION.ordinal(), condition);
|
||||||
setChild(TernaryPart.TRUE.ordinal(), trueBranch);
|
setChild(TernaryPart.TRUE.ordinal(), trueBranch);
|
||||||
|
@ -27,6 +27,7 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class Throw extends IRNode {
|
public class Throw extends IRNode {
|
||||||
public Throw(IRNode throwable) {
|
public Throw(IRNode throwable) {
|
||||||
|
super(throwable.getResultType());
|
||||||
addChild(throwable);
|
addChild(throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import jdk.test.lib.jittester.visitors.Visitor;
|
|||||||
|
|
||||||
public class TryCatchBlock extends IRNode {
|
public class TryCatchBlock extends IRNode {
|
||||||
public TryCatchBlock(IRNode body, IRNode finallyBlock, List<CatchBlock> catchBlocks, int level) {
|
public TryCatchBlock(IRNode body, IRNode finallyBlock, List<CatchBlock> catchBlocks, int level) {
|
||||||
|
super(body.getResultType());
|
||||||
this.level = level;
|
this.level = level;
|
||||||
addChild(body);
|
addChild(body);
|
||||||
addChild(finallyBlock);
|
addChild(finallyBlock);
|
||||||
|
@ -33,9 +33,15 @@ public abstract class Type extends IRNode implements Comparable<Type> {
|
|||||||
private final String typeName;
|
private final String typeName;
|
||||||
|
|
||||||
protected Type(String typeName) {
|
protected Type(String typeName) {
|
||||||
|
super(null);
|
||||||
this.typeName = typeName;
|
this.typeName = typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getResultType() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object t) {
|
public boolean equals(Object t) {
|
||||||
if (this == t) {
|
if (this == t) {
|
||||||
|
@ -27,19 +27,31 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
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.TypeBoolean;
|
||||||
import jdk.test.lib.jittester.types.TypeByte;
|
import jdk.test.lib.jittester.types.TypeByte;
|
||||||
import jdk.test.lib.jittester.types.TypeChar;
|
import jdk.test.lib.jittester.types.TypeChar;
|
||||||
import jdk.test.lib.jittester.types.TypeDouble;
|
import jdk.test.lib.jittester.types.TypeDouble;
|
||||||
import jdk.test.lib.jittester.types.TypeFloat;
|
import jdk.test.lib.jittester.types.TypeFloat;
|
||||||
import jdk.test.lib.jittester.types.TypeInt;
|
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.TypeLong;
|
||||||
import jdk.test.lib.jittester.types.TypeShort;
|
import jdk.test.lib.jittester.types.TypeShort;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
import jdk.test.lib.jittester.types.TypeVoid;
|
||||||
|
|
||||||
public class TypeList {
|
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<Type> TYPES = new ArrayList<>();
|
private static final List<Type> TYPES = new ArrayList<>();
|
||||||
private static final List<Type> BUILTIN_TYPES = new ArrayList<>();
|
private static final List<Type> BUILTIN_TYPES = new ArrayList<>();
|
||||||
private static final List<Type> BUILTIN_INT_TYPES = new ArrayList<>();
|
private static final List<Type> BUILTIN_INT_TYPES = new ArrayList<>();
|
||||||
@ -47,14 +59,14 @@ public class TypeList {
|
|||||||
private static final List<Type> REFERENCE_TYPES = new ArrayList<>();
|
private static final List<Type> REFERENCE_TYPES = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BUILTIN_INT_TYPES.add(new TypeBoolean());
|
BUILTIN_INT_TYPES.add(BOOLEAN);
|
||||||
BUILTIN_INT_TYPES.add(new TypeByte());
|
BUILTIN_INT_TYPES.add(BYTE);
|
||||||
BUILTIN_INT_TYPES.add(new TypeChar());
|
BUILTIN_INT_TYPES.add(CHAR);
|
||||||
BUILTIN_INT_TYPES.add(new TypeShort());
|
BUILTIN_INT_TYPES.add(SHORT);
|
||||||
BUILTIN_INT_TYPES.add(new TypeInt());
|
BUILTIN_INT_TYPES.add(INT);
|
||||||
BUILTIN_INT_TYPES.add(new TypeLong());
|
BUILTIN_INT_TYPES.add(LONG);
|
||||||
BUILTIN_FP_TYPES.add(new TypeFloat());
|
BUILTIN_FP_TYPES.add(FLOAT);
|
||||||
BUILTIN_FP_TYPES.add(new TypeDouble());
|
BUILTIN_FP_TYPES.add(DOUBLE);
|
||||||
|
|
||||||
BUILTIN_TYPES.addAll(BUILTIN_INT_TYPES);
|
BUILTIN_TYPES.addAll(BUILTIN_INT_TYPES);
|
||||||
BUILTIN_TYPES.addAll(BUILTIN_FP_TYPES);
|
BUILTIN_TYPES.addAll(BUILTIN_FP_TYPES);
|
||||||
@ -62,13 +74,13 @@ public class TypeList {
|
|||||||
TYPES.addAll(BUILTIN_TYPES);
|
TYPES.addAll(BUILTIN_TYPES);
|
||||||
|
|
||||||
if (!ProductionParams.disableArrays.value()) {
|
if (!ProductionParams.disableArrays.value()) {
|
||||||
REFERENCE_TYPES.add(new TypeArray().produce());
|
|
||||||
TYPES.addAll(REFERENCE_TYPES);
|
TYPES.addAll(REFERENCE_TYPES);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static TypeVoid getVoid() {
|
STRING.addParent(OBJECT.getName());
|
||||||
return TYPE_VOID;
|
STRING.setParent(OBJECT);
|
||||||
|
add(STRING);
|
||||||
|
add(OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Type> getAll() {
|
public static Collection<Type> getAll() {
|
||||||
@ -100,14 +112,14 @@ public class TypeList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBuiltIn(Type t) {
|
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) {
|
protected static boolean isIn(Type t) {
|
||||||
return TYPES.contains(t);
|
return TYPES.contains(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static boolean isReferenceType(Type t) {
|
public static boolean isReferenceType(Type t) {
|
||||||
return REFERENCE_TYPES.contains(t);
|
return REFERENCE_TYPES.contains(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ import jdk.test.lib.Asserts;
|
|||||||
import jdk.test.lib.jittester.functions.FunctionInfo;
|
import jdk.test.lib.jittester.functions.FunctionInfo;
|
||||||
import jdk.test.lib.jittester.types.TypeArray;
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
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
|
* Class used for parsing included classes file and excluded methods file
|
||||||
@ -62,7 +61,7 @@ public class TypesParser {
|
|||||||
public static void parseTypesAndMethods(String klassesFileName, String exMethodsFileName) {
|
public static void parseTypesAndMethods(String klassesFileName, String exMethodsFileName) {
|
||||||
Asserts.assertNotNull(klassesFileName, "Classes input file name is null");
|
Asserts.assertNotNull(klassesFileName, "Classes input file name is null");
|
||||||
Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty");
|
Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty");
|
||||||
Set<Class<?>> klasses = parseKlasses(klassesFileName);
|
List<Class<?>> klasses = parseKlasses(klassesFileName);
|
||||||
Set<Executable> methodsToExclude;
|
Set<Executable> methodsToExclude;
|
||||||
if (exMethodsFileName != null && !exMethodsFileName.isEmpty()) {
|
if (exMethodsFileName != null && !exMethodsFileName.isEmpty()) {
|
||||||
methodsToExclude = parseMethods(exMethodsFileName);
|
methodsToExclude = parseMethods(exMethodsFileName);
|
||||||
@ -119,15 +118,18 @@ public class TypesParser {
|
|||||||
}
|
}
|
||||||
if (klass.isPrimitive()) {
|
if (klass.isPrimitive()) {
|
||||||
if (klass.equals(void.class)) {
|
if (klass.equals(void.class)) {
|
||||||
type = new TypeVoid();
|
type = TypeList.VOID;
|
||||||
} else {
|
} else {
|
||||||
type = TypeList.find(klass.getName());
|
type = TypeList.find(klass.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int flags = getKlassFlags(klass);
|
int flags = getKlassFlags(klass);
|
||||||
if (klass.isArray()) {
|
if (klass.isArray()) {
|
||||||
TypeKlass elementType
|
Class<?> elementKlass = klass.getComponentType();
|
||||||
= new TypeKlass(klass.getCanonicalName().replaceAll("\\[\\]", ""), flags);
|
while (elementKlass.isArray()) {
|
||||||
|
elementKlass = elementKlass.getComponentType();
|
||||||
|
}
|
||||||
|
Type elementType = getType(elementKlass);
|
||||||
int dim = getArrayClassDimension(klass);
|
int dim = getArrayClassDimension(klass);
|
||||||
type = new TypeArray(elementType, dim);
|
type = new TypeArray(elementType, dim);
|
||||||
} else {
|
} else {
|
||||||
@ -138,10 +140,14 @@ public class TypesParser {
|
|||||||
type = new TypeKlass(canonicalName, flags);
|
type = new TypeKlass(canonicalName, flags);
|
||||||
}
|
}
|
||||||
Class<?> parentKlass = klass.getSuperclass();
|
Class<?> parentKlass = klass.getSuperclass();
|
||||||
|
TypeKlass typeKlass = (TypeKlass) type;
|
||||||
if (parentKlass != null) {
|
if (parentKlass != null) {
|
||||||
TypeKlass parentTypeKlass = (TypeKlass) getType(parentKlass);
|
TypeKlass parentTypeKlass = (TypeKlass) getType(parentKlass);
|
||||||
((TypeKlass) type).addParent(parentTypeKlass.getName());
|
typeKlass.addParent(parentTypeKlass.getName());
|
||||||
((TypeKlass) type).setParent(parentTypeKlass);
|
typeKlass.setParent(parentTypeKlass);
|
||||||
|
}
|
||||||
|
for (Class<?> iface : klass.getInterfaces()) {
|
||||||
|
typeKlass.addParent(getType(iface).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TYPE_CACHE.put(klass, type);
|
TYPE_CACHE.put(klass, type);
|
||||||
@ -197,10 +203,10 @@ public class TypesParser {
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Class<?>> parseKlasses(String klassesFileName) {
|
private static List<Class<?>> parseKlasses(String klassesFileName) {
|
||||||
Asserts.assertNotNull(klassesFileName, "Classes input file name is null");
|
Asserts.assertNotNull(klassesFileName, "Classes input file name is null");
|
||||||
Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty");
|
Asserts.assertFalse(klassesFileName.isEmpty(), "Classes input file name is empty");
|
||||||
Set<String> klassNamesSet = new HashSet<>();
|
List<String> klassNamesList = new ArrayList<>();
|
||||||
Path klassesFilePath = (new File(klassesFileName)).toPath();
|
Path klassesFilePath = (new File(klassesFileName)).toPath();
|
||||||
try {
|
try {
|
||||||
Files.lines(klassesFilePath).forEach(line -> {
|
Files.lines(klassesFilePath).forEach(line -> {
|
||||||
@ -211,20 +217,20 @@ public class TypesParser {
|
|||||||
String msg = String.format("Format of the classes input file \"%s\" is incorrect,"
|
String msg = String.format("Format of the classes input file \"%s\" is incorrect,"
|
||||||
+ " line \"%s\" has wrong format", klassesFileName, line);
|
+ " line \"%s\" has wrong format", klassesFileName, line);
|
||||||
Asserts.assertTrue(line.matches("\\w[\\w\\.$]*"), msg);
|
Asserts.assertTrue(line.matches("\\w[\\w\\.$]*"), msg);
|
||||||
klassNamesSet.add(line.replaceAll(";", ""));
|
klassNamesList.add(line.replaceAll(";", ""));
|
||||||
});
|
});
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new Error("Error reading klasses file", ex);
|
throw new Error("Error reading klasses file", ex);
|
||||||
}
|
}
|
||||||
Set<Class<?>> klassesSet = new HashSet<>();
|
List<Class<?>> klassesList = new ArrayList<>();
|
||||||
klassNamesSet.stream().forEach(klassName -> {
|
klassNamesList.stream().forEach(klassName -> {
|
||||||
try {
|
try {
|
||||||
klassesSet.add(Class.forName(klassName));
|
klassesList.add(Class.forName(klassName));
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
throw new Error("Unexpected exception while parsing klasses file", ex);
|
throw new Error("Unexpected exception while parsing klasses file", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return klassesSet;
|
return klassesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Executable> parseMethods(String methodsFileName) {
|
private static Set<Executable> parseMethods(String methodsFileName) {
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -26,12 +26,8 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class UnaryOperator extends Operator {
|
public class UnaryOperator extends Operator {
|
||||||
protected OperatorKind opKind;
|
|
||||||
protected Type resultType;
|
|
||||||
|
|
||||||
public UnaryOperator(OperatorKind opKind, IRNode expression) {
|
public UnaryOperator(OperatorKind opKind, IRNode expression) {
|
||||||
super(opKind.priority);
|
super(opKind, expression.getResultType());
|
||||||
this.opKind = opKind;
|
|
||||||
addChild(expression);
|
addChild(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +45,4 @@ public class UnaryOperator extends Operator {
|
|||||||
public boolean isPrefix() {
|
public boolean isPrefix() {
|
||||||
return opKind.isPrefix;
|
return opKind.isPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOperatorText() {
|
|
||||||
return opKind.text;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,14 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,10 @@ package jdk.test.lib.jittester;
|
|||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class VariableDeclaration extends IRNode {
|
public class VariableDeclaration extends IRNode {
|
||||||
protected final VariableInfo variableInfo;
|
private final VariableInfo variableInfo;
|
||||||
|
|
||||||
public VariableDeclaration(VariableInfo value) {
|
public VariableDeclaration(VariableInfo value) {
|
||||||
|
super(value.type);
|
||||||
variableInfo = value;
|
variableInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
package jdk.test.lib.jittester;
|
package jdk.test.lib.jittester;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class VariableDeclarationBlock extends IRNode {
|
public class VariableDeclarationBlock extends IRNode {
|
||||||
public VariableDeclarationBlock(ArrayList<IRNode> content, int level) {
|
public VariableDeclarationBlock(ArrayList<? extends Declaration> content, int level) {
|
||||||
|
super(TypeList.VOID);
|
||||||
addChildren(content);
|
addChildren(content);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
}
|
}
|
||||||
@ -40,10 +42,6 @@ public class VariableDeclarationBlock extends IRNode {
|
|||||||
.sum();
|
.sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int size() {
|
|
||||||
return getChildren() != null ? getChildren().size() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public<T> T accept(Visitor<T> v) {
|
public<T> T accept(Visitor<T> v) {
|
||||||
return v.visit(this);
|
return v.visit(this);
|
||||||
|
@ -55,4 +55,8 @@ public class VariableInfo extends Symbol {
|
|||||||
public Symbol deepCopy() {
|
public Symbol deepCopy() {
|
||||||
return new VariableInfo(this);
|
return new VariableInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLocal() {
|
||||||
|
return (flags & LOCAL) != 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
import jdk.test.lib.jittester.Literal;
|
import jdk.test.lib.jittester.Literal;
|
||||||
import jdk.test.lib.jittester.Type;
|
|
||||||
import jdk.test.lib.jittester.VariableDeclaration;
|
import jdk.test.lib.jittester.VariableDeclaration;
|
||||||
import jdk.test.lib.jittester.types.TypeArray;
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
@ -39,6 +38,7 @@ public class ArrayCreation extends IRNode {
|
|||||||
private final List<Byte> dims;
|
private final List<Byte> dims;
|
||||||
|
|
||||||
public ArrayCreation(VariableDeclaration var, TypeArray array, ArrayList<IRNode> dimensionSizeExpressions) {
|
public ArrayCreation(VariableDeclaration var, TypeArray array, ArrayList<IRNode> dimensionSizeExpressions) {
|
||||||
|
super(array);
|
||||||
this.variable = var;
|
this.variable = var;
|
||||||
this.array = array;
|
this.array = array;
|
||||||
addChildren(dimensionSizeExpressions);
|
addChildren(dimensionSizeExpressions);
|
||||||
@ -55,8 +55,8 @@ public class ArrayCreation extends IRNode {
|
|||||||
type.setDimentions(dims);
|
type.setDimentions(dims);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getArrayType() {
|
public TypeArray getArrayType() {
|
||||||
return array.type;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,10 +25,12 @@ package jdk.test.lib.jittester.arrays;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class ArrayElement extends IRNode {
|
public class ArrayElement extends IRNode {
|
||||||
public ArrayElement(IRNode array, ArrayList<IRNode> dimensionExpressions) {
|
public ArrayElement(IRNode array, ArrayList<IRNode> dimensionExpressions) {
|
||||||
|
super(((TypeArray) array.getResultType()).type);
|
||||||
addChild(array);
|
addChild(array);
|
||||||
addChildren(dimensionExpressions);
|
addChildren(dimensionExpressions);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ dimentions, where N < M.
|
|||||||
public class ArrayExtraction extends IRNode {
|
public class ArrayExtraction extends IRNode {
|
||||||
private final List<Byte> dims;
|
private final List<Byte> dims;
|
||||||
public ArrayExtraction(IRNode array, ArrayList<IRNode> dimensionExpressions) {
|
public ArrayExtraction(IRNode array, ArrayList<IRNode> dimensionExpressions) {
|
||||||
|
super(array.getResultType());
|
||||||
addChild(array);
|
addChild(array);
|
||||||
addChildren(dimensionExpressions);
|
addChildren(dimensionExpressions);
|
||||||
if (array instanceof ArrayCreation) {
|
if (array instanceof ArrayCreation) {
|
||||||
@ -56,7 +57,7 @@ public class ArrayExtraction extends IRNode {
|
|||||||
}
|
}
|
||||||
} else if (array instanceof LocalVariable) {
|
} else if (array instanceof LocalVariable) {
|
||||||
LocalVariable loc = (LocalVariable) array;
|
LocalVariable loc = (LocalVariable) array;
|
||||||
TypeArray type = (TypeArray) loc.get().type;
|
TypeArray type = (TypeArray) loc.getVariableInfo().type;
|
||||||
dims = type.getDims();
|
dims = type.getDims();
|
||||||
for (int i = dimensionExpressions.size(); i < type.dimensions; ++i) {
|
for (int i = dimensionExpressions.size(); i < type.dimensions; ++i) {
|
||||||
dims.add(type.getDims().get(i));
|
dims.add(type.getDims().get(i));
|
||||||
|
@ -25,10 +25,12 @@ package jdk.test.lib.jittester.classes;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
public class ClassDefinitionBlock extends IRNode {
|
public class ClassDefinitionBlock extends IRNode {
|
||||||
public ClassDefinitionBlock(ArrayList<IRNode> content, int level) {
|
public ClassDefinitionBlock(ArrayList<IRNode> content, int level) {
|
||||||
|
super(TypeList.VOID);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
addChildren(content);
|
addChildren(content);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
package jdk.test.lib.jittester.classes;
|
package jdk.test.lib.jittester.classes;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.visitors.Visitor;
|
import jdk.test.lib.jittester.visitors.Visitor;
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ public class Interface extends IRNode {
|
|||||||
private TypeKlass parent = null;
|
private TypeKlass parent = null;
|
||||||
|
|
||||||
public Interface(TypeKlass parent, String name, int level, IRNode functionDeclaraionBlock) {
|
public Interface(TypeKlass parent, String name, int level, IRNode functionDeclaraionBlock) {
|
||||||
|
super(TypeList.find(functionDeclaraionBlock.getOwner().getName()));
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
@ -70,19 +70,21 @@ public class Klass extends IRNode {
|
|||||||
IRNode functionDefinitions, IRNode abstractFunctionRedefinitions,
|
IRNode functionDefinitions, IRNode abstractFunctionRedefinitions,
|
||||||
IRNode overridenFunctionRedefitions, IRNode functionDeclarations,
|
IRNode overridenFunctionRedefitions, IRNode functionDeclarations,
|
||||||
IRNode printVariablesBlock) {
|
IRNode printVariablesBlock) {
|
||||||
|
super(thisKlass);
|
||||||
this.thisKlass = thisKlass;
|
this.thisKlass = thisKlass;
|
||||||
klass = thisKlass;
|
owner = thisKlass;
|
||||||
this.parentKlass = parent;
|
this.parentKlass = parent;
|
||||||
this.interfaces = interfaces;
|
this.interfaces = interfaces;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
addChild(variableDeclarations);
|
resizeUpChildren(KlassPart.values().length);
|
||||||
addChild(constructorDefinitions);
|
setChild(KlassPart.DATA_MEMBERS.ordinal(), variableDeclarations);
|
||||||
addChild(abstractFunctionRedefinitions);
|
setChild(KlassPart.CONSTRUCTORS.ordinal(), constructorDefinitions);
|
||||||
addChild(overridenFunctionRedefitions);
|
setChild(KlassPart.REDEFINED_FUNCTIONS.ordinal(), abstractFunctionRedefinitions);
|
||||||
addChild(functionDefinitions);
|
setChild(KlassPart.OVERRIDEN_FUNCTIONS.ordinal(), overridenFunctionRedefitions);
|
||||||
addChild(functionDeclarations);
|
setChild(KlassPart.MEMBER_FUNCTIONS.ordinal(), functionDefinitions);
|
||||||
addChild(printVariablesBlock);
|
setChild(KlassPart.MEMBER_FUNCTIONS_DECLARATIONS.ordinal(), functionDeclarations);
|
||||||
|
setChild(KlassPart.PRINT_VARIABLES.ordinal(), printVariablesBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,6 +40,7 @@ public class MainKlass extends IRNode {
|
|||||||
|
|
||||||
public MainKlass(String name, TypeKlass thisKlass, IRNode variableDeclarations,
|
public MainKlass(String name, TypeKlass thisKlass, IRNode variableDeclarations,
|
||||||
IRNode functionDefinitions, IRNode testFunction, IRNode printVariables) {
|
IRNode functionDefinitions, IRNode testFunction, IRNode printVariables) {
|
||||||
|
super(thisKlass);
|
||||||
addChild(variableDeclarations);
|
addChild(variableDeclarations);
|
||||||
addChild(functionDefinitions);
|
addChild(functionDefinitions);
|
||||||
addChild(testFunction);
|
addChild(testFunction);
|
||||||
@ -64,4 +65,8 @@ public class MainKlass extends IRNode {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TypeKlass getThisKlass() {
|
||||||
|
return thisKlass;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ArgumentDeclarationFactory extends Factory {
|
class ArgumentDeclarationFactory extends Factory<ArgumentDeclaration> {
|
||||||
private final int argumentNumber;
|
private final int argumentNumber;
|
||||||
private final TypeKlass ownerClass;
|
private final TypeKlass ownerClass;
|
||||||
|
|
||||||
|
@ -23,15 +23,15 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
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.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Rule;
|
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;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class ArithmeticOperatorFactory extends Factory {
|
class ArithmeticOperatorFactory extends Factory<Operator> {
|
||||||
private final Rule rule;
|
private final Rule<Operator> rule;
|
||||||
|
|
||||||
ArithmeticOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass,
|
ArithmeticOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass,
|
||||||
Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
||||||
@ -42,7 +42,7 @@ class ArithmeticOperatorFactory extends Factory {
|
|||||||
.setResultType(resultType)
|
.setResultType(resultType)
|
||||||
.setExceptionSafe(exceptionSafe)
|
.setExceptionSafe(exceptionSafe)
|
||||||
.setNoConsts(noconsts);
|
.setNoConsts(noconsts);
|
||||||
rule = new Rule("arithmetic");
|
rule = new Rule<>("arithmetic");
|
||||||
rule.add("add", builder.setOperatorKind(OperatorKind.ADD).getBinaryOperatorFactory());
|
rule.add("add", builder.setOperatorKind(OperatorKind.ADD).getBinaryOperatorFactory());
|
||||||
rule.add("sub", builder.setOperatorKind(OperatorKind.SUB).getBinaryOperatorFactory());
|
rule.add("sub", builder.setOperatorKind(OperatorKind.SUB).getBinaryOperatorFactory());
|
||||||
rule.add("mul", builder.setOperatorKind(OperatorKind.MUL).getBinaryOperatorFactory());
|
rule.add("mul", builder.setOperatorKind(OperatorKind.MUL).getBinaryOperatorFactory());
|
||||||
@ -55,7 +55,7 @@ class ArithmeticOperatorFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Operator produce() throws ProductionFailedException {
|
||||||
return rule.produce();
|
return rule.produce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,14 @@ import jdk.test.lib.jittester.Literal;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
import jdk.test.lib.jittester.ProductionParams;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.VariableDeclaration;
|
import jdk.test.lib.jittester.VariableDeclaration;
|
||||||
import jdk.test.lib.jittester.arrays.ArrayCreation;
|
import jdk.test.lib.jittester.arrays.ArrayCreation;
|
||||||
import jdk.test.lib.jittester.types.TypeArray;
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
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;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ArrayCreationFactory extends SafeFactory {
|
class ArrayCreationFactory extends SafeFactory<ArrayCreation> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
@ -56,16 +55,16 @@ class ArrayCreationFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode sproduce() throws ProductionFailedException {
|
protected ArrayCreation sproduce() throws ProductionFailedException {
|
||||||
if (resultType instanceof TypeArray) {
|
if (resultType instanceof TypeArray) {
|
||||||
TypeArray arrayResultType = (TypeArray) resultType;
|
TypeArray arrayResultType = (TypeArray) resultType;
|
||||||
if (arrayResultType.type.equals(new TypeVoid())) {
|
if (arrayResultType.type.equals(TypeList.VOID)) {
|
||||||
arrayResultType = arrayResultType.produce();
|
arrayResultType = arrayResultType.produce();
|
||||||
}
|
}
|
||||||
IRNodeBuilder builder = new IRNodeBuilder()
|
IRNodeBuilder builder = new IRNodeBuilder()
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setOwnerKlass(ownerClass)
|
.setOwnerKlass(ownerClass)
|
||||||
.setResultType(new TypeByte())
|
.setResultType(TypeList.BYTE)
|
||||||
.setExceptionSafe(exceptionSafe)
|
.setExceptionSafe(exceptionSafe)
|
||||||
.setNoConsts(noconsts);
|
.setNoConsts(noconsts);
|
||||||
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100;
|
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100;
|
||||||
@ -77,14 +76,14 @@ class ArrayCreationFactory extends SafeFactory {
|
|||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce());
|
.produce());
|
||||||
} else {
|
} else {
|
||||||
Literal dimension = (Literal)builder.getLiteralFactory().produce();
|
Literal dimension = builder.getLiteralFactory().produce();
|
||||||
while (Integer.valueOf(dimension.getValue().toString()) < 1) {
|
while (Integer.valueOf(dimension.getValue().toString()) < 1) {
|
||||||
dimension = (Literal)builder.getLiteralFactory().produce();
|
dimension = builder.getLiteralFactory().produce();
|
||||||
}
|
}
|
||||||
dims.add(dimension);
|
dims.add(dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VariableDeclaration var = (VariableDeclaration) builder
|
VariableDeclaration var = builder
|
||||||
.setOwnerKlass(ownerClass)
|
.setOwnerKlass(ownerClass)
|
||||||
.setResultType(arrayResultType)
|
.setResultType(arrayResultType)
|
||||||
.setIsLocal(true)
|
.setIsLocal(true)
|
||||||
|
@ -29,15 +29,15 @@ import jdk.test.lib.jittester.Literal;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
import jdk.test.lib.jittester.ProductionParams;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.ArrayCreation;
|
||||||
import jdk.test.lib.jittester.arrays.ArrayElement;
|
import jdk.test.lib.jittester.arrays.ArrayElement;
|
||||||
import jdk.test.lib.jittester.arrays.ArrayExtraction;
|
import jdk.test.lib.jittester.arrays.ArrayExtraction;
|
||||||
import jdk.test.lib.jittester.types.TypeArray;
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeByte;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ArrayElementFactory extends SafeFactory {
|
class ArrayElementFactory extends SafeFactory<ArrayElement> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
@ -56,7 +56,7 @@ class ArrayElementFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode sproduce() throws ProductionFailedException {
|
protected ArrayElement sproduce() throws ProductionFailedException {
|
||||||
if (resultType instanceof TypeArray) {
|
if (resultType instanceof TypeArray) {
|
||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
@ -76,10 +76,10 @@ class ArrayElementFactory extends SafeFactory {
|
|||||||
.setResultType(new TypeArray(resultType, dimensionsCount))
|
.setResultType(new TypeArray(resultType, dimensionsCount))
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
ExpressionFactory expressionFactory = builder
|
Factory<IRNode> expressionFactory = builder
|
||||||
.setComplexityLimit(complexityPerDimension)
|
.setComplexityLimit(complexityPerDimension)
|
||||||
.setOperatorLimit(operatorLimitPerDimension)
|
.setOperatorLimit(operatorLimitPerDimension)
|
||||||
.setResultType(new TypeByte())
|
.setResultType(TypeList.BYTE)
|
||||||
.getExpressionFactory();
|
.getExpressionFactory();
|
||||||
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.;
|
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.;
|
||||||
ArrayList<IRNode> perDimensionExpressions = new ArrayList<>(dimensionsCount);
|
ArrayList<IRNode> perDimensionExpressions = new ArrayList<>(dimensionsCount);
|
||||||
@ -96,7 +96,7 @@ class ArrayElementFactory extends SafeFactory {
|
|||||||
if (i < arrayExtraction.getDimsNumber())
|
if (i < arrayExtraction.getDimsNumber())
|
||||||
dimLimit = arrayExtraction.getDim(i);
|
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);
|
return new ArrayElement(arrayReturningExpression, perDimensionExpressions);
|
||||||
|
@ -29,14 +29,14 @@ import jdk.test.lib.jittester.Literal;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
import jdk.test.lib.jittester.ProductionParams;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.ArrayCreation;
|
||||||
import jdk.test.lib.jittester.arrays.ArrayExtraction;
|
import jdk.test.lib.jittester.arrays.ArrayExtraction;
|
||||||
import jdk.test.lib.jittester.types.TypeArray;
|
import jdk.test.lib.jittester.types.TypeArray;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeByte;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ArrayExtractionFactory extends SafeFactory {
|
class ArrayExtractionFactory extends SafeFactory<ArrayExtraction> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
@ -55,7 +55,7 @@ class ArrayExtractionFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode sproduce() throws ProductionFailedException {
|
public ArrayExtraction sproduce() throws ProductionFailedException {
|
||||||
if (resultType instanceof TypeArray) {
|
if (resultType instanceof TypeArray) {
|
||||||
TypeArray arrayType = (TypeArray) resultType;
|
TypeArray arrayType = (TypeArray) resultType;
|
||||||
int delta = PseudoRandom.randomNotZero(ProductionParams.dimensionsLimit.value()
|
int delta = PseudoRandom.randomNotZero(ProductionParams.dimensionsLimit.value()
|
||||||
@ -79,7 +79,7 @@ class ArrayExtractionFactory extends SafeFactory {
|
|||||||
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.;
|
double chanceExpression = ProductionParams.chanceExpressionIndex.value() / 100.;
|
||||||
for (int i = 0; i < delta; i++) {
|
for (int i = 0; i < delta; i++) {
|
||||||
if (PseudoRandom.randomBoolean(chanceExpression)) {
|
if (PseudoRandom.randomBoolean(chanceExpression)) {
|
||||||
perDimensionExpression.add(builder.setResultType(new TypeByte())
|
perDimensionExpression.add(builder.setResultType(TypeList.BYTE)
|
||||||
.setComplexityLimit(dimComplLimit)
|
.setComplexityLimit(dimComplLimit)
|
||||||
.setOperatorLimit(dimOpLimit)
|
.setOperatorLimit(dimOpLimit)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
@ -94,7 +94,7 @@ class ArrayExtractionFactory extends SafeFactory {
|
|||||||
if (i < arrayExtraction.getDimsNumber())
|
if (i < arrayExtraction.getDimsNumber())
|
||||||
dimLimit = arrayExtraction.getDim(i);
|
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);
|
return new ArrayExtraction(arrayReturningExpression, perDimensionExpression);
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Rule;
|
import jdk.test.lib.jittester.Rule;
|
||||||
@ -34,7 +35,7 @@ import jdk.test.lib.jittester.TypeList;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class AssignmentOperatorFactory extends Factory {
|
class AssignmentOperatorFactory extends Factory<Operator> {
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
@ -42,8 +43,8 @@ class AssignmentOperatorFactory extends Factory {
|
|||||||
private final boolean noconsts;
|
private final boolean noconsts;
|
||||||
private final TypeKlass ownerClass;
|
private final TypeKlass ownerClass;
|
||||||
|
|
||||||
private Rule fillRule(Type resultType) throws ProductionFailedException {
|
private Rule<Operator> fillRule(Type resultType) throws ProductionFailedException {
|
||||||
Rule rule = new Rule("assignment");
|
Rule<Operator> rule = new Rule<>("assignment");
|
||||||
IRNodeBuilder builder = new IRNodeBuilder()
|
IRNodeBuilder builder = new IRNodeBuilder()
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setOperatorLimit(operatorLimit)
|
.setOperatorLimit(operatorLimit)
|
||||||
@ -84,14 +85,14 @@ class AssignmentOperatorFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Operator produce() throws ProductionFailedException {
|
||||||
if (resultType == null) { // if no result type is given - choose any.
|
if (resultType == null) { // if no result type is given - choose any.
|
||||||
ArrayList<Type> allTypes = new ArrayList<>(TypeList.getAll());
|
ArrayList<Type> allTypes = new ArrayList<>(TypeList.getAll());
|
||||||
PseudoRandom.shuffle(allTypes);
|
PseudoRandom.shuffle(allTypes);
|
||||||
for (Type type : allTypes) {
|
for (Type type : allTypes) {
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
try {
|
try {
|
||||||
IRNode result = fillRule(type).produce();
|
Operator result = fillRule(type).produce();
|
||||||
SymbolTable.merge();
|
SymbolTable.merge();
|
||||||
return result;
|
return result;
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
|
@ -31,8 +31,8 @@ import jdk.test.lib.jittester.ProductionFailedException;
|
|||||||
import jdk.test.lib.jittester.Rule;
|
import jdk.test.lib.jittester.Rule;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
|
||||||
import jdk.test.lib.jittester.VariableBase;
|
import jdk.test.lib.jittester.VariableBase;
|
||||||
|
import jdk.test.lib.jittester.utils.TypeUtil;
|
||||||
import jdk.test.lib.jittester.VariableInfo;
|
import jdk.test.lib.jittester.VariableInfo;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
@ -49,7 +49,7 @@ class AssignmentOperatorImplFactory extends BinaryOperatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, PseudoRandom.randomElement(
|
return new Pair<>(resultType, PseudoRandom.randomElement(
|
||||||
TypeUtil.getImplicitlyCastable(TypeList.getAll(), resultType)));
|
TypeUtil.getImplicitlyCastable(TypeList.getAll(), resultType)));
|
||||||
}
|
}
|
||||||
@ -68,23 +68,22 @@ class AssignmentOperatorImplFactory extends BinaryOperatorFactory {
|
|||||||
.setOperatorLimit(leftOperatorLimit)
|
.setOperatorLimit(leftOperatorLimit)
|
||||||
.setResultType(leftOperandType)
|
.setResultType(leftOperandType)
|
||||||
.setIsConstant(false);
|
.setIsConstant(false);
|
||||||
Rule rule = new Rule("assignment");
|
Rule<VariableBase> rule = new Rule<>("assignment");
|
||||||
rule.add("initialized_nonconst_var", builder.setIsInitialized(true).getVariableFactory());
|
rule.add("initialized_nonconst_var", builder.setIsInitialized(true).getVariableFactory());
|
||||||
rule.add("uninitialized_nonconst_var", builder.setIsInitialized(false).getVariableFactory());
|
rule.add("uninitialized_nonconst_var", builder.setIsInitialized(false).getVariableFactory());
|
||||||
IRNode leftOperandValue = rule.produce();
|
VariableBase leftOperandValue = rule.produce();
|
||||||
IRNode rightOperandValue = builder.setComplexityLimit(rightComplexityLimit)
|
IRNode rightOperandValue = builder.setComplexityLimit(rightComplexityLimit)
|
||||||
.setOperatorLimit(rightOperatorLimit)
|
.setOperatorLimit(rightOperatorLimit)
|
||||||
.setResultType(rightOperandType)
|
.setResultType(rightOperandType)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
try {
|
try {
|
||||||
VariableBase v = (VariableBase) leftOperandValue;
|
if ((leftOperandValue.getVariableInfo().flags & VariableInfo.INITIALIZED) == 0) {
|
||||||
if ((v.get().flags & VariableInfo.INITIALIZED) == 0) {
|
leftOperandValue.getVariableInfo().flags |= VariableInfo.INITIALIZED;
|
||||||
v.get().flags |= VariableInfo.INITIALIZED;
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ProductionFailedException(e.getMessage());
|
throw new ProductionFailedException(e.getMessage());
|
||||||
}
|
}
|
||||||
return new BinaryOperator(opKind, leftOperandValue, rightOperandValue);
|
return new BinaryOperator(opKind, resultType, leftOperandValue, rightOperandValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import jdk.test.lib.jittester.ProductionFailedException;
|
|||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
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.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
@ -47,18 +46,18 @@ class BinaryArithmeticOperatorFactory extends BinaryOperatorFactory {
|
|||||||
// arithmetic for built-in types less capacious than "int" is not supported.
|
// arithmetic for built-in types less capacious than "int" is not supported.
|
||||||
if (TypeList.isBuiltIn(resultType)) {
|
if (TypeList.isBuiltIn(resultType)) {
|
||||||
BuiltInType builtInType = (BuiltInType) resultType;
|
BuiltInType builtInType = (BuiltInType) resultType;
|
||||||
return builtInType.equals(new TypeInt()) || builtInType.isMoreCapaciousThan(new TypeInt());
|
return builtInType.equals(TypeList.INT) || builtInType.isMoreCapaciousThan(TypeList.INT);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
Collection<Type> castableFromResultType = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
|
Collection<Type> castableFromResultType = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
|
||||||
// built-in types less capacious than int are automatically casted to int in arithmetic.
|
// built-in types less capacious than int are automatically casted to int in arithmetic.
|
||||||
final Type leftType = PseudoRandom.randomElement(castableFromResultType);
|
final Type leftType = PseudoRandom.randomElement(castableFromResultType);
|
||||||
final Type rightType = resultType.equals(new TypeInt()) ?
|
final Type rightType = resultType.equals(TypeList.INT) ?
|
||||||
PseudoRandom.randomElement(castableFromResultType) : resultType;
|
PseudoRandom.randomElement(castableFromResultType) : resultType;
|
||||||
//TODO: is there sense to swap them randomly as it was done in original code?
|
//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);
|
return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType);
|
||||||
|
@ -29,10 +29,7 @@ import jdk.test.lib.jittester.ProductionFailedException;
|
|||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
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.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeLong;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,15 +42,15 @@ class BinaryBitwiseOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
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
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
Collection<Type> castableFromResult = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
|
Collection<Type> castableFromResult = TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType);
|
||||||
// built-in types less capacious than int are automatically casted to int in arithmetic.
|
// built-in types less capacious than int are automatically casted to int in arithmetic.
|
||||||
final Type leftType = PseudoRandom.randomElement(castableFromResult);
|
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?
|
//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);
|
return PseudoRandom.randomBoolean() ? new Pair<>(leftType, rightType) : new Pair<>(rightType, leftType);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import jdk.test.lib.jittester.OperatorKind;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
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.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
@ -43,13 +42,13 @@ class BinaryComparisonOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeBoolean());
|
return resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
final List<Type> builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn());
|
final List<Type> builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn());
|
||||||
builtInExceptBoolean.remove(new TypeBoolean());
|
builtInExceptBoolean.remove(TypeList.BOOLEAN);
|
||||||
return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean),
|
return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean),
|
||||||
PseudoRandom.randomElement(builtInExceptBoolean));
|
PseudoRandom.randomElement(builtInExceptBoolean));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import jdk.test.lib.jittester.OperatorKind;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
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.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
@ -43,13 +42,13 @@ class BinaryEqualityOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeBoolean());
|
return resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
final List<Type> builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn());
|
final List<Type> builtInExceptBoolean = new ArrayList<>(TypeList.getBuiltIn());
|
||||||
builtInExceptBoolean.remove(new TypeBoolean());
|
builtInExceptBoolean.remove(TypeList.BOOLEAN);
|
||||||
return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean), PseudoRandom.randomElement(builtInExceptBoolean));
|
return new Pair<>(PseudoRandom.randomElement(builtInExceptBoolean), PseudoRandom.randomElement(builtInExceptBoolean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import jdk.test.lib.jittester.OperatorKind;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
@ -42,11 +42,11 @@ public class BinaryLogicOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeBoolean());
|
return resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, resultType);
|
return new Pair<>(resultType, resultType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +81,6 @@ public class BinaryLogicOperatorFactory extends BinaryOperatorFactory {
|
|||||||
} finally {
|
} finally {
|
||||||
SymbolTable.pop();
|
SymbolTable.pop();
|
||||||
}
|
}
|
||||||
return new BinaryOperator(opKind, leftOperand, rightOperand);
|
return new BinaryOperator(opKind, resultType, leftOperand, rightOperand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import jdk.test.lib.jittester.Type;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
abstract class BinaryOperatorFactory extends OperatorFactory {
|
abstract class BinaryOperatorFactory extends OperatorFactory<BinaryOperator> {
|
||||||
protected final OperatorKind opKind;
|
protected final OperatorKind opKind;
|
||||||
protected final Type resultType;
|
protected final Type resultType;
|
||||||
protected final Type ownerClass;
|
protected final Type ownerClass;
|
||||||
@ -48,7 +48,7 @@ abstract class BinaryOperatorFactory extends OperatorFactory {
|
|||||||
|
|
||||||
protected abstract boolean isApplicable(Type resultType);
|
protected abstract boolean isApplicable(Type resultType);
|
||||||
|
|
||||||
protected abstract Pair<Type, Type> generateTypes() throws ProductionFailedException;
|
protected abstract Pair<Type, Type> generateTypes();
|
||||||
|
|
||||||
protected BinaryOperator generateProduction(Type leftType, Type rightType) throws ProductionFailedException {
|
protected BinaryOperator generateProduction(Type leftType, Type rightType) throws ProductionFailedException {
|
||||||
int leftOpLimit = (int) (PseudoRandom.random() * (operatorLimit - 1));
|
int leftOpLimit = (int) (PseudoRandom.random() * (operatorLimit - 1));
|
||||||
@ -72,11 +72,11 @@ abstract class BinaryOperatorFactory extends OperatorFactory {
|
|||||||
.setResultType(rightType)
|
.setResultType(rightType)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
return new BinaryOperator(opKind, leftExpr, rightExpr);
|
return new BinaryOperator(opKind, resultType, leftExpr, rightExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final IRNode produce() throws ProductionFailedException {
|
public final BinaryOperator produce() throws ProductionFailedException {
|
||||||
if (!isApplicable(resultType)) {
|
if (!isApplicable(resultType)) {
|
||||||
//avoid implicit use of resultType.toString()
|
//avoid implicit use of resultType.toString()
|
||||||
throw new ProductionFailedException("Type " + resultType.getName() + " is not applicable by " + getClass().getName());
|
throw new ProductionFailedException("Type " + resultType.getName() + " is not applicable by " + getClass().getName());
|
||||||
@ -91,7 +91,7 @@ abstract class BinaryOperatorFactory extends OperatorFactory {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
IRNode p = generateProduction(types.first, types.second);
|
BinaryOperator p = generateProduction(types.first, types.second);
|
||||||
SymbolTable.merge();
|
SymbolTable.merge();
|
||||||
return p;
|
return p;
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
|
@ -28,9 +28,7 @@ import jdk.test.lib.jittester.OperatorKind;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
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.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeLong;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
import jdk.test.lib.jittester.utils.TypeUtil;
|
||||||
|
|
||||||
@ -42,13 +40,13 @@ class BinaryShiftOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeInt()) || resultType.equals(new TypeLong());
|
return resultType.equals(TypeList.INT) || resultType.equals(TypeList.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
Type leftType = resultType.equals(new TypeInt()) ? PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), resultType)) : resultType;
|
Type leftType = resultType.equals(TypeList.INT) ? PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), resultType)) : resultType;
|
||||||
Type rightType = PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), new TypeLong()));
|
Type rightType = PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltInInt(), TypeList.LONG));
|
||||||
return new Pair<>(leftType, rightType);
|
return new Pair<>(leftType, rightType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ class BinaryStringPlusFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(TypeList.find("java.lang.String"));
|
return resultType.equals(TypeList.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, resultType);
|
return new Pair<>(resultType, resultType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.OperatorKind;
|
import jdk.test.lib.jittester.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
@ -31,8 +30,6 @@ import jdk.test.lib.jittester.TypeList;
|
|||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
import jdk.test.lib.jittester.utils.TypeUtil;
|
||||||
import jdk.test.lib.jittester.UnaryOperator;
|
import jdk.test.lib.jittester.UnaryOperator;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
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;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class BitwiseInversionOperatorFactory extends UnaryOperatorFactory {
|
class BitwiseInversionOperatorFactory extends UnaryOperatorFactory {
|
||||||
@ -43,12 +40,12 @@ class BitwiseInversionOperatorFactory extends UnaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeInt()) || resultType.equals(new TypeLong());
|
return resultType.equals(TypeList.INT) || resultType.equals(TypeList.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Type generateType() throws ProductionFailedException {
|
protected Type generateType() {
|
||||||
if (resultType.equals(new TypeInt())) {
|
if (resultType.equals(TypeList.INT)) {
|
||||||
return PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType));
|
return PseudoRandom.randomElement(TypeUtil.getImplicitlyCastable(TypeList.getBuiltIn(), resultType));
|
||||||
} else {
|
} else {
|
||||||
return resultType;
|
return resultType;
|
||||||
@ -56,7 +53,7 @@ class BitwiseInversionOperatorFactory extends UnaryOperatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode generateProduction(Type resultType) throws ProductionFailedException {
|
protected UnaryOperator generateProduction(Type resultType) throws ProductionFailedException {
|
||||||
return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1)
|
return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1)
|
||||||
.setOperatorLimit(operatorLimit - 1)
|
.setOperatorLimit(operatorLimit - 1)
|
||||||
.setOwnerKlass((TypeKlass) ownerClass)
|
.setOwnerKlass((TypeKlass) ownerClass)
|
||||||
|
@ -23,15 +23,15 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
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.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Rule;
|
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;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class BitwiseOperatorFactory extends Factory {
|
class BitwiseOperatorFactory extends Factory<Operator> {
|
||||||
private final Rule rule;
|
private final Rule<Operator> rule;
|
||||||
|
|
||||||
BitwiseOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass,
|
BitwiseOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass,
|
||||||
Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
Type resultType, boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
||||||
@ -42,7 +42,7 @@ class BitwiseOperatorFactory extends Factory {
|
|||||||
.setResultType(resultType)
|
.setResultType(resultType)
|
||||||
.setExceptionSafe(exceptionSafe)
|
.setExceptionSafe(exceptionSafe)
|
||||||
.setNoConsts(noconsts);
|
.setNoConsts(noconsts);
|
||||||
rule = new Rule("bitwise");
|
rule = new Rule<>("bitwise");
|
||||||
rule.add("and", builder.setOperatorKind(OperatorKind.BIT_AND).getBinaryOperatorFactory());
|
rule.add("and", builder.setOperatorKind(OperatorKind.BIT_AND).getBinaryOperatorFactory());
|
||||||
rule.add("or", builder.setOperatorKind(OperatorKind.BIT_OR).getBinaryOperatorFactory());
|
rule.add("or", builder.setOperatorKind(OperatorKind.BIT_OR).getBinaryOperatorFactory());
|
||||||
rule.add("xor", builder.setOperatorKind(OperatorKind.BIT_XOR).getBinaryOperatorFactory());
|
rule.add("xor", builder.setOperatorKind(OperatorKind.BIT_XOR).getBinaryOperatorFactory());
|
||||||
@ -53,7 +53,7 @@ class BitwiseOperatorFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Operator produce() throws ProductionFailedException {
|
||||||
return rule.produce();
|
return rule.produce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,12 @@ import jdk.test.lib.jittester.loops.DoWhile;
|
|||||||
import jdk.test.lib.jittester.loops.For;
|
import jdk.test.lib.jittester.loops.For;
|
||||||
import jdk.test.lib.jittester.loops.While;
|
import jdk.test.lib.jittester.loops.While;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class BlockFactory extends Factory {
|
class BlockFactory extends Factory<Block> {
|
||||||
private final Type returnType;
|
private final Type returnType;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
@ -74,7 +73,7 @@ class BlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Block produce() throws ProductionFailedException {
|
||||||
if (statementLimit > 0 && complexityLimit > 0) {
|
if (statementLimit > 0 && complexityLimit > 0) {
|
||||||
List<IRNode> content = new ArrayList<>();
|
List<IRNode> content = new ArrayList<>();
|
||||||
int slimit = PseudoRandom.randomNotZero(statementLimit);
|
int slimit = PseudoRandom.randomNotZero(statementLimit);
|
||||||
@ -89,12 +88,12 @@ class BlockFactory extends Factory {
|
|||||||
.setCanHaveContinues(canHaveContinues)
|
.setCanHaveContinues(canHaveContinues)
|
||||||
.setExceptionSafe(false)
|
.setExceptionSafe(false)
|
||||||
.setNoConsts(false);
|
.setNoConsts(false);
|
||||||
Rule rule;
|
Rule<IRNode> rule;
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
for (int i = 0; i < slimit && climit > 0; ) {
|
for (int i = 0; i < slimit && climit > 0; ) {
|
||||||
int subLimit = (int) (PseudoRandom.random() * (slimit - i - 1));
|
int subLimit = (int) (PseudoRandom.random() * (slimit - i - 1));
|
||||||
builder.setComplexityLimit((long) (PseudoRandom.random() * climit));
|
builder.setComplexityLimit((long) (PseudoRandom.random() * climit));
|
||||||
rule = new Rule("block");
|
rule = new Rule<>("block");
|
||||||
rule.add("statement", builder.getStatementFactory(), 5);
|
rule.add("statement", builder.getStatementFactory(), 5);
|
||||||
if (!ProductionParams.disableVarsInBlock.value()) {
|
if (!ProductionParams.disableVarsInBlock.value()) {
|
||||||
rule.add("decl", builder.setIsLocal(true).getDeclarationFactory());
|
rule.add("decl", builder.setIsLocal(true).getDeclarationFactory());
|
||||||
@ -131,14 +130,14 @@ class BlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ok, if the block can end with break and continue. Generate the appropriate productions.
|
// 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) {
|
if (canHaveBreaks && !subBlock) {
|
||||||
rule.add("break", builder.getBreakFactory());
|
rule.add("break", builder.getBreakFactory());
|
||||||
}
|
}
|
||||||
if (canHaveContinues && !subBlock) {
|
if (canHaveContinues && !subBlock) {
|
||||||
rule.add("continue", builder.getContinueFactory());
|
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());
|
rule.add("return", builder.setComplexityLimit(climit).getReturnFactory());
|
||||||
}
|
}
|
||||||
if (canHaveThrow && !subBlock) {
|
if (canHaveThrow && !subBlock) {
|
||||||
@ -166,7 +165,7 @@ class BlockFactory extends Factory {
|
|||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addControlFlowDeviation(Rule rule, IRNodeBuilder builder) {
|
private void addControlFlowDeviation(Rule<IRNode> rule, IRNodeBuilder builder) {
|
||||||
if (!ProductionParams.disableIf.value()) {
|
if (!ProductionParams.disableIf.value()) {
|
||||||
rule.add("if", builder.getIfFactory());
|
rule.add("if", builder.getIfFactory());
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,11 @@
|
|||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.Break;
|
import jdk.test.lib.jittester.Break;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
|
|
||||||
class BreakFactory extends Factory {
|
class BreakFactory extends Factory<Break> {
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Break produce() throws ProductionFailedException {
|
||||||
return new Break();
|
return new Break();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import jdk.test.lib.jittester.TypeList;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class CastOperatorFactory extends OperatorFactory {
|
class CastOperatorFactory extends OperatorFactory<CastOperator> {
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
private final Type ownerClass;
|
private final Type ownerClass;
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class CastOperatorFactory extends OperatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public CastOperator produce() throws ProductionFailedException {
|
||||||
ArrayList<Type> argType = new ArrayList<>(TypeList.getAll());
|
ArrayList<Type> argType = new ArrayList<>(TypeList.getAll());
|
||||||
PseudoRandom.shuffle(argType);
|
PseudoRandom.shuffle(argType);
|
||||||
for (Type type : argType) {
|
for (Type type : argType) {
|
||||||
try {
|
try {
|
||||||
ExpressionFactory expressionFactory = new IRNodeBuilder()
|
Factory<IRNode> expressionFactory = new IRNodeBuilder()
|
||||||
.setComplexityLimit(complexityLimit - 1)
|
.setComplexityLimit(complexityLimit - 1)
|
||||||
.setOperatorLimit(operatorLimit - 1)
|
.setOperatorLimit(operatorLimit - 1)
|
||||||
.setOwnerKlass((TypeKlass) ownerClass)
|
.setOwnerKlass((TypeKlass) ownerClass)
|
||||||
@ -59,14 +59,11 @@ class CastOperatorFactory extends OperatorFactory {
|
|||||||
.setResultType(type)
|
.setResultType(type)
|
||||||
.getExpressionFactory();
|
.getExpressionFactory();
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
if (type.equals(resultType)) {
|
if (type.equals(resultType) ||
|
||||||
IRNode expr = expressionFactory.produce();
|
((!exceptionSafe || exceptionSafe && !(type instanceof TypeKlass))
|
||||||
SymbolTable.merge();
|
&& type.canExplicitlyCastTo(resultType))) {
|
||||||
return expr;
|
|
||||||
} else if ((!exceptionSafe || exceptionSafe && !(type instanceof TypeKlass))
|
|
||||||
&& type.canExplicitlyCastTo(resultType)) {
|
|
||||||
// In safe mode we cannot explicitly cast an object, because it may throw.
|
// 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();
|
SymbolTable.merge();
|
||||||
return castOperator;
|
return castOperator;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ import jdk.test.lib.jittester.classes.Klass;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ClassDefinitionBlockFactory extends Factory {
|
class ClassDefinitionBlockFactory extends Factory<ClassDefinitionBlock> {
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int classesLimit;
|
private final int classesLimit;
|
||||||
@ -62,7 +62,7 @@ class ClassDefinitionBlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public ClassDefinitionBlock produce() throws ProductionFailedException {
|
||||||
ArrayList<IRNode> content = new ArrayList<>();
|
ArrayList<IRNode> content = new ArrayList<>();
|
||||||
int limit = (int) Math.ceil(PseudoRandom.random() * classesLimit);
|
int limit = (int) Math.ceil(PseudoRandom.random() * classesLimit);
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
@ -74,9 +74,8 @@ class ClassDefinitionBlockFactory extends Factory {
|
|||||||
.setComplexityLimit(classCompl);
|
.setComplexityLimit(classCompl);
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
try {
|
try {
|
||||||
Rule rule = new Rule("class");
|
Rule<IRNode> rule = new Rule<>("class");
|
||||||
rule.add("basic_class", builder.setName(prefix + "_Class_" + i)
|
rule.add("basic_class", builder.setName(prefix + "_Class_" + i)
|
||||||
.setPrinterName(prefix + ".Printer")
|
|
||||||
.setMemberFunctionsLimit(memberFunctionsLimit)
|
.setMemberFunctionsLimit(memberFunctionsLimit)
|
||||||
.getKlassFactory());
|
.getKlassFactory());
|
||||||
if (!ProductionParams.disableInterfaces.value()) {
|
if (!ProductionParams.disableInterfaces.value()) {
|
||||||
@ -110,13 +109,12 @@ class ClassDefinitionBlockFactory extends Factory {
|
|||||||
IRNode randomChild = childs.get(0);
|
IRNode randomChild = childs.get(0);
|
||||||
List<IRNode> leaves = randomChild.getStackableLeaves();
|
List<IRNode> leaves = randomChild.getStackableLeaves();
|
||||||
if (!leaves.isEmpty()) {
|
if (!leaves.isEmpty()) {
|
||||||
PseudoRandom.shuffle(leaves);
|
Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size()));
|
||||||
Block randomLeaf = (Block) leaves.get(0);
|
TypeKlass owner = randomChild.getOwner();
|
||||||
TypeKlass klass = (TypeKlass) randomChild.getKlass();
|
|
||||||
int newLevel = randomLeaf.getLevel() + 1;
|
int newLevel = randomLeaf.getLevel() + 1;
|
||||||
Type retType = randomLeaf.getReturnType();
|
Type retType = randomLeaf.getResultType();
|
||||||
IRNodeBuilder b = new IRNodeBuilder()
|
IRNodeBuilder b = new IRNodeBuilder()
|
||||||
.setOwnerKlass(klass)
|
.setOwnerKlass(owner)
|
||||||
.setResultType(retType)
|
.setResultType(retType)
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setStatementLimit(statementLimit)
|
.setStatementLimit(statementLimit)
|
||||||
@ -137,7 +135,7 @@ class ClassDefinitionBlockFactory extends Factory {
|
|||||||
.filter(c -> c instanceof Klass && c.countDepth() > maxDepth)
|
.filter(c -> c instanceof Klass && c.countDepth() > maxDepth)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (IRNode ch : childs) {
|
for (IRNode ch : childs) {
|
||||||
List<IRNode> leaves = null;
|
List<IRNode> leaves;
|
||||||
do {
|
do {
|
||||||
long depth = Math.max(ch.countDepth(), maxDepth + 1);
|
long depth = Math.max(ch.countDepth(), maxDepth + 1);
|
||||||
leaves = ch.getDeviantBlocks(depth);
|
leaves = ch.getDeviantBlocks(depth);
|
||||||
|
@ -30,8 +30,8 @@ import jdk.test.lib.jittester.OperatorKind;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
|
import jdk.test.lib.jittester.VariableBase;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
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.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
@ -43,11 +43,11 @@ class CompoundArithmeticAssignmentOperatorFactory extends BinaryOperatorFactory
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return TypeList.isBuiltIn(resultType) && !resultType.equals(new TypeBoolean());
|
return TypeList.isBuiltIn(resultType) && !resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, PseudoRandom.randomElement(
|
return new Pair<>(resultType, PseudoRandom.randomElement(
|
||||||
TypeUtil.getExplicitlyCastable(TypeList.getBuiltIn(), resultType)));
|
TypeUtil.getExplicitlyCastable(TypeList.getBuiltIn(), resultType)));
|
||||||
}
|
}
|
||||||
@ -66,13 +66,13 @@ class CompoundArithmeticAssignmentOperatorFactory extends BinaryOperatorFactory
|
|||||||
.setResultType(rightType)
|
.setResultType(rightType)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
IRNode leftExpr = builder.setComplexityLimit(leftComplexityLimit)
|
VariableBase leftExpr = builder.setComplexityLimit(leftComplexityLimit)
|
||||||
.setOperatorLimit(leftOperatorLimit)
|
.setOperatorLimit(leftOperatorLimit)
|
||||||
.setResultType(leftType)
|
.setResultType(leftType)
|
||||||
.setIsConstant(false)
|
.setIsConstant(false)
|
||||||
.setIsInitialized(true)
|
.setIsInitialized(true)
|
||||||
.getVariableFactory()
|
.getVariableFactory()
|
||||||
.produce();
|
.produce();
|
||||||
return new BinaryOperator(opKind, leftExpr, rightExpr);
|
return new BinaryOperator(opKind, resultType, leftExpr, rightExpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class CompoundBitwiseAssignmentOperatorFactory extends BinaryOperatorFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, PseudoRandom.randomElement(TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType)));
|
return new Pair<>(resultType, PseudoRandom.randomElement(TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +71,6 @@ class CompoundBitwiseAssignmentOperatorFactory extends BinaryOperatorFactory {
|
|||||||
.setResultType(rightType)
|
.setResultType(rightType)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
return new BinaryOperator(opKind, leftExpr, rightExpr);
|
return new BinaryOperator(opKind, resultType, leftExpr, rightExpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ import jdk.test.lib.jittester.Type;
|
|||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
import jdk.test.lib.jittester.utils.TypeUtil;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeBoolean;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class CompoundShiftAssignmentOperatorFactory extends BinaryOperatorFactory {
|
class CompoundShiftAssignmentOperatorFactory extends BinaryOperatorFactory {
|
||||||
@ -43,11 +42,11 @@ class CompoundShiftAssignmentOperatorFactory extends BinaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return TypeList.isBuiltInInt(resultType) && !resultType.equals(new TypeBoolean());
|
return TypeList.isBuiltInInt(resultType) && !resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Type, Type> generateTypes() throws ProductionFailedException {
|
protected Pair<Type, Type> generateTypes() {
|
||||||
return new Pair<>(resultType, PseudoRandom.randomElement(
|
return new Pair<>(resultType, PseudoRandom.randomElement(
|
||||||
TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType)));
|
TypeUtil.getExplicitlyCastable(TypeList.getBuiltInInt(), resultType)));
|
||||||
}
|
}
|
||||||
@ -73,6 +72,6 @@ class CompoundShiftAssignmentOperatorFactory extends BinaryOperatorFactory {
|
|||||||
.setResultType(rightType)
|
.setResultType(rightType)
|
||||||
.getExpressionFactory()
|
.getExpressionFactory()
|
||||||
.produce();
|
.produce();
|
||||||
return new BinaryOperator(opKind, leftExpr, rightExpr);
|
return new BinaryOperator(opKind, resultType, leftExpr, rightExpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import jdk.test.lib.jittester.functions.ConstructorDefinitionBlock;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ConstructorDefinitionBlockFactory extends Factory {
|
class ConstructorDefinitionBlockFactory extends Factory<ConstructorDefinitionBlock> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -53,7 +53,7 @@ class ConstructorDefinitionBlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public ConstructorDefinitionBlock produce() throws ProductionFailedException {
|
||||||
IRNodeBuilder builder = new IRNodeBuilder()
|
IRNodeBuilder builder = new IRNodeBuilder()
|
||||||
.setOwnerKlass(ownerClass)
|
.setOwnerKlass(ownerClass)
|
||||||
.setStatementLimit(statementLimit)
|
.setStatementLimit(statementLimit)
|
||||||
|
@ -28,15 +28,15 @@ import jdk.test.lib.jittester.IRNode;
|
|||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Symbol;
|
import jdk.test.lib.jittester.Symbol;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.VariableInfo;
|
import jdk.test.lib.jittester.VariableInfo;
|
||||||
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
||||||
import jdk.test.lib.jittester.functions.ConstructorDefinition;
|
import jdk.test.lib.jittester.functions.ConstructorDefinition;
|
||||||
import jdk.test.lib.jittester.functions.FunctionInfo;
|
import jdk.test.lib.jittester.functions.FunctionInfo;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ConstructorDefinitionFactory extends Factory {
|
class ConstructorDefinitionFactory extends Factory<ConstructorDefinition> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -55,7 +55,7 @@ class ConstructorDefinitionFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public ConstructorDefinition produce() throws ProductionFailedException {
|
||||||
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
||||||
ArrayList<VariableInfo> argumentsInfo = new ArrayList<>(argNumber);
|
ArrayList<VariableInfo> argumentsInfo = new ArrayList<>(argNumber);
|
||||||
ArrayList<ArgumentDeclaration> argumentsDeclaration = new ArrayList<>(argNumber);
|
ArrayList<ArgumentDeclaration> argumentsDeclaration = new ArrayList<>(argNumber);
|
||||||
@ -90,7 +90,7 @@ class ConstructorDefinitionFactory extends Factory {
|
|||||||
}
|
}
|
||||||
long blockComplLimit = (long) (PseudoRandom.random() * complexityLimit);
|
long blockComplLimit = (long) (PseudoRandom.random() * complexityLimit);
|
||||||
try {
|
try {
|
||||||
body = builder.setResultType(new TypeVoid())
|
body = builder.setResultType(TypeList.VOID)
|
||||||
.setComplexityLimit(blockComplLimit)
|
.setComplexityLimit(blockComplLimit)
|
||||||
.setStatementLimit(statementLimit)
|
.setStatementLimit(statementLimit)
|
||||||
.setOperatorLimit(operatorLimit)
|
.setOperatorLimit(operatorLimit)
|
||||||
|
@ -24,12 +24,11 @@
|
|||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.Continue;
|
import jdk.test.lib.jittester.Continue;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
|
|
||||||
class ContinueFactory extends Factory {
|
class ContinueFactory extends Factory<Continue> {
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Continue produce() throws ProductionFailedException {
|
||||||
return new Continue();
|
return new Continue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,20 +24,20 @@
|
|||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
import jdk.test.lib.jittester.LiteralInitializer;
|
import jdk.test.lib.jittester.LiteralInitializer;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.utils.TypeUtil;
|
|
||||||
import jdk.test.lib.jittester.VariableInfo;
|
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.loops.CounterInitializer;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeInt;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class CounterInitializerFactory extends SafeFactory {
|
class CounterInitializerFactory extends SafeFactory<CounterInitializer> {
|
||||||
private final int counterValue;
|
private final int counterValue;
|
||||||
private final TypeKlass ownerClass;
|
private final TypeKlass ownerClass;
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ class CounterInitializerFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode sproduce() throws ProductionFailedException {
|
protected CounterInitializer sproduce() throws ProductionFailedException {
|
||||||
List<Type> types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt());
|
List<Type> types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), TypeList.INT);
|
||||||
types.add(new TypeInt());
|
types.add(TypeList.INT);
|
||||||
final Type selectedType = PseudoRandom.randomElement(types);
|
final Type selectedType = PseudoRandom.randomElement(types);
|
||||||
IRNode init = new LiteralInitializer(counterValue, selectedType);
|
IRNode init = new LiteralInitializer(counterValue, selectedType);
|
||||||
String resultName = "var_" + SymbolTable.getNextVariableNumber();
|
String resultName = "var_" + SymbolTable.getNextVariableNumber();
|
||||||
|
@ -27,10 +27,11 @@ import jdk.test.lib.jittester.IRNode;
|
|||||||
import jdk.test.lib.jittester.LocalVariable;
|
import jdk.test.lib.jittester.LocalVariable;
|
||||||
import jdk.test.lib.jittester.OperatorKind;
|
import jdk.test.lib.jittester.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
|
import jdk.test.lib.jittester.Statement;
|
||||||
import jdk.test.lib.jittester.UnaryOperator;
|
import jdk.test.lib.jittester.UnaryOperator;
|
||||||
import jdk.test.lib.jittester.loops.CounterManipulator;
|
import jdk.test.lib.jittester.loops.CounterManipulator;
|
||||||
|
|
||||||
class CounterManipulatorFactory extends Factory {
|
class CounterManipulatorFactory extends Factory<CounterManipulator> {
|
||||||
private final LocalVariable counter;
|
private final LocalVariable counter;
|
||||||
|
|
||||||
CounterManipulatorFactory(LocalVariable counter) {
|
CounterManipulatorFactory(LocalVariable counter) {
|
||||||
@ -38,9 +39,9 @@ class CounterManipulatorFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public CounterManipulator produce() throws ProductionFailedException {
|
||||||
// We'll keep it simple for the time being..
|
// We'll keep it simple for the time being..
|
||||||
IRNode manipulator = new UnaryOperator(OperatorKind.POST_DEC, counter);
|
IRNode manipulator = new UnaryOperator(OperatorKind.POST_DEC, counter);
|
||||||
return new CounterManipulator(manipulator);
|
return new CounterManipulator(new Statement(manipulator, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import jdk.test.lib.jittester.Rule;
|
|||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class DeclarationFactory extends Factory {
|
class DeclarationFactory extends Factory<Declaration> {
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final boolean isLocal;
|
private final boolean isLocal;
|
||||||
@ -48,29 +48,42 @@ class DeclarationFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Declaration produce() throws ProductionFailedException {
|
||||||
Rule rule = new Rule("declaration");
|
Rule<IRNode> rule = new Rule<>("declaration");
|
||||||
IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass)
|
IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass)
|
||||||
.setResultType(TypeList.getVoid())
|
.setResultType(TypeList.VOID)
|
||||||
.setIsLocal(isLocal)
|
.setIsLocal(isLocal)
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setOperatorLimit(operatorLimit)
|
.setOperatorLimit(operatorLimit)
|
||||||
.setIsLocal(isLocal)
|
.setIsLocal(isLocal)
|
||||||
.setExceptionSafe(exceptionSafe);
|
.setExceptionSafe(exceptionSafe);
|
||||||
rule.add("decl", builder.setIsStatic(false).getVariableDeclarationFactory());
|
rule.add("decl", builder
|
||||||
rule.add("decl_and_init", builder.setIsConstant(false)
|
.setIsStatic(false)
|
||||||
.setIsStatic(false).getVariableInitializationFactory());
|
.getVariableDeclarationFactory());
|
||||||
|
rule.add("decl_and_init", builder
|
||||||
|
.setIsConstant(false)
|
||||||
|
.setIsStatic(false)
|
||||||
|
.getVariableInitializationFactory());
|
||||||
if (!ProductionParams.disableFinalVariables.value()) {
|
if (!ProductionParams.disableFinalVariables.value()) {
|
||||||
rule.add("const_decl_and_init", builder.setIsConstant(true)
|
rule.add("const_decl_and_init", builder
|
||||||
.setIsStatic(false).getVariableInitializationFactory());
|
.setIsConstant(true)
|
||||||
|
.setIsStatic(false)
|
||||||
|
.getVariableInitializationFactory());
|
||||||
}
|
}
|
||||||
if (!isLocal && !ProductionParams.disableStatic.value()) {
|
if (!isLocal && !ProductionParams.disableStatic.value()) {
|
||||||
rule.add("static_decl", builder.setIsStatic(true).getVariableDeclarationFactory());
|
rule.add("static_decl", builder
|
||||||
rule.add("static_decl_and_init", builder.setIsConstant(false)
|
.setIsConstant(false)
|
||||||
.setIsStatic(true).getVariableInitializationFactory());
|
.setIsStatic(true)
|
||||||
|
.getVariableDeclarationFactory());
|
||||||
|
rule.add("static_decl_and_init", builder
|
||||||
|
.setIsConstant(false)
|
||||||
|
.setIsStatic(true)
|
||||||
|
.getVariableInitializationFactory());
|
||||||
if (!ProductionParams.disableFinalVariables.value()) {
|
if (!ProductionParams.disableFinalVariables.value()) {
|
||||||
rule.add("static_const_decl_and_init", builder.setIsConstant(true)
|
rule.add("static_const_decl_and_init", builder
|
||||||
.setIsStatic(true).getVariableInitializationFactory());
|
.setIsConstant(true)
|
||||||
|
.setIsStatic(true)
|
||||||
|
.getVariableInitializationFactory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Declaration(rule.produce());
|
return new Declaration(rule.produce());
|
||||||
|
@ -23,21 +23,21 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.Block;
|
||||||
import jdk.test.lib.jittester.Initialization;
|
|
||||||
import jdk.test.lib.jittester.Literal;
|
import jdk.test.lib.jittester.Literal;
|
||||||
import jdk.test.lib.jittester.LocalVariable;
|
import jdk.test.lib.jittester.LocalVariable;
|
||||||
import jdk.test.lib.jittester.Nothing;
|
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.DoWhile;
|
||||||
import jdk.test.lib.jittester.loops.Loop;
|
import jdk.test.lib.jittester.loops.Loop;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeInt;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class DoWhileFactory extends SafeFactory {
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
class DoWhileFactory extends SafeFactory<DoWhile> {
|
||||||
private final Loop loop;
|
private final Loop loop;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
@ -62,7 +62,8 @@ class DoWhileFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (statementLimit > 0 && complexityLimit > 0) {
|
||||||
long complexity = complexityLimit;
|
long complexity = complexityLimit;
|
||||||
// Loop header parameters
|
// Loop header parameters
|
||||||
@ -89,7 +90,7 @@ class DoWhileFactory extends SafeFactory {
|
|||||||
.setResultType(returnType)
|
.setResultType(returnType)
|
||||||
.setOperatorLimit(operatorLimit);
|
.setOperatorLimit(operatorLimit);
|
||||||
loop.initialization = builder.getCounterInitializerFactory(0).produce();
|
loop.initialization = builder.getCounterInitializerFactory(0).produce();
|
||||||
IRNode header;
|
Block header;
|
||||||
try {
|
try {
|
||||||
header = builder.setComplexityLimit(headerComplLimit)
|
header = builder.setComplexityLimit(headerComplLimit)
|
||||||
.setStatementLimit(headerStatementLimit)
|
.setStatementLimit(headerStatementLimit)
|
||||||
@ -101,17 +102,17 @@ class DoWhileFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
header = new Nothing();
|
header = emptyBlock;
|
||||||
}
|
}
|
||||||
// getChildren().set(DoWhile.DoWhilePart.HEADER.ordinal(), header);
|
// getChildren().set(DoWhile.DoWhilePart.HEADER.ordinal(), header);
|
||||||
LocalVariable counter = new LocalVariable(((Initialization) loop.initialization).get());
|
LocalVariable counter = new LocalVariable(loop.initialization.getVariableInfo());
|
||||||
Literal limiter = new Literal(Integer.valueOf((int) thisLoopIterLimit), new TypeInt());
|
Literal limiter = new Literal((int) thisLoopIterLimit, TypeList.INT);
|
||||||
loop.condition = builder.setComplexityLimit(condComplLimit)
|
loop.condition = builder.setComplexityLimit(condComplLimit)
|
||||||
.setLocalVariable(counter)
|
.setLocalVariable(counter)
|
||||||
.getLoopingConditionFactory(limiter)
|
.getLoopingConditionFactory(limiter)
|
||||||
.produce();
|
.produce();
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
IRNode body1;
|
Block body1;
|
||||||
try {
|
try {
|
||||||
body1 = builder.setComplexityLimit(body1ComplLimit)
|
body1 = builder.setComplexityLimit(body1ComplLimit)
|
||||||
.setStatementLimit(body1StatementLimit)
|
.setStatementLimit(body1StatementLimit)
|
||||||
@ -123,11 +124,11 @@ class DoWhileFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
body1 = new Nothing();
|
body1 = emptyBlock;
|
||||||
}
|
}
|
||||||
// getChildren().set(DoWhile.DoWhilePart.BODY1.ordinal(), body1);
|
// getChildren().set(DoWhile.DoWhilePart.BODY1.ordinal(), body1);
|
||||||
loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce();
|
loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce();
|
||||||
IRNode body2;
|
Block body2;
|
||||||
try {
|
try {
|
||||||
body2 = builder.setComplexityLimit(body2ComplLimit)
|
body2 = builder.setComplexityLimit(body2ComplLimit)
|
||||||
.setStatementLimit(body2StatementLimit)
|
.setStatementLimit(body2StatementLimit)
|
||||||
@ -139,7 +140,7 @@ class DoWhileFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
body2 = new Nothing();
|
body2 = emptyBlock;
|
||||||
}
|
}
|
||||||
// getChildren().set(DoWhile.DoWhilePart.BODY2.ordinal(), body2);
|
// getChildren().set(DoWhile.DoWhilePart.BODY2.ordinal(), body2);
|
||||||
SymbolTable.pop();
|
SymbolTable.pop();
|
||||||
|
@ -29,11 +29,11 @@ import jdk.test.lib.jittester.ProductionFailedException;
|
|||||||
import jdk.test.lib.jittester.ProductionLimiter;
|
import jdk.test.lib.jittester.ProductionLimiter;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
import jdk.test.lib.jittester.ProductionParams;
|
||||||
import jdk.test.lib.jittester.Rule;
|
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;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class ExpressionFactory extends SafeFactory {
|
class ExpressionFactory extends SafeFactory<IRNode> {
|
||||||
private final Rule rule;
|
private final Rule<IRNode> rule;
|
||||||
|
|
||||||
ExpressionFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType,
|
ExpressionFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType,
|
||||||
boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
||||||
@ -44,7 +44,7 @@ class ExpressionFactory extends SafeFactory {
|
|||||||
.setResultType(resultType)
|
.setResultType(resultType)
|
||||||
.setExceptionSafe(exceptionSafe)
|
.setExceptionSafe(exceptionSafe)
|
||||||
.setNoConsts(noconsts);
|
.setNoConsts(noconsts);
|
||||||
rule = new Rule("expression");
|
rule = new Rule<>("expression");
|
||||||
if (!noconsts) {
|
if (!noconsts) {
|
||||||
rule.add("literal", builder.getLiteralFactory());
|
rule.add("literal", builder.getLiteralFactory());
|
||||||
rule.add("constant", builder.setIsConstant(true)
|
rule.add("constant", builder.setIsConstant(true)
|
||||||
|
@ -26,6 +26,6 @@ package jdk.test.lib.jittester.factories;
|
|||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
|
|
||||||
public abstract class Factory {
|
public abstract class Factory<T extends IRNode> {
|
||||||
public abstract IRNode produce() throws ProductionFailedException;
|
public abstract T produce() throws ProductionFailedException;
|
||||||
}
|
}
|
||||||
|
@ -23,22 +23,25 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
|
import jdk.test.lib.jittester.Block;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
import jdk.test.lib.jittester.Initialization;
|
|
||||||
import jdk.test.lib.jittester.Literal;
|
import jdk.test.lib.jittester.Literal;
|
||||||
import jdk.test.lib.jittester.LocalVariable;
|
import jdk.test.lib.jittester.LocalVariable;
|
||||||
import jdk.test.lib.jittester.Nothing;
|
import jdk.test.lib.jittester.Nothing;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Rule;
|
import jdk.test.lib.jittester.Rule;
|
||||||
|
import jdk.test.lib.jittester.Statement;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.For;
|
||||||
import jdk.test.lib.jittester.loops.Loop;
|
import jdk.test.lib.jittester.loops.Loop;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeInt;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class ForFactory extends SafeFactory {
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
class ForFactory extends SafeFactory<For> {
|
||||||
private final Loop loop;
|
private final Loop loop;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
@ -46,7 +49,6 @@ class ForFactory extends SafeFactory {
|
|||||||
private final TypeKlass ownerClass;
|
private final TypeKlass ownerClass;
|
||||||
private final Type returnType;
|
private final Type returnType;
|
||||||
private final int level;
|
private final int level;
|
||||||
private long thisLoopIterLimit = 0;
|
|
||||||
private final boolean canHaveReturn;
|
private final boolean canHaveReturn;
|
||||||
|
|
||||||
ForFactory(TypeKlass ownerClass, Type returnType, long complexityLimit, int statementLimit,
|
ForFactory(TypeKlass ownerClass, Type returnType, long complexityLimit, int statementLimit,
|
||||||
@ -62,7 +64,8 @@ class ForFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (statementLimit <= 0 || complexityLimit <= 0) {
|
||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
@ -81,7 +84,7 @@ class ForFactory extends SafeFactory {
|
|||||||
long statement1ComplLimit = (long) (0.005 * complexity * PseudoRandom.random());
|
long statement1ComplLimit = (long) (0.005 * complexity * PseudoRandom.random());
|
||||||
complexity -= statement1ComplLimit;
|
complexity -= statement1ComplLimit;
|
||||||
// Loop body parameters
|
// 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) {
|
if (thisLoopIterLimit > Integer.MAX_VALUE || thisLoopIterLimit == 0) {
|
||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
@ -100,7 +103,7 @@ class ForFactory extends SafeFactory {
|
|||||||
int body3StatementLimit = PseudoRandom.randomNotZero((int) (statementLimit / 4.0));
|
int body3StatementLimit = PseudoRandom.randomNotZero((int) (statementLimit / 4.0));
|
||||||
// Production
|
// Production
|
||||||
loop.initialization = builder.getCounterInitializerFactory(0).produce();
|
loop.initialization = builder.getCounterInitializerFactory(0).produce();
|
||||||
IRNode header;
|
Block header;
|
||||||
try {
|
try {
|
||||||
header = builder.setComplexityLimit(headerComplLimit)
|
header = builder.setComplexityLimit(headerComplLimit)
|
||||||
.setStatementLimit(headerStatementLimit)
|
.setStatementLimit(headerStatementLimit)
|
||||||
@ -112,12 +115,12 @@ class ForFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
header = new Nothing();
|
header = emptyBlock;
|
||||||
}
|
}
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
IRNode statement1;
|
IRNode statement1;
|
||||||
try {
|
try {
|
||||||
Rule rule = new Rule("statement1");
|
Rule<IRNode> rule = new Rule<>("statement1");
|
||||||
builder.setComplexityLimit(statement1ComplLimit);
|
builder.setComplexityLimit(statement1ComplLimit);
|
||||||
rule.add("assignment", builder.getAssignmentOperatorFactory());
|
rule.add("assignment", builder.getAssignmentOperatorFactory());
|
||||||
rule.add("function", builder.getFunctionFactory(), 0.1);
|
rule.add("function", builder.getFunctionFactory(), 0.1);
|
||||||
@ -129,20 +132,20 @@ class ForFactory extends SafeFactory {
|
|||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
statement1 = new Nothing();
|
statement1 = new Nothing();
|
||||||
}
|
}
|
||||||
LocalVariable counter = new LocalVariable(((Initialization) loop.initialization).get());
|
LocalVariable counter = new LocalVariable(loop.initialization.getVariableInfo());
|
||||||
Literal limiter = new Literal(Integer.valueOf((int) thisLoopIterLimit), new TypeInt());
|
Literal limiter = new Literal((int) thisLoopIterLimit, TypeList.INT);
|
||||||
loop.condition = builder.setComplexityLimit(condComplLimit)
|
loop.condition = builder.setComplexityLimit(condComplLimit)
|
||||||
.setLocalVariable(counter)
|
.setLocalVariable(counter)
|
||||||
.getLoopingConditionFactory(limiter)
|
.getLoopingConditionFactory(limiter)
|
||||||
.produce();
|
.produce();
|
||||||
IRNode statement2;
|
IRNode statement2;
|
||||||
try {
|
try {
|
||||||
statement2 = builder.setComplexityLimit(statement2ComplLimit)
|
statement2 = builder.setComplexityLimit(statement2ComplLimit)
|
||||||
.getAssignmentOperatorFactory().produce();
|
.getAssignmentOperatorFactory().produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
statement2 = new Nothing();
|
statement2 = new Nothing();
|
||||||
}
|
}
|
||||||
IRNode body1;
|
Block body1;
|
||||||
try {
|
try {
|
||||||
body1 = builder.setComplexityLimit(body1ComplLimit)
|
body1 = builder.setComplexityLimit(body1ComplLimit)
|
||||||
.setStatementLimit(body1StatementLimit)
|
.setStatementLimit(body1StatementLimit)
|
||||||
@ -154,10 +157,10 @@ class ForFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
body1 = new Nothing();
|
body1 = emptyBlock;
|
||||||
}
|
}
|
||||||
loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce();
|
loop.manipulator = builder.setLocalVariable(counter).getCounterManipulatorFactory().produce();
|
||||||
IRNode body2;
|
Block body2;
|
||||||
try {
|
try {
|
||||||
body2 = builder.setComplexityLimit(body2ComplLimit)
|
body2 = builder.setComplexityLimit(body2ComplLimit)
|
||||||
.setStatementLimit(body2StatementLimit)
|
.setStatementLimit(body2StatementLimit)
|
||||||
@ -169,9 +172,9 @@ class ForFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
body2 = new Nothing();
|
body2 = emptyBlock;
|
||||||
}
|
}
|
||||||
IRNode body3;
|
Block body3;
|
||||||
try {
|
try {
|
||||||
body3 = builder.setComplexityLimit(body3ComplLimit)
|
body3 = builder.setComplexityLimit(body3ComplLimit)
|
||||||
.setStatementLimit(body3StatementLimit)
|
.setStatementLimit(body3StatementLimit)
|
||||||
@ -183,10 +186,13 @@ class ForFactory extends SafeFactory {
|
|||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
body3 = new Nothing();
|
body3 = emptyBlock;
|
||||||
}
|
}
|
||||||
SymbolTable.pop();
|
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);
|
body2, body3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionDeclarationBlockFactory extends Factory {
|
class FunctionDeclarationBlockFactory extends Factory<FunctionDeclarationBlock> {
|
||||||
private final int memberFunctionsLimit;
|
private final int memberFunctionsLimit;
|
||||||
private final int memberFunctionsArgLimit;
|
private final int memberFunctionsArgLimit;
|
||||||
private final int level;
|
private final int level;
|
||||||
@ -46,7 +46,7 @@ class FunctionDeclarationBlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionDeclarationBlock produce() throws ProductionFailedException {
|
||||||
ArrayList<IRNode> content = new ArrayList<>();
|
ArrayList<IRNode> content = new ArrayList<>();
|
||||||
int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit);
|
int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit);
|
||||||
if (memFunLimit > 0) {
|
if (memFunLimit > 0) {
|
||||||
|
@ -27,7 +27,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Symbol;
|
import jdk.test.lib.jittester.Symbol;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
@ -39,10 +38,9 @@ import jdk.test.lib.jittester.functions.FunctionDeclaration;
|
|||||||
import jdk.test.lib.jittester.functions.FunctionDefinition;
|
import jdk.test.lib.jittester.functions.FunctionDefinition;
|
||||||
import jdk.test.lib.jittester.functions.FunctionInfo;
|
import jdk.test.lib.jittester.functions.FunctionInfo;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionDeclarationFactory extends Factory {
|
class FunctionDeclarationFactory extends Factory<FunctionDeclaration> {
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
private final TypeKlass ownerClass;
|
private final TypeKlass ownerClass;
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -59,11 +57,11 @@ class FunctionDeclarationFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionDeclaration produce() throws ProductionFailedException {
|
||||||
Type resType = resultType;
|
Type resType = resultType;
|
||||||
if (resType == null) {
|
if (resType == null) {
|
||||||
List<Type> types = new ArrayList<>(TypeList.getAll());
|
List<Type> types = new ArrayList<>(TypeList.getAll());
|
||||||
types.add(new TypeVoid());
|
types.add(TypeList.VOID);
|
||||||
resType = PseudoRandom.randomElement(types);
|
resType = PseudoRandom.randomElement(types);
|
||||||
}
|
}
|
||||||
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
||||||
|
@ -35,7 +35,7 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionDefinitionBlockFactory extends Factory {
|
class FunctionDefinitionBlockFactory extends Factory<FunctionDefinitionBlock> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -59,7 +59,7 @@ class FunctionDefinitionBlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionDefinitionBlock produce() throws ProductionFailedException {
|
||||||
ArrayList<IRNode> content = new ArrayList<>();
|
ArrayList<IRNode> content = new ArrayList<>();
|
||||||
int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit);
|
int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit);
|
||||||
if (memFunLimit > 0) {
|
if (memFunLimit > 0) {
|
||||||
|
@ -28,6 +28,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
|
import jdk.test.lib.jittester.Nothing;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Symbol;
|
import jdk.test.lib.jittester.Symbol;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
@ -37,11 +38,11 @@ import jdk.test.lib.jittester.VariableInfo;
|
|||||||
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
||||||
import jdk.test.lib.jittester.functions.FunctionDefinition;
|
import jdk.test.lib.jittester.functions.FunctionDefinition;
|
||||||
import jdk.test.lib.jittester.functions.FunctionInfo;
|
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.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionDefinitionFactory extends Factory {
|
class FunctionDefinitionFactory extends Factory<FunctionDefinition> {
|
||||||
private final Type resultType;
|
private final Type resultType;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
@ -67,11 +68,11 @@ class FunctionDefinitionFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionDefinition produce() throws ProductionFailedException {
|
||||||
Type resType = resultType;
|
Type resType = resultType;
|
||||||
if (resType == null) {
|
if (resType == null) {
|
||||||
List<Type> types = new ArrayList<>(TypeList.getAll());
|
List<Type> types = new ArrayList<>(TypeList.getAll());
|
||||||
types.add(new TypeVoid());
|
types.add(TypeList.VOID);
|
||||||
resType = PseudoRandom.randomElement(types);
|
resType = PseudoRandom.randomElement(types);
|
||||||
}
|
}
|
||||||
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
|
||||||
@ -86,7 +87,7 @@ class FunctionDefinitionFactory extends Factory {
|
|||||||
ArrayList<ArgumentDeclaration> argumentsDeclaration = new ArrayList<>(argNumber);
|
ArrayList<ArgumentDeclaration> argumentsDeclaration = new ArrayList<>(argNumber);
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
IRNode body;
|
IRNode body;
|
||||||
IRNode returnNode;
|
Return returnNode;
|
||||||
FunctionInfo functionInfo;
|
FunctionInfo functionInfo;
|
||||||
try {
|
try {
|
||||||
IRNodeBuilder builder = new IRNodeBuilder().setArgumentType(ownerClass);
|
IRNodeBuilder builder = new IRNodeBuilder().setArgumentType(ownerClass);
|
||||||
@ -127,13 +128,13 @@ class FunctionDefinitionFactory extends Factory {
|
|||||||
.setCanHaveReturn(true)
|
.setCanHaveReturn(true)
|
||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
if (!resType.equals(new TypeVoid())) {
|
if (!resType.equals(TypeList.VOID)) {
|
||||||
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
|
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
|
||||||
.setExceptionSafe(false)
|
.setExceptionSafe(false)
|
||||||
.getReturnFactory()
|
.getReturnFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} else {
|
} else {
|
||||||
returnNode = null;
|
returnNode = new Return(new Nothing());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
SymbolTable.pop();
|
SymbolTable.pop();
|
||||||
|
@ -37,7 +37,7 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionFactory extends SafeFactory {
|
class FunctionFactory extends SafeFactory<Function> {
|
||||||
private final FunctionInfo functionInfo;
|
private final FunctionInfo functionInfo;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
@ -55,7 +55,7 @@ class FunctionFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode sproduce() throws ProductionFailedException {
|
protected Function sproduce() throws ProductionFailedException {
|
||||||
// Currently no function is exception-safe
|
// Currently no function is exception-safe
|
||||||
if (exceptionSafe) {
|
if (exceptionSafe) {
|
||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
@ -72,7 +72,7 @@ class FunctionFactory extends SafeFactory {
|
|||||||
for (Symbol function : allFunctions) {
|
for (Symbol function : allFunctions) {
|
||||||
FunctionInfo functionInfo = (FunctionInfo) function;
|
FunctionInfo functionInfo = (FunctionInfo) function;
|
||||||
// Don't try to construct abstract classes.
|
// Don't try to construct abstract classes.
|
||||||
if (functionInfo.isConstructor() && functionInfo.klass.isAbstract()) {
|
if (functionInfo.isConstructor() && functionInfo.owner.isAbstract()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We don't call methods from the same class which are not final, because if we
|
// We don't call methods from the same class which are not final, because if we
|
||||||
@ -94,7 +94,7 @@ class FunctionFactory extends SafeFactory {
|
|||||||
|
|
||||||
// If it's a local call.. or it's a call using some variable to some object of some type in our hierarchy
|
// 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;
|
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
|
if ((functionInfo.flags & FunctionInfo.FINAL) == 0 && (functionInfo.flags & FunctionInfo.STATIC) == 0
|
||||||
&& (functionInfo.flags & FunctionInfo.NONRECURSIVE) == 0) {
|
&& (functionInfo.flags & FunctionInfo.NONRECURSIVE) == 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -121,7 +121,7 @@ class FunctionFactory extends SafeFactory {
|
|||||||
// If there are function with a same name and same number of args,
|
// If there are function with a same name and same number of args,
|
||||||
// then disable usage of foldable expressions in the args.
|
// then disable usage of foldable expressions in the args.
|
||||||
boolean noconsts = false;
|
boolean noconsts = false;
|
||||||
Collection<Symbol> allFuncsInKlass = SymbolTable.getAllCombined(functionInfo.klass,
|
Collection<Symbol> allFuncsInKlass = SymbolTable.getAllCombined(functionInfo.owner,
|
||||||
FunctionInfo.class);
|
FunctionInfo.class);
|
||||||
for (Symbol s2 : allFuncsInKlass) {
|
for (Symbol s2 : allFuncsInKlass) {
|
||||||
FunctionInfo i2 = (FunctionInfo) function;
|
FunctionInfo i2 = (FunctionInfo) function;
|
||||||
|
@ -34,7 +34,7 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
|
import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class FunctionRedefinitionBlockFactory extends Factory {
|
class FunctionRedefinitionBlockFactory extends Factory<FunctionRedefinitionBlock> {
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
@ -53,7 +53,7 @@ class FunctionRedefinitionBlockFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionRedefinitionBlock produce() throws ProductionFailedException {
|
||||||
ArrayList<IRNode> content = new ArrayList<>();
|
ArrayList<IRNode> content = new ArrayList<>();
|
||||||
if (functionSet.size() > 0) {
|
if (functionSet.size() > 0) {
|
||||||
long funcComplexity = complexityLimit / functionSet.size();
|
long funcComplexity = complexityLimit / functionSet.size();
|
||||||
|
@ -25,17 +25,19 @@ package jdk.test.lib.jittester.factories;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
|
import jdk.test.lib.jittester.Nothing;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.SymbolTable;
|
import jdk.test.lib.jittester.SymbolTable;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.VariableInfo;
|
import jdk.test.lib.jittester.VariableInfo;
|
||||||
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
|
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.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.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class FunctionRedefinitionFactory extends Factory {
|
class FunctionRedefinitionFactory extends Factory<FunctionRedefinition> {
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementLimit;
|
private final int statementLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -47,14 +49,14 @@ class FunctionRedefinitionFactory extends Factory {
|
|||||||
long complexityLimit, int statementLimit, int operatorLimit, int level, int flags) {
|
long complexityLimit, int statementLimit, int operatorLimit, int level, int flags) {
|
||||||
this.ownerClass = ownerClass;
|
this.ownerClass = ownerClass;
|
||||||
this.functionInfo = new FunctionInfo(functionInfo); // do deep coping
|
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) {
|
if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
|
||||||
functionInfo.argTypes.get(0).type = ownerClass; // redefine type of this
|
functionInfo.argTypes.get(0).type = ownerClass; // redefine type of this
|
||||||
}
|
}
|
||||||
functionInfo.flags = flags; // apply new flags.
|
functionInfo.flags = flags; // apply new flags.
|
||||||
// fix the type of class where the args would be declared
|
// fix the type of class where the args would be declared
|
||||||
for (VariableInfo varInfo : functionInfo.argTypes) {
|
for (VariableInfo varInfo : functionInfo.argTypes) {
|
||||||
varInfo.klass = ownerClass;
|
varInfo.owner = ownerClass;
|
||||||
}
|
}
|
||||||
this.complexityLimit = complexityLimit;
|
this.complexityLimit = complexityLimit;
|
||||||
this.statementLimit = statementLimit;
|
this.statementLimit = statementLimit;
|
||||||
@ -63,14 +65,14 @@ class FunctionRedefinitionFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public FunctionRedefinition produce() throws ProductionFailedException {
|
||||||
ArrayList<VariableInfo> argumentsInfo = functionInfo.argTypes;
|
ArrayList<VariableInfo> argumentsInfo = functionInfo.argTypes;
|
||||||
SymbolTable.push();
|
SymbolTable.push();
|
||||||
IRNode body;
|
IRNode body;
|
||||||
IRNode returnNode;
|
Return returnNode;
|
||||||
ArrayList<ArgumentDeclaration> argumentsDeclaration;
|
ArrayList<ArgumentDeclaration> argumentsDeclaration;
|
||||||
try {
|
try {
|
||||||
if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
|
if (functionInfo.isStatic()) {
|
||||||
argumentsDeclaration = new ArrayList<>(argumentsInfo.size());
|
argumentsDeclaration = new ArrayList<>(argumentsInfo.size());
|
||||||
for (VariableInfo varInfo : argumentsInfo) {
|
for (VariableInfo varInfo : argumentsInfo) {
|
||||||
argumentsDeclaration.add(new ArgumentDeclaration(varInfo));
|
argumentsDeclaration.add(new ArgumentDeclaration(varInfo));
|
||||||
@ -98,13 +100,13 @@ class FunctionRedefinitionFactory extends Factory {
|
|||||||
.setCanHaveReturn(true)
|
.setCanHaveReturn(true)
|
||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
if (!functionInfo.type.equals(new TypeVoid())) {
|
if (!functionInfo.type.equals(TypeList.VOID)) {
|
||||||
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
|
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
|
||||||
.setExceptionSafe(false)
|
.setExceptionSafe(false)
|
||||||
.getReturnFactory()
|
.getReturnFactory()
|
||||||
.produce();
|
.produce();
|
||||||
} else {
|
} else {
|
||||||
returnNode = null;
|
returnNode = new Return(new Nothing());
|
||||||
}
|
}
|
||||||
} catch (ProductionFailedException e) {
|
} catch (ProductionFailedException e) {
|
||||||
SymbolTable.pop();
|
SymbolTable.pop();
|
||||||
@ -112,12 +114,12 @@ class FunctionRedefinitionFactory extends Factory {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
SymbolTable.pop();
|
SymbolTable.pop();
|
||||||
if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
|
if (!functionInfo.isStatic()) {
|
||||||
functionInfo.flags &= ~FunctionInfo.ABSTRACT;
|
functionInfo.flags &= ~FunctionInfo.ABSTRACT;
|
||||||
}
|
}
|
||||||
// If it's all ok, add the function to the symbol table.
|
// If it's all ok, add the function to the symbol table.
|
||||||
SymbolTable.add(functionInfo);
|
SymbolTable.add(functionInfo);
|
||||||
return new FunctionDefinition(functionInfo, argumentsDeclaration, body, returnNode);
|
return new FunctionRedefinition(functionInfo, argumentsDeclaration, body, returnNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,64 @@ package jdk.test.lib.jittester.factories;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
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.Literal;
|
||||||
import jdk.test.lib.jittester.LocalVariable;
|
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.OperatorKind;
|
||||||
|
import jdk.test.lib.jittester.PrintVariables;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
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.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.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.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;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
public class IRNodeBuilder {
|
public class IRNodeBuilder {
|
||||||
@ -63,41 +113,40 @@ public class IRNodeBuilder {
|
|||||||
private Optional<Boolean> isConstant = Optional.empty();
|
private Optional<Boolean> isConstant = Optional.empty();
|
||||||
private Optional<Boolean> isInitialized = Optional.empty();
|
private Optional<Boolean> isInitialized = Optional.empty();
|
||||||
private Optional<String> name = Optional.empty();
|
private Optional<String> name = Optional.empty();
|
||||||
private Optional<String> printerName = Optional.empty();
|
|
||||||
private Optional<Integer> flags = Optional.empty();
|
private Optional<Integer> flags = Optional.empty();
|
||||||
private Optional<FunctionInfo> functionInfo = Optional.empty();
|
private Optional<FunctionInfo> functionInfo = Optional.empty();
|
||||||
private Optional<Boolean> semicolon = Optional.empty();
|
private Optional<Boolean> semicolon = Optional.empty();
|
||||||
|
|
||||||
public ArgumentDeclarationFactory getArgumentDeclarationFactory() {
|
public Factory<ArgumentDeclaration> getArgumentDeclarationFactory() {
|
||||||
return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber());
|
return new ArgumentDeclarationFactory(getArgumentType(), getVariableNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Factory getArithmeticOperatorFactory() throws ProductionFailedException {
|
public Factory<Operator> getArithmeticOperatorFactory() throws ProductionFailedException {
|
||||||
return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(),
|
return new ArithmeticOperatorFactory(getComplexityLimit(), getOperatorLimit(),
|
||||||
getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
|
getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayCreationFactory getArrayCreationFactory() {
|
public Factory<ArrayCreation> getArrayCreationFactory() {
|
||||||
return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new ArrayCreationFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayElementFactory getArrayElementFactory() {
|
public Factory<ArrayElement> getArrayElementFactory() {
|
||||||
return new ArrayElementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new ArrayElementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayExtractionFactory getArrayExtractionFactory() {
|
public Factory<ArrayExtraction> getArrayExtractionFactory() {
|
||||||
return new ArrayExtractionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new ArrayExtractionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssignmentOperatorFactory getAssignmentOperatorFactory() {
|
public Factory<Operator> getAssignmentOperatorFactory() {
|
||||||
return new AssignmentOperatorFactory(getComplexityLimit(), getOperatorLimit(),
|
return new AssignmentOperatorFactory(getComplexityLimit(), getOperatorLimit(),
|
||||||
getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts());
|
getOwnerClass(), resultType.orElse(null), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryOperatorFactory getBinaryOperatorFactory() throws ProductionFailedException {
|
public Factory<BinaryOperator> getBinaryOperatorFactory() throws ProductionFailedException {
|
||||||
OperatorKind o = getOperatorKind();
|
OperatorKind o = getOperatorKind();
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case ASSIGN:
|
case ASSIGN:
|
||||||
@ -166,7 +215,7 @@ public class IRNodeBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnaryOperatorFactory getUnaryOperatorFactory() throws ProductionFailedException {
|
public Factory<UnaryOperator> getUnaryOperatorFactory() throws ProductionFailedException {
|
||||||
OperatorKind o = getOperatorKind();
|
OperatorKind o = getOperatorKind();
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case NOT:
|
case NOT:
|
||||||
@ -193,24 +242,24 @@ public class IRNodeBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFactory getBlockFactory() throws ProductionFailedException {
|
public Factory<Block> getBlockFactory() {
|
||||||
return new BlockFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
return new BlockFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false),
|
getStatementLimit(), getOperatorLimit(), getLevel(), subBlock.orElse(false),
|
||||||
canHaveBreaks.orElse(false), canHaveContinues.orElse(false),
|
canHaveBreaks.orElse(false), canHaveContinues.orElse(false),
|
||||||
canHaveReturn.orElse(false), canHaveReturn.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<Break> getBreakFactory() {
|
||||||
return new BreakFactory();
|
return new BreakFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CastOperatorFactory getCastOperatorFactory() {
|
public Factory<CastOperator> getCastOperatorFactory() {
|
||||||
return new CastOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new CastOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Factory getClassDefinitionBlockFactory() {
|
public Factory<ClassDefinitionBlock> getClassDefinitionBlockFactory() {
|
||||||
return new ClassDefinitionBlockFactory(getPrefix(),
|
return new ClassDefinitionBlockFactory(getPrefix(),
|
||||||
ProductionParams.classesLimit.value(),
|
ProductionParams.classesLimit.value(),
|
||||||
ProductionParams.memberFunctionsLimit.value(),
|
ProductionParams.memberFunctionsLimit.value(),
|
||||||
@ -221,7 +270,7 @@ public class IRNodeBuilder {
|
|||||||
getLevel());
|
getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Factory getMainKlassFactory() {
|
public Factory<MainKlass> getMainKlassFactory() {
|
||||||
return new MainKlassFactory(getName(), getComplexityLimit(),
|
return new MainKlassFactory(getName(), getComplexityLimit(),
|
||||||
ProductionParams.memberFunctionsLimit.value(),
|
ProductionParams.memberFunctionsLimit.value(),
|
||||||
ProductionParams.memberFunctionsArgLimit.value(),
|
ProductionParams.memberFunctionsArgLimit.value(),
|
||||||
@ -230,200 +279,200 @@ public class IRNodeBuilder {
|
|||||||
ProductionParams.operatorLimit.value());
|
ProductionParams.operatorLimit.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConstructorDefinitionBlockFactory getConstructorDefinitionBlockFactory() {
|
public Factory<ConstructorDefinitionBlock> getConstructorDefinitionBlockFactory() {
|
||||||
return new ConstructorDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
return new ConstructorDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
||||||
ProductionParams.memberFunctionsArgLimit.value(), getComplexityLimit(),
|
ProductionParams.memberFunctionsArgLimit.value(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel());
|
getStatementLimit(), getOperatorLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConstructorDefinitionFactory getConstructorDefinitionFactory() {
|
public Factory<ConstructorDefinition> getConstructorDefinitionFactory() {
|
||||||
return new ConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
|
return new ConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(),
|
getStatementLimit(), getOperatorLimit(),
|
||||||
getMemberFunctionsArgLimit(), getLevel());
|
getMemberFunctionsArgLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContinueFactory getContinueFactory() {
|
public Factory<Continue> getContinueFactory() {
|
||||||
return new ContinueFactory();
|
return new ContinueFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterInitializerFactory getCounterInitializerFactory(int counterValue) {
|
public Factory<CounterInitializer> getCounterInitializerFactory(int counterValue) {
|
||||||
return new CounterInitializerFactory(getOwnerClass(), counterValue);
|
return new CounterInitializerFactory(getOwnerClass(), counterValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterManipulatorFactory getCounterManipulatorFactory() {
|
public Factory<CounterManipulator> getCounterManipulatorFactory() {
|
||||||
return new CounterManipulatorFactory(getLocalVariable());
|
return new CounterManipulatorFactory(getLocalVariable());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeclarationFactory getDeclarationFactory() {
|
public Factory<Declaration> getDeclarationFactory() {
|
||||||
return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(),
|
return new DeclarationFactory(getOwnerClass(), getComplexityLimit(), getOperatorLimit(),
|
||||||
getIsLocal(), getExceptionSafe());
|
getIsLocal(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoWhileFactory getDoWhileFactory() {
|
public Factory<DoWhile> getDoWhileFactory() {
|
||||||
return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
return new DoWhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public WhileFactory getWhileFactory() {
|
public Factory<While> getWhileFactory() {
|
||||||
return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
return new WhileFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IfFactory getIfFactory() {
|
public Factory<If> getIfFactory() {
|
||||||
return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
return new IfFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(),
|
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveBreaks(),
|
||||||
getCanHaveContinues(), getCanHaveReturn());
|
getCanHaveContinues(), getCanHaveReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForFactory getForFactory() {
|
public Factory<For> getForFactory() {
|
||||||
return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
return new ForFactory(getOwnerClass(), getResultType(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
getStatementLimit(), getOperatorLimit(), getLevel(), getCanHaveReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SwitchFactory getSwitchFactory() { // TODO: switch is not used now
|
public Factory<Switch> getSwitchFactory() { // TODO: switch is not used now
|
||||||
return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(),
|
return new SwitchFactory(getOwnerClass(), getComplexityLimit(), getStatementLimit(),
|
||||||
getOperatorLimit(), getLevel(), getCanHaveReturn());
|
getOperatorLimit(), getLevel(), getCanHaveReturn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionFactory getExpressionFactory() throws ProductionFailedException {
|
public Factory<IRNode> getExpressionFactory() throws ProductionFailedException {
|
||||||
return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new ExpressionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionDeclarationBlockFactory getFunctionDeclarationBlockFactory() {
|
public Factory<FunctionDeclarationBlock> getFunctionDeclarationBlockFactory() {
|
||||||
return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
return new FunctionDeclarationBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
||||||
getMemberFunctionsArgLimit(), getLevel());
|
getMemberFunctionsArgLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionDeclarationFactory getFunctionDeclarationFactory() {
|
public Factory<FunctionDeclaration> getFunctionDeclarationFactory() {
|
||||||
return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(null),
|
return new FunctionDeclarationFactory(getName(), getOwnerClass(),resultType.orElse(TypeList.VOID),
|
||||||
getMemberFunctionsArgLimit(), getFlags());
|
getMemberFunctionsArgLimit(), getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionDefinitionBlockFactory getFunctionDefinitionBlockFactory() {
|
public Factory<FunctionDefinitionBlock> getFunctionDefinitionBlockFactory() {
|
||||||
return new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
return new FunctionDefinitionBlockFactory(getOwnerClass(), getMemberFunctionsLimit(),
|
||||||
getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(),
|
getMemberFunctionsArgLimit(), getComplexityLimit(), getStatementLimit(),
|
||||||
getOperatorLimit(), getLevel(), getFlags());
|
getOperatorLimit(), getLevel(), getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionDefinitionFactory getFunctionDefinitionFactory() {
|
public Factory<FunctionDefinition> getFunctionDefinitionFactory() {
|
||||||
return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(null),
|
return new FunctionDefinitionFactory(getName(), getOwnerClass(), resultType.orElse(TypeList.VOID),
|
||||||
getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
|
getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
|
||||||
getMemberFunctionsArgLimit(), getLevel(), getFlags());
|
getMemberFunctionsArgLimit(), getLevel(), getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionFactory getFunctionFactory() {
|
public Factory<Function> getFunctionFactory() {
|
||||||
return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new FunctionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
resultType.orElse(null), getExceptionSafe());
|
resultType.orElse(null), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionRedefinitionBlockFactory getFunctionRedefinitionBlockFactory(Collection<Symbol>
|
public Factory<FunctionRedefinitionBlock> getFunctionRedefinitionBlockFactory(Collection<Symbol>
|
||||||
functionSet) {
|
functionSet) {
|
||||||
return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(),
|
return new FunctionRedefinitionBlockFactory(functionSet, getOwnerClass(),
|
||||||
getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel());
|
getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunctionRedefinitionFactory getFunctionRedefinitionFactory() {
|
public Factory<FunctionRedefinition> getFunctionRedefinitionFactory() {
|
||||||
return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(),
|
return new FunctionRedefinitionFactory(getFunctionInfo(), getOwnerClass(),
|
||||||
getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(),
|
getComplexityLimit(), getStatementLimit(), getOperatorLimit(), getLevel(),
|
||||||
getFlags());
|
getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public InterfaceFactory getInterfaceFactory() {
|
public Factory<Interface> getInterfaceFactory() {
|
||||||
return new InterfaceFactory(getName(), getMemberFunctionsLimit(),
|
return new InterfaceFactory(getName(), getMemberFunctionsLimit(),
|
||||||
getMemberFunctionsArgLimit(), getLevel());
|
getMemberFunctionsArgLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KlassFactory getKlassFactory() {
|
public Factory<Klass> getKlassFactory() {
|
||||||
return new KlassFactory(getName(), getPrinterName(), getComplexityLimit(),
|
return new KlassFactory(getName(), getComplexityLimit(),
|
||||||
getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(),
|
getMemberFunctionsLimit(), getMemberFunctionsArgLimit(), getStatementLimit(),
|
||||||
getOperatorLimit(), getLevel());
|
getOperatorLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitedExpressionFactory getLimitedExpressionFactory() throws ProductionFailedException {
|
public Factory<IRNode> getLimitedExpressionFactory() throws ProductionFailedException {
|
||||||
return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(),
|
return new LimitedExpressionFactory(getComplexityLimit(), getOperatorLimit(),
|
||||||
getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
|
getOwnerClass(), getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiteralFactory getLiteralFactory() {
|
public Factory<Literal> getLiteralFactory() {
|
||||||
return new LiteralFactory(getResultType());
|
return new LiteralFactory(getResultType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalVariableFactory getLocalVariableFactory() {
|
public Factory<LocalVariable> getLocalVariableFactory() {
|
||||||
return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags());
|
return new LocalVariableFactory(/*getVariableType()*/getResultType(), getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogicOperatorFactory getLogicOperatorFactory() throws ProductionFailedException {
|
public Factory<Operator> getLogicOperatorFactory() throws ProductionFailedException {
|
||||||
return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new LogicOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoopingConditionFactory getLoopingConditionFactory(Literal _limiter) {
|
public Factory<LoopingCondition> getLoopingConditionFactory(Literal _limiter) {
|
||||||
return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new LoopingConditionFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getLocalVariable(), _limiter);
|
getLocalVariable(), _limiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NonStaticMemberVariableFactory getNonStaticMemberVariableFactory() {
|
public Factory<NonStaticMemberVariable> getNonStaticMemberVariableFactory() {
|
||||||
return new NonStaticMemberVariableFactory(getComplexityLimit(), getOperatorLimit(),
|
return new NonStaticMemberVariableFactory(getComplexityLimit(), getOperatorLimit(),
|
||||||
getOwnerClass(), /*getVariableType()*/getResultType(), getFlags(), getExceptionSafe());
|
getOwnerClass(), /*getVariableType()*/getResultType(), getFlags(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public NothingFactory getNothingFactory() {
|
public Factory<Nothing> getNothingFactory() {
|
||||||
return new NothingFactory();
|
return new NothingFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrintVariablesFactory getPrintVariablesFactory() {
|
public Factory<PrintVariables> getPrintVariablesFactory() {
|
||||||
return new PrintVariablesFactory(getPrinterName(), getOwnerClass(), getLevel());
|
return new PrintVariablesFactory(getOwnerClass(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReturnFactory getReturnFactory() {
|
public Factory<Return> getReturnFactory() {
|
||||||
return new ReturnFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new ReturnFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe());
|
getResultType(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThrowFactory getThrowFactory() {
|
public Factory<Throw> getThrowFactory() {
|
||||||
return new ThrowFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe());
|
return new ThrowFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(), getResultType(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatementFactory getStatementFactory() {
|
public Factory<Statement> getStatementFactory() {
|
||||||
return new StatementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new StatementFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getExceptionSafe(), getNoConsts(), semicolon.orElse(true));
|
getExceptionSafe(), getNoConsts(), semicolon.orElse(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticConstructorDefinitionFactory getStaticConstructorDefinitionFactory() {
|
public Factory<StaticConstructorDefinition> getStaticConstructorDefinitionFactory() {
|
||||||
return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
|
return new StaticConstructorDefinitionFactory(getOwnerClass(), getComplexityLimit(),
|
||||||
getStatementLimit(), getOperatorLimit(), getLevel());
|
getStatementLimit(), getOperatorLimit(), getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StaticMemberVariableFactory getStaticMemberVariableFactory() {
|
public Factory<StaticMemberVariable> getStaticMemberVariableFactory() {
|
||||||
return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags());
|
return new StaticMemberVariableFactory(getOwnerClass(), /*getVariableType()*/getResultType(), getFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TernaryOperatorFactory getTernaryOperatorFactory() {
|
public Factory<TernaryOperator> getTernaryOperatorFactory() {
|
||||||
return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new TernaryOperatorFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
getResultType(), getExceptionSafe(), getNoConsts());
|
getResultType(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableDeclarationBlockFactory getVariableDeclarationBlockFactory() {
|
public Factory<VariableDeclarationBlock> getVariableDeclarationBlockFactory() {
|
||||||
return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(),
|
return new VariableDeclarationBlockFactory(getOwnerClass(), getComplexityLimit(),
|
||||||
getOperatorLimit(), getLevel(), getExceptionSafe());
|
getOperatorLimit(), getLevel(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableDeclarationFactory getVariableDeclarationFactory() {
|
public Factory<VariableDeclaration> getVariableDeclarationFactory() {
|
||||||
return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType());
|
return new VariableDeclarationFactory(getOwnerClass(), getIsStatic(), getIsLocal(), getResultType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableFactory getVariableFactory() {
|
public Factory<VariableBase> getVariableFactory() {
|
||||||
return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
return new VariableFactory(getComplexityLimit(), getOperatorLimit(), getOwnerClass(),
|
||||||
/*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts());
|
/*getVariableType()*/getResultType(), getIsConstant(), getIsInitialized(), getExceptionSafe(), getNoConsts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VariableInitializationFactory getVariableInitializationFactory() {
|
public Factory<VariableInitialization> getVariableInitializationFactory() {
|
||||||
return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(),
|
return new VariableInitializationFactory(getOwnerClass(), getIsConstant(), getIsStatic(),
|
||||||
getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe());
|
getIsLocal(), getComplexityLimit(), getOperatorLimit(), getExceptionSafe());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TryCatchBlockFactory getTryCatchBlockFactory() {
|
public Factory<TryCatchBlock> getTryCatchBlockFactory() {
|
||||||
return new TryCatchBlockFactory(getOwnerClass(), getResultType(),
|
return new TryCatchBlockFactory(getOwnerClass(), getResultType(),
|
||||||
getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
|
getComplexityLimit(), getStatementLimit(), getOperatorLimit(),
|
||||||
getLevel(), subBlock.orElse(false), getCanHaveBreaks(),
|
getLevel(), subBlock.orElse(false), getCanHaveBreaks(),
|
||||||
@ -570,11 +619,6 @@ public class IRNodeBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRNodeBuilder setPrinterName(String value) {
|
|
||||||
printerName = Optional.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IRNodeBuilder setSemicolon(boolean value) {
|
public IRNodeBuilder setSemicolon(boolean value) {
|
||||||
semicolon = Optional.of(value);
|
semicolon = Optional.of(value);
|
||||||
return this;
|
return this;
|
||||||
@ -698,9 +742,4 @@ public class IRNodeBuilder {
|
|||||||
return functionInfo.orElseThrow(() -> new IllegalArgumentException(
|
return functionInfo.orElseThrow(() -> new IllegalArgumentException(
|
||||||
"FunctionInfo wasn't set"));
|
"FunctionInfo wasn't set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrinterName() {
|
|
||||||
return printerName.orElseThrow(() -> new IllegalArgumentException(
|
|
||||||
"printerName wasn't set"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,21 +23,22 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
|
import jdk.test.lib.jittester.Block;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
import jdk.test.lib.jittester.IRNode;
|
||||||
import jdk.test.lib.jittester.If;
|
import jdk.test.lib.jittester.If;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
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.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeBoolean;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class IfFactory extends SafeFactory {
|
class IfFactory extends SafeFactory<If> {
|
||||||
protected long complexityLimit;
|
protected final long complexityLimit;
|
||||||
protected int statementLimit;
|
protected final int statementLimit;
|
||||||
protected int operatorLimit;
|
protected final int operatorLimit;
|
||||||
protected boolean canHaveBreaks;
|
protected final boolean canHaveBreaks;
|
||||||
protected boolean canHaveContinues;
|
protected final boolean canHaveContinues;
|
||||||
protected boolean canHaveReturn;
|
protected final boolean canHaveReturn;
|
||||||
protected final TypeKlass ownerClass;
|
protected final TypeKlass ownerClass;
|
||||||
protected final Type returnType;
|
protected final Type returnType;
|
||||||
protected final int level;
|
protected final int level;
|
||||||
@ -57,7 +58,7 @@ class IfFactory extends SafeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode sproduce() throws ProductionFailedException {
|
public If sproduce() throws ProductionFailedException {
|
||||||
// resizeUpChildren(If.IfPart.values().length);
|
// resizeUpChildren(If.IfPart.values().length);
|
||||||
if (statementLimit > 0 && complexityLimit > 0) {
|
if (statementLimit > 0 && complexityLimit > 0) {
|
||||||
long conditionComplLimit = (long) (0.01 * PseudoRandom.random() * (complexityLimit - 1));
|
long conditionComplLimit = (long) (0.01 * PseudoRandom.random() * (complexityLimit - 1));
|
||||||
@ -65,7 +66,7 @@ class IfFactory extends SafeFactory {
|
|||||||
.setOwnerKlass(ownerClass)
|
.setOwnerKlass(ownerClass)
|
||||||
.setOperatorLimit(operatorLimit);
|
.setOperatorLimit(operatorLimit);
|
||||||
IRNode condition = builder.setComplexityLimit(conditionComplLimit)
|
IRNode condition = builder.setComplexityLimit(conditionComplLimit)
|
||||||
.setResultType(new TypeBoolean())
|
.setResultType(TypeList.BOOLEAN)
|
||||||
.setExceptionSafe(false)
|
.setExceptionSafe(false)
|
||||||
.setNoConsts(false)
|
.setNoConsts(false)
|
||||||
.getLimitedExpressionFactory()
|
.getLimitedExpressionFactory()
|
||||||
@ -83,7 +84,7 @@ class IfFactory extends SafeFactory {
|
|||||||
controlDeviation = PseudoRandom.randomBoolean() ? If.IfPart.THEN : If.IfPart.ELSE;
|
controlDeviation = PseudoRandom.randomBoolean() ? If.IfPart.THEN : If.IfPart.ELSE;
|
||||||
}
|
}
|
||||||
if (ifBlockLimit > 0 && ifBlockComplLimit > 0) {
|
if (ifBlockLimit > 0 && ifBlockComplLimit > 0) {
|
||||||
IRNode thenBlock = null;
|
Block thenBlock;
|
||||||
builder.setResultType(returnType)
|
builder.setResultType(returnType)
|
||||||
.setLevel(level)
|
.setLevel(level)
|
||||||
.setComplexityLimit(ifBlockComplLimit)
|
.setComplexityLimit(ifBlockComplLimit)
|
||||||
@ -104,7 +105,7 @@ class IfFactory extends SafeFactory {
|
|||||||
.produce();
|
.produce();
|
||||||
}
|
}
|
||||||
// setChild(If.IfPart.THEN.ordinal(), thenBlock);
|
// setChild(If.IfPart.THEN.ordinal(), thenBlock);
|
||||||
IRNode elseBlock = null;
|
Block elseBlock = null;
|
||||||
if (elseBlockLimit > 0 && elseBlockComplLimit > 0) {
|
if (elseBlockLimit > 0 && elseBlockComplLimit > 0) {
|
||||||
builder.setComplexityLimit(elseBlockComplLimit)
|
builder.setComplexityLimit(elseBlockComplLimit)
|
||||||
.setStatementLimit(elseBlockLimit);
|
.setStatementLimit(elseBlockLimit);
|
||||||
|
@ -23,14 +23,12 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.OperatorKind;
|
import jdk.test.lib.jittester.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.UnaryOperator;
|
import jdk.test.lib.jittester.UnaryOperator;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeBoolean;
|
|
||||||
|
|
||||||
class IncDecOperatorFactory extends UnaryOperatorFactory {
|
class IncDecOperatorFactory extends UnaryOperatorFactory {
|
||||||
IncDecOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit,
|
IncDecOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit,
|
||||||
@ -40,11 +38,11 @@ class IncDecOperatorFactory extends UnaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return TypeList.isBuiltInInt(resultType) && !resultType.equals(new TypeBoolean());
|
return TypeList.isBuiltInInt(resultType) && !resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode generateProduction(Type l) throws ProductionFailedException {
|
protected UnaryOperator generateProduction(Type l) throws ProductionFailedException {
|
||||||
return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1)
|
return new UnaryOperator(opKind, new IRNodeBuilder().setComplexityLimit(complexityLimit - 1)
|
||||||
.setOperatorLimit(operatorLimit - 1)
|
.setOperatorLimit(operatorLimit - 1)
|
||||||
.setOwnerKlass((TypeKlass) ownerClass)
|
.setOwnerKlass((TypeKlass) ownerClass)
|
||||||
|
@ -37,7 +37,7 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class InterfaceFactory extends Factory {
|
class InterfaceFactory extends Factory<Interface> {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int memberFunctionsLimit;
|
private final int memberFunctionsLimit;
|
||||||
private final int memberFunctionsArgLimit;
|
private final int memberFunctionsArgLimit;
|
||||||
@ -52,7 +52,7 @@ class InterfaceFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Interface produce() throws ProductionFailedException {
|
||||||
TypeKlass thisKlass;
|
TypeKlass thisKlass;
|
||||||
// Do we want to inherit something?
|
// Do we want to inherit something?
|
||||||
if (!ProductionParams.disableInheritance.value()) {
|
if (!ProductionParams.disableInheritance.value()) {
|
||||||
@ -76,7 +76,7 @@ class InterfaceFactory extends Factory {
|
|||||||
parent.addChild(name);
|
parent.addChild(name);
|
||||||
for (Symbol symbol : SymbolTable.getAllCombined(parent, FunctionInfo.class)) {
|
for (Symbol symbol : SymbolTable.getAllCombined(parent, FunctionInfo.class)) {
|
||||||
FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
|
FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
|
||||||
functionInfo.klass = thisKlass;
|
functionInfo.owner = thisKlass;
|
||||||
functionInfo.argTypes.get(0).type = thisKlass;
|
functionInfo.argTypes.get(0).type = thisKlass;
|
||||||
SymbolTable.add(functionInfo);
|
SymbolTable.add(functionInfo);
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,8 @@ import jdk.test.lib.jittester.functions.FunctionInfo;
|
|||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class KlassFactory extends Factory {
|
class KlassFactory extends Factory<Klass> {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String printerName;
|
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementsInFunctionLimit;
|
private final int statementsInFunctionLimit;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -55,11 +54,10 @@ class KlassFactory extends Factory {
|
|||||||
private TypeKlass parent;
|
private TypeKlass parent;
|
||||||
private int memberFunctionsLimit;
|
private int memberFunctionsLimit;
|
||||||
|
|
||||||
KlassFactory(String name, String printerName, long complexityLimit,
|
KlassFactory(String name, long complexityLimit,
|
||||||
int memberFunctionsLimit, int memberFunctionsArgLimit, int statementsInFunctionLimit,
|
int memberFunctionsLimit, int memberFunctionsArgLimit, int statementsInFunctionLimit,
|
||||||
int operatorLimit, int level) {
|
int operatorLimit, int level) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.printerName = printerName;
|
|
||||||
this.complexityLimit = complexityLimit;
|
this.complexityLimit = complexityLimit;
|
||||||
this.memberFunctionsLimit = memberFunctionsLimit;
|
this.memberFunctionsLimit = memberFunctionsLimit;
|
||||||
this.memberFunctionsArgLimit = memberFunctionsArgLimit;
|
this.memberFunctionsArgLimit = memberFunctionsArgLimit;
|
||||||
@ -70,7 +68,7 @@ class KlassFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Klass produce() throws ProductionFailedException {
|
||||||
HashSet<Symbol> abstractSet = new HashSet<>();
|
HashSet<Symbol> abstractSet = new HashSet<>();
|
||||||
HashSet<Symbol> overrideSet = new HashSet<>();
|
HashSet<Symbol> overrideSet = new HashSet<>();
|
||||||
thisKlass = new TypeKlass(name);
|
thisKlass = new TypeKlass(name);
|
||||||
@ -135,15 +133,11 @@ class KlassFactory extends Factory {
|
|||||||
SymbolTable.remove(symbol);
|
SymbolTable.remove(symbol);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parent = (TypeKlass) TypeList.find("java.lang.Object");
|
parent = TypeList.OBJECT;
|
||||||
thisKlass.addParent(parent.getName());
|
thisKlass.addParent(parent.getName());
|
||||||
thisKlass.setParent(parent);
|
thisKlass.setParent(parent);
|
||||||
parent.addChild(name);
|
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,
|
SymbolTable.add(new VariableInfo("this", thisKlass, thisKlass,
|
||||||
VariableInfo.FINAL | VariableInfo.LOCAL | VariableInfo.INITIALIZED));
|
VariableInfo.FINAL | VariableInfo.LOCAL | VariableInfo.INITIALIZED));
|
||||||
IRNode variableDeclarations = null;
|
IRNode variableDeclarations = null;
|
||||||
@ -152,8 +146,7 @@ class KlassFactory extends Factory {
|
|||||||
IRNode functionDeclarations = null;
|
IRNode functionDeclarations = null;
|
||||||
IRNode abstractFunctionsRedefinitions = null;
|
IRNode abstractFunctionsRedefinitions = null;
|
||||||
IRNode overridenFunctionsRedefinitions = null;
|
IRNode overridenFunctionsRedefinitions = null;
|
||||||
IRNodeBuilder builder = new IRNodeBuilder().setPrinterName(printerName)
|
IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(thisKlass)
|
||||||
.setOwnerKlass(thisKlass)
|
|
||||||
.setExceptionSafe(true);
|
.setExceptionSafe(true);
|
||||||
try {
|
try {
|
||||||
builder.setLevel(level + 1)
|
builder.setLevel(level + 1)
|
||||||
@ -227,7 +220,7 @@ class KlassFactory extends Factory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (probableParents.isEmpty()) {
|
if (probableParents.isEmpty()) {
|
||||||
parent = (TypeKlass) TypeList.find("java.lang.Object");
|
parent = TypeList.OBJECT;
|
||||||
} else {
|
} else {
|
||||||
parent = (TypeKlass) PseudoRandom.randomElement(probableParents);
|
parent = (TypeKlass) PseudoRandom.randomElement(probableParents);
|
||||||
}
|
}
|
||||||
@ -246,7 +239,7 @@ class KlassFactory extends Factory {
|
|||||||
functionInfo.argTypes.get(0).type = thisKlass;
|
functionInfo.argTypes.get(0).type = thisKlass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
symbolCopy.klass = thisKlass;
|
symbolCopy.owner = thisKlass;
|
||||||
SymbolTable.add(symbolCopy);
|
SymbolTable.add(symbolCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,10 +269,9 @@ class KlassFactory extends Factory {
|
|||||||
interfaces.add(iface);
|
interfaces.add(iface);
|
||||||
iface.addChild(name);
|
iface.addChild(name);
|
||||||
thisKlass.addParent(iface.getName());
|
thisKlass.addParent(iface.getName());
|
||||||
thisKlass.setParent(iface);
|
|
||||||
for (Symbol symbol : SymbolTable.getAllCombined(iface, FunctionInfo.class)) {
|
for (Symbol symbol : SymbolTable.getAllCombined(iface, FunctionInfo.class)) {
|
||||||
FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
|
FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
|
||||||
functionInfo.klass = thisKlass;
|
functionInfo.owner = thisKlass;
|
||||||
functionInfo.argTypes.get(0).type = thisKlass;
|
functionInfo.argTypes.get(0).type = thisKlass;
|
||||||
SymbolTable.add(functionInfo);
|
SymbolTable.add(functionInfo);
|
||||||
}
|
}
|
||||||
|
@ -23,23 +23,16 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.Literal;
|
import jdk.test.lib.jittester.Literal;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.ProductionParams;
|
import jdk.test.lib.jittester.ProductionParams;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
import jdk.test.lib.jittester.TypeList;
|
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;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class LiteralFactory extends Factory {
|
import java.util.Locale;
|
||||||
|
|
||||||
|
class LiteralFactory extends Factory<Literal> {
|
||||||
protected final Type resultType;
|
protected final Type resultType;
|
||||||
|
|
||||||
LiteralFactory(Type resultType) {
|
LiteralFactory(Type resultType) {
|
||||||
@ -47,31 +40,39 @@ class LiteralFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Literal produce() throws ProductionFailedException {
|
||||||
Literal literal;
|
Literal literal;
|
||||||
if (resultType.equals(new TypeBoolean())) {
|
if (resultType.equals(TypeList.BOOLEAN)) {
|
||||||
literal = new Literal(PseudoRandom.randomBoolean(), new TypeBoolean());
|
literal = new Literal(PseudoRandom.randomBoolean(), TypeList.BOOLEAN);
|
||||||
} else if (resultType.equals(new TypeChar())) {
|
} else if (resultType.equals(TypeList.CHAR)) {
|
||||||
literal = new Literal((char) ((char) (PseudoRandom.random() * ('z' - 'A')) + 'A'), new TypeChar());
|
literal = new Literal((char) ((char) (PseudoRandom.random() * ('z' - 'A')) + 'A'), TypeList.CHAR);
|
||||||
} else if (resultType.equals(new TypeInt())) {
|
} else if (resultType.equals(TypeList.INT)) {
|
||||||
literal = new Literal((int) (PseudoRandom.random() * Integer.MAX_VALUE), new TypeInt());
|
literal = new Literal((int) (PseudoRandom.random() * Integer.MAX_VALUE), TypeList.INT);
|
||||||
} else if (resultType.equals(new TypeLong())) {
|
} else if (resultType.equals(TypeList.LONG)) {
|
||||||
literal = new Literal((long) (PseudoRandom.random() * Long.MAX_VALUE), new TypeLong());
|
literal = new Literal((long) (PseudoRandom.random() * Long.MAX_VALUE), TypeList.LONG);
|
||||||
} else if (resultType.equals(new TypeFloat())) {
|
} else if (resultType.equals(TypeList.FLOAT)) {
|
||||||
literal = new Literal((float) (PseudoRandom.random() * Float.MAX_VALUE), new TypeFloat());
|
literal = new Literal(new Float(String.format(
|
||||||
} else if (resultType.equals(new TypeDouble())) {
|
(Locale) null,
|
||||||
literal = new Literal(PseudoRandom.random() * Double.MAX_VALUE, new TypeDouble());
|
"%." + ProductionParams.floatingPointPrecision.value() + "EF",
|
||||||
} else if (resultType.equals(new TypeByte())) {
|
(float) PseudoRandom.random() * Float.MAX_VALUE)),
|
||||||
literal = new Literal((byte)(PseudoRandom.random() * Byte.MAX_VALUE),new TypeByte());
|
TypeList.FLOAT);
|
||||||
} else if (resultType.equals(new TypeShort())) {
|
} else if (resultType.equals(TypeList.DOUBLE)) {
|
||||||
literal = new Literal((short)(PseudoRandom.random() * Short.MAX_VALUE), new TypeShort());
|
literal = new Literal(new Double(String.format(
|
||||||
} else if (resultType.equals(TypeList.find("java.lang.String"))) {
|
(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());
|
int size = (int) (PseudoRandom.random() * ProductionParams.stringLiteralSizeLimit.value());
|
||||||
byte[] str = new byte[size];
|
byte[] str = new byte[size];
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
str[i] = (byte) ((int) (('z' - 'a') * PseudoRandom.random()) + 'a');
|
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 {
|
} else {
|
||||||
throw new ProductionFailedException();
|
throw new ProductionFailedException();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.LocalVariable;
|
import jdk.test.lib.jittester.LocalVariable;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Symbol;
|
import jdk.test.lib.jittester.Symbol;
|
||||||
@ -33,7 +33,7 @@ import jdk.test.lib.jittester.Type;
|
|||||||
import jdk.test.lib.jittester.VariableInfo;
|
import jdk.test.lib.jittester.VariableInfo;
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class LocalVariableFactory extends Factory {
|
class LocalVariableFactory extends Factory<LocalVariable> {
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final int flags;
|
private final int flags;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class LocalVariableFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public LocalVariable produce() throws ProductionFailedException {
|
||||||
// Get the variables of the requested type from SymbolTable
|
// Get the variables of the requested type from SymbolTable
|
||||||
ArrayList<Symbol> allVariables = new ArrayList<>(SymbolTable.get(type, VariableInfo.class));
|
ArrayList<Symbol> allVariables = new ArrayList<>(SymbolTable.get(type, VariableInfo.class));
|
||||||
if (!allVariables.isEmpty()) {
|
if (!allVariables.isEmpty()) {
|
||||||
|
@ -23,15 +23,15 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
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.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Rule;
|
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;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class LogicOperatorFactory extends Factory {
|
class LogicOperatorFactory extends Factory<Operator> {
|
||||||
private final Rule rule;
|
private final Rule<Operator> rule;
|
||||||
|
|
||||||
LogicOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType,
|
LogicOperatorFactory(long complexityLimit, int operatorLimit, TypeKlass ownerClass, Type resultType,
|
||||||
boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
boolean exceptionSafe, boolean noconsts) throws ProductionFailedException {
|
||||||
@ -42,7 +42,7 @@ class LogicOperatorFactory extends Factory {
|
|||||||
.setResultType(resultType)
|
.setResultType(resultType)
|
||||||
.setExceptionSafe(exceptionSafe)
|
.setExceptionSafe(exceptionSafe)
|
||||||
.setNoConsts(noconsts);
|
.setNoConsts(noconsts);
|
||||||
rule = new Rule("arithmetic");
|
rule = new Rule<>("arithmetic");
|
||||||
rule.add("land", builder.setOperatorKind(OperatorKind.AND).getBinaryOperatorFactory());
|
rule.add("land", builder.setOperatorKind(OperatorKind.AND).getBinaryOperatorFactory());
|
||||||
rule.add("lor", builder.setOperatorKind(OperatorKind.OR).getBinaryOperatorFactory());
|
rule.add("lor", builder.setOperatorKind(OperatorKind.OR).getBinaryOperatorFactory());
|
||||||
rule.add("greater", builder.setOperatorKind(OperatorKind.GT).getBinaryOperatorFactory());
|
rule.add("greater", builder.setOperatorKind(OperatorKind.GT).getBinaryOperatorFactory());
|
||||||
@ -55,7 +55,7 @@ class LogicOperatorFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public Operator produce() throws ProductionFailedException {
|
||||||
return rule.produce();
|
return rule.produce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
|
|
||||||
package jdk.test.lib.jittester.factories;
|
package jdk.test.lib.jittester.factories;
|
||||||
|
|
||||||
import jdk.test.lib.jittester.IRNode;
|
|
||||||
import jdk.test.lib.jittester.OperatorKind;
|
import jdk.test.lib.jittester.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
import jdk.test.lib.jittester.Type;
|
import jdk.test.lib.jittester.Type;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.UnaryOperator;
|
import jdk.test.lib.jittester.UnaryOperator;
|
||||||
import jdk.test.lib.jittester.types.TypeBoolean;
|
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
|
|
||||||
class LogicalInversionOperatorFactory extends UnaryOperatorFactory {
|
class LogicalInversionOperatorFactory extends UnaryOperatorFactory {
|
||||||
@ -39,11 +38,11 @@ class LogicalInversionOperatorFactory extends UnaryOperatorFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isApplicable(Type resultType) {
|
protected boolean isApplicable(Type resultType) {
|
||||||
return resultType.equals(new TypeBoolean());
|
return resultType.equals(TypeList.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IRNode generateProduction(Type resultType) throws ProductionFailedException {
|
protected UnaryOperator generateProduction(Type resultType) throws ProductionFailedException {
|
||||||
return new UnaryOperator(opKind, new ExpressionFactory(complexityLimit - 1,
|
return new UnaryOperator(opKind, new ExpressionFactory(complexityLimit - 1,
|
||||||
operatorLimit - 1, (TypeKlass) ownerClass, resultType, exceptionSafe, noconsts).produce());
|
operatorLimit - 1, (TypeKlass) ownerClass, resultType, exceptionSafe, noconsts).produce());
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ import jdk.test.lib.jittester.Literal;
|
|||||||
import jdk.test.lib.jittester.LocalVariable;
|
import jdk.test.lib.jittester.LocalVariable;
|
||||||
import jdk.test.lib.jittester.OperatorKind;
|
import jdk.test.lib.jittester.OperatorKind;
|
||||||
import jdk.test.lib.jittester.ProductionFailedException;
|
import jdk.test.lib.jittester.ProductionFailedException;
|
||||||
|
import jdk.test.lib.jittester.TypeList;
|
||||||
import jdk.test.lib.jittester.loops.LoopingCondition;
|
import jdk.test.lib.jittester.loops.LoopingCondition;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeBoolean;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class LoopingConditionFactory extends Factory {
|
class LoopingConditionFactory extends Factory<LoopingCondition> {
|
||||||
private final LocalVariable counter;
|
private final LocalVariable counter;
|
||||||
private final Literal limiter;
|
private final Literal limiter;
|
||||||
private final int operatorLimit;
|
private final int operatorLimit;
|
||||||
@ -51,11 +51,11 @@ class LoopingConditionFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public LoopingCondition produce() throws ProductionFailedException {
|
||||||
IRNode leftExpression = null;
|
IRNode leftExpression = null;
|
||||||
IRNode rightExpression = null;
|
IRNode rightExpression = null;
|
||||||
LimitedExpressionFactory exprFactory = new IRNodeBuilder()
|
Factory<IRNode> exprFactory = new IRNodeBuilder()
|
||||||
.setResultType(new TypeBoolean())
|
.setResultType(TypeList.BOOLEAN)
|
||||||
.setComplexityLimit((complexityLimit - 1) / 2)
|
.setComplexityLimit((complexityLimit - 1) / 2)
|
||||||
.setOperatorLimit((operatorLimit - 1) / 2)
|
.setOperatorLimit((operatorLimit - 1) / 2)
|
||||||
.setOwnerKlass(ownerClass)
|
.setOwnerKlass(ownerClass)
|
||||||
@ -75,10 +75,10 @@ class LoopingConditionFactory extends Factory {
|
|||||||
// Just as a temporary solution we'll assume that the counter is monotonically increasing.
|
// Just as a temporary solution we'll assume that the counter is monotonically increasing.
|
||||||
// And use counter < n condition to limit the loop.
|
// And use counter < n condition to limit the loop.
|
||||||
// In future we may introduce other equivalent relations as well.
|
// In future we may introduce other equivalent relations as well.
|
||||||
IRNode condition = new BinaryOperator(OperatorKind.LT, counter, limiter);
|
BinaryOperator condition = new BinaryOperator(OperatorKind.LT, TypeList.BOOLEAN, counter, limiter);
|
||||||
condition = (rightExpression != null) ? new BinaryOperator(OperatorKind.AND, condition,
|
condition = (rightExpression != null) ? new BinaryOperator(OperatorKind.AND, TypeList.BOOLEAN, condition,
|
||||||
rightExpression) : condition;
|
rightExpression) : condition;
|
||||||
condition = (leftExpression != null) ? new BinaryOperator(OperatorKind.AND, leftExpression,
|
condition = (leftExpression != null) ? new BinaryOperator(OperatorKind.AND, TypeList.BOOLEAN, leftExpression,
|
||||||
condition) : condition;
|
condition) : condition;
|
||||||
return new LoopingCondition(condition);
|
return new LoopingCondition(condition);
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,9 @@ import jdk.test.lib.jittester.VariableInfo;
|
|||||||
import jdk.test.lib.jittester.classes.MainKlass;
|
import jdk.test.lib.jittester.classes.MainKlass;
|
||||||
import jdk.test.lib.jittester.functions.FunctionInfo;
|
import jdk.test.lib.jittester.functions.FunctionInfo;
|
||||||
import jdk.test.lib.jittester.types.TypeKlass;
|
import jdk.test.lib.jittester.types.TypeKlass;
|
||||||
import jdk.test.lib.jittester.types.TypeVoid;
|
|
||||||
import jdk.test.lib.jittester.utils.PseudoRandom;
|
import jdk.test.lib.jittester.utils.PseudoRandom;
|
||||||
|
|
||||||
class MainKlassFactory extends Factory {
|
class MainKlassFactory extends Factory<MainKlass> {
|
||||||
private final String name;
|
private final String name;
|
||||||
private final long complexityLimit;
|
private final long complexityLimit;
|
||||||
private final int statementsInTestFunctionLimit;
|
private final int statementsInTestFunctionLimit;
|
||||||
@ -64,8 +63,8 @@ class MainKlassFactory extends Factory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRNode produce() throws ProductionFailedException {
|
public MainKlass produce() throws ProductionFailedException {
|
||||||
TypeKlass parent = (TypeKlass) TypeList.find("java.lang.Object");
|
TypeKlass parent = TypeList.OBJECT;
|
||||||
thisKlass = new TypeKlass(name);
|
thisKlass = new TypeKlass(name);
|
||||||
thisKlass.addParent(parent.getName());
|
thisKlass.addParent(parent.getName());
|
||||||
thisKlass.setParent(parent);
|
thisKlass.setParent(parent);
|
||||||
@ -80,8 +79,7 @@ class MainKlassFactory extends Factory {
|
|||||||
.setMemberFunctionsArgLimit(memberFunctionsArgLimit)
|
.setMemberFunctionsArgLimit(memberFunctionsArgLimit)
|
||||||
.setStatementLimit(statementsInFunctionLimit)
|
.setStatementLimit(statementsInFunctionLimit)
|
||||||
.setLevel(1)
|
.setLevel(1)
|
||||||
.setExceptionSafe(true)
|
.setExceptionSafe(true);
|
||||||
.setPrinterName("Printer");
|
|
||||||
IRNode variableDeclarations = builder
|
IRNode variableDeclarations = builder
|
||||||
.setComplexityLimit((long) (complexityLimit * 0.05))
|
.setComplexityLimit((long) (complexityLimit * 0.05))
|
||||||
.getVariableDeclarationBlockFactory().produce();
|
.getVariableDeclarationBlockFactory().produce();
|
||||||
@ -93,7 +91,7 @@ class MainKlassFactory extends Factory {
|
|||||||
.getFunctionDefinitionBlockFactory()
|
.getFunctionDefinitionBlockFactory()
|
||||||
.produce();
|
.produce();
|
||||||
}
|
}
|
||||||
IRNode testFunction = builder.setResultType(new TypeVoid())
|
IRNode testFunction = builder.setResultType(TypeList.VOID)
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setStatementLimit(statementsInTestFunctionLimit)
|
.setStatementLimit(statementsInTestFunctionLimit)
|
||||||
.getBlockFactory()
|
.getBlockFactory()
|
||||||
@ -109,6 +107,7 @@ class MainKlassFactory extends Factory {
|
|||||||
childs.add(printVariables);
|
childs.add(printVariables);
|
||||||
ensureMinDepth(childs, builder);
|
ensureMinDepth(childs, builder);
|
||||||
ensureMaxDepth(childs);
|
ensureMaxDepth(childs);
|
||||||
|
TypeList.add(thisKlass);
|
||||||
return new MainKlass(name, thisKlass, variableDeclarations,
|
return new MainKlass(name, thisKlass, variableDeclarations,
|
||||||
functionDefinitions, testFunction, printVariables);
|
functionDefinitions, testFunction, printVariables);
|
||||||
}
|
}
|
||||||
@ -119,7 +118,7 @@ class MainKlassFactory extends Factory {
|
|||||||
.filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth)
|
.filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (IRNode child : filtered) {
|
for (IRNode child : filtered) {
|
||||||
List<IRNode> leaves = null;
|
List<IRNode> leaves;
|
||||||
do {
|
do {
|
||||||
long depth = Math.max(child.countDepth(), maxDepth + 1);
|
long depth = Math.max(child.countDepth(), maxDepth + 1);
|
||||||
leaves = child.getDeviantBlocks(depth);
|
leaves = child.getDeviantBlocks(depth);
|
||||||
@ -138,16 +137,14 @@ class MainKlassFactory extends Factory {
|
|||||||
private void addMoreChildren(List<IRNode> childs, int minDepth, IRNodeBuilder builder)
|
private void addMoreChildren(List<IRNode> childs, int minDepth, IRNodeBuilder builder)
|
||||||
throws ProductionFailedException {
|
throws ProductionFailedException {
|
||||||
while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) {
|
while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) {
|
||||||
PseudoRandom.shuffle(childs);
|
IRNode randomChild = childs.get(PseudoRandom.randomNotNegative(childs.size()));
|
||||||
IRNode randomChild = childs.get(0);
|
|
||||||
List<IRNode> leaves = randomChild.getStackableLeaves();
|
List<IRNode> leaves = randomChild.getStackableLeaves();
|
||||||
if (!leaves.isEmpty()) {
|
if (!leaves.isEmpty()) {
|
||||||
PseudoRandom.shuffle(leaves);
|
Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size()));
|
||||||
Block randomLeaf = (Block) leaves.get(0);
|
TypeKlass owner = randomChild.getOwner();
|
||||||
TypeKlass klass = (TypeKlass) randomChild.getKlass();
|
|
||||||
int newLevel = randomLeaf.getLevel() + 1;
|
int newLevel = randomLeaf.getLevel() + 1;
|
||||||
Type retType = randomLeaf.getReturnType();
|
Type retType = randomLeaf.getResultType();
|
||||||
IRNode newBlock = builder.setOwnerKlass(klass)
|
IRNode newBlock = builder.setOwnerKlass(owner)
|
||||||
.setResultType(retType)
|
.setResultType(retType)
|
||||||
.setComplexityLimit(complexityLimit)
|
.setComplexityLimit(complexityLimit)
|
||||||
.setStatementLimit(statementsInFunctionLimit)
|
.setStatementLimit(statementsInFunctionLimit)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user