Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java
41149 views
1
/*
2
* Copyright (c) 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
/*
25
* @test
26
* @key stress randomness
27
* @bug 8235332 8248226
28
* @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) fields with StressGCM
29
* @library /
30
*
31
* @run main/othervm -Xbatch
32
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestCloneAccessStressGCM::test
33
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:-ReduceInitialCardMarks
34
* compiler.arraycopy.TestCloneAccessStressGCM
35
* @run main/othervm -Xbatch
36
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestCloneAccessStressGCM::test
37
* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:-ReduceInitialCardMarks
38
* -XX:-ReduceBulkZeroing
39
* compiler.arraycopy.TestCloneAccessStressGCM
40
*/
41
42
package compiler.arraycopy;
43
44
public class TestCloneAccessStressGCM {
45
46
static int test(E src) throws CloneNotSupportedException {
47
// ArrayCopyNode for this clone is not inlined since there are more than 8 (=ArrayCopyLoadStoreMaxElem) fields
48
E dest = (E)src.clone();
49
50
// The ArrayCopyNode initialization for the clone is executed after the LoadI nodes for 'dest' due to a
51
// memory input from the uninitialized new object instead of the ArrayCopyNode. As a result, uninitialized
52
// memory is read for each field and added together.
53
return dest.i1 + dest.i2 + dest.i3 + dest.i4 + dest.i5 +
54
dest.i6 + dest.i7 + dest.i8 + dest.i9;
55
}
56
57
public static void main(String[] args) throws Exception {
58
TestCloneAccessStressGCM test = new TestCloneAccessStressGCM();
59
int result = 0;
60
E e = new E();
61
for (int i = 0; i < 20000; i++) {
62
result = test(e);
63
if (result != 36) {
64
throw new RuntimeException("Return value not 36. Got: " + result + "; additional check: " + e.sum());
65
}
66
}
67
68
if (result != 36) {
69
throw new RuntimeException("Return value not 36. Got: " + result + "; additional check: " + e.sum());
70
}
71
}
72
}
73
74
class E implements Cloneable {
75
/*
76
* Need more than 8 (=ArrayCopyLoadStoreMaxElem) fields
77
*/
78
int i1;
79
int i2;
80
int i3;
81
int i4;
82
int i5;
83
int i6;
84
int i7;
85
int i8;
86
int i9;
87
88
E() {
89
i1 = 0;
90
i2 = 1;
91
i3 = 2;
92
i4 = 3;
93
i5 = 4;
94
i6 = 5;
95
i7 = 6;
96
i8 = 7;
97
i9 = 8;
98
}
99
100
public Object clone() throws CloneNotSupportedException {
101
return super.clone();
102
}
103
104
public int sum() {
105
return i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9;
106
}
107
}
108
109
110