< prev index next >
test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/FunctionRedefinitionFactory.java
Print this page
*** 23,43 ****
package jdk.test.lib.jittester.factories;
import java.util.ArrayList;
import jdk.test.lib.jittester.IRNode;
import jdk.test.lib.jittester.ProductionFailedException;
import jdk.test.lib.jittester.SymbolTable;
import jdk.test.lib.jittester.VariableInfo;
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
- import jdk.test.lib.jittester.functions.FunctionDefinition;
import jdk.test.lib.jittester.functions.FunctionInfo;
import jdk.test.lib.jittester.types.TypeKlass;
- import jdk.test.lib.jittester.types.TypeVoid;
import jdk.test.lib.jittester.utils.PseudoRandom;
! class FunctionRedefinitionFactory extends Factory {
private final long complexityLimit;
private final int statementLimit;
private final int operatorLimit;
private final int level;
private final TypeKlass ownerClass;
--- 23,45 ----
package jdk.test.lib.jittester.factories;
import java.util.ArrayList;
import jdk.test.lib.jittester.IRNode;
+ import jdk.test.lib.jittester.Nothing;
import jdk.test.lib.jittester.ProductionFailedException;
import jdk.test.lib.jittester.SymbolTable;
+ import jdk.test.lib.jittester.TypeList;
import jdk.test.lib.jittester.VariableInfo;
import jdk.test.lib.jittester.functions.ArgumentDeclaration;
import jdk.test.lib.jittester.functions.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.utils.PseudoRandom;
! class FunctionRedefinitionFactory extends Factory<FunctionRedefinition> {
private final long complexityLimit;
private final int statementLimit;
private final int operatorLimit;
private final int level;
private final TypeKlass ownerClass;
*** 45,78 ****
FunctionRedefinitionFactory(FunctionInfo functionInfo, TypeKlass ownerClass,
long complexityLimit, int statementLimit, int operatorLimit, int level, int flags) {
this.ownerClass = ownerClass;
this.functionInfo = new FunctionInfo(functionInfo); // do deep coping
! functionInfo.klass = ownerClass; // important! fix klass!
if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
functionInfo.argTypes.get(0).type = ownerClass; // redefine type of this
}
functionInfo.flags = flags; // apply new flags.
// fix the type of class where the args would be declared
for (VariableInfo varInfo : functionInfo.argTypes) {
! varInfo.klass = ownerClass;
}
this.complexityLimit = complexityLimit;
this.statementLimit = statementLimit;
this.operatorLimit = operatorLimit;
this.level = level;
}
@Override
! public IRNode produce() throws ProductionFailedException {
ArrayList<VariableInfo> argumentsInfo = functionInfo.argTypes;
SymbolTable.push();
IRNode body;
! IRNode returnNode;
ArrayList<ArgumentDeclaration> argumentsDeclaration;
try {
! if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
argumentsDeclaration = new ArrayList<>(argumentsInfo.size());
for (VariableInfo varInfo : argumentsInfo) {
argumentsDeclaration.add(new ArgumentDeclaration(varInfo));
SymbolTable.add(varInfo);
}
--- 47,80 ----
FunctionRedefinitionFactory(FunctionInfo functionInfo, TypeKlass ownerClass,
long complexityLimit, int statementLimit, int operatorLimit, int level, int flags) {
this.ownerClass = ownerClass;
this.functionInfo = new FunctionInfo(functionInfo); // do deep coping
! functionInfo.owner = ownerClass; // important! fix klass!
if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
functionInfo.argTypes.get(0).type = ownerClass; // redefine type of this
}
functionInfo.flags = flags; // apply new flags.
// fix the type of class where the args would be declared
for (VariableInfo varInfo : functionInfo.argTypes) {
! varInfo.owner = ownerClass;
}
this.complexityLimit = complexityLimit;
this.statementLimit = statementLimit;
this.operatorLimit = operatorLimit;
this.level = level;
}
@Override
! public FunctionRedefinition produce() throws ProductionFailedException {
ArrayList<VariableInfo> argumentsInfo = functionInfo.argTypes;
SymbolTable.push();
IRNode body;
! Return returnNode;
ArrayList<ArgumentDeclaration> argumentsDeclaration;
try {
! if (functionInfo.isStatic()) {
argumentsDeclaration = new ArrayList<>(argumentsInfo.size());
for (VariableInfo varInfo : argumentsInfo) {
argumentsDeclaration.add(new ArgumentDeclaration(varInfo));
SymbolTable.add(varInfo);
}
*** 96,123 ****
.setCanHaveBreaks(false)
.setCanHaveContinues(false)
.setCanHaveReturn(true)
.getBlockFactory()
.produce();
! if (!functionInfo.type.equals(new TypeVoid())) {
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
.setExceptionSafe(false)
.getReturnFactory()
.produce();
} else {
! returnNode = null;
}
} catch (ProductionFailedException e) {
SymbolTable.pop();
SymbolTable.add(functionInfo);
throw e;
}
SymbolTable.pop();
! if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
functionInfo.flags &= ~FunctionInfo.ABSTRACT;
}
// If it's all ok, add the function to the symbol table.
SymbolTable.add(functionInfo);
! return new FunctionDefinition(functionInfo, argumentsDeclaration, body, returnNode);
}
}
--- 98,125 ----
.setCanHaveBreaks(false)
.setCanHaveContinues(false)
.setCanHaveReturn(true)
.getBlockFactory()
.produce();
! if (!functionInfo.type.equals(TypeList.VOID)) {
returnNode = builder.setComplexityLimit(complexityLimit - blockComplLimit)
.setExceptionSafe(false)
.getReturnFactory()
.produce();
} else {
! returnNode = new Return(new Nothing());
}
} catch (ProductionFailedException e) {
SymbolTable.pop();
SymbolTable.add(functionInfo);
throw e;
}
SymbolTable.pop();
! if (!functionInfo.isStatic()) {
functionInfo.flags &= ~FunctionInfo.ABSTRACT;
}
// If it's all ok, add the function to the symbol table.
SymbolTable.add(functionInfo);
! return new FunctionRedefinition(functionInfo, argumentsDeclaration, body, returnNode);
}
}
< prev index next >