13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 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.List; 27 import jdk.test.lib.jittester.IRNode; 28 import jdk.test.lib.jittester.LiteralInitializer; 29 import jdk.test.lib.jittester.ProductionFailedException; 30 import jdk.test.lib.jittester.SymbolTable; 31 import jdk.test.lib.jittester.Type; 32 import jdk.test.lib.jittester.TypeList; 33 import jdk.test.lib.jittester.TypeUtil; 34 import jdk.test.lib.jittester.VariableInfo; 35 import jdk.test.lib.jittester.loops.CounterInitializer; 36 import jdk.test.lib.jittester.types.TypeKlass; 37 import jdk.test.lib.jittester.types.TypeInt; 38 import jdk.test.lib.jittester.utils.PseudoRandom; 39 40 class CounterInitializerFactory extends SafeFactory { 41 private final int counterValue; 42 private final TypeKlass ownerClass; 43 44 CounterInitializerFactory(TypeKlass ownerClass, int counterValue) { 45 this.ownerClass = ownerClass; 46 this.counterValue = counterValue; 47 } 48 49 @Override 50 protected IRNode sproduce() throws ProductionFailedException { 51 List<Type> types = TypeUtil.getMoreCapatiousThan(TypeList.getBuiltIn(), new TypeInt()); 52 types.add(new TypeInt()); 53 final Type selectedType = PseudoRandom.randomElement(types); 54 IRNode init = new LiteralInitializer(counterValue, selectedType); 55 String resultName = "var_" + SymbolTable.getNextVariableNumber(); 56 VariableInfo varInfo = new VariableInfo(resultName, ownerClass, selectedType, 57 VariableInfo.FINAL | VariableInfo.LOCAL | VariableInfo.INITIALIZED); 58 SymbolTable.add(varInfo); 59 return new CounterInitializer(varInfo, init); 60 } 61 } | 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 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.List; 27 import jdk.test.lib.jittester.IRNode; 28 import jdk.test.lib.jittester.LiteralInitializer; 29 import jdk.test.lib.jittester.ProductionFailedException; 30 import jdk.test.lib.jittester.SymbolTable; 31 import jdk.test.lib.jittester.Type; 32 import jdk.test.lib.jittester.TypeList; 33 import jdk.test.lib.jittester.utils.TypeUtil; 34 import jdk.test.lib.jittester.VariableInfo; 35 import jdk.test.lib.jittester.loops.CounterInitializer; 36 import jdk.test.lib.jittester.types.TypeKlass; 37 import jdk.test.lib.jittester.types.TypeInt; 38 import jdk.test.lib.jittester.utils.PseudoRandom; 39 40 class CounterInitializerFactory extends SafeFactory { 41 private final int counterValue; 42 private final TypeKlass ownerClass; 43 44 CounterInitializerFactory(TypeKlass ownerClass, int counterValue) { 45 this.ownerClass = ownerClass; 46 this.counterValue = counterValue; 47 } 48 49 @Override 50 protected IRNode sproduce() throws ProductionFailedException { 51 List<Type> types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt()); 52 types.add(new TypeInt()); 53 final Type selectedType = PseudoRandom.randomElement(types); 54 IRNode init = new LiteralInitializer(counterValue, selectedType); 55 String resultName = "var_" + SymbolTable.getNextVariableNumber(); 56 VariableInfo varInfo = new VariableInfo(resultName, ownerClass, selectedType, 57 VariableInfo.FINAL | VariableInfo.LOCAL | VariableInfo.INITIALIZED); 58 SymbolTable.add(varInfo); 59 return new CounterInitializer(varInfo, init); 60 } 61 } |