Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/arraycopy/TestInstanceCloneAsLoadsStores.java
64474 views
1
/*
2
* Copyright (c) 2016, 2022, 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 6700100 8156760 8248226 8285301
27
* @summary small instance clone as loads/stores
28
* @library /
29
*
30
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
31
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m*
32
* compiler.arraycopy.TestInstanceCloneAsLoadsStores
33
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
34
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m*
35
* -XX:+IgnoreUnrecognizedVMOptions -XX:+StressArrayCopyMacroNode
36
* compiler.arraycopy.TestInstanceCloneAsLoadsStores
37
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
38
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m*
39
* -XX:+IgnoreUnrecognizedVMOptions -XX:-ReduceInitialCardMarks
40
* compiler.arraycopy.TestInstanceCloneAsLoadsStores
41
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
42
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m*
43
* -XX:+IgnoreUnrecognizedVMOptions -XX:-ReduceInitialCardMarks -XX:-ReduceBulkZeroing
44
* compiler.arraycopy.TestInstanceCloneAsLoadsStores
45
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
46
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestInstanceCloneAsLoadsStores::m*
47
* -XX:+UnlockExperimentalVMOptions -XX:+AlwaysAtomicAccesses
48
* compiler.arraycopy.TestInstanceCloneAsLoadsStores
49
*/
50
51
package compiler.arraycopy;
52
53
public class TestInstanceCloneAsLoadsStores extends TestInstanceCloneUtils {
54
55
// Should be compiled as loads/stores
56
static Object m1(D src) throws CloneNotSupportedException {
57
return src.clone();
58
}
59
60
// Should be compiled as adds of src (dest allocation eliminated)
61
static int m2(D src) throws CloneNotSupportedException {
62
D dest = (D)src.clone();
63
return dest.i1 + dest.i2 + ((int)dest.i3) + dest.i4 + dest.i5;
64
}
65
66
// Should be compiled as arraycopy stub call (object too large)
67
static int m3(E src) throws CloneNotSupportedException {
68
E dest = (E)src.clone();
69
return dest.i1 + dest.i2 + dest.i3 + dest.i4 + dest.i5 +
70
dest.i6 + dest.i7 + dest.i8 + dest.i9;
71
}
72
73
// Need profiling on src's type to be able to know number of
74
// fields. Cannot clone as loads/stores if compile doesn't use it.
75
static Object m4(A src) throws CloneNotSupportedException {
76
return src.clone();
77
}
78
79
// Same as above but should optimize out dest allocation
80
static int m5(A src) throws CloneNotSupportedException {
81
A dest = (A)src.clone();
82
return dest.i1 + dest.i2 + dest.i3 + dest.i4 + dest.i5;
83
}
84
85
// Check that if we have no fields to clone we do fine
86
static Object m6(F src) throws CloneNotSupportedException {
87
return src.clone();
88
}
89
90
// With virtual call to clone: clone inlined from profling which
91
// gives us exact type of src so we can clone it with
92
// loads/stores.
93
static G m7(G src) throws CloneNotSupportedException {
94
return (G)src.myclone();
95
}
96
97
// Virtual call to clone but single target: exact type unknown,
98
// clone intrinsic uses profiling to determine exact type and
99
// clone with loads/stores.
100
static J m8(J src) throws CloneNotSupportedException {
101
return (J)src.myclone();
102
}
103
104
public static void main(String[] args) throws Exception {
105
106
TestInstanceCloneAsLoadsStores test = new TestInstanceCloneAsLoadsStores();
107
108
test.doTest(d, "m1");
109
test.doTest(d, "m2");
110
test.doTest(e, "m3");
111
test.doTest(a, "m4");
112
test.doTest(a, "m5");
113
test.doTest(f, "m6");
114
test.doTest(g, "m7");
115
test.doTest(k, "m8");
116
117
if (!test.success) {
118
throw new RuntimeException("some tests failed");
119
}
120
121
}
122
}
123
124