blob: 98d4d962818923d47a1c48a50f203190062d0211 [file] [log] [blame]
Calin Juravle877fd962016-01-05 14:29:29 +00001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17class Main {
18 public String getA() {
19 return "A";
20 }
21 public String getB() {
22 return "B";
23 }
24 public String getC() {
25 return "C";
26 }
27}
Calin Juravlee0ac1152017-02-13 19:03:47 -080028
29class TestInline {
30 public int inlineMonomorphic(Super s) {
31 return s.getValue();
32 }
33
34 public int inlinePolymorphic(Super s) {
35 return s.getValue();
36 }
37
38 public int inlineMegamorphic(Super s) {
39 return s.getValue();
40 }
41
Calin Juravle589e71e2017-03-03 16:05:05 -080042 public int inlineMissingTypes(Super s) {
43 return s.getValue();
44 }
45
Calin Juravlee0ac1152017-02-13 19:03:47 -080046 public int noInlineCache(Super s) {
47 return s.getValue();
48 }
Alex Lighta2f13192021-02-03 18:19:03 -080049
50 public int inlineMultiMonomorphic(Super s, Secret sec) {
51 return s.getValue() + sec.getIdentity();
52 }
53
54 public int inlineMultiPolymorphic(Super s, Secret sec) {
55 return s.getValue() + sec.getIdentity();
56 }
57
58 public int inlineTriplePolymorphic(Super s, Secret sec, Secret thr) {
59 return s.getValue() + sec.getIdentity() + thr.getIdentity();
60 }
61
62 public int inlineMultiMegamorphic(Super s, Secret sec) {
63 return s.getValue() + sec.getIdentity();
64 }
65
66 public int inlineMultiMissingTypes(Super s, Secret sec) {
67 return s.getValue() + sec.getIdentity();
68 }
69
70 public int noInlineCacheMulti(Super s, Secret sec) {
71 return s.getValue() + sec.getIdentity();
72 }
Calin Juravlee0ac1152017-02-13 19:03:47 -080073}
74
Alex Lightcff30a02021-03-25 17:33:32 -070075class TestInlineSubtype extends TestInline {
76 public void foobar() {
77 this.inlineMonomorphic(new SubA());
78 }
79}
80
Alex Lighta2f13192021-02-03 18:19:03 -080081abstract class Secret {
82 abstract int getIdentity();
83}
84
85abstract class Super extends Secret {
Calin Juravlee0ac1152017-02-13 19:03:47 -080086 abstract int getValue();
87}
88
89class SubA extends Super {
90 int getValue() { return 42; }
Alex Lighta2f13192021-02-03 18:19:03 -080091 int getIdentity() { return 24; }
Calin Juravlee0ac1152017-02-13 19:03:47 -080092}
93
94class SubB extends Super {
95 int getValue() { return 38; };
Alex Lighta2f13192021-02-03 18:19:03 -080096 int getIdentity() { return 83; }
Calin Juravlee0ac1152017-02-13 19:03:47 -080097}
98
99class SubD extends Super {
100 int getValue() { return 20; };
Alex Lighta2f13192021-02-03 18:19:03 -0800101 int getIdentity() { return 2; };
Calin Juravlee0ac1152017-02-13 19:03:47 -0800102}
103
104class SubE extends Super {
105 int getValue() { return 16; };
Alex Lighta2f13192021-02-03 18:19:03 -0800106 int getIdentity() { return 61; };
Calin Juravlee0ac1152017-02-13 19:03:47 -0800107}
Calin Juravle1061c7d2019-09-23 21:00:29 -0400108
109// Add a class with lots of methods so we can test profile guided compilation triggers.
110class ZLotsOfMethods {
111 public void m1() {}
112 public void m2() {}
113 public void m3() {}
114 public void m4() {}
115 public void m5() {}
116 public void m6() {}
117 public void m7() {}
118 public void m8() {}
119 public void m9() {}
120 public void m10() {}
121 public void m11() {}
122 public void m12() {}
123 public void m13() {}
124 public void m14() {}
125 public void m15() {}
126 public void m16() {}
127 public void m17() {}
128 public void m18() {}
129 public void m19() {}
130 public void m20() {}
131 public void m21() {}
132 public void m22() {}
133 public void m23() {}
134 public void m24() {}
135 public void m25() {}
136 public void m26() {}
137 public void m27() {}
138 public void m28() {}
139 public void m29() {}
140 public void m30() {}
141 public void m31() {}
142 public void m32() {}
143 public void m33() {}
144 public void m34() {}
145 public void m35() {}
146 public void m36() {}
147 public void m37() {}
148 public void m38() {}
149 public void m39() {}
150 public void m40() {}
151 public void m41() {}
152 public void m42() {}
153 public void m43() {}
154 public void m44() {}
155 public void m45() {}
156 public void m46() {}
157 public void m47() {}
158 public void m48() {}
159 public void m49() {}
160 public void m50() {}
161 public void m51() {}
162 public void m52() {}
163 public void m53() {}
164 public void m54() {}
165 public void m55() {}
166 public void m56() {}
167 public void m57() {}
168 public void m58() {}
169 public void m59() {}
170 public void m60() {}
171 public void m61() {}
172 public void m62() {}
173 public void m63() {}
174 public void m64() {}
175 public void m65() {}
176 public void m66() {}
177 public void m67() {}
178 public void m68() {}
179 public void m69() {}
180 public void m70() {}
181 public void m71() {}
182 public void m72() {}
183 public void m73() {}
184 public void m74() {}
185 public void m75() {}
186 public void m76() {}
187 public void m77() {}
188 public void m78() {}
189 public void m79() {}
190 public void m80() {}
191 public void m81() {}
192 public void m82() {}
193 public void m83() {}
194 public void m84() {}
195 public void m85() {}
196 public void m86() {}
197 public void m87() {}
198 public void m88() {}
199 public void m89() {}
200 public void m90() {}
201 public void m91() {}
202 public void m92() {}
203 public void m93() {}
204 public void m94() {}
205 public void m95() {}
206 public void m96() {}
207 public void m97() {}
208 public void m98() {}
209 public void m99() {}
210 public void m100() {}
211 public void m101() {}
212 public void m102() {}
213 public void m103() {}
214 public void m104() {}
215 public void m105() {}
216 public void m106() {}
217 public void m107() {}
218 public void m108() {}
219 public void m109() {}
220 public void m110() {}
221 public void m111() {}
222 public void m112() {}
223 public void m113() {}
224 public void m114() {}
225 public void m115() {}
226 public void m116() {}
227 public void m117() {}
228 public void m118() {}
229 public void m119() {}
230 public void m120() {}
231 public void m121() {}
232 public void m122() {}
233 public void m123() {}
234 public void m124() {}
235 public void m125() {}
236 public void m126() {}
237 public void m127() {}
238 public void m128() {}
239 public void m129() {}
240 public void m130() {}
241 public void m131() {}
242 public void m132() {}
243 public void m133() {}
244 public void m134() {}
245 public void m135() {}
246 public void m136() {}
247 public void m137() {}
248 public void m138() {}
249 public void m139() {}
250 public void m140() {}
251 public void m141() {}
252 public void m142() {}
253 public void m143() {}
254 public void m144() {}
255 public void m145() {}
256 public void m146() {}
257 public void m147() {}
258 public void m148() {}
259 public void m149() {}
260 public void m150() {}
261}