Home | History | Annotate | Download | only in smali
      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 # Checker test to make sure the only inlined instruction is SubMain.bar.
     19 
     20 ## CHECK-START: int SmaliTests.$opt$noinline$foo(Main) inliner (after)
     21 ## CHECK-DAG:                InvokeVirtual method_name:Main.foo
     22 ## CHECK-DAG: <<Const:i\d+>> IntConstant 3
     23 ## CHECK:                    begin_block
     24 ## CHECK:                    BoundType klass:SubMain
     25 ## CHECK:                    Return [<<Const>>]
     26 ## CHECK-NOT:                begin_block
     27 ## CHECK:                    end_block
     28 .method public static $opt$noinline$foo(LMain;)I
     29     .registers 3
     30     .param p0, "o"    # LMain;
     31     .prologue
     32 
     33     # if (doThrow) { throw new Error(); }
     34     sget-boolean v0, LMain;->doThrow:Z
     35     if-eqz v0, :doThrow_false
     36     new-instance v0, Ljava/lang/Error;
     37     invoke-direct {v0}, Ljava/lang/Error;-><init>()V
     38     throw v0
     39 
     40   :doThrow_false
     41     # if (o.getClass() == Main.class || o.getClass() != SubMain.class)
     42     invoke-virtual {p0}, LMain;->getClass()Ljava/lang/Class;
     43     move-result-object v0
     44     const-class v1, LMain;
     45     if-eq v0, v1, :class_is_Main_and_not_SubMain
     46 
     47     invoke-virtual {p0}, LMain;->getClass()Ljava/lang/Class;
     48     move-result-object v0
     49     const-class v1, LSubMain;
     50     if-eq v0, v1, :else
     51 
     52   :class_is_Main_and_not_SubMain
     53     # return o.foo()
     54     invoke-virtual {p0}, LMain;->foo()I
     55     move-result v0
     56     return v0
     57 
     58   :else
     59     # return o.bar()
     60     invoke-virtual {p0}, LMain;->bar()I
     61     move-result v0
     62     return v0
     63 .end method
     64 
     65 
     66