Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/gcbarriers/G1CrashTest.java
41149 views
1
/*
2
* Copyright (c) 2013, 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
26
* @bug 8023472
27
* @summary C2 optimization breaks with G1
28
*
29
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
30
* -Dcount=100000 compiler.gcbarriers.G1CrashTest
31
*
32
* @author [email protected]
33
*/
34
35
package compiler.gcbarriers;
36
37
public class G1CrashTest {
38
static Object[] set = new Object[11];
39
40
public static void main(String[] args) throws InterruptedException {
41
for (int j = 0; j < Integer.getInteger("count"); j++) {
42
Object key = new Object();
43
insertKey(key);
44
if (j > set.length / 2) {
45
Object[] oldKeys = set;
46
set = new Object[2 * set.length - 1];
47
for (Object o : oldKeys) {
48
if (o != null)
49
insertKey(o);
50
}
51
}
52
}
53
}
54
55
static void insertKey(Object key) {
56
int hash = key.hashCode() & 0x7fffffff;
57
int index = hash % set.length;
58
Object cur = set[index];
59
if (cur == null)
60
set[index] = key;
61
else
62
insertKeyRehash(key, index, hash, cur);
63
}
64
65
static void insertKeyRehash(Object key, int index, int hash, Object cur) {
66
int loopIndex = index;
67
int firstRemoved = -1;
68
do {
69
if (cur == "dead")
70
firstRemoved = 1;
71
index--;
72
if (index < 0)
73
index += set.length;
74
cur = set[index];
75
if (cur == null) {
76
if (firstRemoved != -1)
77
set[firstRemoved] = "dead";
78
else
79
set[index] = key;
80
return;
81
}
82
} while (index != loopIndex);
83
if (firstRemoved != -1)
84
set[firstRemoved] = null;
85
}
86
}
87
88