Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codecache/jmx/UsageThresholdIncreasedTest.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 UsageThresholdIncreasedTest
26
* @summary verifying that threshold hasn't been hit after allocation smaller
27
* than threshold value and that threshold value can be changed
28
* @library /test/lib /
29
* @modules java.base/jdk.internal.misc
30
* java.management
31
* @build sun.hotspot.WhiteBox
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
33
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
34
* -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
35
* -XX:CompileCommand=compileonly,null::*
36
* -XX:-SegmentedCodeCache
37
* compiler.codecache.jmx.UsageThresholdIncreasedTest
38
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39
* -XX:+WhiteBoxAPI -XX:-UseCodeCacheFlushing -XX:-MethodFlushing
40
* -XX:CompileCommand=compileonly,null::*
41
* -XX:+SegmentedCodeCache
42
* compiler.codecache.jmx.UsageThresholdIncreasedTest
43
*/
44
45
package compiler.codecache.jmx;
46
47
import sun.hotspot.code.BlobType;
48
49
import java.lang.management.MemoryPoolMXBean;
50
51
public class UsageThresholdIncreasedTest {
52
53
private static final int ALLOCATION_STEP = 5;
54
private static final long THRESHOLD_STEP = ALLOCATION_STEP
55
* CodeCacheUtils.MIN_ALLOCATION;
56
private final BlobType btype;
57
58
public UsageThresholdIncreasedTest(BlobType btype) {
59
this.btype = btype;
60
}
61
62
public static void main(String[] args) {
63
for (BlobType btype : BlobType.getAvailable()) {
64
new UsageThresholdIncreasedTest(btype).runTest();
65
}
66
}
67
68
private void checkUsageThresholdCount(MemoryPoolMXBean bean, long count){
69
CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), count,
70
String.format("Usage threshold was hit: %d times for %s "
71
+ "Threshold value: %d with current usage: %d",
72
bean.getUsageThresholdCount(), bean.getName(),
73
bean.getUsageThreshold(), bean.getUsage().getUsed()));
74
}
75
76
protected void runTest() {
77
long headerSize = CodeCacheUtils.getHeaderSize(btype);
78
long allocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize);
79
MemoryPoolMXBean bean = btype.getMemoryPool();
80
long initialCount = bean.getUsageThresholdCount();
81
long initialSize = bean.getUsage().getUsed();
82
bean.setUsageThreshold(initialSize + THRESHOLD_STEP);
83
for (int i = 0; i < ALLOCATION_STEP - 1; i++) {
84
CodeCacheUtils.WB.allocateCodeBlob(allocationUnit, btype.id);
85
}
86
// Usage threshold check is triggered by GC cycle, so, call it
87
CodeCacheUtils.WB.fullGC();
88
checkUsageThresholdCount(bean, initialCount);
89
long filledSize = bean.getUsage().getUsed();
90
bean.setUsageThreshold(filledSize + THRESHOLD_STEP);
91
for (int i = 0; i < ALLOCATION_STEP - 1; i++) {
92
CodeCacheUtils.WB.allocateCodeBlob(allocationUnit, btype.id);
93
}
94
CodeCacheUtils.WB.fullGC();
95
checkUsageThresholdCount(bean, initialCount);
96
System.out.println("INFO: Case finished successfully for " + bean.getName());
97
}
98
}
99
100