Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codecache/jmx/UsageThresholdNotExceededTest.java
41153 views
1
/*
2
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test UsageThresholdNotExceededTest
26
* @summary verifying that usage threshold not exceeded while allocating less
27
* than usage threshold
28
* @library /test/lib /
29
* @modules java.base/jdk.internal.misc
30
* java.management
31
*
32
* @build sun.hotspot.WhiteBox
33
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
34
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35
* -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
36
* -XX:CompileCommand=compileonly,null::*
37
* -XX:+SegmentedCodeCache
38
* compiler.codecache.jmx.UsageThresholdNotExceededTest
39
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
40
* -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
41
* -XX:CompileCommand=compileonly,null::*
42
* -XX:-SegmentedCodeCache
43
* compiler.codecache.jmx.UsageThresholdNotExceededTest
44
*/
45
46
package compiler.codecache.jmx;
47
48
import sun.hotspot.code.BlobType;
49
50
import java.lang.management.MemoryPoolMXBean;
51
52
public class UsageThresholdNotExceededTest {
53
54
private final BlobType btype;
55
56
public UsageThresholdNotExceededTest(BlobType btype) {
57
this.btype = btype;
58
}
59
60
public static void main(String[] args) {
61
for (BlobType btype : BlobType.getAvailable()) {
62
new UsageThresholdNotExceededTest(btype).runTest();
63
}
64
}
65
66
protected void runTest() {
67
MemoryPoolMXBean bean = btype.getMemoryPool();
68
long initialThresholdCount = bean.getUsageThresholdCount();
69
long initialUsage = bean.getUsage().getUsed();
70
71
bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION);
72
long size = CodeCacheUtils.getHeaderSize(btype);
73
74
CodeCacheUtils.WB.allocateCodeBlob(Math.max(0, CodeCacheUtils.MIN_ALLOCATION
75
- size), btype.id);
76
// a gc cycle triggers usage threshold recalculation
77
CodeCacheUtils.WB.fullGC();
78
CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), initialThresholdCount,
79
String.format("Usage threshold was hit: %d times for %s. "
80
+ "Threshold value: %d with current usage: %d",
81
bean.getUsageThresholdCount(), bean.getName(),
82
bean.getUsageThreshold(), bean.getUsage().getUsed()));
83
System.out.println("INFO: Case finished successfully for " + bean.getName());
84
}
85
}
86
87