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