< prev index next >

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

Print this page


  88 @Retention(RetentionPolicy.RUNTIME)
  89 @interface Warmup {
  90     int value();
  91 }
  92 
  93 public abstract class ValueTypeTest {
  94     // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing. This forces all
  95     // compilable methods to be compiled with C1, regardless of the @Test(compLevel=?) setting.
  96     static final boolean TEST_C1 = Boolean.getBoolean("test.c1");
  97 
  98     // Should we execute tests that assume (ValueType[] <: Object[])?
  99     static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance");
 100 
 101     // Random test values
 102     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
 103     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
 104 
 105     // User defined settings
 106     protected static final boolean XCOMP = Platform.isComp();
 107     private static final boolean PRINT_GRAPH = true;

 108     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
 109     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && !TEST_C1 && !XCOMP;
 110     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
 111     private static final String SCENARIOS = System.getProperty("Scenarios", "");
 112     private static final String TESTLIST = System.getProperty("Testlist", "");
 113     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
 114     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 115     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));
 116 
 117     // Pre-defined settings
 118     private static final String[] defaultFlags = {
 119         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 120         "-XX:CompileCommand=quiet",
 121         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 122         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 123         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 124         "-XX:CompileCommand=inline,compiler.valhalla.valuetypes.MyValue*::<init>",
 125         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"};
 126     private static final String[] printFlags = {
 127         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintOptoAssembly"};


 549 
 550         // Compile class initializers
 551         int compLevel = getCompLevel(null);
 552         WHITE_BOX.enqueueInitializerForCompilation(clazz, compLevel);
 553     }
 554 
 555     private void run(Class<?>... classes) throws Exception {
 556         if (USE_COMPILER && PRINT_IDEAL && !XCOMP) {
 557             System.out.println("PrintIdeal enabled");
 558         }
 559         System.out.format("rI = %d, rL = %d\n", rI, rL);
 560 
 561         setup(getClass());
 562         for (Class<?> clazz : classes) {
 563             setup(clazz);
 564         }
 565 
 566         // Execute tests
 567         TreeMap<Long, String> durations = PRINT_TIMES ? new TreeMap<Long, String>() : null;
 568         for (Method test : tests.values()) {



 569             long startTime = System.nanoTime();
 570             Method verifier = getClass().getMethod(test.getName() + "_verifier", boolean.class);
 571             // Warmup using verifier method
 572             Warmup anno = test.getAnnotation(Warmup.class);
 573             int warmup = anno == null ? WARMUP : anno.value();
 574             for (int i = 0; i < warmup; ++i) {
 575                 verifier.invoke(this, true);
 576             }
 577             int compLevel = getCompLevel(test.getAnnotation(Test.class));
 578             // Trigger compilation
 579             WHITE_BOX.enqueueMethodForCompilation(test, compLevel);
 580             Asserts.assertTrue(!USE_COMPILER || WHITE_BOX.isMethodCompiled(test, false), test + " not compiled");
 581             // Check result
 582             verifier.invoke(this, false);
 583             if (PRINT_TIMES) {
 584                 long endTime = System.nanoTime();
 585                 long duration = (endTime - startTime);
 586                 durations.put(duration, test.getName());



 587             }
 588         }
 589 
 590         // Print execution times
 591         if (PRINT_TIMES) {
 592           System.out.println("\n\nTest execution times:");
 593           for (Map.Entry<Long, String> entry : durations.entrySet()) {
 594               System.out.format("%-10s%15d ns\n", entry.getValue() + ":", entry.getKey());
 595           }
 596         }
 597     }
 598 
 599     // Choose the appropriate compilation level for a method, according to the given annotation.
 600     //
 601     // Currently, if TEST_C1 is true, we always use COMP_LEVEL_SIMPLE. Otherwise, if the
 602     // compLevel is unspecified, the default is COMP_LEVEL_FULL_OPTIMIZATION.
 603     int getCompLevel(Object annotation) {
 604         if (TEST_C1) {
 605             return COMP_LEVEL_SIMPLE;
 606         }


  88 @Retention(RetentionPolicy.RUNTIME)
  89 @interface Warmup {
  90     int value();
  91 }
  92 
  93 public abstract class ValueTypeTest {
  94     // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing. This forces all
  95     // compilable methods to be compiled with C1, regardless of the @Test(compLevel=?) setting.
  96     static final boolean TEST_C1 = Boolean.getBoolean("test.c1");
  97 
  98     // Should we execute tests that assume (ValueType[] <: Object[])?
  99     static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance");
 100 
 101     // Random test values
 102     public static final int  rI = Utils.getRandomInstance().nextInt() % 1000;
 103     public static final long rL = Utils.getRandomInstance().nextLong() % 1000;
 104 
 105     // User defined settings
 106     protected static final boolean XCOMP = Platform.isComp();
 107     private static final boolean PRINT_GRAPH = true;
 108     private static final boolean VERBOSE = Boolean.parseBoolean(System.getProperty("Verbose", "false"));
 109     private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false"));
 110     private static       boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && !TEST_C1 && !XCOMP;
 111     private static final boolean VERIFY_VM = Boolean.parseBoolean(System.getProperty("VerifyVM", "false"));
 112     private static final String SCENARIOS = System.getProperty("Scenarios", "");
 113     private static final String TESTLIST = System.getProperty("Testlist", "");
 114     private static final String EXCLUDELIST = System.getProperty("Exclude", "");
 115     private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251"));
 116     private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false"));
 117 
 118     // Pre-defined settings
 119     private static final String[] defaultFlags = {
 120         "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1",
 121         "-XX:CompileCommand=quiet",
 122         "-XX:CompileCommand=compileonly,java.lang.invoke.*::*",
 123         "-XX:CompileCommand=compileonly,java.lang.Long::sum",
 124         "-XX:CompileCommand=compileonly,java.lang.Object::<init>",
 125         "-XX:CompileCommand=inline,compiler.valhalla.valuetypes.MyValue*::<init>",
 126         "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"};
 127     private static final String[] printFlags = {
 128         "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintOptoAssembly"};


 550 
 551         // Compile class initializers
 552         int compLevel = getCompLevel(null);
 553         WHITE_BOX.enqueueInitializerForCompilation(clazz, compLevel);
 554     }
 555 
 556     private void run(Class<?>... classes) throws Exception {
 557         if (USE_COMPILER && PRINT_IDEAL && !XCOMP) {
 558             System.out.println("PrintIdeal enabled");
 559         }
 560         System.out.format("rI = %d, rL = %d\n", rI, rL);
 561 
 562         setup(getClass());
 563         for (Class<?> clazz : classes) {
 564             setup(clazz);
 565         }
 566 
 567         // Execute tests
 568         TreeMap<Long, String> durations = PRINT_TIMES ? new TreeMap<Long, String>() : null;
 569         for (Method test : tests.values()) {
 570             if (VERBOSE) {
 571                 System.out.println("Starting " + test.getName());
 572             }
 573             long startTime = System.nanoTime();
 574             Method verifier = getClass().getMethod(test.getName() + "_verifier", boolean.class);
 575             // Warmup using verifier method
 576             Warmup anno = test.getAnnotation(Warmup.class);
 577             int warmup = anno == null ? WARMUP : anno.value();
 578             for (int i = 0; i < warmup; ++i) {
 579                 verifier.invoke(this, true);
 580             }
 581             int compLevel = getCompLevel(test.getAnnotation(Test.class));
 582             // Trigger compilation
 583             WHITE_BOX.enqueueMethodForCompilation(test, compLevel);
 584             Asserts.assertTrue(!USE_COMPILER || WHITE_BOX.isMethodCompiled(test, false), test + " not compiled");
 585             // Check result
 586             verifier.invoke(this, false);
 587             if (PRINT_TIMES || VERBOSE) {
 588                 long endTime = System.nanoTime();
 589                 long duration = (endTime - startTime);
 590                 durations.put(duration, test.getName());
 591                 if (VERBOSE) {
 592                     System.out.println("Done " + test.getName() + ": " + duration + "ms");
 593                 }
 594             }
 595         }
 596 
 597         // Print execution times
 598         if (PRINT_TIMES) {
 599           System.out.println("\n\nTest execution times:");
 600           for (Map.Entry<Long, String> entry : durations.entrySet()) {
 601               System.out.format("%-10s%15d ns\n", entry.getValue() + ":", entry.getKey());
 602           }
 603         }
 604     }
 605 
 606     // Choose the appropriate compilation level for a method, according to the given annotation.
 607     //
 608     // Currently, if TEST_C1 is true, we always use COMP_LEVEL_SIMPLE. Otherwise, if the
 609     // compLevel is unspecified, the default is COMP_LEVEL_FULL_OPTIMIZATION.
 610     int getCompLevel(Object annotation) {
 611         if (TEST_C1) {
 612             return COMP_LEVEL_SIMPLE;
 613         }
< prev index next >