Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/TestConcurrentGCBreakpoints.java
40930 views
1
/*
2
* Copyright (c) 2020, 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
package gc;
25
26
/*
27
* @test TestConcurrentGCBreakpoints
28
* @summary Test of WhiteBox concurrent GC control.
29
* @library /test/lib
30
* @build sun.hotspot.WhiteBox
31
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
32
* @run main/othervm
33
* -Xbootclasspath/a:.
34
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35
* gc.TestConcurrentGCBreakpoints
36
*/
37
38
import sun.hotspot.WhiteBox;
39
import sun.hotspot.gc.GC;
40
41
public class TestConcurrentGCBreakpoints {
42
43
private static final WhiteBox WB = WhiteBox.getWhiteBox();
44
45
// All testN() assume initial state is idle, and restore that state.
46
47
// Step through the common breakpoints.
48
private static void testSimpleCycle() throws Exception {
49
System.out.println("testSimpleCycle");
50
try {
51
// Run one cycle.
52
WB.concurrentGCRunTo(WB.AFTER_MARKING_STARTED);
53
WB.concurrentGCRunTo(WB.BEFORE_MARKING_COMPLETED);
54
WB.concurrentGCRunToIdle();
55
// Run a second cycle.
56
WB.concurrentGCRunTo(WB.AFTER_MARKING_STARTED);
57
WB.concurrentGCRunTo(WB.BEFORE_MARKING_COMPLETED);
58
WB.concurrentGCRunToIdle();
59
} finally {
60
WB.concurrentGCRunToIdle();
61
}
62
}
63
64
// Verify attempted wraparound detected and reported.
65
private static void testEndBeforeBreakpointError() throws Exception {
66
System.out.println("testEndBeforeBreakpointError");
67
try {
68
WB.concurrentGCRunTo(WB.BEFORE_MARKING_COMPLETED);
69
try {
70
WB.concurrentGCRunTo(WB.AFTER_MARKING_STARTED);
71
} catch (IllegalStateException e) {
72
// Reached end of cycle before desired breakpoint.
73
}
74
} finally {
75
WB.concurrentGCRunToIdle();
76
}
77
}
78
79
// Verify attempted wraparound detected and reported without throw.
80
private static void testEndBeforeBreakpoint() throws Exception {
81
System.out.println("testEndBeforeBreakpoint");
82
try {
83
WB.concurrentGCRunTo(WB.BEFORE_MARKING_COMPLETED);
84
if (WB.concurrentGCRunTo(WB.AFTER_MARKING_STARTED, false)) {
85
throw new RuntimeException("Unexpected wraparound");
86
}
87
} finally {
88
WB.concurrentGCRunToIdle();
89
}
90
}
91
92
private static void testUnknownBreakpoint() throws Exception {
93
System.out.println("testUnknownBreakpoint");
94
try {
95
if (WB.concurrentGCRunTo("UNKNOWN BREAKPOINT", false)) {
96
throw new RuntimeException("RunTo UNKNOWN BREAKPOINT");
97
}
98
} finally {
99
WB.concurrentGCRunToIdle();
100
}
101
}
102
103
private static void test() throws Exception {
104
try {
105
System.out.println("taking control");
106
WB.concurrentGCAcquireControl();
107
testSimpleCycle();
108
testEndBeforeBreakpointError();
109
testEndBeforeBreakpoint();
110
testUnknownBreakpoint();
111
} finally {
112
System.out.println("releasing control");
113
WB.concurrentGCReleaseControl();
114
}
115
}
116
117
private static boolean expectSupported() {
118
return GC.G1.isSelected() ||
119
GC.Z.isSelected() ||
120
GC.Shenandoah.isSelected();
121
}
122
123
private static boolean expectUnsupported() {
124
return GC.Serial.isSelected() ||
125
GC.Parallel.isSelected() ||
126
GC.Epsilon.isSelected();
127
}
128
129
public static void main(String[] args) throws Exception {
130
boolean supported = WB.supportsConcurrentGCBreakpoints();
131
if (expectSupported()) {
132
if (supported) {
133
test();
134
} else {
135
throw new RuntimeException("Expected support");
136
}
137
} else if (expectUnsupported()) {
138
if (supported) {
139
throw new RuntimeException("Unexpected support");
140
}
141
} else {
142
throw new RuntimeException("Unknown GC");
143
}
144
}
145
}
146
147