Home | History | Annotate | Download | only in benchmarks
      1 /*
      2  * Copyright 2016 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 
     17 package benchmarks;
     18 
     19 public class InvokeInterface {
     20   static MultiClass multi;
     21 
     22   static {
     23     multi = new MultiClass();
     24   }
     25 
     26   public void timeCall0Concrete(int nreps) {
     27     MultiClass m = multi;
     28     for (int i = 0; i < nreps; i++) {
     29       doCall0Concrete(m);
     30     }
     31   }
     32 
     33   public void timeCall0Interface(int nreps) {
     34     MultiClass m = multi;
     35     for (int i = 0; i < nreps; i++) {
     36       doCall0Interface(m);
     37     }
     38   }
     39 
     40   public void timeCall1Interface(int nreps) {
     41     MultiClass m = multi;
     42     for (int i = 0; i < nreps; i++) {
     43       doCall1Interface(m);
     44     }
     45   }
     46 
     47   public void timeCall2Interface(int nreps) {
     48     MultiClass m = multi;
     49     for (int i = 0; i < nreps; i++) {
     50       doCall2Interface(m);
     51     }
     52   }
     53 
     54   public void timeCall3Interface(int nreps) {
     55     MultiClass m = multi;
     56     for (int i = 0; i < nreps; i++) {
     57       doCall3Interface(m);
     58     }
     59   }
     60 
     61   public void timeCall4Interface(int nreps) {
     62     MultiClass m = multi;
     63     for (int i = 0; i < nreps; i++) {
     64       doCall4Interface(m);
     65     }
     66   }
     67 
     68   public void timeCall5Interface(int nreps) {
     69     MultiClass m = multi;
     70     for (int i = 0; i < nreps; i++) {
     71       doCall5Interface(m);
     72     }
     73   }
     74 
     75   public void timeCall6Interface(int nreps) {
     76     MultiClass m = multi;
     77     for (int i = 0; i < nreps; i++) {
     78       doCall6Interface(m);
     79     }
     80   }
     81 
     82   public void timeCall7Interface(int nreps) {
     83     MultiClass m = multi;
     84     for (int i = 0; i < nreps; i++) {
     85       doCall7Interface(m);
     86     }
     87   }
     88 
     89   public void timeCall8Interface(int nreps) {
     90     MultiClass m = multi;
     91     for (int i = 0; i < nreps; i++) {
     92       doCall8Interface(m);
     93     }
     94   }
     95 
     96   public void timeCall9Interface(int nreps) {
     97     MultiClass m = multi;
     98     for (int i = 0; i < nreps; i++) {
     99       doCall9Interface(m);
    100     }
    101   }
    102 
    103   public void timeCall10Interface(int nreps) {
    104     MultiClass m = multi;
    105     for (int i = 0; i < nreps; i++) {
    106       doCall10Interface(m);
    107     }
    108   }
    109 
    110   public void timeCall11Interface(int nreps) {
    111     MultiClass m = multi;
    112     for (int i = 0; i < nreps; i++) {
    113       doCall11Interface(m);
    114     }
    115   }
    116 
    117   public void timeCall12Interface(int nreps) {
    118     MultiClass m = multi;
    119     for (int i = 0; i < nreps; i++) {
    120       doCall12Interface(m);
    121     }
    122   }
    123 
    124   public void timeCall13Interface(int nreps) {
    125     MultiClass m = multi;
    126     for (int i = 0; i < nreps; i++) {
    127       doCall13Interface(m);
    128     }
    129   }
    130 
    131   public void timeCall14Interface(int nreps) {
    132     MultiClass m = multi;
    133     for (int i = 0; i < nreps; i++) {
    134       doCall14Interface(m);
    135     }
    136   }
    137 
    138   public void timeCall15Interface(int nreps) {
    139     MultiClass m = multi;
    140     for (int i = 0; i < nreps; i++) {
    141       doCall15Interface(m);
    142     }
    143   }
    144 
    145   public void timeCall16Interface(int nreps) {
    146     MultiClass m = multi;
    147     for (int i = 0; i < nreps; i++) {
    148       doCall16Interface(m);
    149     }
    150   }
    151 
    152   public void timeCall17Interface(int nreps) {
    153     MultiClass m = multi;
    154     for (int i = 0; i < nreps; i++) {
    155       doCall17Interface(m);
    156     }
    157   }
    158 
    159   public void timeCall18Interface(int nreps) {
    160     MultiClass m = multi;
    161     for (int i = 0; i < nreps; i++) {
    162       doCall18Interface(m);
    163     }
    164   }
    165 
    166   public void timeCall19Interface(int nreps) {
    167     MultiClass m = multi;
    168     for (int i = 0; i < nreps; i++) {
    169       doCall19Interface(m);
    170     }
    171   }
    172 
    173   public void timeCall20Interface(int nreps) {
    174     MultiClass m = multi;
    175     for (int i = 0; i < nreps; i++) {
    176       doCall20Interface(m);
    177     }
    178   }
    179 
    180   public void timeCall21Interface(int nreps) {
    181     MultiClass m = multi;
    182     for (int i = 0; i < nreps; i++) {
    183       doCall21Interface(m);
    184     }
    185   }
    186 
    187   public void timeCall22Interface(int nreps) {
    188     MultiClass m = multi;
    189     for (int i = 0; i < nreps; i++) {
    190       doCall22Interface(m);
    191     }
    192   }
    193 
    194   public void timeCall23Interface(int nreps) {
    195     MultiClass m = multi;
    196     for (int i = 0; i < nreps; i++) {
    197       doCall23Interface(m);
    198     }
    199   }
    200 
    201   public void timeCall24Interface(int nreps) {
    202     MultiClass m = multi;
    203     for (int i = 0; i < nreps; i++) {
    204       doCall24Interface(m);
    205     }
    206   }
    207 
    208   public void timeCall25Interface(int nreps) {
    209     MultiClass m = multi;
    210     for (int i = 0; i < nreps; i++) {
    211       doCall25Interface(m);
    212     }
    213   }
    214 
    215   public void timeCall26Interface(int nreps) {
    216     MultiClass m = multi;
    217     for (int i = 0; i < nreps; i++) {
    218       doCall26Interface(m);
    219     }
    220   }
    221 
    222   public void timeCall27Interface(int nreps) {
    223     MultiClass m = multi;
    224     for (int i = 0; i < nreps; i++) {
    225       doCall27Interface(m);
    226     }
    227   }
    228 
    229   public void timeCall28Interface(int nreps) {
    230     MultiClass m = multi;
    231     for (int i = 0; i < nreps; i++) {
    232       doCall28Interface(m);
    233     }
    234   }
    235 
    236   public void timeCall29Interface(int nreps) {
    237     MultiClass m = multi;
    238     for (int i = 0; i < nreps; i++) {
    239       doCall29Interface(m);
    240     }
    241   }
    242 
    243   public void timeCall30Interface(int nreps) {
    244     MultiClass m = multi;
    245     for (int i = 0; i < nreps; i++) {
    246       doCall30Interface(m);
    247     }
    248   }
    249 
    250   public void timeCall31Interface(int nreps) {
    251     MultiClass m = multi;
    252     for (int i = 0; i < nreps; i++) {
    253       doCall31Interface(m);
    254     }
    255   }
    256 
    257   public void timeCall32Interface(int nreps) {
    258     MultiClass m = multi;
    259     for (int i = 0; i < nreps; i++) {
    260       doCall32Interface(m);
    261     }
    262   }
    263 
    264   public void timeCall33Interface(int nreps) {
    265     MultiClass m = multi;
    266     for (int i = 0; i < nreps; i++) {
    267       doCall33Interface(m);
    268     }
    269   }
    270 
    271   public void timeCall34Interface(int nreps) {
    272     MultiClass m = multi;
    273     for (int i = 0; i < nreps; i++) {
    274       doCall34Interface(m);
    275     }
    276   }
    277 
    278   public void timeCall35Interface(int nreps) {
    279     MultiClass m = multi;
    280     for (int i = 0; i < nreps; i++) {
    281       doCall35Interface(m);
    282     }
    283   }
    284 
    285   public void timeCall36Interface(int nreps) {
    286     MultiClass m = multi;
    287     for (int i = 0; i < nreps; i++) {
    288       doCall36Interface(m);
    289     }
    290   }
    291 
    292   public void timeCall37Interface(int nreps) {
    293     MultiClass m = multi;
    294     for (int i = 0; i < nreps; i++) {
    295       doCall37Interface(m);
    296     }
    297   }
    298 
    299   public void timeCall38Interface(int nreps) {
    300     MultiClass m = multi;
    301     for (int i = 0; i < nreps; i++) {
    302       doCall38Interface(m);
    303     }
    304   }
    305 
    306   public void timeCall39Interface(int nreps) {
    307     MultiClass m = multi;
    308     for (int i = 0; i < nreps; i++) {
    309       doCall39Interface(m);
    310     }
    311   }
    312 
    313   public void timeCall40Interface(int nreps) {
    314     MultiClass m = multi;
    315     for (int i = 0; i < nreps; i++) {
    316       doCall40Interface(m);
    317     }
    318   }
    319 
    320   public void timeCall41Interface(int nreps) {
    321     MultiClass m = multi;
    322     for (int i = 0; i < nreps; i++) {
    323       doCall41Interface(m);
    324     }
    325   }
    326 
    327   public void timeCall42Interface(int nreps) {
    328     MultiClass m = multi;
    329     for (int i = 0; i < nreps; i++) {
    330       doCall42Interface(m);
    331     }
    332   }
    333 
    334   public void timeCall43Interface(int nreps) {
    335     MultiClass m = multi;
    336     for (int i = 0; i < nreps; i++) {
    337       doCall43Interface(m);
    338     }
    339   }
    340 
    341   public void timeCall44Interface(int nreps) {
    342     MultiClass m = multi;
    343     for (int i = 0; i < nreps; i++) {
    344       doCall44Interface(m);
    345     }
    346   }
    347 
    348   public void timeCall45Interface(int nreps) {
    349     MultiClass m = multi;
    350     for (int i = 0; i < nreps; i++) {
    351       doCall45Interface(m);
    352     }
    353   }
    354 
    355   public void timeCall46Interface(int nreps) {
    356     MultiClass m = multi;
    357     for (int i = 0; i < nreps; i++) {
    358       doCall46Interface(m);
    359     }
    360   }
    361 
    362   public void timeCall47Interface(int nreps) {
    363     MultiClass m = multi;
    364     for (int i = 0; i < nreps; i++) {
    365       doCall47Interface(m);
    366     }
    367   }
    368 
    369   public void timeCall48Interface(int nreps) {
    370     MultiClass m = multi;
    371     for (int i = 0; i < nreps; i++) {
    372       doCall48Interface(m);
    373     }
    374   }
    375 
    376   public void timeCall49Interface(int nreps) {
    377     MultiClass m = multi;
    378     for (int i = 0; i < nreps; i++) {
    379       doCall49Interface(m);
    380     }
    381   }
    382 
    383   public void timeCall50Interface(int nreps) {
    384     MultiClass m = multi;
    385     for (int i = 0; i < nreps; i++) {
    386       doCall50Interface(m);
    387     }
    388   }
    389 
    390   public void timeCall51Interface(int nreps) {
    391     MultiClass m = multi;
    392     for (int i = 0; i < nreps; i++) {
    393       doCall51Interface(m);
    394     }
    395   }
    396 
    397   public void timeCall52Interface(int nreps) {
    398     MultiClass m = multi;
    399     for (int i = 0; i < nreps; i++) {
    400       doCall52Interface(m);
    401     }
    402   }
    403 
    404   public void timeCall53Interface(int nreps) {
    405     MultiClass m = multi;
    406     for (int i = 0; i < nreps; i++) {
    407       doCall53Interface(m);
    408     }
    409   }
    410 
    411   public void timeCall54Interface(int nreps) {
    412     MultiClass m = multi;
    413     for (int i = 0; i < nreps; i++) {
    414       doCall54Interface(m);
    415     }
    416   }
    417 
    418   public void timeCall55Interface(int nreps) {
    419     MultiClass m = multi;
    420     for (int i = 0; i < nreps; i++) {
    421       doCall55Interface(m);
    422     }
    423   }
    424 
    425   public void timeCall56Interface(int nreps) {
    426     MultiClass m = multi;
    427     for (int i = 0; i < nreps; i++) {
    428       doCall56Interface(m);
    429     }
    430   }
    431 
    432   public void timeCall57Interface(int nreps) {
    433     MultiClass m = multi;
    434     for (int i = 0; i < nreps; i++) {
    435       doCall57Interface(m);
    436     }
    437   }
    438 
    439   public void timeCall58Interface(int nreps) {
    440     MultiClass m = multi;
    441     for (int i = 0; i < nreps; i++) {
    442       doCall58Interface(m);
    443     }
    444   }
    445 
    446   public void timeCall59Interface(int nreps) {
    447     MultiClass m = multi;
    448     for (int i = 0; i < nreps; i++) {
    449       doCall59Interface(m);
    450     }
    451   }
    452 
    453   public void timeCall60Interface(int nreps) {
    454     MultiClass m = multi;
    455     for (int i = 0; i < nreps; i++) {
    456       doCall60Interface(m);
    457     }
    458   }
    459 
    460   public void timeCall61Interface(int nreps) {
    461     MultiClass m = multi;
    462     for (int i = 0; i < nreps; i++) {
    463       doCall61Interface(m);
    464     }
    465   }
    466 
    467   public void timeCall62Interface(int nreps) {
    468     MultiClass m = multi;
    469     for (int i = 0; i < nreps; i++) {
    470       doCall62Interface(m);
    471     }
    472   }
    473 
    474   public void timeCall63Interface(int nreps) {
    475     MultiClass m = multi;
    476     for (int i = 0; i < nreps; i++) {
    477       doCall63Interface(m);
    478     }
    479   }
    480 
    481   public void timeCall64Interface(int nreps) {
    482     MultiClass m = multi;
    483     for (int i = 0; i < nreps; i++) {
    484       doCall64Interface(m);
    485     }
    486   }
    487 
    488   // Try calling these through the IMT/IfTable
    489   public void doCall0Interface(Iface0 i) { i.callIface0(); }
    490   public void doCall1Interface(Iface1 i) { i.callIface1(); }
    491   public void doCall2Interface(Iface2 i) { i.callIface2(); }
    492   public void doCall3Interface(Iface3 i) { i.callIface3(); }
    493   public void doCall4Interface(Iface4 i) { i.callIface4(); }
    494   public void doCall5Interface(Iface5 i) { i.callIface5(); }
    495   public void doCall6Interface(Iface6 i) { i.callIface6(); }
    496   public void doCall7Interface(Iface7 i) { i.callIface7(); }
    497   public void doCall8Interface(Iface8 i) { i.callIface8(); }
    498   public void doCall9Interface(Iface9 i) { i.callIface9(); }
    499   public void doCall10Interface(Iface10 i) { i.callIface10(); }
    500   public void doCall11Interface(Iface11 i) { i.callIface11(); }
    501   public void doCall12Interface(Iface12 i) { i.callIface12(); }
    502   public void doCall13Interface(Iface13 i) { i.callIface13(); }
    503   public void doCall14Interface(Iface14 i) { i.callIface14(); }
    504   public void doCall15Interface(Iface15 i) { i.callIface15(); }
    505   public void doCall16Interface(Iface16 i) { i.callIface16(); }
    506   public void doCall17Interface(Iface17 i) { i.callIface17(); }
    507   public void doCall18Interface(Iface18 i) { i.callIface18(); }
    508   public void doCall19Interface(Iface19 i) { i.callIface19(); }
    509   public void doCall20Interface(Iface20 i) { i.callIface20(); }
    510   public void doCall21Interface(Iface21 i) { i.callIface21(); }
    511   public void doCall22Interface(Iface22 i) { i.callIface22(); }
    512   public void doCall23Interface(Iface23 i) { i.callIface23(); }
    513   public void doCall24Interface(Iface24 i) { i.callIface24(); }
    514   public void doCall25Interface(Iface25 i) { i.callIface25(); }
    515   public void doCall26Interface(Iface26 i) { i.callIface26(); }
    516   public void doCall27Interface(Iface27 i) { i.callIface27(); }
    517   public void doCall28Interface(Iface28 i) { i.callIface28(); }
    518   public void doCall29Interface(Iface29 i) { i.callIface29(); }
    519   public void doCall30Interface(Iface30 i) { i.callIface30(); }
    520   public void doCall31Interface(Iface31 i) { i.callIface31(); }
    521   public void doCall32Interface(Iface32 i) { i.callIface32(); }
    522   public void doCall33Interface(Iface33 i) { i.callIface33(); }
    523   public void doCall34Interface(Iface34 i) { i.callIface34(); }
    524   public void doCall35Interface(Iface35 i) { i.callIface35(); }
    525   public void doCall36Interface(Iface36 i) { i.callIface36(); }
    526   public void doCall37Interface(Iface37 i) { i.callIface37(); }
    527   public void doCall38Interface(Iface38 i) { i.callIface38(); }
    528   public void doCall39Interface(Iface39 i) { i.callIface39(); }
    529   public void doCall40Interface(Iface40 i) { i.callIface40(); }
    530   public void doCall41Interface(Iface41 i) { i.callIface41(); }
    531   public void doCall42Interface(Iface42 i) { i.callIface42(); }
    532   public void doCall43Interface(Iface43 i) { i.callIface43(); }
    533   public void doCall44Interface(Iface44 i) { i.callIface44(); }
    534   public void doCall45Interface(Iface45 i) { i.callIface45(); }
    535   public void doCall46Interface(Iface46 i) { i.callIface46(); }
    536   public void doCall47Interface(Iface47 i) { i.callIface47(); }
    537   public void doCall48Interface(Iface48 i) { i.callIface48(); }
    538   public void doCall49Interface(Iface49 i) { i.callIface49(); }
    539   public void doCall50Interface(Iface50 i) { i.callIface50(); }
    540   public void doCall51Interface(Iface51 i) { i.callIface51(); }
    541   public void doCall52Interface(Iface52 i) { i.callIface52(); }
    542   public void doCall53Interface(Iface53 i) { i.callIface53(); }
    543   public void doCall54Interface(Iface54 i) { i.callIface54(); }
    544   public void doCall55Interface(Iface55 i) { i.callIface55(); }
    545   public void doCall56Interface(Iface56 i) { i.callIface56(); }
    546   public void doCall57Interface(Iface57 i) { i.callIface57(); }
    547   public void doCall58Interface(Iface58 i) { i.callIface58(); }
    548   public void doCall59Interface(Iface59 i) { i.callIface59(); }
    549   public void doCall60Interface(Iface60 i) { i.callIface60(); }
    550   public void doCall61Interface(Iface61 i) { i.callIface61(); }
    551   public void doCall62Interface(Iface62 i) { i.callIface62(); }
    552   public void doCall63Interface(Iface63 i) { i.callIface63(); }
    553   public void doCall64Interface(Iface64 i) { i.callIface64(); }
    554 
    555   // Try calling this through the vtable for comparison.
    556   public void doCall0Concrete(MultiClass m) { m.callIface0(); }
    557 
    558   // IMTs are 64 entries in length. By making this 65 interfaces we guarantee that we will have a
    559   // collision.
    560   static class MultiClass implements Iface0, Iface1, Iface2, Iface3, Iface4,
    561                                      Iface5, Iface6, Iface7, Iface8, Iface9,
    562                                      Iface10, Iface11, Iface12, Iface13, Iface14,
    563                                      Iface15, Iface16, Iface17, Iface18, Iface19,
    564                                      Iface20, Iface21, Iface22, Iface23, Iface24,
    565                                      Iface25, Iface26, Iface27, Iface28, Iface29,
    566                                      Iface30, Iface31, Iface32, Iface33, Iface34,
    567                                      Iface35, Iface36, Iface37, Iface38, Iface39,
    568                                      Iface40, Iface41, Iface42, Iface43, Iface44,
    569                                      Iface45, Iface46, Iface47, Iface48, Iface49,
    570                                      Iface50, Iface51, Iface52, Iface53, Iface54,
    571                                      Iface55, Iface56, Iface57, Iface58, Iface59,
    572                                      Iface60, Iface61, Iface62, Iface63, Iface64 { }
    573 
    574   // The declaration of the 64 interfaces. We give them all default methods to avoid having to
    575   // repeat ourselves.
    576   static interface Iface0 { default void callIface0() {} }
    577   static interface Iface1 { default void callIface1() {} }
    578   static interface Iface2 { default void callIface2() {} }
    579   static interface Iface3 { default void callIface3() {} }
    580   static interface Iface4 { default void callIface4() {} }
    581   static interface Iface5 { default void callIface5() {} }
    582   static interface Iface6 { default void callIface6() {} }
    583   static interface Iface7 { default void callIface7() {} }
    584   static interface Iface8 { default void callIface8() {} }
    585   static interface Iface9 { default void callIface9() {} }
    586   static interface Iface10 { default void callIface10() {} }
    587   static interface Iface11 { default void callIface11() {} }
    588   static interface Iface12 { default void callIface12() {} }
    589   static interface Iface13 { default void callIface13() {} }
    590   static interface Iface14 { default void callIface14() {} }
    591   static interface Iface15 { default void callIface15() {} }
    592   static interface Iface16 { default void callIface16() {} }
    593   static interface Iface17 { default void callIface17() {} }
    594   static interface Iface18 { default void callIface18() {} }
    595   static interface Iface19 { default void callIface19() {} }
    596   static interface Iface20 { default void callIface20() {} }
    597   static interface Iface21 { default void callIface21() {} }
    598   static interface Iface22 { default void callIface22() {} }
    599   static interface Iface23 { default void callIface23() {} }
    600   static interface Iface24 { default void callIface24() {} }
    601   static interface Iface25 { default void callIface25() {} }
    602   static interface Iface26 { default void callIface26() {} }
    603   static interface Iface27 { default void callIface27() {} }
    604   static interface Iface28 { default void callIface28() {} }
    605   static interface Iface29 { default void callIface29() {} }
    606   static interface Iface30 { default void callIface30() {} }
    607   static interface Iface31 { default void callIface31() {} }
    608   static interface Iface32 { default void callIface32() {} }
    609   static interface Iface33 { default void callIface33() {} }
    610   static interface Iface34 { default void callIface34() {} }
    611   static interface Iface35 { default void callIface35() {} }
    612   static interface Iface36 { default void callIface36() {} }
    613   static interface Iface37 { default void callIface37() {} }
    614   static interface Iface38 { default void callIface38() {} }
    615   static interface Iface39 { default void callIface39() {} }
    616   static interface Iface40 { default void callIface40() {} }
    617   static interface Iface41 { default void callIface41() {} }
    618   static interface Iface42 { default void callIface42() {} }
    619   static interface Iface43 { default void callIface43() {} }
    620   static interface Iface44 { default void callIface44() {} }
    621   static interface Iface45 { default void callIface45() {} }
    622   static interface Iface46 { default void callIface46() {} }
    623   static interface Iface47 { default void callIface47() {} }
    624   static interface Iface48 { default void callIface48() {} }
    625   static interface Iface49 { default void callIface49() {} }
    626   static interface Iface50 { default void callIface50() {} }
    627   static interface Iface51 { default void callIface51() {} }
    628   static interface Iface52 { default void callIface52() {} }
    629   static interface Iface53 { default void callIface53() {} }
    630   static interface Iface54 { default void callIface54() {} }
    631   static interface Iface55 { default void callIface55() {} }
    632   static interface Iface56 { default void callIface56() {} }
    633   static interface Iface57 { default void callIface57() {} }
    634   static interface Iface58 { default void callIface58() {} }
    635   static interface Iface59 { default void callIface59() {} }
    636   static interface Iface60 { default void callIface60() {} }
    637   static interface Iface61 { default void callIface61() {} }
    638   static interface Iface62 { default void callIface62() {} }
    639   static interface Iface63 { default void callIface63() {} }
    640   static interface Iface64 { default void callIface64() {} }
    641 }
    642