xref: /aosp_15_r20/art/test/570-checker-osr/src/Main.java (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2016 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker public class Main {
main(String[] args)18*795d594fSAndroid Build Coastguard Worker   public static void main(String[] args) {
19*795d594fSAndroid Build Coastguard Worker     System.loadLibrary(args[0]);
20*795d594fSAndroid Build Coastguard Worker     new SubMain();
21*795d594fSAndroid Build Coastguard Worker     if ($noinline$returnInt() != 53) {
22*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
23*795d594fSAndroid Build Coastguard Worker     }
24*795d594fSAndroid Build Coastguard Worker     if ($noinline$returnFloat() != 42.2f) {
25*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
26*795d594fSAndroid Build Coastguard Worker     }
27*795d594fSAndroid Build Coastguard Worker     if ($noinline$returnDouble() != Double.longBitsToDouble(0xF000000000001111L)) {
28*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value ");
29*795d594fSAndroid Build Coastguard Worker     }
30*795d594fSAndroid Build Coastguard Worker     if ($noinline$returnLong() != 0xFFFF000000001111L) {
31*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
32*795d594fSAndroid Build Coastguard Worker     }
33*795d594fSAndroid Build Coastguard Worker 
34*795d594fSAndroid Build Coastguard Worker     try {
35*795d594fSAndroid Build Coastguard Worker       $noinline$deopt();
36*795d594fSAndroid Build Coastguard Worker     } catch (Exception e) {}
37*795d594fSAndroid Build Coastguard Worker     DeoptimizationController.stopDeoptimization();
38*795d594fSAndroid Build Coastguard Worker 
39*795d594fSAndroid Build Coastguard Worker     $noinline$inlineCache(new Main(), /* isSecondInvocation */ false);
40*795d594fSAndroid Build Coastguard Worker     if ($noinline$inlineCache(new SubMain(), /* isSecondInvocation */ true) != SubMain.class) {
41*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
42*795d594fSAndroid Build Coastguard Worker     }
43*795d594fSAndroid Build Coastguard Worker 
44*795d594fSAndroid Build Coastguard Worker     $noinline$inlineCache2(new Main(), /* isSecondInvocation */ false);
45*795d594fSAndroid Build Coastguard Worker     if ($noinline$inlineCache2(new SubMain(), /* isSecondInvocation */ true) != SubMain.class) {
46*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
47*795d594fSAndroid Build Coastguard Worker     }
48*795d594fSAndroid Build Coastguard Worker 
49*795d594fSAndroid Build Coastguard Worker     // Test polymorphic inline cache to the same target (inlineCache3).
50*795d594fSAndroid Build Coastguard Worker     $noinline$inlineCache3(new Main(), /* isSecondInvocation */ false);
51*795d594fSAndroid Build Coastguard Worker     $noinline$inlineCache3(new SubMain(), /* isSecondInvocation */ false);
52*795d594fSAndroid Build Coastguard Worker     if ($noinline$inlineCache3(new SubMain(), /* isSecondInvocation */ true) != null) {
53*795d594fSAndroid Build Coastguard Worker       throw new Error("Unexpected return value");
54*795d594fSAndroid Build Coastguard Worker     }
55*795d594fSAndroid Build Coastguard Worker 
56*795d594fSAndroid Build Coastguard Worker     $noinline$stackOverflow(new Main(), /* isSecondInvocation */ false);
57*795d594fSAndroid Build Coastguard Worker     $noinline$stackOverflow(new SubMain(), /* isSecondInvocation */ true);
58*795d594fSAndroid Build Coastguard Worker 
59*795d594fSAndroid Build Coastguard Worker     $opt$noinline$testOsrInlineLoop(null);
60*795d594fSAndroid Build Coastguard Worker     System.out.println("b28210356 passed.");
61*795d594fSAndroid Build Coastguard Worker   }
62*795d594fSAndroid Build Coastguard Worker 
$noinline$returnInt()63*795d594fSAndroid Build Coastguard Worker   public static int $noinline$returnInt() {
64*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
65*795d594fSAndroid Build Coastguard Worker     // already JITted, skip the wait for OSR code.
66*795d594fSAndroid Build Coastguard Worker     boolean interpreting = isInInterpreter("$noinline$returnInt");
67*795d594fSAndroid Build Coastguard Worker     int i = 0;
68*795d594fSAndroid Build Coastguard Worker     for (; i < 100000; ++i) {
69*795d594fSAndroid Build Coastguard Worker     }
70*795d594fSAndroid Build Coastguard Worker     if (interpreting) {
71*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$returnInt")) {}
72*795d594fSAndroid Build Coastguard Worker     }
73*795d594fSAndroid Build Coastguard Worker     System.out.println(i);
74*795d594fSAndroid Build Coastguard Worker     return 53;
75*795d594fSAndroid Build Coastguard Worker   }
76*795d594fSAndroid Build Coastguard Worker 
$noinline$returnFloat()77*795d594fSAndroid Build Coastguard Worker   public static float $noinline$returnFloat() {
78*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
79*795d594fSAndroid Build Coastguard Worker     // already JITted, skip the wait for OSR code.
80*795d594fSAndroid Build Coastguard Worker     boolean interpreting = isInInterpreter("$noinline$returnFloat");
81*795d594fSAndroid Build Coastguard Worker     int i = 0;
82*795d594fSAndroid Build Coastguard Worker     for (; i < 200000; ++i) {
83*795d594fSAndroid Build Coastguard Worker     }
84*795d594fSAndroid Build Coastguard Worker     if (interpreting) {
85*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$returnFloat")) {}
86*795d594fSAndroid Build Coastguard Worker     }
87*795d594fSAndroid Build Coastguard Worker     System.out.println(i);
88*795d594fSAndroid Build Coastguard Worker     return 42.2f;
89*795d594fSAndroid Build Coastguard Worker   }
90*795d594fSAndroid Build Coastguard Worker 
$noinline$returnDouble()91*795d594fSAndroid Build Coastguard Worker   public static double $noinline$returnDouble() {
92*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
93*795d594fSAndroid Build Coastguard Worker     // already JITted, skip the wait for OSR code.
94*795d594fSAndroid Build Coastguard Worker     boolean interpreting = isInInterpreter("$noinline$returnDouble");
95*795d594fSAndroid Build Coastguard Worker     int i = 0;
96*795d594fSAndroid Build Coastguard Worker     for (; i < 300000; ++i) {
97*795d594fSAndroid Build Coastguard Worker     }
98*795d594fSAndroid Build Coastguard Worker     if (interpreting) {
99*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$returnDouble")) {}
100*795d594fSAndroid Build Coastguard Worker     }
101*795d594fSAndroid Build Coastguard Worker     System.out.println(i);
102*795d594fSAndroid Build Coastguard Worker     return Double.longBitsToDouble(0xF000000000001111L);
103*795d594fSAndroid Build Coastguard Worker   }
104*795d594fSAndroid Build Coastguard Worker 
$noinline$returnLong()105*795d594fSAndroid Build Coastguard Worker   public static long $noinline$returnLong() {
106*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
107*795d594fSAndroid Build Coastguard Worker     // already JITted, skip the wait for OSR code.
108*795d594fSAndroid Build Coastguard Worker     boolean interpreting = isInInterpreter("$noinline$returnLong");
109*795d594fSAndroid Build Coastguard Worker     int i = 0;
110*795d594fSAndroid Build Coastguard Worker     for (; i < 400000; ++i) {
111*795d594fSAndroid Build Coastguard Worker     }
112*795d594fSAndroid Build Coastguard Worker     if (interpreting) {
113*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$returnLong")) {}
114*795d594fSAndroid Build Coastguard Worker     }
115*795d594fSAndroid Build Coastguard Worker     System.out.println(i);
116*795d594fSAndroid Build Coastguard Worker     return 0xFFFF000000001111L;
117*795d594fSAndroid Build Coastguard Worker   }
118*795d594fSAndroid Build Coastguard Worker 
$noinline$deopt()119*795d594fSAndroid Build Coastguard Worker   public static void $noinline$deopt() {
120*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
121*795d594fSAndroid Build Coastguard Worker     // already JITted, skip the wait for OSR code.
122*795d594fSAndroid Build Coastguard Worker     boolean interpreting = isInInterpreter("$noinline$deopt");
123*795d594fSAndroid Build Coastguard Worker     int i = 0;
124*795d594fSAndroid Build Coastguard Worker     for (; i < 100000; ++i) {
125*795d594fSAndroid Build Coastguard Worker     }
126*795d594fSAndroid Build Coastguard Worker     if (interpreting) {
127*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$deopt")) {}
128*795d594fSAndroid Build Coastguard Worker     }
129*795d594fSAndroid Build Coastguard Worker     DeoptimizationController.startDeoptimization();
130*795d594fSAndroid Build Coastguard Worker   }
131*795d594fSAndroid Build Coastguard Worker 
$noinline$inlineCache(Main m, boolean isSecondInvocation)132*795d594fSAndroid Build Coastguard Worker   public static Class<?> $noinline$inlineCache(Main m, boolean isSecondInvocation) {
133*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
134*795d594fSAndroid Build Coastguard Worker     // already JITted, just return the expected value.
135*795d594fSAndroid Build Coastguard Worker     if (!isInInterpreter("$noinline$inlineCache")) {
136*795d594fSAndroid Build Coastguard Worker       return SubMain.class;
137*795d594fSAndroid Build Coastguard Worker     }
138*795d594fSAndroid Build Coastguard Worker 
139*795d594fSAndroid Build Coastguard Worker     ensureHasProfilingInfo("$noinline$inlineCache");
140*795d594fSAndroid Build Coastguard Worker 
141*795d594fSAndroid Build Coastguard Worker     // Ensure that we have OSR code to jump to.
142*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
143*795d594fSAndroid Build Coastguard Worker       ensureHasOsrCode("$noinline$inlineCache");
144*795d594fSAndroid Build Coastguard Worker     }
145*795d594fSAndroid Build Coastguard Worker 
146*795d594fSAndroid Build Coastguard Worker     // This call will be optimized in the OSR compiled code
147*795d594fSAndroid Build Coastguard Worker     // to check and deoptimize if m is not of type 'Main'.
148*795d594fSAndroid Build Coastguard Worker     Main other = m.inlineCache();
149*795d594fSAndroid Build Coastguard Worker 
150*795d594fSAndroid Build Coastguard Worker     // Jump to OSR compiled code. The second run
151*795d594fSAndroid Build Coastguard Worker     // of this method will have 'm' as a SubMain, and the compiled
152*795d594fSAndroid Build Coastguard Worker     // code we are jumping to will have wrongly optimize other as being a
153*795d594fSAndroid Build Coastguard Worker     // 'Main'.
154*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
155*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$inlineCache")) {}
156*795d594fSAndroid Build Coastguard Worker     }
157*795d594fSAndroid Build Coastguard Worker 
158*795d594fSAndroid Build Coastguard Worker     // We used to wrongly optimize this call and assume 'other' was a 'Main'.
159*795d594fSAndroid Build Coastguard Worker     return other.returnClass();
160*795d594fSAndroid Build Coastguard Worker   }
161*795d594fSAndroid Build Coastguard Worker 
$noinline$inlineCache2(Main m, boolean isSecondInvocation)162*795d594fSAndroid Build Coastguard Worker   public static Class<?> $noinline$inlineCache2(Main m, boolean isSecondInvocation) {
163*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
164*795d594fSAndroid Build Coastguard Worker     // already JITted, just return the expected value.
165*795d594fSAndroid Build Coastguard Worker     if (!isInInterpreter("$noinline$inlineCache2")) {
166*795d594fSAndroid Build Coastguard Worker       return SubMain.class;
167*795d594fSAndroid Build Coastguard Worker     }
168*795d594fSAndroid Build Coastguard Worker 
169*795d594fSAndroid Build Coastguard Worker     ensureHasProfilingInfo("$noinline$inlineCache2");
170*795d594fSAndroid Build Coastguard Worker 
171*795d594fSAndroid Build Coastguard Worker     // Ensure that we have OSR code to jump to.
172*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
173*795d594fSAndroid Build Coastguard Worker       ensureHasOsrCode("$noinline$inlineCache2");
174*795d594fSAndroid Build Coastguard Worker     }
175*795d594fSAndroid Build Coastguard Worker 
176*795d594fSAndroid Build Coastguard Worker     // This call will be optimized in the OSR compiled code
177*795d594fSAndroid Build Coastguard Worker     // to check and deoptimize if m is not of type 'Main'.
178*795d594fSAndroid Build Coastguard Worker     Main other = m.inlineCache2();
179*795d594fSAndroid Build Coastguard Worker 
180*795d594fSAndroid Build Coastguard Worker     // Jump to OSR compiled code. The second run
181*795d594fSAndroid Build Coastguard Worker     // of this method will have 'm' as a SubMain, and the compiled
182*795d594fSAndroid Build Coastguard Worker     // code we are jumping to will have wrongly optimize other as being null.
183*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
184*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$inlineCache2")) {}
185*795d594fSAndroid Build Coastguard Worker     }
186*795d594fSAndroid Build Coastguard Worker 
187*795d594fSAndroid Build Coastguard Worker     // We used to wrongly optimize this code and assume 'other' was always null.
188*795d594fSAndroid Build Coastguard Worker     return (other == null) ? null : other.returnClass();
189*795d594fSAndroid Build Coastguard Worker   }
190*795d594fSAndroid Build Coastguard Worker 
$noinline$inlineCache3(Main m, boolean isSecondInvocation)191*795d594fSAndroid Build Coastguard Worker   public static Class<?> $noinline$inlineCache3(Main m, boolean isSecondInvocation) {
192*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
193*795d594fSAndroid Build Coastguard Worker     // already JITted, just return the expected value.
194*795d594fSAndroid Build Coastguard Worker     if (!isInInterpreter("$noinline$inlineCache3")) {
195*795d594fSAndroid Build Coastguard Worker       return null;
196*795d594fSAndroid Build Coastguard Worker     }
197*795d594fSAndroid Build Coastguard Worker 
198*795d594fSAndroid Build Coastguard Worker     ensureHasProfilingInfo("$noinline$inlineCache3");
199*795d594fSAndroid Build Coastguard Worker 
200*795d594fSAndroid Build Coastguard Worker     // Ensure that we have OSR code to jump to.
201*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
202*795d594fSAndroid Build Coastguard Worker       ensureHasOsrCode("$noinline$inlineCache3");
203*795d594fSAndroid Build Coastguard Worker     }
204*795d594fSAndroid Build Coastguard Worker 
205*795d594fSAndroid Build Coastguard Worker     // This call will be optimized in the OSR compiled code
206*795d594fSAndroid Build Coastguard Worker     // to check and deoptimize if m is not of type 'Main'.
207*795d594fSAndroid Build Coastguard Worker     Main other = m.inlineCache3();
208*795d594fSAndroid Build Coastguard Worker 
209*795d594fSAndroid Build Coastguard Worker     // Jump to OSR compiled code. The second run
210*795d594fSAndroid Build Coastguard Worker     // of this method will have 'm' as a SubMain, and the compiled
211*795d594fSAndroid Build Coastguard Worker     // code we are jumping to will have wrongly optimize other as being null.
212*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
213*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$inlineCache3")) {}
214*795d594fSAndroid Build Coastguard Worker     }
215*795d594fSAndroid Build Coastguard Worker 
216*795d594fSAndroid Build Coastguard Worker     // We used to wrongly optimize this code and assume 'other' was always null.
217*795d594fSAndroid Build Coastguard Worker     return (other == null) ? null : other.returnClass();
218*795d594fSAndroid Build Coastguard Worker   }
219*795d594fSAndroid Build Coastguard Worker 
inlineCache()220*795d594fSAndroid Build Coastguard Worker   public Main inlineCache() {
221*795d594fSAndroid Build Coastguard Worker     return new Main();
222*795d594fSAndroid Build Coastguard Worker   }
223*795d594fSAndroid Build Coastguard Worker 
inlineCache2()224*795d594fSAndroid Build Coastguard Worker   public Main inlineCache2() {
225*795d594fSAndroid Build Coastguard Worker     return null;
226*795d594fSAndroid Build Coastguard Worker   }
227*795d594fSAndroid Build Coastguard Worker 
inlineCache3()228*795d594fSAndroid Build Coastguard Worker   public Main inlineCache3() {
229*795d594fSAndroid Build Coastguard Worker     return null;
230*795d594fSAndroid Build Coastguard Worker   }
231*795d594fSAndroid Build Coastguard Worker 
returnClass()232*795d594fSAndroid Build Coastguard Worker   public Class<?> returnClass() {
233*795d594fSAndroid Build Coastguard Worker     return Main.class;
234*795d594fSAndroid Build Coastguard Worker   }
235*795d594fSAndroid Build Coastguard Worker 
otherInlineCache()236*795d594fSAndroid Build Coastguard Worker   public void otherInlineCache() {
237*795d594fSAndroid Build Coastguard Worker     return;
238*795d594fSAndroid Build Coastguard Worker   }
239*795d594fSAndroid Build Coastguard Worker 
$noinline$stackOverflow(Main m, boolean isSecondInvocation)240*795d594fSAndroid Build Coastguard Worker   public static void $noinline$stackOverflow(Main m, boolean isSecondInvocation) {
241*795d594fSAndroid Build Coastguard Worker     // If we are running in non-JIT mode, or were unlucky enough to get this method
242*795d594fSAndroid Build Coastguard Worker     // already JITted, just return the expected value.
243*795d594fSAndroid Build Coastguard Worker     if (!isInInterpreter("$noinline$stackOverflow")) {
244*795d594fSAndroid Build Coastguard Worker       return;
245*795d594fSAndroid Build Coastguard Worker     }
246*795d594fSAndroid Build Coastguard Worker 
247*795d594fSAndroid Build Coastguard Worker     // We need a ProfilingInfo object to populate the 'otherInlineCache' call.
248*795d594fSAndroid Build Coastguard Worker     ensureHasProfilingInfo("$noinline$stackOverflow");
249*795d594fSAndroid Build Coastguard Worker 
250*795d594fSAndroid Build Coastguard Worker     if (isSecondInvocation) {
251*795d594fSAndroid Build Coastguard Worker       // Ensure we have an OSR code and we jump to it.
252*795d594fSAndroid Build Coastguard Worker       while (!isInOsrCode("$noinline$stackOverflow")) {}
253*795d594fSAndroid Build Coastguard Worker     }
254*795d594fSAndroid Build Coastguard Worker 
255*795d594fSAndroid Build Coastguard Worker     for (int i = 0; i < (isSecondInvocation ? 10000000 : 1); ++i) {
256*795d594fSAndroid Build Coastguard Worker       // The first invocation of $noinline$stackOverflow will populate the inline
257*795d594fSAndroid Build Coastguard Worker       // cache with Main. The second invocation of the method, will see a SubMain
258*795d594fSAndroid Build Coastguard Worker       // and will therefore trigger deoptimization.
259*795d594fSAndroid Build Coastguard Worker       m.otherInlineCache();
260*795d594fSAndroid Build Coastguard Worker     }
261*795d594fSAndroid Build Coastguard Worker   }
262*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$testOsrInlineLoop(String[] args)263*795d594fSAndroid Build Coastguard Worker   public static void $opt$noinline$testOsrInlineLoop(String[] args) {
264*795d594fSAndroid Build Coastguard Worker     // Regression test for inlining a method with a loop to a method without a loop in OSR mode.
265*795d594fSAndroid Build Coastguard Worker     assertIntEquals(12, $opt$inline$testRemoveSuspendCheck(12, 5));
266*795d594fSAndroid Build Coastguard Worker     // Since we cannot have a loop directly in this method, we need to force the OSR
267*795d594fSAndroid Build Coastguard Worker     // compilation from native code.
268*795d594fSAndroid Build Coastguard Worker     ensureHasProfilingInfo("$opt$noinline$testOsrInlineLoop");
269*795d594fSAndroid Build Coastguard Worker     ensureHasOsrCode("$opt$noinline$testOsrInlineLoop");
270*795d594fSAndroid Build Coastguard Worker   }
271*795d594fSAndroid Build Coastguard Worker 
$opt$inline$testRemoveSuspendCheck(int x, int y)272*795d594fSAndroid Build Coastguard Worker   public static int $opt$inline$testRemoveSuspendCheck(int x, int y) {
273*795d594fSAndroid Build Coastguard Worker     // For this test we need an inlined loop and have DCE re-run loop analysis
274*795d594fSAndroid Build Coastguard Worker     // after inlining.
275*795d594fSAndroid Build Coastguard Worker     while (y > 0) {
276*795d594fSAndroid Build Coastguard Worker       while ($opt$inline$inlineFalse() || !$opt$inline$inlineTrue()) {
277*795d594fSAndroid Build Coastguard Worker         x++;
278*795d594fSAndroid Build Coastguard Worker       }
279*795d594fSAndroid Build Coastguard Worker       y--;
280*795d594fSAndroid Build Coastguard Worker     }
281*795d594fSAndroid Build Coastguard Worker     return x;
282*795d594fSAndroid Build Coastguard Worker   }
283*795d594fSAndroid Build Coastguard Worker 
$opt$inline$inlineTrue()284*795d594fSAndroid Build Coastguard Worker   public static boolean $opt$inline$inlineTrue() {
285*795d594fSAndroid Build Coastguard Worker     return true;
286*795d594fSAndroid Build Coastguard Worker   }
287*795d594fSAndroid Build Coastguard Worker 
$opt$inline$inlineFalse()288*795d594fSAndroid Build Coastguard Worker   public static boolean $opt$inline$inlineFalse() {
289*795d594fSAndroid Build Coastguard Worker     return false;
290*795d594fSAndroid Build Coastguard Worker   }
291*795d594fSAndroid Build Coastguard Worker 
assertIntEquals(int expected, int result)292*795d594fSAndroid Build Coastguard Worker   public static void assertIntEquals(int expected, int result) {
293*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
294*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
295*795d594fSAndroid Build Coastguard Worker     }
296*795d594fSAndroid Build Coastguard Worker   }
297*795d594fSAndroid Build Coastguard Worker 
isInOsrCode(String methodName)298*795d594fSAndroid Build Coastguard Worker   public static native boolean isInOsrCode(String methodName);
isInInterpreter(String methodName)299*795d594fSAndroid Build Coastguard Worker   public static native boolean isInInterpreter(String methodName);
ensureHasProfilingInfo(String methodName)300*795d594fSAndroid Build Coastguard Worker   public static void ensureHasProfilingInfo(String methodName) {
301*795d594fSAndroid Build Coastguard Worker     ensureJitBaselineCompiled(Main.class, methodName);
302*795d594fSAndroid Build Coastguard Worker   }
ensureHasOsrCode(String methodName)303*795d594fSAndroid Build Coastguard Worker   public static native void ensureHasOsrCode(String methodName);
ensureJitBaselineCompiled(Class<?> cls, String methodName)304*795d594fSAndroid Build Coastguard Worker   public static native void ensureJitBaselineCompiled(Class<?> cls, String methodName);
305*795d594fSAndroid Build Coastguard Worker }
306*795d594fSAndroid Build Coastguard Worker 
307*795d594fSAndroid Build Coastguard Worker class SubMain extends Main {
returnClass()308*795d594fSAndroid Build Coastguard Worker   public Class<?> returnClass() {
309*795d594fSAndroid Build Coastguard Worker     return SubMain.class;
310*795d594fSAndroid Build Coastguard Worker   }
311*795d594fSAndroid Build Coastguard Worker 
inlineCache()312*795d594fSAndroid Build Coastguard Worker   public Main inlineCache() {
313*795d594fSAndroid Build Coastguard Worker     return new SubMain();
314*795d594fSAndroid Build Coastguard Worker   }
315*795d594fSAndroid Build Coastguard Worker 
inlineCache2()316*795d594fSAndroid Build Coastguard Worker   public Main inlineCache2() {
317*795d594fSAndroid Build Coastguard Worker     return new SubMain();
318*795d594fSAndroid Build Coastguard Worker   }
319*795d594fSAndroid Build Coastguard Worker 
otherInlineCache()320*795d594fSAndroid Build Coastguard Worker   public void otherInlineCache() {
321*795d594fSAndroid Build Coastguard Worker     return;
322*795d594fSAndroid Build Coastguard Worker   }
323*795d594fSAndroid Build Coastguard Worker }
324