< prev index next >

test/hotspot/jtreg/compiler/valhalla/valuetypes/ValueTypeTest.java

Print this page


  67 
  68 // Force method inlining during compilation
  69 @Retention(RetentionPolicy.RUNTIME)
  70 @interface ForceInline { }
  71 
  72 // Prevent method inlining during compilation
  73 @Retention(RetentionPolicy.RUNTIME)
  74 @interface DontInline { }
  75 
  76 // Prevent method compilation
  77 @Retention(RetentionPolicy.RUNTIME)
  78 @interface DontCompile { }
  79 
  80 // Number of warmup iterations
  81 @Retention(RetentionPolicy.RUNTIME)
  82 @interface Warmup {
  83     int value();
  84 }
  85 
  86 public abstract class ValueTypeTest {



  87     // Random test values
  88     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
  89     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
  90 
  91     // User defined settings
  92     private static final boolean PRINT_GRAPH = true;
  93     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
  94     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true"));
  95     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
  96     private static final String SCENARIOS = System.getProperty("Scenarios", "");
  97     private static final String TESTLIST = System.getProperty("Testlist", "");
  98     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
  99     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 100     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));
 101 
 102     // Pre-defined settings
 103     private static final List<String> defaultFlags = Arrays.asList(
 104         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 105         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
 106         "-XX:CompileCommand=quiet",
 107         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 108         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 109         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 110         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*");
 111     private static final List<String> verifyFlags = Arrays.asList(
 112         "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC",
 113         "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing", "-XX:+StressValueTypeReturnedAsFields");
 114 
 115     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
 116     protected static final int ValueTypePassFieldsAsArgsOn = 0x1;
 117     protected static final int ValueTypePassFieldsAsArgsOff = 0x2;
 118     protected static final int ValueTypeArrayFlattenOn = 0x4;
 119     protected static final int ValueTypeArrayFlattenOff = 0x8;
 120     protected static final int ValueTypeReturnedAsFieldsOn = 0x10;
 121     protected static final int ValueTypeReturnedAsFieldsOff = 0x20;
 122     static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn;
 123     protected static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs");
 124     protected static final boolean ValueTypeArrayFlatten = (Boolean)WHITE_BOX.getVMFlag("ValueArrayFlatten");
 125     protected static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields");
 126     protected static final boolean NullableValueTypes = (Boolean)WHITE_BOX.getVMFlag("NullableValueTypes");
 127     protected static final int COMP_LEVEL_ANY = -2;
 128     protected static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
 129     protected static final Hashtable<String, Method> tests = new Hashtable<String, Method>();
 130     protected static final boolean USE_COMPILER = WHITE_BOX.getBooleanVMFlag("UseCompiler");
 131     protected static final boolean PRINT_IDEAL  = WHITE_BOX.getBooleanVMFlag("PrintIdeal");
 132     protected static final boolean XCOMP = Platform.isComp();
 133 
 134     // Regular expressions used to match nodes in the PrintIdeal output
 135     protected static final String START = "(\\d+\\t(.*";
 136     protected static final String MID = ".*)+\\t===.*";
 137     protected static final String END = ")|";
 138     protected static final String ALLOC  = "(.*precise klass compiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_instance_Java" + END;
 139     protected static final String ALLOCA = "(.*precise klass \\[Lcompiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_array_Java" + END;
 140     protected static final String LOAD   = START + "Load(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END;
 141     protected static final String LOADK  = START + "LoadK" + MID + END;
 142     protected static final String STORE  = START + "Store(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END;
 143     protected static final String LOOP   = START + "Loop" + MID + "" + END;
 144     protected static final String TRAP   = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END;
 145     protected static final String RETURN = START + "Return" + MID + "returns" + END;
 146     protected static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END;
 147     protected static final String NPE = START + "CallStaticJava" + MID + "null_check" + END;
 148     protected static final String CALL = START + "CallStaticJava" + MID + END;


 153         ArrayList<String> list = new ArrayList<String>();
 154         if (prefix != null) {
 155             for (String s : prefix) {
 156                 list.add(s);
 157             }
 158         }
 159         if (extra != null) {
 160             for (String s : extra) {
 161                 list.add(s);
 162             }
 163         }
 164 
 165         return list.toArray(new String[list.size()]);
 166     }
 167 
 168     /**
 169      * Override getNumScenarios and getVMParameters if you want to run with more than
 170      * the 5 built-in scenarios
 171      */
 172     public int getNumScenarios() {



 173         return 5;
 174     }

 175 
 176     /**
 177      * VM paramaters for the 5 built-in test scenarios. If your test needs to append
 178      * extra parameters for (some of) these scenarios, override getExtraVMParameters().
 179      */
 180     public String[] getVMParameters(int scenario) {






 181         switch (scenario) {
 182         case 0: return new String[] {
 183                 "-XX:+AlwaysIncrementalInline",
 184                 "-XX:ValueArrayElemMaxFlatOops=-1",
 185                 "-XX:ValueArrayElemMaxFlatSize=-1",
 186                 "-XX:+ValueArrayFlatten",
 187                 "-XX:ValueFieldMaxFlatSize=-1",
 188                 "-XX:+ValueTypePassFieldsAsArgs",
 189                 "-XX:+ValueTypeReturnedAsFields"};
 190         case 1: return new String[] {
 191                 "-XX:-UseCompressedOops",
 192                 "-XX:ValueArrayElemMaxFlatOops=-1",
 193                 "-XX:ValueArrayElemMaxFlatSize=-1",
 194                 "-XX:+ValueArrayFlatten",
 195                 "-XX:ValueFieldMaxFlatSize=-1",
 196                 "-XX:-ValueTypePassFieldsAsArgs",
 197                 "-XX:-ValueTypeReturnedAsFields"};
 198         case 2: return new String[] {
 199                 "-DVerifyIR=false",
 200                 "-XX:-UseCompressedOops",




  67 
  68 // Force method inlining during compilation
  69 @Retention(RetentionPolicy.RUNTIME)
  70 @interface ForceInline { }
  71 
  72 // Prevent method inlining during compilation
  73 @Retention(RetentionPolicy.RUNTIME)
  74 @interface DontInline { }
  75 
  76 // Prevent method compilation
  77 @Retention(RetentionPolicy.RUNTIME)
  78 @interface DontCompile { }
  79 
  80 // Number of warmup iterations
  81 @Retention(RetentionPolicy.RUNTIME)
  82 @interface Warmup {
  83     int value();
  84 }
  85 
  86 public abstract class ValueTypeTest {
  87     // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing.
  88     static final boolean TEST_C1 = Boolean.getBoolean("test.c1");
  89 
  90     // Random test values
  91     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
  92     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
  93 
  94     // User defined settings
  95     private static final boolean PRINT_GRAPH = true;
  96     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
  97     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && (!TEST_C1);
  98     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
  99     private static final String SCENARIOS = System.getProperty("Scenarios", "");
 100     private static final String TESTLIST = System.getProperty("Testlist", "");
 101     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
 102     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 103     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));
 104 
 105     // Pre-defined settings
 106     private static final List<String> defaultFlags = Arrays.asList(
 107         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 108         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
 109         "-XX:CompileCommand=quiet",
 110         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 111         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 112         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 113         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*");
 114     private static final List<String> verifyFlags = Arrays.asList(
 115         "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC",
 116         "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing", "-XX:+StressValueTypeReturnedAsFields");
 117 
 118     protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
 119     protected static final int ValueTypePassFieldsAsArgsOn = 0x1;
 120     protected static final int ValueTypePassFieldsAsArgsOff = 0x2;
 121     protected static final int ValueTypeArrayFlattenOn = 0x4;
 122     protected static final int ValueTypeArrayFlattenOff = 0x8;
 123     protected static final int ValueTypeReturnedAsFieldsOn = 0x10;
 124     protected static final int ValueTypeReturnedAsFieldsOff = 0x20;
 125     static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn;
 126     protected static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs");
 127     protected static final boolean ValueTypeArrayFlatten = (Boolean)WHITE_BOX.getVMFlag("ValueArrayFlatten");
 128     protected static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields");
 129     protected static final boolean NullableValueTypes = (Boolean)WHITE_BOX.getVMFlag("NullableValueTypes");
 130     protected static final int COMP_LEVEL_ANY = -2;
 131     protected static final int COMP_LEVEL_FULL_OPTIMIZATION = TEST_C1 ? 1 : 4;
 132     protected static final Hashtable<String, Method> tests = new Hashtable<String, Method>();
 133     protected static final boolean USE_COMPILER = WHITE_BOX.getBooleanVMFlag("UseCompiler");
 134     protected static final boolean PRINT_IDEAL  = WHITE_BOX.getBooleanVMFlag("PrintIdeal");
 135     protected static final boolean XCOMP = Platform.isComp();
 136 
 137     // Regular expressions used to match nodes in the PrintIdeal output
 138     protected static final String START = "(\\d+\\t(.*";
 139     protected static final String MID = ".*)+\\t===.*";
 140     protected static final String END = ")|";
 141     protected static final String ALLOC  = "(.*precise klass compiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_instance_Java" + END;
 142     protected static final String ALLOCA = "(.*precise klass \\[Lcompiler/valhalla/valuetypes/MyValue.*\\R(.*(nop|spill).*\\R)*.*_new_array_Java" + END;
 143     protected static final String LOAD   = START + "Load(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END;
 144     protected static final String LOADK  = START + "LoadK" + MID + END;
 145     protected static final String STORE  = START + "Store(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/valuetypes/MyValue.*" + END;
 146     protected static final String LOOP   = START + "Loop" + MID + "" + END;
 147     protected static final String TRAP   = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END;
 148     protected static final String RETURN = START + "Return" + MID + "returns" + END;
 149     protected static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END;
 150     protected static final String NPE = START + "CallStaticJava" + MID + "null_check" + END;
 151     protected static final String CALL = START + "CallStaticJava" + MID + END;


 156         ArrayList<String> list = new ArrayList<String>();
 157         if (prefix != null) {
 158             for (String s : prefix) {
 159                 list.add(s);
 160             }
 161         }
 162         if (extra != null) {
 163             for (String s : extra) {
 164                 list.add(s);
 165             }
 166         }
 167 
 168         return list.toArray(new String[list.size()]);
 169     }
 170 
 171     /**
 172      * Override getNumScenarios and getVMParameters if you want to run with more than
 173      * the 5 built-in scenarios
 174      */
 175     public int getNumScenarios() {
 176         if (TEST_C1) {
 177             return 1;
 178         } else {
 179             return 5;
 180         }
 181     }
 182 
 183     /**
 184      * VM paramaters for the 5 built-in test scenarios. If your test needs to append
 185      * extra parameters for (some of) these scenarios, override getExtraVMParameters().
 186      */
 187     public String[] getVMParameters(int scenario) {
 188         if (TEST_C1) {
 189             return new String[] {
 190                     "-XX:+EnableValhallaC1",
 191             };
 192         }
 193 
 194         switch (scenario) {
 195         case 0: return new String[] {
 196                 "-XX:+AlwaysIncrementalInline",
 197                 "-XX:ValueArrayElemMaxFlatOops=-1",
 198                 "-XX:ValueArrayElemMaxFlatSize=-1",
 199                 "-XX:+ValueArrayFlatten",
 200                 "-XX:ValueFieldMaxFlatSize=-1",
 201                 "-XX:+ValueTypePassFieldsAsArgs",
 202                 "-XX:+ValueTypeReturnedAsFields"};
 203         case 1: return new String[] {
 204                 "-XX:-UseCompressedOops",
 205                 "-XX:ValueArrayElemMaxFlatOops=-1",
 206                 "-XX:ValueArrayElemMaxFlatSize=-1",
 207                 "-XX:+ValueArrayFlatten",
 208                 "-XX:ValueFieldMaxFlatSize=-1",
 209                 "-XX:-ValueTypePassFieldsAsArgs",
 210                 "-XX:-ValueTypeReturnedAsFields"};
 211         case 2: return new String[] {
 212                 "-DVerifyIR=false",
 213                 "-XX:-UseCompressedOops",


< prev index next >