8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
authoriignatyev
Wed, 13 Nov 2019 10:59:25 -0800
changeset 59063 058d299b22b6
parent 59062 6530de931b8e
child 59064 f1a5d48d0471
8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay Reviewed-by: kvn, epavlova, roland, mdoerr
test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
--- a/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java	Wed Nov 13 10:51:41 2019 -0800
+++ b/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java	Wed Nov 13 10:59:25 2019 -0800
@@ -27,16 +27,38 @@
  * @summary C2: LoopStripMining doesn't strip as expected
  * @requires vm.compiler2.enabled
  *
- * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+SafepointTimeout -XX:+SafepointALot
- *                   -XX:+AbortVMOnSafepointTimeout -XX:SafepointTimeoutDelay=500 -XX:GuaranteedSafepointInterval=500
- *                   -XX:-TieredCompilation -XX:+UseCountedLoopSafepoints -XX:LoopStripMiningIter=1000
- *                   -XX:LoopUnrollLimit=0 -XX:CompileCommand=compileonly,CheckLoopStripMining::test_loop -Xcomp CheckLoopStripMining
- *
+ * @library /test/lib
+ * @run driver compiler.loopstripmining.CheckLoopStripMining
  */
 
-public class CheckLoopStripMining {
+package compiler.loopstripmining;
+
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.ProcessTools;
 
-  public static int test_loop(int x) {
+public class CheckLoopStripMining {
+  public static void main(String args[]) throws Exception {
+    ProcessTools.executeTestJvm(
+        "-XX:+UnlockDiagnosticVMOptions",
+        // to prevent biased locking handshakes from changing the timing of this test
+        "-XX:-UseBiasedLocking",
+        "-XX:+SafepointTimeout",
+        "-XX:+SafepointALot",
+        "-XX:+AbortVMOnSafepointTimeout",
+        "-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(500),
+        "-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(500),
+        "-XX:-TieredCompilation",
+        "-XX:+UseCountedLoopSafepoints",
+        "-XX:LoopStripMiningIter=1000",
+        "-XX:LoopUnrollLimit=0",
+        "-XX:CompileCommand=compileonly,compiler.loopstripmining.CheckLoopStripMining$Test::test_loop",
+        "-Xcomp",
+        Test.class.getName()).shouldHaveExitValue(0)
+                             .stdoutShouldContain("sum: 715827882");
+  }
+
+  public static class Test {
+    public static int test_loop(int x) {
       int sum = 0;
       if (x != 0) {
           for (int y = 1; y < Integer.MAX_VALUE; ++y) {
@@ -44,10 +66,11 @@
           }
       }
       return sum;
-  }
+    }
 
-  public static void main(String args[]) {
-    int sum = test_loop(3);
-    System.out.println("sum: " + sum);
+    public static void main(String args[]) {
+      int sum = test_loop(3);
+      System.out.println("sum: " + sum);
+    }
   }
 }