Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
| 17 | public class Main { |
| 18 | public static void main(String[] args) { |
| 19 | if ($opt$inline$returnInt() != 4) { |
| 20 | throw new Error(); |
| 21 | } |
| 22 | |
| 23 | if ($opt$inline$returnParameter(42) != 42) { |
| 24 | throw new Error(); |
| 25 | } |
| 26 | |
| 27 | if ($opt$inline$returnWide() != 12L) { |
| 28 | throw new Error(); |
| 29 | } |
| 30 | |
| 31 | if ($opt$inline$returnWideParameter(0x100000001L) != 0x100000001L) { |
| 32 | throw new Error(); |
| 33 | } |
| 34 | |
| 35 | if ($opt$inline$returnReferenceParameter(Main.class) != Main.class) { |
| 36 | throw new Error(); |
| 37 | } |
| 38 | |
| 39 | $opt$inline$returnVoid(); |
| 40 | $opt$inline$returnVoidWithOneParameter(32); |
| 41 | |
| 42 | if ($opt$inline$returnAdd(42, 1) != 43) { |
| 43 | throw new Error(); |
| 44 | } |
| 45 | |
| 46 | if ($opt$inline$returnSub(42, 1) != 41) { |
| 47 | throw new Error(); |
| 48 | } |
Nicolas Geoffray | 259136f | 2014-12-17 23:21:58 +0000 | [diff] [blame] | 49 | |
| 50 | // Some architectures used to not be able to allocate registers with |
| 51 | // floating point operations. This call is a regression test that we don't |
| 52 | // try inlining methods with floats in it on such architectures. The |
| 53 | // compiler used to crash after inlining a method it cannot allocate |
| 54 | // registers for. |
| 55 | tryInlineFloat(); |
| 56 | } |
| 57 | |
| 58 | public static int tryInlineFloat() { |
| 59 | return useFloatMethod(); |
| 60 | } |
| 61 | |
| 62 | public static float staticFloat = 42.0f; |
| 63 | |
| 64 | public static int useFloatMethod() { |
| 65 | return (int)staticFloat; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | public static int $opt$inline$returnParameter(int a) { |
| 69 | return a; |
| 70 | } |
| 71 | |
| 72 | public static int $opt$inline$returnAdd(int a, int b) { |
| 73 | return a + b; |
| 74 | } |
| 75 | |
| 76 | public static int $opt$inline$returnSub(int a, int b) { |
| 77 | return a - b; |
| 78 | } |
| 79 | |
| 80 | public static int $opt$inline$returnInt() { |
| 81 | return 4; |
| 82 | } |
| 83 | |
| 84 | public static long $opt$inline$returnWideParameter(long a) { |
| 85 | return a; |
| 86 | } |
| 87 | |
| 88 | public static long $opt$inline$returnWide() { |
| 89 | return 12L; |
| 90 | } |
| 91 | |
| 92 | public static Object $opt$inline$returnReferenceParameter(Object o) { |
| 93 | return o; |
| 94 | } |
| 95 | |
| 96 | public static void $opt$inline$returnVoid() { |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | public static void $opt$inline$returnVoidWithOneParameter(int a) { |
| 101 | return; |
| 102 | } |
| 103 | } |