test/gc/arguments/TestMaxHeapSizeTools.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff test/gc/arguments

test/gc/arguments/TestMaxHeapSizeTools.java

Print this page




  47 
  48 class TestMaxHeapSizeTools {
  49 
  50   public static void checkMinInitialMaxHeapFlags(String gcflag) throws Exception {
  51     checkInvalidMinInitialHeapCombinations(gcflag);
  52     checkValidMinInitialHeapCombinations(gcflag);
  53     checkInvalidInitialMaxHeapCombinations(gcflag);
  54     checkValidInitialMaxHeapCombinations(gcflag);
  55   }
  56 
  57   public static void checkMinInitialErgonomics(String gcflag) throws Exception {
  58     // heap sizing ergonomics use the value NewSize + OldSize as default values
  59     // for ergonomics calculation. Retrieve these values.
  60     long[] values = new long[2];
  61     getNewOldSize(gcflag, values);
  62 
  63     // we check cases with values smaller and larger than this default value.
  64     long newPlusOldSize = values[0] + values[1];
  65     long smallValue = newPlusOldSize / 2;
  66     long largeValue = newPlusOldSize * 2;

  67 
  68     // -Xms is not set
  69     checkErgonomics(new String[] { gcflag, "-Xmx16M" }, values, -1, -1);
  70     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  71     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-XX:InitialHeapSize=" + largeValue }, values, -1, largeValue);
  72     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-XX:InitialHeapSize=0" }, values, -1, -1);
  73 
  74     // -Xms is set to zero
  75     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms0" }, values, -1, -1);
  76     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms0", "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  77     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms0", "-XX:InitialHeapSize=" + largeValue }, values, -1, largeValue);
  78     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms0", "-XX:InitialHeapSize=0" }, values, -1, -1);
  79 
  80     // -Xms is set to small value
  81     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + smallValue }, values, -1, -1);
  82     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + smallValue, "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  83     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + smallValue, "-XX:InitialHeapSize=" + largeValue }, values, smallValue, largeValue);
  84     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + smallValue, "-XX:InitialHeapSize=0" }, values, smallValue, -1);
  85 
  86     // -Xms is set to large value
  87     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + largeValue }, values, largeValue, largeValue);
  88     // the next case has already been checked elsewhere and gives an error
  89     // checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + largeValue, "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  90     // the next case has already been checked elsewhere too
  91     // checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + largeValue, "-XX:InitialHeapSize=" + largeValue }, values, values[0], largeValue);
  92     checkErgonomics(new String[] { gcflag, "-Xmx16M", "-Xms" + largeValue, "-XX:InitialHeapSize=0" }, values, largeValue, -1);
  93   }
  94 
  95   private static long align_up(long value, long alignment) {
  96     long alignmentMinusOne = alignment - 1;
  97     return (value + alignmentMinusOne) & ~alignmentMinusOne;
  98   }
  99 
 100   private static void getNewOldSize(String gcflag, long[] values) throws Exception {
 101     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag,
 102       "-XX:+PrintFlagsFinal", "-version");
 103     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 104     output.shouldHaveExitValue(0);
 105 
 106     String stdout = output.getStdout();
 107     values[0] = getFlagValue(" NewSize", stdout);
 108     values[1] = getFlagValue(" OldSize", stdout);
 109   }
 110 
 111   public static void checkGenMaxHeapErgo(String gcflag) throws Exception {
 112     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 3);




  47 
  48 class TestMaxHeapSizeTools {
  49 
  50   public static void checkMinInitialMaxHeapFlags(String gcflag) throws Exception {
  51     checkInvalidMinInitialHeapCombinations(gcflag);
  52     checkValidMinInitialHeapCombinations(gcflag);
  53     checkInvalidInitialMaxHeapCombinations(gcflag);
  54     checkValidInitialMaxHeapCombinations(gcflag);
  55   }
  56 
  57   public static void checkMinInitialErgonomics(String gcflag) throws Exception {
  58     // heap sizing ergonomics use the value NewSize + OldSize as default values
  59     // for ergonomics calculation. Retrieve these values.
  60     long[] values = new long[2];
  61     getNewOldSize(gcflag, values);
  62 
  63     // we check cases with values smaller and larger than this default value.
  64     long newPlusOldSize = values[0] + values[1];
  65     long smallValue = newPlusOldSize / 2;
  66     long largeValue = newPlusOldSize * 2;
  67     long maxHeapSize = largeValue + (2 * 1024 * 1024);
  68 
  69     // -Xms is not set
  70     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize }, values, -1, -1);
  71     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-XX:InitialHeapSize=" + smallValue }, values, -1, smallValue);
  72     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-XX:InitialHeapSize=" + largeValue }, values, -1, largeValue);
  73     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-XX:InitialHeapSize=0" }, values, -1, -1);
  74 
  75     // -Xms is set to zero
  76     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms0" }, values, -1, -1);
  77     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms0", "-XX:InitialHeapSize=" + smallValue }, values, -1, smallValue);
  78     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms0", "-XX:InitialHeapSize=" + largeValue }, values, -1, largeValue);
  79     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms0", "-XX:InitialHeapSize=0" }, values, -1, -1);
  80 
  81     // -Xms is set to small value
  82     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + smallValue }, values, -1, -1);
  83     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + smallValue, "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  84     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + smallValue, "-XX:InitialHeapSize=" + largeValue }, values, smallValue, largeValue);
  85     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + smallValue, "-XX:InitialHeapSize=0" }, values, smallValue, -1);
  86 
  87     // -Xms is set to large value
  88     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + largeValue }, values, largeValue, largeValue);
  89     // the next case has already been checked elsewhere and gives an error
  90     // checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + largeValue, "-XX:InitialHeapSize=" + smallValue }, values, smallValue, smallValue);
  91     // the next case has already been checked elsewhere too
  92     // checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + largeValue, "-XX:InitialHeapSize=" + largeValue }, values, values[0], largeValue);
  93     checkErgonomics(new String[] { gcflag, "-Xmx" + maxHeapSize, "-Xms" + largeValue, "-XX:InitialHeapSize=0" }, values, largeValue, -1);
  94   }
  95 
  96   private static long align_up(long value, long alignment) {
  97     long alignmentMinusOne = alignment - 1;
  98     return (value + alignmentMinusOne) & ~alignmentMinusOne;
  99   }
 100 
 101   private static void getNewOldSize(String gcflag, long[] values) throws Exception {
 102     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(gcflag,
 103       "-XX:+PrintFlagsFinal", "-version");
 104     OutputAnalyzer output = new OutputAnalyzer(pb.start());
 105     output.shouldHaveExitValue(0);
 106 
 107     String stdout = output.getStdout();
 108     values[0] = getFlagValue(" NewSize", stdout);
 109     values[1] = getFlagValue(" OldSize", stdout);
 110   }
 111 
 112   public static void checkGenMaxHeapErgo(String gcflag) throws Exception {
 113     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 3);


test/gc/arguments/TestMaxHeapSizeTools.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File