< prev index next >

test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/MainKlassFactory.java

Print this page

        

*** 36,49 **** import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.classes.MainKlass; import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeKlass; - import jdk.test.lib.jittester.types.TypeVoid; import jdk.test.lib.jittester.utils.PseudoRandom; ! class MainKlassFactory extends Factory { private final String name; private final long complexityLimit; private final int statementsInTestFunctionLimit; private final int statementsInFunctionLimit; private final int operatorLimit; --- 36,48 ---- import jdk.test.lib.jittester.TypeList; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.classes.MainKlass; import jdk.test.lib.jittester.functions.FunctionInfo; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; ! class MainKlassFactory extends Factory<MainKlass> { private final String name; private final long complexityLimit; private final int statementsInTestFunctionLimit; private final int statementsInFunctionLimit; private final int operatorLimit;
*** 62,73 **** this.statementsInTestFunctionLimit = statementsInTestFunctionLimit; this.operatorLimit = operatorLimit; } @Override ! public IRNode produce() throws ProductionFailedException { ! TypeKlass parent = (TypeKlass) TypeList.find("java.lang.Object"); thisKlass = new TypeKlass(name); thisKlass.addParent(parent.getName()); thisKlass.setParent(parent); parent.addChild(name); parent.addChild(thisKlass); --- 61,72 ---- this.statementsInTestFunctionLimit = statementsInTestFunctionLimit; this.operatorLimit = operatorLimit; } @Override ! public MainKlass produce() throws ProductionFailedException { ! TypeKlass parent = TypeList.OBJECT; thisKlass = new TypeKlass(name); thisKlass.addParent(parent.getName()); thisKlass.setParent(parent); parent.addChild(name); parent.addChild(thisKlass);
*** 78,89 **** .setOperatorLimit(operatorLimit) .setMemberFunctionsLimit(memberFunctionsLimit) .setMemberFunctionsArgLimit(memberFunctionsArgLimit) .setStatementLimit(statementsInFunctionLimit) .setLevel(1) ! .setExceptionSafe(true) ! .setPrinterName("Printer"); IRNode variableDeclarations = builder .setComplexityLimit((long) (complexityLimit * 0.05)) .getVariableDeclarationBlockFactory().produce(); IRNode functionDefinitions = null; if (!ProductionParams.disableFunctions.value()) { --- 77,87 ---- .setOperatorLimit(operatorLimit) .setMemberFunctionsLimit(memberFunctionsLimit) .setMemberFunctionsArgLimit(memberFunctionsArgLimit) .setStatementLimit(statementsInFunctionLimit) .setLevel(1) ! .setExceptionSafe(true); IRNode variableDeclarations = builder .setComplexityLimit((long) (complexityLimit * 0.05)) .getVariableDeclarationBlockFactory().produce(); IRNode functionDefinitions = null; if (!ProductionParams.disableFunctions.value()) {
*** 91,101 **** .setComplexityLimit((long) (complexityLimit * 0.01 * PseudoRandom.random())) .setFlags(FunctionInfo.NONRECURSIVE) .getFunctionDefinitionBlockFactory() .produce(); } ! IRNode testFunction = builder.setResultType(new TypeVoid()) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInTestFunctionLimit) .getBlockFactory() .produce(); SymbolTable.remove(new Symbol("this", thisKlass, thisKlass, VariableInfo.NONE)); --- 89,99 ---- .setComplexityLimit((long) (complexityLimit * 0.01 * PseudoRandom.random())) .setFlags(FunctionInfo.NONRECURSIVE) .getFunctionDefinitionBlockFactory() .produce(); } ! IRNode testFunction = builder.setResultType(TypeList.VOID) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInTestFunctionLimit) .getBlockFactory() .produce(); SymbolTable.remove(new Symbol("this", thisKlass, thisKlass, VariableInfo.NONE));
*** 107,127 **** childs.add(functionDefinitions); childs.add(testFunction); childs.add(printVariables); ensureMinDepth(childs, builder); ensureMaxDepth(childs); return new MainKlass(name, thisKlass, variableDeclarations, functionDefinitions, testFunction, printVariables); } private void ensureMaxDepth(List<IRNode> childs) { int maxDepth = ProductionParams.maxCfgDepth.value(); List<IRNode> filtered = childs.stream() .filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth) .collect(Collectors.toList()); for (IRNode child : filtered) { ! List<IRNode> leaves = null; do { long depth = Math.max(child.countDepth(), maxDepth + 1); leaves = child.getDeviantBlocks(depth); leaves.get(0).removeSelf(); } while (!leaves.isEmpty() && child.countDepth() > maxDepth); --- 105,126 ---- childs.add(functionDefinitions); childs.add(testFunction); childs.add(printVariables); ensureMinDepth(childs, builder); ensureMaxDepth(childs); + TypeList.add(thisKlass); return new MainKlass(name, thisKlass, variableDeclarations, functionDefinitions, testFunction, printVariables); } private void ensureMaxDepth(List<IRNode> childs) { int maxDepth = ProductionParams.maxCfgDepth.value(); List<IRNode> filtered = childs.stream() .filter(c -> c.isCFDeviation() && c.countDepth() > maxDepth) .collect(Collectors.toList()); for (IRNode child : filtered) { ! List<IRNode> leaves; do { long depth = Math.max(child.countDepth(), maxDepth + 1); leaves = child.getDeviantBlocks(depth); leaves.get(0).removeSelf(); } while (!leaves.isEmpty() && child.countDepth() > maxDepth);
*** 136,155 **** } private void addMoreChildren(List<IRNode> childs, int minDepth, IRNodeBuilder builder) throws ProductionFailedException { while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) { ! PseudoRandom.shuffle(childs); ! IRNode randomChild = childs.get(0); List<IRNode> leaves = randomChild.getStackableLeaves(); if (!leaves.isEmpty()) { ! PseudoRandom.shuffle(leaves); ! Block randomLeaf = (Block) leaves.get(0); ! TypeKlass klass = (TypeKlass) randomChild.getKlass(); int newLevel = randomLeaf.getLevel() + 1; ! Type retType = randomLeaf.getReturnType(); ! IRNode newBlock = builder.setOwnerKlass(klass) .setResultType(retType) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInFunctionLimit) .setLevel(newLevel) .getBlockFactory() --- 135,152 ---- } private void addMoreChildren(List<IRNode> childs, int minDepth, IRNodeBuilder builder) throws ProductionFailedException { while (!childs.isEmpty() && IRNode.countDepth(childs) < minDepth) { ! IRNode randomChild = childs.get(PseudoRandom.randomNotNegative(childs.size())); List<IRNode> leaves = randomChild.getStackableLeaves(); if (!leaves.isEmpty()) { ! Block randomLeaf = (Block) leaves.get(PseudoRandom.randomNotNegative(leaves.size())); ! TypeKlass owner = randomChild.getOwner(); int newLevel = randomLeaf.getLevel() + 1; ! Type retType = randomLeaf.getResultType(); ! IRNode newBlock = builder.setOwnerKlass(owner) .setResultType(retType) .setComplexityLimit(complexityLimit) .setStatementLimit(statementsInFunctionLimit) .setLevel(newLevel) .getBlockFactory()
< prev index next >