Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codecache/OverflowCodeCacheTest.java
41152 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 OverflowCodeCacheTest
26
* @bug 8059550
27
* @summary testing of code cache segments overflow
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:CompileCommand=compileonly,null::*
36
* -XX:-SegmentedCodeCache
37
* compiler.codecache.OverflowCodeCacheTest
38
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39
* -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,null::*
40
* -XX:+SegmentedCodeCache
41
* compiler.codecache.OverflowCodeCacheTest
42
*/
43
44
package compiler.codecache;
45
46
import jdk.test.lib.Asserts;
47
import sun.hotspot.WhiteBox;
48
import sun.hotspot.code.BlobType;
49
import sun.hotspot.code.CodeBlob;
50
51
import java.lang.management.MemoryPoolMXBean;
52
import java.util.ArrayList;
53
import java.util.EnumSet;
54
55
public class OverflowCodeCacheTest {
56
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
57
58
public static void main(String[] args) {
59
EnumSet<BlobType> blobTypes = BlobType.getAvailable();
60
for (BlobType type : blobTypes) {
61
new OverflowCodeCacheTest(type).test();
62
}
63
}
64
65
private final BlobType type;
66
private final MemoryPoolMXBean bean;
67
private OverflowCodeCacheTest(BlobType type) {
68
this.type = type;
69
this.bean = type.getMemoryPool();
70
}
71
72
private void test() {
73
System.out.printf("type %s%n", type);
74
System.out.println("allocating till possible...");
75
ArrayList<Long> blobs = new ArrayList<>();
76
int compilationActivityMode = -1;
77
try {
78
long addr;
79
int size = (int) (getHeapSize() >> 7);
80
while ((addr = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) {
81
blobs.add(addr);
82
83
BlobType actualType = CodeBlob.getCodeBlob(addr).code_blob_type;
84
if (actualType != type) {
85
// check we got allowed overflow handling
86
Asserts.assertTrue(type.allowTypeWhenOverflow(actualType),
87
type + " doesn't allow using " + actualType + " when overflow");
88
}
89
}
90
/* now, remember compilationActivityMode to check it later, after freeing, since we
91
possibly have no free cache for futher work */
92
compilationActivityMode = WHITE_BOX.getCompilationActivityMode();
93
} finally {
94
for (Long blob : blobs) {
95
WHITE_BOX.freeCodeBlob(blob);
96
}
97
}
98
Asserts.assertNotEquals(compilationActivityMode, 1 /* run_compilation*/,
99
"Compilation must be disabled when CodeCache(CodeHeap) overflows");
100
}
101
102
private long getHeapSize() {
103
return bean.getUsage().getMax();
104
}
105
106
}
107
108