1# Copyright (C) 2016 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15.class public LTest; 16 17.super Ljava/lang/Object; 18 19.method public static test([I)I 20 .locals 2 21 const/4 v0, 0 22 :try1_begin 23 array-length v1, p0 24 :try1_end 25 add-int/lit8 v0, v1, -1 26 :try2_begin 27 aget v0, p0, v0 28 :try2_end 29 :end 30 return v0 31 32 :catch_all 33 # Regression test for bug 32545860: 34 # SimplifyIfs() would have redirected exception handler edges leading here. 35 # Note: There is no move-exception here to prevent matching the SimplifyIfs() pattern. 36 if-eqz v0, :is_zero 37 const/4 v0, -1 38 goto :end 39 :is_zero 40 const/4 v0, -2 41 goto :end 42 43 .catchall {:try1_begin .. :try1_end } :catch_all 44 .catchall {:try2_begin .. :try2_end } :catch_all 45.end method 46 47.method public static test2([II)I 48 .locals 3 49 move v0, p1 50 :try_begin 51 array-length v1, p0 52 add-int/lit8 v1, v1, -1 53 add-int/lit8 v0, v0, 1 54 aget v1, p0, v1 55 const/4 v0, 2 56 aget v2, p0, p1 57 const/4 v0, 3 58 :try_end 59 :end 60 return v0 61 62 :catch_all 63 # Regression test for bug 32546110: 64 # SimplifyIfs() would have looked at predecessors of this block based on the indexes 65 # of the catch Phi's inputs. For catch blocks these two arrays are unrelated, so 66 # this caused out-of-range access triggering a DCHECK() in dchecked_vector<>. 67 # Note: There is no move-exception here to prevent matching the SimplifyIfs() pattern. 68 if-eqz v0, :is_zero 69 const/4 v0, -1 70 goto :end 71 :is_zero 72 const/4 v0, -2 73 goto :end 74 75 .catchall {:try_begin .. :try_end } :catch_all 76.end method 77