Mercurial > hg > graal-compiler
comparison test/gc/arguments/TestMaxHeapSizeTools.java @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 6827d470020d |
children |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
39 final class MinInitialMaxValues { | 39 final class MinInitialMaxValues { |
40 public long minHeapSize; | 40 public long minHeapSize; |
41 public long initialHeapSize; | 41 public long initialHeapSize; |
42 public long maxHeapSize; | 42 public long maxHeapSize; |
43 | 43 |
44 public long spaceAlignment; | 44 public long minAlignment; |
45 public long heapAlignment; | 45 public long maxAlignment; |
46 } | 46 } |
47 | 47 |
48 class TestMaxHeapSizeTools { | 48 class TestMaxHeapSizeTools { |
49 | 49 |
50 public static void checkMinInitialMaxHeapFlags(String gcflag) throws Exception { | 50 public static void checkMinInitialMaxHeapFlags(String gcflag) throws Exception { |
190 // | 190 // |
191 // where A, B, X, Y and Z are sizes in bytes. | 191 // where A, B, X, Y and Z are sizes in bytes. |
192 // Unfortunately there is no other way to retrieve the minimum heap size and | 192 // Unfortunately there is no other way to retrieve the minimum heap size and |
193 // the alignments. | 193 // the alignments. |
194 | 194 |
195 Matcher m = Pattern.compile("Minimum heap \\d+ Initial heap \\d+ Maximum heap \\d+ Space alignment \\d+ Heap alignment \\d+"). | 195 Matcher m = Pattern.compile("Minimum heap \\d+ Initial heap \\d+ Maximum heap \\d+ Min alignment \\d+ Max alignment \\d+"). |
196 matcher(output.getStdout()); | 196 matcher(output.getStdout()); |
197 if (!m.find()) { | 197 if (!m.find()) { |
198 throw new RuntimeException("Could not find heap size string."); | 198 throw new RuntimeException("Could not find heap size string."); |
199 } | 199 } |
200 | 200 |
202 | 202 |
203 // actual values | 203 // actual values |
204 val.minHeapSize = valueAfter(match, "Minimum heap "); | 204 val.minHeapSize = valueAfter(match, "Minimum heap "); |
205 val.initialHeapSize = valueAfter(match, "Initial heap "); | 205 val.initialHeapSize = valueAfter(match, "Initial heap "); |
206 val.maxHeapSize = valueAfter(match, "Maximum heap "); | 206 val.maxHeapSize = valueAfter(match, "Maximum heap "); |
207 val.spaceAlignment = valueAfter(match, "Space alignment "); | 207 val.minAlignment = valueAfter(match, "Min alignment "); |
208 val.heapAlignment = valueAfter(match, "Heap alignment "); | 208 val.maxAlignment = valueAfter(match, "Max alignment "); |
209 } | 209 } |
210 | 210 |
211 /** | 211 /** |
212 * Verify whether the VM automatically synchronizes minimum and initial heap size if only | 212 * Verify whether the VM automatically synchronizes minimum and initial heap size if only |
213 * one is given for the GC specified. | 213 * one is given for the GC specified. |
216 long expectedMin, long expectedInitial) throws Exception { | 216 long expectedMin, long expectedInitial) throws Exception { |
217 | 217 |
218 MinInitialMaxValues v = new MinInitialMaxValues(); | 218 MinInitialMaxValues v = new MinInitialMaxValues(); |
219 getMinInitialMaxHeap(args, v); | 219 getMinInitialMaxHeap(args, v); |
220 | 220 |
221 if ((expectedMin != -1) && (align_up(expectedMin, v.heapAlignment) != v.minHeapSize)) { | 221 if ((expectedMin != -1) && (align_up(expectedMin, v.minAlignment) != v.minHeapSize)) { |
222 throw new RuntimeException("Actual minimum heap size of " + v.minHeapSize + | 222 throw new RuntimeException("Actual minimum heap size of " + v.minHeapSize + |
223 " differs from expected minimum heap size of " + expectedMin); | 223 " differs from expected minimum heap size of " + expectedMin); |
224 } | 224 } |
225 | 225 |
226 if ((expectedInitial != -1) && (align_up(expectedInitial, v.heapAlignment) != v.initialHeapSize)) { | 226 if ((expectedInitial != -1) && (align_up(expectedInitial, v.minAlignment) != v.initialHeapSize)) { |
227 throw new RuntimeException("Actual initial heap size of " + v.initialHeapSize + | 227 throw new RuntimeException("Actual initial heap size of " + v.initialHeapSize + |
228 " differs from expected initial heap size of " + expectedInitial); | 228 " differs from expected initial heap size of " + expectedInitial); |
229 } | 229 } |
230 | 230 |
231 // always check the invariant min <= initial <= max heap size | 231 // always check the invariant min <= initial <= max heap size |
245 final long K = 1024; | 245 final long K = 1024; |
246 | 246 |
247 MinInitialMaxValues v = new MinInitialMaxValues(); | 247 MinInitialMaxValues v = new MinInitialMaxValues(); |
248 getMinInitialMaxHeap(new String[] { gcflag, "-XX:MaxHeapSize=" + maxHeapsize + "M" }, v); | 248 getMinInitialMaxHeap(new String[] { gcflag, "-XX:MaxHeapSize=" + maxHeapsize + "M" }, v); |
249 | 249 |
250 long expectedHeapSize = align_up(maxHeapsize * K * K, v.heapAlignment); | 250 long expectedHeapSize = align_up(maxHeapsize * K * K, v.maxAlignment); |
251 long actualHeapSize = v.maxHeapSize; | 251 long actualHeapSize = v.maxHeapSize; |
252 | 252 |
253 if (actualHeapSize > expectedHeapSize) { | 253 if (actualHeapSize > expectedHeapSize) { |
254 throw new RuntimeException("Heap has " + actualHeapSize + | 254 throw new RuntimeException("Heap has " + actualHeapSize + |
255 " bytes, expected to be less than " + expectedHeapSize); | 255 " bytes, expected to be less than " + expectedHeapSize); |