test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
changeset 59063 058d299b22b6
parent 54119 6bf8877eb1b9
equal deleted inserted replaced
59062:6530de931b8e 59063:058d299b22b6
    25  * @test
    25  * @test
    26  * @bug 8220374
    26  * @bug 8220374
    27  * @summary C2: LoopStripMining doesn't strip as expected
    27  * @summary C2: LoopStripMining doesn't strip as expected
    28  * @requires vm.compiler2.enabled
    28  * @requires vm.compiler2.enabled
    29  *
    29  *
    30  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+SafepointTimeout -XX:+SafepointALot
    30  * @library /test/lib
    31  *                   -XX:+AbortVMOnSafepointTimeout -XX:SafepointTimeoutDelay=500 -XX:GuaranteedSafepointInterval=500
    31  * @run driver compiler.loopstripmining.CheckLoopStripMining
    32  *                   -XX:-TieredCompilation -XX:+UseCountedLoopSafepoints -XX:LoopStripMiningIter=1000
       
    33  *                   -XX:LoopUnrollLimit=0 -XX:CompileCommand=compileonly,CheckLoopStripMining::test_loop -Xcomp CheckLoopStripMining
       
    34  *
       
    35  */
    32  */
    36 
    33 
       
    34 package compiler.loopstripmining;
       
    35 
       
    36 import jdk.test.lib.Utils;
       
    37 import jdk.test.lib.process.ProcessTools;
       
    38 
    37 public class CheckLoopStripMining {
    39 public class CheckLoopStripMining {
       
    40   public static void main(String args[]) throws Exception {
       
    41     ProcessTools.executeTestJvm(
       
    42         "-XX:+UnlockDiagnosticVMOptions",
       
    43         // to prevent biased locking handshakes from changing the timing of this test
       
    44         "-XX:-UseBiasedLocking",
       
    45         "-XX:+SafepointTimeout",
       
    46         "-XX:+SafepointALot",
       
    47         "-XX:+AbortVMOnSafepointTimeout",
       
    48         "-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(500),
       
    49         "-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(500),
       
    50         "-XX:-TieredCompilation",
       
    51         "-XX:+UseCountedLoopSafepoints",
       
    52         "-XX:LoopStripMiningIter=1000",
       
    53         "-XX:LoopUnrollLimit=0",
       
    54         "-XX:CompileCommand=compileonly,compiler.loopstripmining.CheckLoopStripMining$Test::test_loop",
       
    55         "-Xcomp",
       
    56         Test.class.getName()).shouldHaveExitValue(0)
       
    57                              .stdoutShouldContain("sum: 715827882");
       
    58   }
    38 
    59 
    39   public static int test_loop(int x) {
    60   public static class Test {
       
    61     public static int test_loop(int x) {
    40       int sum = 0;
    62       int sum = 0;
    41       if (x != 0) {
    63       if (x != 0) {
    42           for (int y = 1; y < Integer.MAX_VALUE; ++y) {
    64           for (int y = 1; y < Integer.MAX_VALUE; ++y) {
    43               if (y % x == 0) ++sum;
    65               if (y % x == 0) ++sum;
    44           }
    66           }
    45       }
    67       }
    46       return sum;
    68       return sum;
    47   }
    69     }
    48 
    70 
    49   public static void main(String args[]) {
    71     public static void main(String args[]) {
    50     int sum = test_loop(3);
    72       int sum = test_loop(3);
    51     System.out.println("sum: " + sum);
    73       System.out.println("sum: " + sum);
       
    74     }
    52   }
    75   }
    53 }
    76 }