Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/gc/g1/TestEdenSurvivorLessThanMax.java
40942 views
1
/*
2
* Copyright (c) 2018, 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.g1;
25
26
/*
27
* @test TestEdenSurvivorLessThanMax
28
* @bug 8152724
29
* @summary Check that G1 eden plus survivor max capacity after GC does not exceed maximum number of regions.
30
* @requires vm.gc.G1
31
* @library /test/lib
32
* @build sun.hotspot.WhiteBox
33
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
34
* @run main/othervm -Xbootclasspath/a:. -Xlog:gc+heap=debug -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx64M -Xms64M -Xmn50M -XX:SurvivorRatio=1 gc.g1.TestEdenSurvivorLessThanMax
35
*/
36
37
import sun.hotspot.WhiteBox;
38
39
// The test fills the heap in a way that previous to 8152724 the maximum number of survivor regions
40
// for that young gc was higher than there was free space left which is impossible.
41
public class TestEdenSurvivorLessThanMax {
42
private static final long BYTES_TO_FILL = 50 * 1024 * 1024;
43
44
private static final WhiteBox WB = WhiteBox.getWhiteBox();
45
46
public static void main(String[] args) throws Exception {
47
Object o = new int[100];
48
49
long objSize = WB.getObjectSize(o);
50
51
// Fill eden to approximately ~90%.
52
int numObjs = (int)((BYTES_TO_FILL / objSize) * 9 / 10);
53
for (int i = 0; i < numObjs; i++) {
54
o = new int[100];
55
}
56
57
WB.youngGC();
58
59
System.out.println(o.toString());
60
}
61
}
62
63
64