David Brazdil | f555258 | 2015-12-27 13:36:12 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | |
| 17 | |
| 18 | public class Main { |
| 19 | |
| 20 | public static Object returnIntArray() { return new int[10]; } |
| 21 | |
| 22 | /// CHECK-START: void Main.boundTypeForMergingPhi() ssa_builder (after) |
| 23 | /// CHECK-DAG: ArraySet [<<NC:l\d+>>,{{i\d+}},{{i\d+}}] |
| 24 | /// CHECK-DAG: <<NC>> NullCheck [<<Phi:l\d+>>] |
| 25 | /// CHECK-DAG: <<Phi>> Phi klass:int[] |
| 26 | |
| 27 | public static void boundTypeForMergingPhi() { |
| 28 | int[] array = new int[20]; |
| 29 | if (array.hashCode() > 5) { |
| 30 | array = (int[]) returnIntArray(); |
| 31 | } |
| 32 | array[0] = 14; |
| 33 | } |
| 34 | |
| 35 | /// CHECK-START: void Main.boundTypeForLoopPhi() ssa_builder (after) |
| 36 | /// CHECK-DAG: ArraySet [<<NC:l\d+>>,{{i\d+}},{{i\d+}}] |
| 37 | /// CHECK-DAG: <<NC>> NullCheck [<<Phi:l\d+>>] |
| 38 | /// CHECK-DAG: <<Phi>> Phi klass:int[] |
| 39 | |
| 40 | public static void boundTypeForLoopPhi() { |
| 41 | int[] array = new int[20]; |
| 42 | int i = 0; |
| 43 | while (i < 4) { |
| 44 | ++i; |
| 45 | array[i] = i; |
| 46 | if (i > 2) { |
| 47 | array = (int[]) returnIntArray(); |
| 48 | } |
| 49 | } |
| 50 | array[0] = 14; |
| 51 | } |
| 52 | |
| 53 | /// CHECK-START: void Main.boundTypeForCatchPhi() ssa_builder (after) |
| 54 | /// CHECK-DAG: ArraySet [<<NC:l\d+>>,{{i\d+}},{{i\d+}}] |
| 55 | /// CHECK-DAG: <<NC>> NullCheck [<<Phi:l\d+>>] |
| 56 | /// CHECK-DAG: <<Phi>> Phi is_catch_phi:true klass:int[] |
| 57 | |
| 58 | public static void boundTypeForCatchPhi() { |
| 59 | int[] array1 = new int[20]; |
| 60 | int[] array2 = (int[]) returnIntArray(); |
| 61 | |
| 62 | int[] catch_phi = array1; |
| 63 | try { |
| 64 | System.nanoTime(); |
| 65 | catch_phi = array2; |
| 66 | System.nanoTime(); |
| 67 | } catch (Throwable ex) { |
| 68 | catch_phi[0] = 14; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public static void main(String[] args) { } |
| 73 | } |