< prev index next >

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

Print this page


 110 
 111     // Should we execute tests that assume (ValueType[] <: Object[])?
 112     static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance");
 113 
 114     // Random test values
 115     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
 116     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
 117 
 118     // User defined settings
 119     protected static final boolean XCOMP = Platform.isComp();
 120     private static final boolean PRINT_GRAPH = true;
 121     protected static final boolean VERBOSE = Boolean.parseBoolean(System.getProperty("Verbose", "false"));
 122     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
 123     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && !TEST_C1 && !XCOMP;
 124     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
 125     private static final String SCENARIOS = System.getProperty("Scenarios", "");
 126     private static final String TESTLIST = System.getProperty("Testlist", "");
 127     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
 128     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 129     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));




 130 
 131     // Pre-defined settings
 132     private static final String[] defaultFlags = {
 133         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 134         "-XX:CompileCommand=quiet",
 135         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 136         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 137         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 138         "-XX:CompileCommand=inline,compiler.valhalla.valuetypes.MyValue*::<init>",
 139         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"};
 140     private static final String[] printFlags = {
 141         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintOptoAssembly"};
 142     private static final String[] verifyFlags = {
 143         "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC",
 144         "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing"};
 145 
 146     protected static final int ValueTypePassFieldsAsArgsOn = 0x1;
 147     protected static final int ValueTypePassFieldsAsArgsOff = 0x2;
 148     protected static final int ValueTypeArrayFlattenOn = 0x4;
 149     protected static final int ValueTypeArrayFlattenOff = 0x8;


 278     }
 279 
 280     public static void main(String[] args) throws Throwable {
 281         if (args.length != 1) {
 282             throw new RuntimeException("Usage: @run main/othervm/timeout=120 -Xbootclasspath/a:." +
 283                                        " -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions" +
 284                                        " -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI" +
 285                                        " compiler.valhalla.valuetypes.ValueTypeTest <YourTestMainClass>");
 286         }
 287         String testMainClassName = args[0];
 288         Class testMainClass = Class.forName(testMainClassName);
 289         ValueTypeTest test = (ValueTypeTest)testMainClass.newInstance();
 290         List<String> scenarios = null;
 291         if (!SCENARIOS.isEmpty()) {
 292            scenarios = Arrays.asList(SCENARIOS.split(","));
 293         }
 294         for (int i=0; i<test.getNumScenarios(); i++) {
 295             if (scenarios == null || scenarios.contains(Integer.toString(i))) {
 296                 System.out.println("Scenario #" + i + " -------- ");
 297                 String[] cmds = InputArguments.getVmInputArgs();



 298                 cmds = concat(cmds, test.getVMParameters(i));
 299                 cmds = concat(cmds, test.getExtraVMParameters(i));
 300                 cmds = concat(cmds, testMainClassName);
 301 
 302                 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds);
 303                 String output = oa.getOutput();
 304                 oa.shouldHaveExitValue(0);
 305                 System.out.println(output);
 306             } else {
 307                 System.out.println("Scenario #" + i + " is skipped due to -Dscenarios=" + SCENARIOS);
 308             }
 309         }
 310     }
 311 
 312     // To exclude test cases, use -DExclude=<case1>,<case2>,...
 313     // Each case can be just the method name, or can be <class>.<method>. The latter form is useful
 314     // when you are running several tests at the same time.
 315     //
 316     // jtreg -DExclude=test12 TestArrays.java
 317     // jtreg -DExclude=test34 TestLWorld.java


 636         }
 637     }
 638 
 639     // Choose the appropriate compilation level for a method, according to the given annotation.
 640     //
 641     // Currently, if TEST_C1 is true, we always use COMP_LEVEL_SIMPLE. Otherwise, if the
 642     // compLevel is unspecified, the default is COMP_LEVEL_FULL_OPTIMIZATION.
 643     int getCompLevel(Object annotation) {
 644         if (TEST_C1 && !(this instanceof TestCallingConventionC1)) {
 645             return COMP_LEVEL_SIMPLE;
 646         }
 647         int compLevel;
 648         if (annotation == null) {
 649             compLevel = COMP_LEVEL_ANY;
 650         } else if (annotation instanceof Test) {
 651             compLevel = ((Test)annotation).compLevel();
 652         } else {
 653             compLevel = ((ForceCompile)annotation).compLevel();
 654         }
 655         if (compLevel == COMP_LEVEL_ANY) {












 656             compLevel = COMP_LEVEL_FULL_OPTIMIZATION;
 657         }
 658         if (compLevel > (int)TieredStopAtLevel) {
 659             compLevel = (int)TieredStopAtLevel;
 660         }
 661         return compLevel;
 662     }
 663 }


 110 
 111     // Should we execute tests that assume (ValueType[] <: Object[])?
 112     static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance");
 113 
 114     // Random test values
 115     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
 116     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
 117 
 118     // User defined settings
 119     protected static final boolean XCOMP = Platform.isComp();
 120     private static final boolean PRINT_GRAPH = true;
 121     protected static final boolean VERBOSE = Boolean.parseBoolean(System.getProperty("Verbose", "false"));
 122     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
 123     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && !TEST_C1 && !XCOMP;
 124     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
 125     private static final String SCENARIOS = System.getProperty("Scenarios", "");
 126     private static final String TESTLIST = System.getProperty("Testlist", "");
 127     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
 128     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 129     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));
 130     protected static final boolean FLIP_C1_C2 = Boolean.parseBoolean(System.getProperty("FlipC1C2", "false"));
 131 
 132     // "jtreg -DXcomp=true" runs all the scenarios with -Xcomp. This is faster than "jtreg -javaoptions:-Xcomp".
 133     protected static final boolean RUN_SCENARIOS_WITH_XCOMP = Boolean.parseBoolean(System.getProperty("Xcomp", "false"));
 134 
 135     // Pre-defined settings
 136     private static final String[] defaultFlags = {
 137         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 138         "-XX:CompileCommand=quiet",
 139         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 140         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 141         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 142         "-XX:CompileCommand=inline,compiler.valhalla.valuetypes.MyValue*::<init>",
 143         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"};
 144     private static final String[] printFlags = {
 145         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintOptoAssembly"};
 146     private static final String[] verifyFlags = {
 147         "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC",
 148         "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing"};
 149 
 150     protected static final int ValueTypePassFieldsAsArgsOn = 0x1;
 151     protected static final int ValueTypePassFieldsAsArgsOff = 0x2;
 152     protected static final int ValueTypeArrayFlattenOn = 0x4;
 153     protected static final int ValueTypeArrayFlattenOff = 0x8;


 282     }
 283 
 284     public static void main(String[] args) throws Throwable {
 285         if (args.length != 1) {
 286             throw new RuntimeException("Usage: @run main/othervm/timeout=120 -Xbootclasspath/a:." +
 287                                        " -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions" +
 288                                        " -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI" +
 289                                        " compiler.valhalla.valuetypes.ValueTypeTest <YourTestMainClass>");
 290         }
 291         String testMainClassName = args[0];
 292         Class testMainClass = Class.forName(testMainClassName);
 293         ValueTypeTest test = (ValueTypeTest)testMainClass.newInstance();
 294         List<String> scenarios = null;
 295         if (!SCENARIOS.isEmpty()) {
 296            scenarios = Arrays.asList(SCENARIOS.split(","));
 297         }
 298         for (int i=0; i<test.getNumScenarios(); i++) {
 299             if (scenarios == null || scenarios.contains(Integer.toString(i))) {
 300                 System.out.println("Scenario #" + i + " -------- ");
 301                 String[] cmds = InputArguments.getVmInputArgs();
 302                 if (RUN_SCENARIOS_WITH_XCOMP) {
 303                     cmds = concat(cmds, "-Xcomp");
 304                 }
 305                 cmds = concat(cmds, test.getVMParameters(i));
 306                 cmds = concat(cmds, test.getExtraVMParameters(i));
 307                 cmds = concat(cmds, testMainClassName);
 308 
 309                 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds);
 310                 String output = oa.getOutput();
 311                 oa.shouldHaveExitValue(0);
 312                 System.out.println(output);
 313             } else {
 314                 System.out.println("Scenario #" + i + " is skipped due to -Dscenarios=" + SCENARIOS);
 315             }
 316         }
 317     }
 318 
 319     // To exclude test cases, use -DExclude=<case1>,<case2>,...
 320     // Each case can be just the method name, or can be <class>.<method>. The latter form is useful
 321     // when you are running several tests at the same time.
 322     //
 323     // jtreg -DExclude=test12 TestArrays.java
 324     // jtreg -DExclude=test34 TestLWorld.java


 643         }
 644     }
 645 
 646     // Choose the appropriate compilation level for a method, according to the given annotation.
 647     //
 648     // Currently, if TEST_C1 is true, we always use COMP_LEVEL_SIMPLE. Otherwise, if the
 649     // compLevel is unspecified, the default is COMP_LEVEL_FULL_OPTIMIZATION.
 650     int getCompLevel(Object annotation) {
 651         if (TEST_C1 && !(this instanceof TestCallingConventionC1)) {
 652             return COMP_LEVEL_SIMPLE;
 653         }
 654         int compLevel;
 655         if (annotation == null) {
 656             compLevel = COMP_LEVEL_ANY;
 657         } else if (annotation instanceof Test) {
 658             compLevel = ((Test)annotation).compLevel();
 659         } else {
 660             compLevel = ((ForceCompile)annotation).compLevel();
 661         }
 662         if (compLevel == COMP_LEVEL_ANY) {
 663             compLevel = COMP_LEVEL_FULL_OPTIMIZATION;
 664         }
 665         if (FLIP_C1_C2) {
 666             // Effectively treat all (compLevel = C1) as (compLevel = C2), and
 667             //                       (compLevel = C2) as (compLevel = C1).
 668             if (compLevel == COMP_LEVEL_SIMPLE) {
 669                 compLevel = COMP_LEVEL_FULL_OPTIMIZATION;
 670             } else if (compLevel == COMP_LEVEL_FULL_OPTIMIZATION) {
 671                 compLevel = COMP_LEVEL_SIMPLE;
 672             }
 673         }
 674         if (!TEST_C1 && compLevel < COMP_LEVEL_FULL_OPTIMIZATION) {
 675             compLevel = COMP_LEVEL_FULL_OPTIMIZATION;
 676         }
 677         if (compLevel > (int)TieredStopAtLevel) {
 678             compLevel = (int)TieredStopAtLevel;
 679         }
 680         return compLevel;
 681     }
 682 }
< prev index next >