Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/cha/DefaultRootMethod.java
41149 views
1
/*
2
* Copyright (c) 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
/*
25
* @test
26
* @requires !vm.graal.enabled & vm.opt.final.UseVtableBasedCHA == true
27
* @modules java.base/jdk.internal.org.objectweb.asm
28
* java.base/jdk.internal.misc
29
* java.base/jdk.internal.vm.annotation
30
* @library /test/lib /
31
* @compile Utils.java
32
* @build sun.hotspot.WhiteBox
33
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
34
*
35
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
36
* -XX:+PrintCompilation -XX:+PrintInlining -XX:+TraceDependencies -verbose:class -XX:CompileCommand=quiet
37
* -XX:CompileCommand=compileonly,*::m
38
* -XX:CompileCommand=compileonly,*::test -XX:CompileCommand=dontinline,*::test
39
* -Xbatch -Xmixed -XX:+WhiteBoxAPI
40
* -XX:-TieredCompilation
41
* compiler.cha.DefaultRootMethod
42
*
43
* @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
44
* -XX:+PrintCompilation -XX:+PrintInlining -XX:+TraceDependencies -verbose:class -XX:CompileCommand=quiet
45
* -XX:CompileCommand=compileonly,*::m
46
* -XX:CompileCommand=compileonly,*::test -XX:CompileCommand=dontinline,*::test
47
* -Xbatch -Xmixed -XX:+WhiteBoxAPI
48
* -XX:+TieredCompilation -XX:TieredStopAtLevel=1
49
* compiler.cha.DefaultRootMethod
50
*/
51
package compiler.cha;
52
53
import static compiler.cha.Utils.*;
54
55
public class DefaultRootMethod {
56
public static void main(String[] args) {
57
run(DefaultRoot.class);
58
run(InheritedDefault.class);
59
System.out.println("TEST PASSED");
60
}
61
62
public static class DefaultRoot extends ATest<DefaultRoot.C> {
63
public DefaultRoot() {
64
super(C.class, D.class);
65
}
66
67
interface I { default Object m() { return CORRECT; } }
68
69
static class C implements I { /* inherited I.m */}
70
71
static class D extends C { /* inherited I.m */ }
72
73
static abstract class E1 extends C { /* empty */ }
74
static abstract class E2 extends C { public abstract Object m(); }
75
static abstract class E3 extends C { public Object m() { return "E3.m"; } }
76
77
interface I1 extends I { Object m(); }
78
interface I2 extends I { default Object m() { return "I2.m"; } }
79
80
static abstract class F1 extends C implements I1 { }
81
static abstract class F2 extends C implements I2 { }
82
83
static class G extends C { public Object m() { return CORRECT; } }
84
85
@Override
86
public Object test(C obj) {
87
return obj.m(); // invokevirtual C.m()
88
}
89
90
@Override
91
public void checkInvalidReceiver() {
92
// nothing to do: concrete class types are enforced by the verifier
93
}
94
95
@TestCase
96
public void test() {
97
// 0. Trigger compilation of a megamorphic call site
98
compile(megamorphic()); // Dn <: D.m <: C <: I.m DEFAULT
99
assertCompiled();
100
101
// Dependency: type = unique_concrete_method, context = C, method = D.m
102
103
// 1. No invalidation: abstract classes don't participate in CHA.
104
initialize(E1.class, // ABSTRACT E1 <: C <: I.m DEFAULT
105
E2.class, // ABSTRACT E2.m ABSTRACT <: C <: I.m DEFAULT
106
E3.class, // ABSTRACT E3.m <: C <: I.m DEFAULT
107
F1.class, // ABSTRACT F1 <: C <: I.m DEFAULT, I1.m ABSTRACT
108
F2.class); // ABSTRACT F2 <: C <: I.m DEFAULT, I2.m DEFAULT
109
assertCompiled();
110
111
// 2. Dependency invalidation: G.m <: C <: I.m DEFAULT
112
load(G.class);
113
assertCompiled();
114
115
// 3. Dependency invalidation: G.m <: C <: I.m DEFAULT
116
initialize(G.class);
117
assertNotCompiled();
118
119
// 4. Recompilation: no inlining, no dependencies
120
compile(megamorphic());
121
call(new C() { public Object m() { return CORRECT; } }); // Cn.m <: C <: I.m DEFAULT
122
call(new G() { public Object m() { return CORRECT; } }); // Gn <: G.m <: C <: I.m DEFAULT
123
assertCompiled();
124
}
125
}
126
127
public static class InheritedDefault extends ATest<InheritedDefault.C> {
128
public InheritedDefault() {
129
super(C.class, D.class);
130
}
131
132
interface I { Object m(); }
133
interface J extends I { default Object m() { return CORRECT; } }
134
135
static abstract class C implements I { /* inherits I.m ABSTRACT */}
136
137
// NB! The class is marked abstract to avoid abstract_with_unique_concrete_subtype dependency
138
static abstract class D extends C implements J { /* inherits J.m DEFAULT*/ }
139
140
static abstract class E1 extends C { /* empty */ }
141
static abstract class E2 extends C { public abstract Object m(); }
142
static abstract class E3 extends C { public Object m() { return "E3.m"; } }
143
144
interface I1 extends I { Object m(); }
145
interface I2 extends I { default Object m() { return "I2.m"; } }
146
147
static abstract class F1 extends C implements I1 { }
148
static abstract class F2 extends C implements I2 { }
149
150
interface K extends I { default Object m() { return CORRECT; } }
151
static class G extends C implements K { /* inherits K.m DEFAULT */ }
152
153
@Override
154
public Object test(C obj) {
155
return obj.m(); // invokevirtual C.m()
156
}
157
158
@Override
159
public void checkInvalidReceiver() {
160
// nothing to do: concrete class types are enforced by the verifier
161
}
162
163
@TestCase
164
public void test() {
165
// 0. Trigger compilation of a megamorphic call site
166
compile(megamorphic()); // Dn <: D.m <: C <: I.m ABSTRACT, J.m DEFAULT
167
assertCompiled();
168
169
// Dependency: type = unique_concrete_method, context = C, method = D.m
170
171
// 1. No invalidation: abstract classes don't participate in CHA.
172
initialize(E1.class, // ABSTRACT E1 <: C <: I.m ABSTRACT
173
E2.class, // ABSTRACT E2.m ABSTRACT <: C <: I.m ABSTRACT
174
E3.class, // ABSTRACT E3.m <: C <: I.m ABSTRACT
175
F1.class, // ABSTRACT F1 <: C <: I.m ABSTRACT, I1.m ABSTRACT
176
F2.class); // ABSTRACT F2 <: C <: I.m ABSTRACT, I2.m DEFAULT
177
assertCompiled();
178
179
// 2. No invalidation: not yet linked classes don't participate in CHA.
180
load(G.class);
181
assertCompiled();
182
183
// 3. Dependency invalidation: G.m <: C <: I.m DEFAULT
184
initialize(G.class);
185
assertNotCompiled();
186
187
// 4. Recompilation: no inlining, no dependencies
188
compile(megamorphic());
189
call(new C() { public Object m() { return CORRECT; } }); // Cn.m <: C <: I.m DEFAULT
190
call(new G() { public Object m() { return CORRECT; } }); // Gn <: G.m <: C <: I.m DEFAULT
191
assertCompiled();
192
}
193
}
194
}
195
196