1 # Copyright (C) 2017 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 LSmaliTests; 16 .super Ljava/lang/Object; 17 18 ## CHECK-START: char SmaliTests.stringCharAtCatch(java.lang.String, int) instruction_simplifier (before) 19 ## CHECK-DAG: <<Char:c\d+>> InvokeVirtual intrinsic:StringCharAt 20 ## CHECK-DAG: Return [<<Char>>] 21 22 ## CHECK-START: char SmaliTests.stringCharAtCatch(java.lang.String, int) instruction_simplifier (after) 23 ## CHECK-DAG: <<String:l\d+>> ParameterValue 24 ## CHECK-DAG: <<Pos:i\d+>> ParameterValue 25 ## CHECK-DAG: <<NullCk:l\d+>> NullCheck [<<String>>] 26 ## CHECK-DAG: <<Length:i\d+>> ArrayLength [<<NullCk>>] is_string_length:true 27 ## CHECK-DAG: <<Bounds:i\d+>> BoundsCheck [<<Pos>>,<<Length>>] is_string_char_at:true 28 ## CHECK-DAG: <<Char:c\d+>> ArrayGet [<<NullCk>>,<<Bounds>>] is_string_char_at:true 29 ## CHECK-DAG: Return [<<Char>>] 30 31 ## CHECK-START: char SmaliTests.stringCharAtCatch(java.lang.String, int) instruction_simplifier (after) 32 ## CHECK-NOT: InvokeVirtual intrinsic:StringCharAt 33 .method public static stringCharAtCatch(Ljava/lang/String;I)C 34 .registers 4 35 .param p0, "s" # Ljava/lang/String; 36 .param p1, "pos" # I 37 38 .prologue 39 40 # if (doThrow) { throw new Error(); } 41 sget-boolean v1, LMain;->doThrow:Z 42 if-eqz v1, :doThrow_false 43 new-instance v1, Ljava/lang/Error; 44 invoke-direct {v1}, Ljava/lang/Error;-><init>()V 45 throw v1 46 47 :doThrow_false 48 :try_start 49 # tmp = s.charAt(pos) 50 invoke-virtual {p0, p1}, Ljava/lang/String;->charAt(I)C 51 :try_end 52 .catch Ljava/lang/StringIndexOutOfBoundsException; {:try_start .. :try_end} :catch 53 54 # return tmp 55 move-result v1 56 return v1 57 58 :catch 59 # return '\0' 60 move-exception v0 61 const/4 v1, 0x0 62 return v1 63 .end method 64 65