1# 2# Copyright (C) 2017 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.class public LSmali; 17.super Ljava/lang/Object; 18 19## CHECK-START: int Smali.bufferLen2() builder (after) 20## CHECK-DAG: <<New:l\d+>> NewInstance 21## CHECK-DAG: <<String1:l\d+>> LoadString 22## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<New>>,<<String1>>] intrinsic:StringBufferAppend 23## CHECK-DAG: <<String2:l\d+>> LoadString 24## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<Append1>>,<<String2>>] intrinsic:StringBufferAppend 25## CHECK-DAG: InvokeVirtual [<<Append2>>] intrinsic:StringBufferLength 26.method public static bufferLen2()I 27 .registers 3 28 29 new-instance v0, Ljava/lang/StringBuffer; 30 31 invoke-direct {v0}, Ljava/lang/StringBuffer;-><init>()V 32 33 const-string v1, "x" 34 invoke-virtual {v0, v1}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer; 35 move-result-object v1 36 37 const-string v2, "y" 38 invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer; 39 move-result-object v1 40 41 invoke-virtual {v1}, Ljava/lang/StringBuffer;->length()I 42 move-result v1 43 44 return v1 45.end method 46 47## CHECK-START: int Smali.builderLen2() instruction_simplifier (before) 48## CHECK-DAG: <<New:l\d+>> NewInstance 49## CHECK-DAG: <<String1:l\d+>> LoadString 50## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<New>>,<<String1>>] intrinsic:StringBuilderAppendString 51## CHECK-DAG: <<String2:l\d+>> LoadString 52## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<Append1>>,<<String2>>] intrinsic:StringBuilderAppendString 53## CHECK-DAG: InvokeVirtual [<<Append2>>] intrinsic:StringBuilderLength 54 55## CHECK-START: int Smali.builderLen2() instruction_simplifier (after) 56## CHECK-DAG: <<New:l\d+>> NewInstance 57## CHECK-DAG: <<String1:l\d+>> LoadString 58## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<New>>,<<String1>>] intrinsic:StringBuilderAppendString 59## CHECK-DAG: <<String2:l\d+>> LoadString 60## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<New>>,<<String2>>] intrinsic:StringBuilderAppendString 61## CHECK-DAG: InvokeVirtual [<<New>>] intrinsic:StringBuilderLength 62.method public static builderLen2()I 63 .registers 3 64 65 new-instance v0, Ljava/lang/StringBuilder; 66 67 invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V 68 69 const-string v1, "x" 70 invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; 71 move-result-object v1 72 73 const-string v2, "y" 74 invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; 75 move-result-object v1 76 77 invoke-virtual {v1}, Ljava/lang/StringBuilder;->length()I 78 move-result v1 79 80 return v1 81.end method 82 83## CHECK-START: int Smali.bufferLoopAppender() instruction_simplifier (before) 84## CHECK-DAG: <<New:l\d+>> NewInstance loop:none 85## CHECK-DAG: <<String1:l\d+>> LoadString loop:<<Loop:B\d+>> 86## CHECK-DAG: <<Null1:l\d+>> NullCheck [<<New>>] loop:<<Loop>> 87## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<Null1>>,<<String1>>] intrinsic:StringBufferAppend loop:<<Loop>> 88## CHECK-DAG: <<String2:l\d+>> LoadString loop:<<Loop>> 89## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<Append1>>,<<String2>>] intrinsic:StringBufferAppend loop:<<Loop>> 90## CHECK-DAG: <<String3:l\d+>> LoadString loop:<<Loop>> 91## CHECK-DAG: <<Append3:l\d+>> InvokeVirtual [<<Append2>>,<<String3>>] intrinsic:StringBufferAppend loop:<<Loop>> 92## CHECK-DAG: <<Null4:l\d+>> NullCheck [<<New>>] loop:none 93## CHECK-DAG: InvokeVirtual [<<Null4>>] intrinsic:StringBufferLength loop:none 94 95## CHECK-START: int Smali.bufferLoopAppender() instruction_simplifier (after) 96## CHECK-DAG: <<New:l\d+>> NewInstance loop:none 97## CHECK-DAG: <<String1:l\d+>> LoadString loop:<<Loop:B\d+>> 98## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<New>>,<<String1>>] intrinsic:StringBufferAppend loop:<<Loop>> 99## CHECK-DAG: <<String2:l\d+>> LoadString loop:<<Loop>> 100## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<New>>,<<String2>>] intrinsic:StringBufferAppend loop:<<Loop>> 101## CHECK-DAG: <<String3:l\d+>> LoadString loop:<<Loop>> 102## CHECK-DAG: <<Append3:l\d+>> InvokeVirtual [<<New>>,<<String3>>] intrinsic:StringBufferAppend loop:<<Loop>> 103## CHECK-DAG: InvokeVirtual [<<New>>] intrinsic:StringBufferLength loop:none 104.method public static bufferLoopAppender()I 105 .registers 4 106 107 new-instance v0, Ljava/lang/StringBuffer; 108 109 invoke-direct {v0}, Ljava/lang/StringBuffer;-><init>()V 110 111 const/4 v1, 0x0 112 113 :goto_6 114 const/16 v2, 0xa 115 116 if-ge v1, v2, :cond_1e 117 118 const-string v2, "x" 119 invoke-virtual {v0, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer; 120 move-result-object v2 121 122 const-string v3, "y" 123 invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer; 124 move-result-object v2 125 126 const-string v3, "z" 127 invoke-virtual {v2, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer; 128 129 add-int/lit8 v1, v1, 0x1 130 goto :goto_6 131 132 :cond_1e 133 invoke-virtual {v0}, Ljava/lang/StringBuffer;->length()I 134 135 move-result v2 136 137 return v2 138.end method 139 140## CHECK-START: int Smali.builderLoopAppender() instruction_simplifier (before) 141## CHECK-DAG: <<New:l\d+>> NewInstance loop:none 142## CHECK-DAG: <<String1:l\d+>> LoadString loop:<<Loop:B\d+>> 143## CHECK-DAG: <<Null1:l\d+>> NullCheck [<<New>>] loop:<<Loop>> 144## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<Null1>>,<<String1>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 145## CHECK-DAG: <<String2:l\d+>> LoadString loop:<<Loop>> 146## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<Append1>>,<<String2>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 147## CHECK-DAG: <<String3:l\d+>> LoadString loop:<<Loop>> 148## CHECK-DAG: <<Append3:l\d+>> InvokeVirtual [<<Append2>>,<<String3>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 149## CHECK-DAG: <<Null4:l\d+>> NullCheck [<<New>>] loop:none 150## CHECK-DAG: InvokeVirtual [<<Null4>>] intrinsic:StringBuilderLength loop:none 151 152## CHECK-START: int Smali.builderLoopAppender() instruction_simplifier (after) 153## CHECK-DAG: <<New:l\d+>> NewInstance loop:none 154## CHECK-DAG: <<String1:l\d+>> LoadString loop:<<Loop:B\d+>> 155## CHECK-DAG: <<Append1:l\d+>> InvokeVirtual [<<New>>,<<String1>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 156## CHECK-DAG: <<String2:l\d+>> LoadString loop:<<Loop>> 157## CHECK-DAG: <<Append2:l\d+>> InvokeVirtual [<<New>>,<<String2>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 158## CHECK-DAG: <<String3:l\d+>> LoadString loop:<<Loop>> 159## CHECK-DAG: <<Append3:l\d+>> InvokeVirtual [<<New>>,<<String3>>] intrinsic:StringBuilderAppendString loop:<<Loop>> 160## CHECK-DAG: InvokeVirtual [<<New>>] intrinsic:StringBuilderLength loop:none 161.method public static builderLoopAppender()I 162 .registers 4 163 164 new-instance v0, Ljava/lang/StringBuilder; 165 166 invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V 167 168 const/4 v1, 0x0 169 170 :goto_6 171 const/16 v2, 0xa 172 173 if-ge v1, v2, :cond_1e 174 175 const-string v2, "x" 176 177 invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; 178 move-result-object v2 179 const-string v3, "y" 180 181 invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; 182 move-result-object v2 183 const-string v3, "z" 184 185 invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; 186 add-int/lit8 v1, v1, 0x1 187 188 goto :goto_6 189 190 :cond_1e 191 invoke-virtual {v0}, Ljava/lang/StringBuilder;->length()I 192 193 move-result v2 194 195 return v2 196.end method 197