Home | History | Annotate | Download | only in smali
      1 # Copyright (C) 2015 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 LTestCase;
     16 .super Ljava/lang/Object;
     17 
     18 # Situation:
     19 #  - PhiA: PrimVoid + PrimNot equivalents
     20 #  - PhiB: PrimVoid (PrimVoid PhiA as input)
     21 # DeadPhiHandling:
     22 #  - iterate over blocks in reverse post order
     23 #    - update PrimVoid PhiA to PrimNot
     24 #    - update inputs of PrimNot PhiA
     25 #    - set type of PhiB
     26 #  - left with two PrimNot equivalents of PhiA
     27 
     28 .method public static testCase_ReversePostOrder(IILjava/lang/Object;)V
     29   .registers 5
     30 
     31   # v0 - Phi A
     32   # v1 - Phi B
     33   # p0 - int arg1
     34   # p1 - int arg2
     35   # p2 - ref arg3
     36 
     37   if-nez p0, :else1
     38   :then1
     39     if-nez p1, :else2
     40     :then2
     41       const/4 v1, 0x0
     42       goto :merge2
     43 
     44     :else2
     45       move-object v1, p2
     46       goto :merge2
     47 
     48     :merge2
     49       # PhiA [null, arg3]
     50       move-object v0, v1                                 # create PrimNot PhiA equivalent
     51       invoke-static {}, Ljava/lang/System;->nanoTime()J  # env use of both PhiA equivalents
     52       goto :merge1
     53 
     54   :else1
     55     move-object v0, p2
     56     goto :merge1
     57 
     58   :merge1
     59     # PhiB [PhiA, arg3]
     60     invoke-static {}, Ljava/lang/System;->nanoTime()J    # env use of PhiB
     61 
     62   return-void
     63 .end method
     64 
     65 # Situation:
     66 #  - PhiA: PrimVoid + PrimNot (PrimInt inputs)
     67 #  - PhiB: PrimVoid + PrimNot (PrimInt inputs)
     68 #  - PhiC: PrimVoid only
     69 # DeadPhiHandling:
     70 #  - iterate over blocks in reverse post order
     71 #    - add both PhiAs to worklist, set PrimVoid PhiA to PrimInt
     72 #    - update inputs of PrimNot PhiB ; add PrimNot PhiA to worklist
     73 #    - update PhiC to PrimNot
     74 #  - start processing worklist
     75 #    - PrimNot PhiA: update inputs, no equivalent created
     76 #    - PrimInt PhiA: update inputs, set to PrimNot, use instead of PrimNot PhiA
     77 #    - add PhiBs to worklist as users of PhiA
     78 #    - PrimInt PhiB: set type to PrimNot, equivalent live and in worklist
     79 
     80 .method public static testCase_FixPointIteration(IILjava/lang/Object;Ljava/lang/Object;)V
     81   .registers 6
     82 
     83   # v0 - Phi A, C
     84   # v1 - Phi B
     85   # p0 - int arg1
     86   # p1 - int arg2
     87   # p2 - ref arg3
     88   # p3 - ref arg4
     89 
     90   const/4 v0, 0x0
     91 
     92   :loop_header
     93   # PhiA [null, PhiC] for v0
     94 
     95   if-eqz p0, :else1
     96   :then1
     97     const/4 v1, 0x0
     98     goto :merge1
     99   :else1
    100     move-object v1, v0                                   # create PrimNot equivalent of PhiA
    101     invoke-static {}, Ljava/lang/System;->nanoTime()J    # env use of both PhiA equivalents
    102     goto :merge1
    103   :merge1
    104   # PhiB [null, PhiA] for v1
    105 
    106   move-object v0, v1                                     # creates PrimNot equivalent of PhiB
    107   invoke-static {}, Ljava/lang/System;->nanoTime()J      # env use of both PhiB equivalents
    108 
    109   if-eqz p1, :else2
    110   :then2
    111     move-object v0, p2
    112     goto :merge2
    113   :else2
    114     move-object v0, p3
    115     goto :merge2
    116   :merge2
    117   # PhiC [arg3, arg4] for v0, second input of PhiA
    118 
    119   if-eqz p1, :loop_header
    120   return-void
    121 .end method
    122