Nicolas Geoffray | 0397163 | 2016-03-17 10:44:24 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | public class Main { |
| 18 | public static Object[] getObjectArray() { return null; } |
| 19 | public static long[] getLongArray() { return null; } |
| 20 | |
| 21 | public static void main(String[] args) { |
| 22 | try { |
| 23 | foo(); |
| 24 | throw new Error("Expected NullPointerException"); |
| 25 | } catch (NullPointerException e) { |
| 26 | // Expected. |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /// CHECK-START: void Main.foo() load_store_elimination (after) |
| 31 | /// CHECK-DAG: <<Null:l\d+>> NullConstant |
| 32 | /// CHECK-DAG: <<Check:l\d+>> NullCheck [<<Null>>] |
| 33 | /// CHECK-DAG: <<Get1:j\d+>> ArrayGet [<<Check>>,{{i\d+}}] |
| 34 | /// CHECK-DAG: <<Get2:l\d+>> ArrayGet [<<Check>>,{{i\d+}}] |
| 35 | public static void foo() { |
| 36 | longField = getLongArray()[0]; |
| 37 | objectField = getObjectArray()[0]; |
| 38 | } |
| 39 | |
| 40 | public static long longField; |
| 41 | public static Object objectField; |
| 42 | } |