33 * @build UsageThresholdNotExceededTest 34 * @run main ClassFileInstaller sun.hotspot.WhiteBox 35 * sun.hotspot.WhiteBox$WhiteBoxPermission 36 * @run main/othervm -Xbootclasspath/a:. -XX:-UseCodeCacheFlushing 37 * -XX:-MethodFlushing -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 38 * -XX:+SegmentedCodeCache -XX:CompileCommand=compileonly,null::* 39 * UsageThresholdNotExceededTest 40 * @summary verifying that usage threshold not exceeded while allocating less 41 * than usage threshold 42 */ 43 public class UsageThresholdNotExceededTest { 44 45 private final BlobType btype; 46 47 public UsageThresholdNotExceededTest(BlobType btype) { 48 this.btype = btype; 49 } 50 51 public static void main(String[] args) { 52 for (BlobType btype : BlobType.getAvailable()) { 53 if (CodeCacheUtils.isCodeHeapPredictable(btype)) { 54 new UsageThresholdNotExceededTest(btype).runTest(); 55 } 56 } 57 } 58 59 protected void runTest() { 60 MemoryPoolMXBean bean = btype.getMemoryPool(); 61 long initialThresholdCount = bean.getUsageThresholdCount(); 62 long initialUsage = bean.getUsage().getUsed(); 63 bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION); 64 CodeCacheUtils.WB.allocateCodeBlob(CodeCacheUtils.MIN_ALLOCATION 65 - CodeCacheUtils.getHeaderSize(btype), btype.id); 66 // a gc cycle triggers usage threshold recalculation 67 CodeCacheUtils.WB.fullGC(); 68 Asserts.assertEQ(bean.getUsageThresholdCount(), initialThresholdCount, 69 String.format("Usage threshold was hit: %d times for %s. " 70 + "Threshold value: %d with current usage: %d", 71 bean.getUsageThresholdCount(), bean.getName(), 72 bean.getUsageThreshold(), bean.getUsage().getUsed())); 73 74 System.out.println("INFO: Case finished successfully for " 75 + bean.getName()); 76 } 77 } | 33 * @build UsageThresholdNotExceededTest 34 * @run main ClassFileInstaller sun.hotspot.WhiteBox 35 * sun.hotspot.WhiteBox$WhiteBoxPermission 36 * @run main/othervm -Xbootclasspath/a:. -XX:-UseCodeCacheFlushing 37 * -XX:-MethodFlushing -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 38 * -XX:+SegmentedCodeCache -XX:CompileCommand=compileonly,null::* 39 * UsageThresholdNotExceededTest 40 * @summary verifying that usage threshold not exceeded while allocating less 41 * than usage threshold 42 */ 43 public class UsageThresholdNotExceededTest { 44 45 private final BlobType btype; 46 47 public UsageThresholdNotExceededTest(BlobType btype) { 48 this.btype = btype; 49 } 50 51 public static void main(String[] args) { 52 for (BlobType btype : BlobType.getAvailable()) { 53 new UsageThresholdNotExceededTest(btype).runTest(); 54 } 55 } 56 57 protected void runTest() { 58 MemoryPoolMXBean bean = btype.getMemoryPool(); 59 long initialThresholdCount = bean.getUsageThresholdCount(); 60 long initialUsage = bean.getUsage().getUsed(); 61 bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION); 62 CodeCacheUtils.WB.allocateCodeBlob(CodeCacheUtils.MIN_ALLOCATION 63 - CodeCacheUtils.getHeaderSize(btype), btype.id); 64 // a gc cycle triggers usage threshold recalculation 65 CodeCacheUtils.WB.fullGC(); 66 CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), initialThresholdCount, 67 String.format("Usage threshold was hit: %d times for %s. " 68 + "Threshold value: %d with current usage: %d", 69 bean.getUsageThresholdCount(), bean.getName(), 70 bean.getUsageThreshold(), bean.getUsage().getUsed())); 71 System.out.println("INFO: Case finished successfully for " + bean.getName()); 72 } 73 } |