< prev index next >

test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java

Print this page




  44 import java.util.List;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collections;
  48 import jdk.test.lib.Asserts;
  49 
  50 /* Idea of this test is to check if ideal graph has CountedLoopEnd->SafePoint edge in case
  51    of UseCountedLoopSafepoint enabled and has no such edge in case it's disabled. Restricting
  52    compilation to testMethod only will leave only one counted loop (the one in testedMethod) */
  53 public class UseCountedLoopSafepointsTest {
  54 
  55     public static void main (String args[]) {
  56         check(true); // check ideal graph with UseCountedLoopSafepoint enabled
  57         check(false); // ... and disabled
  58     }
  59 
  60     private static void check(boolean enabled) {
  61         OutputAnalyzer oa;
  62         try {
  63             oa = ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.",
  64                     "-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints", "-XX:+WhiteBoxAPI",

  65                     "-XX:-Inline", "-Xbatch", "-XX:+PrintIdeal", "-XX:LoopUnrollLimit=0",
  66                     "-XX:CompileOnly=" + UseCountedLoopSafepoints.class.getName() + "::testMethod",
  67                     UseCountedLoopSafepoints.class.getName());
  68         } catch (Exception e) {
  69             throw new Error("Exception launching child for case enabled=" + enabled + " : " + e, e);
  70         }
  71         oa.shouldHaveExitValue(0);
  72         // parse output in seach of SafePoint and CountedLoopEnd nodes
  73         List<Node> safePoints = new ArrayList<>();
  74         List<Node> loopEnds = new ArrayList<>();
  75         for (String line : oa.getOutput().split("\\n")) {
  76             int separatorIndex = line.indexOf("\t===");
  77             if (separatorIndex > -1) {
  78                 String header = line.substring(0, separatorIndex);
  79                 if (header.endsWith("\tSafePoint")) {
  80                     safePoints.add(new Node("SafePoint", line));
  81                 } else if (header.endsWith("\tCountedLoopEnd")) {
  82                     loopEnds.add(new Node("CountedLoopEnd", line));
  83                 }
  84             }




  44 import java.util.List;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.Collections;
  48 import jdk.test.lib.Asserts;
  49 
  50 /* Idea of this test is to check if ideal graph has CountedLoopEnd->SafePoint edge in case
  51    of UseCountedLoopSafepoint enabled and has no such edge in case it's disabled. Restricting
  52    compilation to testMethod only will leave only one counted loop (the one in testedMethod) */
  53 public class UseCountedLoopSafepointsTest {
  54 
  55     public static void main (String args[]) {
  56         check(true); // check ideal graph with UseCountedLoopSafepoint enabled
  57         check(false); // ... and disabled
  58     }
  59 
  60     private static void check(boolean enabled) {
  61         OutputAnalyzer oa;
  62         try {
  63             oa = ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.",
  64                                              "-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints",
  65                                              "-XX:LoopStripMiningIter=" + (enabled ? "1" : "0"), "-XX:+WhiteBoxAPI",
  66                     "-XX:-Inline", "-Xbatch", "-XX:+PrintIdeal", "-XX:LoopUnrollLimit=0",
  67                     "-XX:CompileOnly=" + UseCountedLoopSafepoints.class.getName() + "::testMethod",
  68                     UseCountedLoopSafepoints.class.getName());
  69         } catch (Exception e) {
  70             throw new Error("Exception launching child for case enabled=" + enabled + " : " + e, e);
  71         }
  72         oa.shouldHaveExitValue(0);
  73         // parse output in seach of SafePoint and CountedLoopEnd nodes
  74         List<Node> safePoints = new ArrayList<>();
  75         List<Node> loopEnds = new ArrayList<>();
  76         for (String line : oa.getOutput().split("\\n")) {
  77             int separatorIndex = line.indexOf("\t===");
  78             if (separatorIndex > -1) {
  79                 String header = line.substring(0, separatorIndex);
  80                 if (header.endsWith("\tSafePoint")) {
  81                     safePoints.add(new Node("SafePoint", line));
  82                 } else if (header.endsWith("\tCountedLoopEnd")) {
  83                     loopEnds.add(new Node("CountedLoopEnd", line));
  84                 }
  85             }


< prev index next >