blob: 7485163314b3969ca6ee908a085590d6c525ff31 [file] [log] [blame]
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +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
17public class Main {
18 public static void main(String[] args) {
19 System.loadLibrary(args[0]);
20 if ($noinline$returnInt() != 53) {
21 throw new Error("Unexpected return value");
22 }
23 if ($noinline$returnFloat() != 42.2f) {
24 throw new Error("Unexpected return value");
25 }
26 if ($noinline$returnDouble() != Double.longBitsToDouble(0xF000000000001111L)) {
27 throw new Error("Unexpected return value ");
28 }
29 if ($noinline$returnLong() != 0xFFFF000000001111L) {
30 throw new Error("Unexpected return value");
31 }
32
33 try {
34 $noinline$deopt();
35 } catch (Exception e) {}
36 }
37
38 public static int $noinline$returnInt() {
39 if (doThrow) throw new Error("");
40 int i = 0;
41 for (; i < 100000000; ++i) {
42 }
43 while (!ensureInOsrCode()) {}
44 System.out.println(i);
45 return 53;
46 }
47
48 public static float $noinline$returnFloat() {
49 if (doThrow) throw new Error("");
50 int i = 0;
51 for (; i < 200000000; ++i) {
52 }
53 while (!ensureInOsrCode()) {}
54 System.out.println(i);
55 return 42.2f;
56 }
57
58 public static double $noinline$returnDouble() {
59 if (doThrow) throw new Error("");
60 int i = 0;
61 for (; i < 300000000; ++i) {
62 }
63 while (!ensureInOsrCode()) {}
64 System.out.println(i);
65 return Double.longBitsToDouble(0xF000000000001111L);
66 }
67
68 public static long $noinline$returnLong() {
69 if (doThrow) throw new Error("");
70 int i = 1000000;
71 for (; i < 400000000; ++i) {
72 }
73 while (!ensureInOsrCode()) {}
74 System.out.println(i);
75 return 0xFFFF000000001111L;
76 }
77
78 public static void $noinline$deopt() {
79 if (doThrow) throw new Error("");
80 int i = 0;
81 for (; i < 100000000; ++i) {
82 }
83 while (!ensureInOsrCode()) {}
84 DeoptimizationController.startDeoptimization();
85 }
86
87 public static int[] array = new int[4];
88
89 public static native boolean ensureInOsrCode();
90
91 public static boolean doThrow = false;
92}