提交 d7f7ae46 编写于 作者: D dsamersoff

Merge

/*
* 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 @@ public final class CodeCacheUtils {
}
}
/**
* 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)
......
......@@ -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 @@ public class PeakUsageTest {
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 @@ public class PeakUsageTest {
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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册