< prev index next >

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

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib.jittester.factories;
  25 
  26 import java.util.ArrayList;
  27 import java.util.Collection;
  28 import jdk.test.lib.jittester.IRNode;
  29 import jdk.test.lib.jittester.ProductionFailedException;
  30 import jdk.test.lib.jittester.Symbol;
  31 import jdk.test.lib.jittester.SymbolTable;
  32 import jdk.test.lib.jittester.VariableInfo;
  33 import jdk.test.lib.jittester.functions.FunctionInfo;
  34 import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
  35 import jdk.test.lib.jittester.types.TypeKlass;
  36 
  37 class FunctionRedefinitionBlockFactory extends Factory {
  38     private final int statementLimit;
  39     private final int operatorLimit;
  40     private final long complexityLimit;
  41     private final int level;
  42     private final TypeKlass ownerClass;
  43     private final Collection<Symbol> functionSet;
  44 
  45     FunctionRedefinitionBlockFactory(Collection<Symbol> functionSet, TypeKlass ownerClass,
  46             long complexityLimit, int statementLimit, int operatorLimit, int level) {
  47         this.functionSet = functionSet;
  48         this.ownerClass = ownerClass;
  49         this.complexityLimit = complexityLimit;
  50         this.statementLimit = statementLimit;
  51         this.operatorLimit = operatorLimit;
  52         this.level = level;
  53     }
  54 
  55     @Override
  56     public IRNode produce() throws ProductionFailedException {
  57         ArrayList<IRNode> content = new ArrayList<>();
  58         if (functionSet.size() > 0) {
  59             long funcComplexity = complexityLimit / functionSet.size();
  60             IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass)
  61                     .setComplexityLimit(funcComplexity)
  62                     .setStatementLimit(statementLimit)
  63                     .setOperatorLimit(operatorLimit)
  64                     .setLevel(level);
  65             for (Symbol symbol : functionSet) {
  66                 FunctionInfo functionInfo = (FunctionInfo) symbol;
  67                 Symbol thisSymbol = null;
  68                 if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
  69                     thisSymbol = SymbolTable.get("this", VariableInfo.class);
  70                     SymbolTable.remove(thisSymbol);
  71                 }
  72                 try {
  73                     content.add(builder.setFunctionInfo(functionInfo)
  74                             .setFlags(functionInfo.flags)
  75                             .getFunctionRedefinitionFactory()
  76                             .produce());


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.test.lib.jittester.factories;
  25 
  26 import java.util.ArrayList;
  27 import java.util.Collection;
  28 import jdk.test.lib.jittester.IRNode;
  29 import jdk.test.lib.jittester.ProductionFailedException;
  30 import jdk.test.lib.jittester.Symbol;
  31 import jdk.test.lib.jittester.SymbolTable;
  32 import jdk.test.lib.jittester.VariableInfo;
  33 import jdk.test.lib.jittester.functions.FunctionInfo;
  34 import jdk.test.lib.jittester.functions.FunctionRedefinitionBlock;
  35 import jdk.test.lib.jittester.types.TypeKlass;
  36 
  37 class FunctionRedefinitionBlockFactory extends Factory<FunctionRedefinitionBlock> {
  38     private final int statementLimit;
  39     private final int operatorLimit;
  40     private final long complexityLimit;
  41     private final int level;
  42     private final TypeKlass ownerClass;
  43     private final Collection<Symbol> functionSet;
  44 
  45     FunctionRedefinitionBlockFactory(Collection<Symbol> functionSet, TypeKlass ownerClass,
  46             long complexityLimit, int statementLimit, int operatorLimit, int level) {
  47         this.functionSet = functionSet;
  48         this.ownerClass = ownerClass;
  49         this.complexityLimit = complexityLimit;
  50         this.statementLimit = statementLimit;
  51         this.operatorLimit = operatorLimit;
  52         this.level = level;
  53     }
  54 
  55     @Override
  56     public FunctionRedefinitionBlock produce() throws ProductionFailedException {
  57         ArrayList<IRNode> content = new ArrayList<>();
  58         if (functionSet.size() > 0) {
  59             long funcComplexity = complexityLimit / functionSet.size();
  60             IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlass(ownerClass)
  61                     .setComplexityLimit(funcComplexity)
  62                     .setStatementLimit(statementLimit)
  63                     .setOperatorLimit(operatorLimit)
  64                     .setLevel(level);
  65             for (Symbol symbol : functionSet) {
  66                 FunctionInfo functionInfo = (FunctionInfo) symbol;
  67                 Symbol thisSymbol = null;
  68                 if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
  69                     thisSymbol = SymbolTable.get("this", VariableInfo.class);
  70                     SymbolTable.remove(thisSymbol);
  71                 }
  72                 try {
  73                     content.add(builder.setFunctionInfo(functionInfo)
  74                             .setFlags(functionInfo.flags)
  75                             .getFunctionRedefinitionFactory()
  76                             .produce());
< prev index next >