David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 1 | /* |
Roland Levillain | 6a92a03 | 2015-07-23 12:15:01 +0100 | [diff] [blame^] | 2 | * Copyright (C) 2015 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 | */ |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 16 | |
| 17 | public class Main { |
| 18 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 19 | /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (before) |
| 20 | /// CHECK: NullConstant |
| 21 | /// CHECK-NOT: NullConstant |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 22 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 23 | /// CHECK-START: java.lang.Object Main.InlineNullConstant() inliner (after) |
| 24 | /// CHECK: NullConstant |
| 25 | /// CHECK-NOT: NullConstant |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 26 | |
| 27 | public static Object returnNullConstant(Object x) { |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | public static Object InlineNullConstant() { |
| 32 | return returnNullConstant(null); |
| 33 | } |
| 34 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 35 | /// CHECK-START: int Main.InlineIntConstant() inliner (before) |
| 36 | /// CHECK: IntConstant 42 |
| 37 | /// CHECK-NOT: IntConstant 42 |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 38 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 39 | /// CHECK-START: int Main.InlineIntConstant() inliner (after) |
| 40 | /// CHECK: IntConstant 42 |
| 41 | /// CHECK-NOT: IntConstant 42 |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 42 | |
| 43 | public static int returnIntConstant(int x) { |
| 44 | return 42; |
| 45 | } |
| 46 | |
| 47 | public static int InlineIntConstant() { |
| 48 | return returnIntConstant(42); |
| 49 | } |
| 50 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 51 | /// CHECK-START: long Main.InlineLongConstant() inliner (before) |
| 52 | /// CHECK: LongConstant 42 |
| 53 | /// CHECK-NOT: LongConstant 42 |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 54 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 55 | /// CHECK-START: long Main.InlineLongConstant() inliner (after) |
| 56 | /// CHECK: LongConstant 42 |
| 57 | /// CHECK-NOT: LongConstant 42 |
David Brazdil | 4a3faec | 2015-04-16 10:38:44 +0100 | [diff] [blame] | 58 | |
| 59 | public static long returnLongConstant(long x) { |
| 60 | return 42L; |
| 61 | } |
| 62 | |
| 63 | public static long InlineLongConstant() { |
| 64 | return returnLongConstant(42L); |
| 65 | } |
| 66 | |
| 67 | public static void main(String[] args) { |
| 68 | if (InlineNullConstant() != null) { |
| 69 | throw new Error("Expected null"); |
| 70 | } else if (InlineIntConstant() != 42) { |
| 71 | throw new Error("Expected int 42"); |
| 72 | } else if (InlineLongConstant() != 42L) { |
| 73 | throw new Error("Expected long 42"); |
| 74 | } |
| 75 | } |
| 76 | } |