8160083: compiler.codecache.jmx.InitialAndMaxUsageTest can not be used w/ disabled SegmentedCodeCache
Reviewed-by: kvn
--- a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java Mon Aug 08 17:06:21 2016 +0200
+++ b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java Tue Aug 09 14:16:44 2016 +0300
@@ -36,6 +36,11 @@
* -XX:CompileCommand=compileonly,null::* -XX:-UseLargePages
* -XX:+SegmentedCodeCache
* compiler.codecache.jmx.InitialAndMaxUsageTest
+ * @run main/othervm -Xbootclasspath/a:. -XX:-UseCodeCacheFlushing
+ * -XX:-MethodFlushing -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:CompileCommand=compileonly,null::* -XX:-UseLargePages
+ * -XX:-SegmentedCodeCache
+ * compiler.codecache.jmx.InitialAndMaxUsageTest
*/
package compiler.codecache.jmx;
@@ -70,10 +75,16 @@
}
}
- private void fillWithSize(long size, List<Long> blobs) {
+ private void fillWithSize(long size, List<Long> blobs, MemoryPoolMXBean bean) {
long blob;
- while ((blob = CodeCacheUtils.WB.allocateCodeBlob(size, btype.id))
- != 0L) {
+ /* Don't fill too much to have space for adapters. So, stop after crossing 95% and
+ don't allocate in case we'll cross 97% on next allocation. We can hit situation
+ like 94% -> (1 allocation) -> 100% otherwise. So, check if
+ <Usage + allocatedSize> is less than 97%, then allocate in case it is, then, stop
+ further allocations with given size in case <Usage> more than 95% */
+ while (((double) bean.getUsage().getUsed() + size <= (CACHE_USAGE_COEF + 0.02d) * maxSize)
+ && (blob = CodeCacheUtils.WB.allocateCodeBlob(size, btype.id)) != 0L
+ && ((double) bean.getUsage().getUsed() <= CACHE_USAGE_COEF * maxSize)) {
blobs.add(blob);
}
}
@@ -96,7 +107,7 @@
optimization */
try {
for (int coef = 1000000; coef > 0; coef /= 10) {
- fillWithSize(coef * minAllocationUnit, blobs);
+ fillWithSize(coef * minAllocationUnit, blobs, bean);
}
Asserts.assertGT((double) bean.getUsage().getUsed(),
CACHE_USAGE_COEF * maxSize, String.format("Unable to fill "