--- a/hotspot/test/compiler/codecache/jmx/CodeCacheUtils.java Thu Aug 18 14:07:00 2016 +0300
+++ b/hotspot/test/compiler/codecache/jmx/CodeCacheUtils.java Thu Aug 18 11:11:40 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -119,6 +119,28 @@
}
}
+ /**
+ * Verifies that 'newValue' is equal to 'oldValue' if usage of the
+ * corresponding code heap is predictable. Checks the weaker condition
+ * 'newValue <= oldValue' if usage is not predictable because intermediate
+ * allocations may happen.
+ *
+ * @param btype BlobType of the code heap to be checked
+ * @param newValue New value to be verified
+ * @param oldValue Old value to be verified
+ * @param msg Error message if verification fails
+ */
+ public static void assertEQorLTE(BlobType btype, long newValue, long oldValue, String msg) {
+ if (CodeCacheUtils.isCodeHeapPredictable(btype)) {
+ // Usage is predictable, check strong == condition
+ Asserts.assertEQ(newValue, oldValue, msg);
+ } else {
+ // Usage is not predictable, check weaker <= condition
+ Asserts.assertLTE(newValue, oldValue, msg);
+ }
+ }
+
+
public static void disableCollectionUsageThresholds() {
BlobType.getAvailable().stream()
.map(BlobType::getMemoryPool)
--- a/hotspot/test/compiler/codecache/jmx/PeakUsageTest.java Thu Aug 18 14:07:00 2016 +0300
+++ b/hotspot/test/compiler/codecache/jmx/PeakUsageTest.java Thu Aug 18 11:11:40 2016 +0000
@@ -27,7 +27,6 @@
* @modules java.base/jdk.internal.misc
* java.management
*
- * @ignore 8151345
* @build ompiler.codecache.jmx.PeakUsageTest
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -69,9 +68,17 @@
bean.resetPeakUsage();
long addr = CodeCacheUtils.WB.allocateCodeBlob(
CodeCacheUtils.ALLOCATION_SIZE, btype.id);
- long newPeakUsage = bean.getPeakUsage().getUsed();
+
try {
- CodeCacheUtils.assertEQorGTE(btype, newPeakUsage, bean.getUsage().getUsed(),
+ /*
+ Always save peakUsage after saving currentUsage. Reversing the order
+ can lead to inconsistent results (currentUsage > peakUsage) because
+ of intermediate allocations.
+ */
+ long currUsage = bean.getUsage().getUsed();
+ long peakUsage = bean.getPeakUsage().getUsed();
+ CodeCacheUtils.assertEQorLTE(btype, currUsage,
+ peakUsage,
"Peak usage does not match usage after allocation for "
+ bean.getName());
} finally {
@@ -79,19 +86,21 @@
CodeCacheUtils.WB.freeCodeBlob(addr);
}
}
- CodeCacheUtils.assertEQorGTE(btype, newPeakUsage, bean.getPeakUsage().getUsed(),
- "Code cache peak usage has changed after usage decreased for "
- + bean.getName());
bean.resetPeakUsage();
- CodeCacheUtils.assertEQorGTE(btype, bean.getPeakUsage().getUsed(),
- bean.getUsage().getUsed(),
+ long currUsage = bean.getUsage().getUsed();
+ long peakUsage = bean.getPeakUsage().getUsed();
+ CodeCacheUtils.assertEQorLTE(btype, currUsage,
+ peakUsage,
"Code cache peak usage is not equal to usage after reset for "
+ bean.getName());
long addr2 = CodeCacheUtils.WB.allocateCodeBlob(
CodeCacheUtils.ALLOCATION_SIZE, btype.id);
try {
- CodeCacheUtils.assertEQorGTE(btype, bean.getPeakUsage().getUsed(),
- bean.getUsage().getUsed(),
+ currUsage = bean.getUsage().getUsed();
+ peakUsage = bean.getPeakUsage().getUsed();
+
+ CodeCacheUtils.assertEQorLTE(btype, currUsage,
+ peakUsage,
"Code cache peak usage is not equal to usage after fresh "
+ "allocation for " + bean.getName());
} finally {