Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/g1/TestPLABSizeBounds.java
40942 views
1
/*
2
* Copyright (c) 2015, 2020, 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.g1;
25
26
/*
27
* @test TestPLABSizeBounds
28
* @bug 8134857
29
* @summary Regression test to ensure that G1 supports PLAB sizes of half a region size.
30
* @requires vm.gc.G1
31
* @library /test/lib
32
* @modules java.base/jdk.internal.misc
33
* java.management
34
* @run driver gc.g1.TestPLABSizeBounds
35
*/
36
37
import java.util.ArrayList;
38
39
import jdk.test.lib.Platform;
40
import jdk.test.lib.process.OutputAnalyzer;
41
import jdk.test.lib.process.ProcessTools;
42
43
public class TestPLABSizeBounds {
44
45
public static final int M = 1024 * 1024;
46
47
/**
48
* Starts the VM with the given region size and the given PLAB size arguments. The VM start should
49
* succeed if shouldSucceed is true, otherwise it should fail.
50
*
51
* @param regionSize The region size the VM should be started with in bytes.
52
* @param plabSize The young and old gen PLAB sizes the VM should be started with in machine words.
53
* @param shouldSucceed The expected result of the VM invocation.
54
*/
55
public static void runTest(int regionSize, int plabSize, boolean shouldSucceed) throws Exception {
56
ArrayList<String> testArguments = new ArrayList<String>();
57
58
testArguments.add("-XX:+UseG1GC");
59
testArguments.add("-Xmx256M");
60
testArguments.add("-XX:G1HeapRegionSize=" + regionSize);
61
testArguments.add("-XX:YoungPLABSize=" + plabSize);
62
testArguments.add("-XX:OldPLABSize=" + plabSize);
63
testArguments.add(GCTest.class.getName());
64
65
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments);
66
OutputAnalyzer output = new OutputAnalyzer(pb.start());
67
68
if (shouldSucceed) {
69
output.shouldHaveExitValue(0);
70
} else {
71
output.shouldHaveExitValue(1);
72
}
73
}
74
75
public static void runRegionTest(int regionSize) throws Exception {
76
final int regionSizeInBytes = regionSize * M;
77
final int wordSize = Platform.is32bit() ? 4 : 8;
78
79
runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2 - 1, true);
80
runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2, true);
81
runTest(regionSizeInBytes, (regionSizeInBytes / wordSize) / 2 + 1, false);
82
}
83
84
public static void main(String[] args) throws Exception {
85
runRegionTest(1);
86
runRegionTest(2);
87
runRegionTest(4);
88
runRegionTest(8);
89
runRegionTest(16);
90
runRegionTest(32);
91
}
92
93
static class GCTest {
94
public static void main(String [] args) {
95
System.out.println("Test completed.");
96
}
97
}
98
}
99
100
101