Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/shenandoah/jvmti/TestHeapDump.java
41153 views
1
/*
2
* Copyright (c) 2017, 2020, Red Hat, Inc. 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
/**
26
* @test TestHeapDump
27
* @summary Tests JVMTI heap dumps
28
* @requires vm.gc.Shenandoah
29
* @requires vm.jvmti
30
* @compile TestHeapDump.java
31
* @run main/othervm/native/timeout=300 -agentlib:TestHeapDump -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx128m -XX:ShenandoahGCHeuristics=aggressive TestHeapDump
32
*
33
*/
34
35
/**
36
* @test TestHeapDump
37
* @summary Tests JVMTI heap dumps
38
* @requires vm.gc.Shenandoah
39
* @requires vm.jvmti
40
* @requires vm.bits == "64"
41
* @compile TestHeapDump.java
42
* @run main/othervm/native/timeout=300 -agentlib:TestHeapDump -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx128m -XX:ShenandoahGCHeuristics=aggressive -XX:-UseCompressedOops TestHeapDump
43
*/
44
45
/**
46
* @test TestHeapDump
47
* @summary Tests JVMTI heap dumps
48
* @requires vm.gc.Shenandoah
49
* @requires vm.jvmti
50
* @compile TestHeapDump.java
51
* @run main/othervm/native/timeout=300 -agentlib:TestHeapDump -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -Xmx128m -XX:ShenandoahGCHeuristics=aggressive -XX:+UseStringDeduplication TestHeapDump
52
*/
53
54
import java.lang.ref.Reference;
55
56
public class TestHeapDump {
57
58
private static final int NUM_ITER = 10000;
59
60
private static final int ARRAY_SIZE = 1000;
61
62
private static final int EXPECTED_OBJECTS =
63
ARRAY_SIZE + // array reachable from instance field
64
1 + // static field root
65
1; // local field root
66
67
static {
68
try {
69
System.loadLibrary("TestHeapDump");
70
} catch (UnsatisfiedLinkError ule) {
71
System.err.println("Could not load TestHeapDump library");
72
System.err.println("java.library.path: "
73
+ System.getProperty("java.library.path"));
74
throw ule;
75
}
76
}
77
78
native static int heapdump(Class<?> filterClass);
79
80
public static void main(String args[]) {
81
new TestHeapDump().run();
82
}
83
84
// This root needs to be discovered
85
static Object root = new TestObject();
86
87
// This field needs to be discovered
88
TestObject[] array;
89
90
public void run() {
91
array = new TestObject[ARRAY_SIZE];
92
for (int i = 0; i < ARRAY_SIZE; i++) {
93
array[i] = new TestObject();
94
}
95
TestObject localRoot = new TestObject();
96
for (int i = 0; i < NUM_ITER; i++) {
97
int numObjs = heapdump(TestObject.class);
98
if (numObjs != EXPECTED_OBJECTS) {
99
throw new RuntimeException("Expected " + EXPECTED_OBJECTS + " objects, but got " + numObjs);
100
}
101
}
102
Reference.reachabilityFence(array);
103
Reference.reachabilityFence(localRoot);
104
}
105
106
// We look for the instances of this class during the heap scan
107
public static class TestObject {}
108
}
109
110