1 /* 2 * Copyright (C) 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 class Main { getA()18 public String getA() { 19 return "A"; 20 } getB()21 public String getB() { 22 return "B"; 23 } getC()24 public String getC() { 25 return "C"; 26 } 27 } 28 29 class TestInline { inlineMonomorphic(Super s)30 public int inlineMonomorphic(Super s) { 31 return s.getValue(); 32 } 33 inlinePolymorphic(Super s)34 public int inlinePolymorphic(Super s) { 35 return s.getValue(); 36 } 37 inlineMegamorphic(Super s)38 public int inlineMegamorphic(Super s) { 39 return s.getValue(); 40 } 41 inlineMissingTypes(Super s)42 public int inlineMissingTypes(Super s) { 43 return s.getValue(); 44 } 45 noInlineCache(Super s)46 public int noInlineCache(Super s) { 47 return s.getValue(); 48 } 49 inlineMultiMonomorphic(Super s, Secret sec)50 public int inlineMultiMonomorphic(Super s, Secret sec) { 51 return s.getValue() + sec.getIdentity(); 52 } 53 inlineMultiPolymorphic(Super s, Secret sec)54 public int inlineMultiPolymorphic(Super s, Secret sec) { 55 return s.getValue() + sec.getIdentity(); 56 } 57 inlineTriplePolymorphic(Super s, Secret sec, Secret thr)58 public int inlineTriplePolymorphic(Super s, Secret sec, Secret thr) { 59 return s.getValue() + sec.getIdentity() + thr.getIdentity(); 60 } 61 inlineMultiMegamorphic(Super s, Secret sec)62 public int inlineMultiMegamorphic(Super s, Secret sec) { 63 return s.getValue() + sec.getIdentity(); 64 } 65 inlineMultiMissingTypes(Super s, Secret sec)66 public int inlineMultiMissingTypes(Super s, Secret sec) { 67 return s.getValue() + sec.getIdentity(); 68 } 69 noInlineCacheMulti(Super s, Secret sec)70 public int noInlineCacheMulti(Super s, Secret sec) { 71 return s.getValue() + sec.getIdentity(); 72 } 73 } 74 75 class TestInlineSubtype extends TestInline { foobar()76 public void foobar() { 77 this.inlineMonomorphic(new SubA()); 78 } 79 } 80 81 abstract class Secret { getIdentity()82 abstract int getIdentity(); 83 } 84 85 abstract class Super extends Secret { getValue()86 abstract int getValue(); 87 } 88 89 class SubA extends Super { getValue()90 int getValue() { return 42; } getIdentity()91 int getIdentity() { return 24; } 92 } 93 94 class SubB extends Super { getValue()95 int getValue() { return 38; }; getIdentity()96 int getIdentity() { return 83; } 97 } 98 99 class SubD extends Super { getValue()100 int getValue() { return 20; }; getIdentity()101 int getIdentity() { return 2; }; 102 } 103 104 class SubE extends Super { getValue()105 int getValue() { return 16; }; getIdentity()106 int getIdentity() { return 61; }; 107 } 108 109 // Add a class with lots of methods so we can test profile guided compilation triggers. 110 class ZLotsOfMethods { m1()111 public void m1() {} m2()112 public void m2() {} m3()113 public void m3() {} m4()114 public void m4() {} m5()115 public void m5() {} m6()116 public void m6() {} m7()117 public void m7() {} m8()118 public void m8() {} m9()119 public void m9() {} m10()120 public void m10() {} m11()121 public void m11() {} m12()122 public void m12() {} m13()123 public void m13() {} m14()124 public void m14() {} m15()125 public void m15() {} m16()126 public void m16() {} m17()127 public void m17() {} m18()128 public void m18() {} m19()129 public void m19() {} m20()130 public void m20() {} m21()131 public void m21() {} m22()132 public void m22() {} m23()133 public void m23() {} m24()134 public void m24() {} m25()135 public void m25() {} m26()136 public void m26() {} m27()137 public void m27() {} m28()138 public void m28() {} m29()139 public void m29() {} m30()140 public void m30() {} m31()141 public void m31() {} m32()142 public void m32() {} m33()143 public void m33() {} m34()144 public void m34() {} m35()145 public void m35() {} m36()146 public void m36() {} m37()147 public void m37() {} m38()148 public void m38() {} m39()149 public void m39() {} m40()150 public void m40() {} m41()151 public void m41() {} m42()152 public void m42() {} m43()153 public void m43() {} m44()154 public void m44() {} m45()155 public void m45() {} m46()156 public void m46() {} m47()157 public void m47() {} m48()158 public void m48() {} m49()159 public void m49() {} m50()160 public void m50() {} m51()161 public void m51() {} m52()162 public void m52() {} m53()163 public void m53() {} m54()164 public void m54() {} m55()165 public void m55() {} m56()166 public void m56() {} m57()167 public void m57() {} m58()168 public void m58() {} m59()169 public void m59() {} m60()170 public void m60() {} m61()171 public void m61() {} m62()172 public void m62() {} m63()173 public void m63() {} m64()174 public void m64() {} m65()175 public void m65() {} m66()176 public void m66() {} m67()177 public void m67() {} m68()178 public void m68() {} m69()179 public void m69() {} m70()180 public void m70() {} m71()181 public void m71() {} m72()182 public void m72() {} m73()183 public void m73() {} m74()184 public void m74() {} m75()185 public void m75() {} m76()186 public void m76() {} m77()187 public void m77() {} m78()188 public void m78() {} m79()189 public void m79() {} m80()190 public void m80() {} m81()191 public void m81() {} m82()192 public void m82() {} m83()193 public void m83() {} m84()194 public void m84() {} m85()195 public void m85() {} m86()196 public void m86() {} m87()197 public void m87() {} m88()198 public void m88() {} m89()199 public void m89() {} m90()200 public void m90() {} m91()201 public void m91() {} m92()202 public void m92() {} m93()203 public void m93() {} m94()204 public void m94() {} m95()205 public void m95() {} m96()206 public void m96() {} m97()207 public void m97() {} m98()208 public void m98() {} m99()209 public void m99() {} m100()210 public void m100() {} m101()211 public void m101() {} m102()212 public void m102() {} m103()213 public void m103() {} m104()214 public void m104() {} m105()215 public void m105() {} m106()216 public void m106() {} m107()217 public void m107() {} m108()218 public void m108() {} m109()219 public void m109() {} m110()220 public void m110() {} m111()221 public void m111() {} m112()222 public void m112() {} m113()223 public void m113() {} m114()224 public void m114() {} m115()225 public void m115() {} m116()226 public void m116() {} m117()227 public void m117() {} m118()228 public void m118() {} m119()229 public void m119() {} m120()230 public void m120() {} m121()231 public void m121() {} m122()232 public void m122() {} m123()233 public void m123() {} m124()234 public void m124() {} m125()235 public void m125() {} m126()236 public void m126() {} m127()237 public void m127() {} m128()238 public void m128() {} m129()239 public void m129() {} m130()240 public void m130() {} m131()241 public void m131() {} m132()242 public void m132() {} m133()243 public void m133() {} m134()244 public void m134() {} m135()245 public void m135() {} m136()246 public void m136() {} m137()247 public void m137() {} m138()248 public void m138() {} m139()249 public void m139() {} m140()250 public void m140() {} m141()251 public void m141() {} m142()252 public void m142() {} m143()253 public void m143() {} m144()254 public void m144() {} m145()255 public void m145() {} m146()256 public void m146() {} m147()257 public void m147() {} m148()258 public void m148() {} m149()259 public void m149() {} m150()260 public void m150() {} 261 } 262