buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 17 | #include "oat/runtime/oat_support_entrypoints.h" |
| 18 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 19 | namespace art { |
| 20 | |
| 21 | /* |
| 22 | * This source files contains "gen" codegen routines that should |
| 23 | * be applicable to most targets. Only mid-level support utilities |
| 24 | * and "op" calls may be used here. |
| 25 | */ |
| 26 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 27 | /* |
| 28 | * If there are any ins passed in registers that have not been promoted |
| 29 | * to a callee-save register, flush them to the frame. Perform intial |
| 30 | * assignment of promoted arguments. |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 31 | * |
| 32 | * argLocs is an array of location records describing the incoming arguments |
| 33 | * with one location record per word of argument. |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 34 | */ |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 35 | void flushIns(CompilationUnit* cUnit, RegLocation* argLocs, RegLocation rlMethod) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 36 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 37 | /* |
| 38 | * Dummy up a RegLocation for the incoming Method* |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 39 | * It will attempt to keep kArg0 live (or copy it to home location |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 40 | * if promoted). |
| 41 | */ |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 42 | RegLocation rlSrc = rlMethod; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 43 | rlSrc.location = kLocPhysReg; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 44 | rlSrc.lowReg = targetReg(kArg0); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 45 | rlSrc.home = false; |
| 46 | oatMarkLive(cUnit, rlSrc.lowReg, rlSrc.sRegLow); |
| 47 | storeValue(cUnit, rlMethod, rlSrc); |
| 48 | // If Method* has been promoted, explicitly flush |
| 49 | if (rlMethod.location == kLocPhysReg) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 50 | storeWordDisp(cUnit, targetReg(kSp), 0, targetReg(kArg0)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 51 | } |
buzbee | 9c044ce | 2012-03-18 13:24:07 -0700 | [diff] [blame] | 52 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 53 | if (cUnit->numIns == 0) |
| 54 | return; |
| 55 | const int numArgRegs = 3; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 56 | static SpecialTargetRegister argRegs[] = {kArg1, kArg2, kArg3}; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 57 | int startVReg = cUnit->numDalvikRegisters - cUnit->numIns; |
| 58 | /* |
| 59 | * Copy incoming arguments to their proper home locations. |
| 60 | * NOTE: an older version of dx had an issue in which |
| 61 | * it would reuse static method argument registers. |
| 62 | * This could result in the same Dalvik virtual register |
| 63 | * being promoted to both core and fp regs. To account for this, |
| 64 | * we only copy to the corresponding promoted physical register |
| 65 | * if it matches the type of the SSA name for the incoming |
| 66 | * argument. It is also possible that long and double arguments |
| 67 | * end up half-promoted. In those cases, we must flush the promoted |
| 68 | * half to memory as well. |
| 69 | */ |
| 70 | for (int i = 0; i < cUnit->numIns; i++) { |
| 71 | PromotionMap* vMap = &cUnit->promotionMap[startVReg + i]; |
| 72 | if (i < numArgRegs) { |
| 73 | // If arriving in register |
| 74 | bool needFlush = true; |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 75 | RegLocation* tLoc = &argLocs[i]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 76 | if ((vMap->coreLocation == kLocPhysReg) && !tLoc->fp) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 77 | opRegCopy(cUnit, vMap->coreReg, targetReg(argRegs[i])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 78 | needFlush = false; |
| 79 | } else if ((vMap->fpLocation == kLocPhysReg) && tLoc->fp) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 80 | opRegCopy(cUnit, vMap->fpReg, targetReg(argRegs[i])); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 81 | needFlush = false; |
| 82 | } else { |
| 83 | needFlush = true; |
| 84 | } |
buzbee | 86a4bce | 2012-03-06 18:15:00 -0800 | [diff] [blame] | 85 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 86 | // For wide args, force flush if only half is promoted |
| 87 | if (tLoc->wide) { |
| 88 | PromotionMap* pMap = vMap + (tLoc->highWord ? -1 : +1); |
| 89 | needFlush |= (pMap->coreLocation != vMap->coreLocation) || |
| 90 | (pMap->fpLocation != vMap->fpLocation); |
| 91 | } |
| 92 | if (needFlush) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 93 | storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i), |
| 94 | targetReg(argRegs[i]), kWord); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 95 | } |
| 96 | } else { |
| 97 | // If arriving in frame & promoted |
| 98 | if (vMap->coreLocation == kLocPhysReg) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 99 | loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 100 | vMap->coreReg); |
| 101 | } |
| 102 | if (vMap->fpLocation == kLocPhysReg) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 103 | loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 104 | vMap->fpReg); |
| 105 | } |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 106 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 107 | } |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 108 | } |
| 109 | |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 110 | void scanMethodLiteralPool(CompilationUnit* cUnit, LIR** methodTarget, LIR** codeTarget, |
| 111 | const DexFile* dexFile, uint32_t dexMethodIdx) |
Ian Rogers | 3fa1379 | 2012-03-18 15:53:45 -0700 | [diff] [blame] | 112 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 113 | LIR* curTarget = cUnit->methodLiteralList; |
| 114 | LIR* nextTarget = curTarget != NULL ? curTarget->next : NULL; |
| 115 | while (curTarget != NULL && nextTarget != NULL) { |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 116 | if (curTarget->operands[0] == reinterpret_cast<intptr_t>(dexFile) && |
| 117 | nextTarget->operands[0] == static_cast<int>(dexMethodIdx)) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 118 | *codeTarget = curTarget; |
| 119 | *methodTarget = nextTarget; |
| 120 | DCHECK((*codeTarget)->next == *methodTarget); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 121 | DCHECK_EQ((*codeTarget)->operands[0], reinterpret_cast<intptr_t>(dexFile)); |
| 122 | DCHECK_EQ((*methodTarget)->operands[0], static_cast<int>(dexMethodIdx)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 123 | break; |
Ian Rogers | 3fa1379 | 2012-03-18 15:53:45 -0700 | [diff] [blame] | 124 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 125 | curTarget = nextTarget->next; |
| 126 | nextTarget = curTarget != NULL ? curTarget->next : NULL; |
| 127 | } |
Ian Rogers | 3fa1379 | 2012-03-18 15:53:45 -0700 | [diff] [blame] | 128 | } |
| 129 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 130 | /* |
Elliott Hughes | bdf6c3d | 2012-03-20 13:43:53 -0700 | [diff] [blame] | 131 | * Bit of a hack here - in the absence of a real scheduling pass, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 132 | * emit the next instruction in static & direct invoke sequences. |
| 133 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 134 | int nextSDCallInsn(CompilationUnit* cUnit, CallInfo* info, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 135 | int state, uint32_t dexIdx, uint32_t unused, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 136 | uintptr_t directCode, uintptr_t directMethod, |
| 137 | InvokeType type) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 138 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 139 | if (cUnit->instructionSet != kThumb2) { |
| 140 | // Disable sharpening |
| 141 | directCode = 0; |
| 142 | directMethod = 0; |
| 143 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 144 | if (directCode != 0 && directMethod != 0) { |
| 145 | switch (state) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 146 | case 0: // Get the current Method* [sets kArg0] |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 147 | if (directCode != static_cast<unsigned int>(-1)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 148 | loadConstant(cUnit, targetReg(kInvokeTgt), directCode); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 149 | } else { |
| 150 | LIR* dataTarget = scanLiteralPool(cUnit->codeLiteralList, dexIdx, 0); |
| 151 | if (dataTarget == NULL) { |
| 152 | dataTarget = addWordData(cUnit, &cUnit->codeLiteralList, dexIdx); |
| 153 | dataTarget->operands[1] = type; |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 154 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 155 | LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 156 | oatAppendLIR(cUnit, loadPcRel); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 157 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 158 | } |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 159 | if (directMethod != static_cast<unsigned int>(-1)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 160 | loadConstant(cUnit, targetReg(kArg0), directMethod); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 161 | } else { |
| 162 | LIR* dataTarget = scanLiteralPool(cUnit->methodLiteralList, dexIdx, 0); |
| 163 | if (dataTarget == NULL) { |
| 164 | dataTarget = addWordData(cUnit, &cUnit->methodLiteralList, dexIdx); |
| 165 | dataTarget->operands[1] = type; |
| 166 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 167 | LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 168 | oatAppendLIR(cUnit, loadPcRel); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 169 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 170 | } |
| 171 | break; |
| 172 | default: |
| 173 | return -1; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 174 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 175 | } else { |
| 176 | switch (state) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 177 | case 0: // Get the current Method* [sets kArg0] |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 178 | // TUNING: we can save a reg copy if Method* has been promoted. |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 179 | loadCurrMethodDirect(cUnit, targetReg(kArg0)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 180 | break; |
| 181 | case 1: // Get method->dex_cache_resolved_methods_ |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 182 | loadWordDisp(cUnit, targetReg(kArg0), |
| 183 | AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), targetReg(kArg0)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 184 | // Set up direct code if known. |
| 185 | if (directCode != 0) { |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 186 | if (directCode != static_cast<unsigned int>(-1)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 187 | loadConstant(cUnit, targetReg(kInvokeTgt), directCode); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 188 | } else { |
| 189 | LIR* dataTarget = scanLiteralPool(cUnit->codeLiteralList, dexIdx, 0); |
| 190 | if (dataTarget == NULL) { |
| 191 | dataTarget = addWordData(cUnit, &cUnit->codeLiteralList, dexIdx); |
| 192 | dataTarget->operands[1] = type; |
| 193 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 194 | LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 195 | oatAppendLIR(cUnit, loadPcRel); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 196 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | break; |
| 200 | case 2: // Grab target method* |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 201 | loadWordDisp(cUnit, targetReg(kArg0), |
| 202 | Array::DataOffset(sizeof(Object*)).Int32Value() + dexIdx * 4, targetReg(kArg0)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 203 | break; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 204 | case 3: // Grab the code from the method* |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 205 | if (cUnit->instructionSet != kX86) { |
| 206 | if (directCode == 0) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 207 | loadWordDisp(cUnit, targetReg(kArg0), AbstractMethod::GetCodeOffset().Int32Value(), |
| 208 | targetReg(kInvokeTgt)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 209 | } |
| 210 | break; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 211 | } |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 212 | // Intentional fallthrough for x86 |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 213 | default: |
| 214 | return -1; |
| 215 | } |
| 216 | } |
| 217 | return state + 1; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* |
Elliott Hughes | bdf6c3d | 2012-03-20 13:43:53 -0700 | [diff] [blame] | 221 | * Bit of a hack here - in the absence of a real scheduling pass, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 222 | * emit the next instruction in a virtual invoke sequence. |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 223 | * We can use kLr as a temp prior to target address loading |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 224 | * Note also that we'll load the first argument ("this") into |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 225 | * kArg1 here rather than the standard loadArgRegs. |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 226 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 227 | int nextVCallInsn(CompilationUnit* cUnit, CallInfo* info, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 228 | int state, uint32_t dexIdx, uint32_t methodIdx, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 229 | uintptr_t unused, uintptr_t unused2, InvokeType unused3) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 230 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 231 | /* |
| 232 | * This is the fast path in which the target virtual method is |
| 233 | * fully resolved at compile time. |
| 234 | */ |
| 235 | switch (state) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 236 | case 0: { // Get "this" [set kArg1] |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 237 | RegLocation rlArg = info->args[0]; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 238 | loadValueDirectFixed(cUnit, rlArg, targetReg(kArg1)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 239 | break; |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 240 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 241 | case 1: // Is "this" null? [use kArg1] |
| 242 | genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), info->optFlags); |
| 243 | // get this->klass_ [use kArg1, set kInvokeTgt] |
| 244 | loadWordDisp(cUnit, targetReg(kArg1), Object::ClassOffset().Int32Value(), |
| 245 | targetReg(kInvokeTgt)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 246 | break; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 247 | case 2: // Get this->klass_->vtable [usr kInvokeTgt, set kInvokeTgt] |
| 248 | loadWordDisp(cUnit, targetReg(kInvokeTgt), Class::VTableOffset().Int32Value(), |
| 249 | targetReg(kInvokeTgt)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 250 | break; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 251 | case 3: // Get target method [use kInvokeTgt, set kArg0] |
| 252 | loadWordDisp(cUnit, targetReg(kInvokeTgt), (methodIdx * 4) + |
| 253 | Array::DataOffset(sizeof(Object*)).Int32Value(), targetReg(kArg0)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 254 | break; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 255 | case 4: // Get the compiled code address [uses kArg0, sets kInvokeTgt] |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 256 | if (cUnit->instructionSet != kX86) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 257 | loadWordDisp(cUnit, targetReg(kArg0), AbstractMethod::GetCodeOffset().Int32Value(), |
| 258 | targetReg(kInvokeTgt)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 259 | break; |
| 260 | } |
| 261 | // Intentional fallthrough for X86 |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 262 | default: |
| 263 | return -1; |
| 264 | } |
| 265 | return state + 1; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 266 | } |
| 267 | |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 268 | /* |
| 269 | * All invoke-interface calls bounce off of art_invoke_interface_trampoline, |
| 270 | * which will locate the target and continue on via a tail call. |
| 271 | */ |
| 272 | int nextInterfaceCallInsn(CompilationUnit* cUnit, CallInfo* info, int state, |
| 273 | uint32_t dexIdx, uint32_t unused, uintptr_t unused2, |
| 274 | uintptr_t directMethod, InvokeType unused4) |
| 275 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 276 | if (cUnit->instructionSet != kThumb2) { |
| 277 | // Disable sharpening |
| 278 | directMethod = 0; |
| 279 | } |
| 280 | int trampoline = (cUnit->instructionSet == kX86) ? 0 |
| 281 | : ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 282 | |
| 283 | if (directMethod != 0) { |
| 284 | switch (state) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 285 | case 0: // Load the trampoline target [sets kInvokeTgt]. |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 286 | if (cUnit->instructionSet != kX86) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 287 | loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 288 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 289 | // Get the interface Method* [sets kArg0] |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 290 | if (directMethod != static_cast<unsigned int>(-1)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 291 | loadConstant(cUnit, targetReg(kArg0), directMethod); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 292 | } else { |
| 293 | LIR* dataTarget = scanLiteralPool(cUnit->methodLiteralList, dexIdx, 0); |
| 294 | if (dataTarget == NULL) { |
| 295 | dataTarget = addWordData(cUnit, &cUnit->methodLiteralList, dexIdx); |
| 296 | dataTarget->operands[1] = kInterface; |
| 297 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 298 | LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 299 | oatAppendLIR(cUnit, loadPcRel); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 300 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 301 | } |
| 302 | break; |
| 303 | default: |
| 304 | return -1; |
| 305 | } |
| 306 | } else { |
| 307 | switch (state) { |
| 308 | case 0: |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 309 | // Get the current Method* [sets kArg0] - TUNING: remove copy of method if it is promoted. |
| 310 | loadCurrMethodDirect(cUnit, targetReg(kArg0)); |
| 311 | // Load the trampoline target [sets kInvokeTgt]. |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 312 | if (cUnit->instructionSet != kX86) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 313 | loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 314 | } |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 315 | break; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 316 | case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0] |
| 317 | loadWordDisp(cUnit, targetReg(kArg0), |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 318 | AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 319 | targetReg(kArg0)); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 320 | break; |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 321 | case 2: // Grab target method* [set/use kArg0] |
| 322 | loadWordDisp(cUnit, targetReg(kArg0), |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 323 | Array::DataOffset(sizeof(Object*)).Int32Value() + dexIdx * 4, |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 324 | targetReg(kArg0)); |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 325 | break; |
| 326 | default: |
| 327 | return -1; |
| 328 | } |
| 329 | } |
| 330 | return state + 1; |
| 331 | } |
| 332 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 333 | int nextInvokeInsnSP(CompilationUnit* cUnit, CallInfo* info, int trampoline, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 334 | int state, uint32_t dexIdx, uint32_t methodIdx) |
| 335 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 336 | /* |
| 337 | * This handles the case in which the base method is not fully |
| 338 | * resolved at compile time, we bail to a runtime helper. |
| 339 | */ |
| 340 | if (state == 0) { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 341 | if (cUnit->instructionSet != kX86) { |
| 342 | // Load trampoline target |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 343 | loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 344 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 345 | // Load kArg0 with method index |
| 346 | loadConstant(cUnit, targetReg(kArg0), dexIdx); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 347 | return 1; |
| 348 | } |
| 349 | return -1; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 350 | } |
| 351 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 352 | int nextStaticCallInsnSP(CompilationUnit* cUnit, CallInfo* info, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 353 | int state, uint32_t dexIdx, uint32_t methodIdx, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 354 | uintptr_t unused, uintptr_t unused2, |
| 355 | InvokeType unused3) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 356 | { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 357 | int trampoline = ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 358 | return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 359 | } |
| 360 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 361 | int nextDirectCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 362 | uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 363 | uintptr_t unused2, InvokeType unused3) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 364 | { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 365 | int trampoline = ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 366 | return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 367 | } |
| 368 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 369 | int nextSuperCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 370 | uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 371 | uintptr_t unused2, InvokeType unused3) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 372 | { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 373 | int trampoline = ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 374 | return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 375 | } |
| 376 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 377 | int nextVCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 378 | uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 379 | uintptr_t unused2, InvokeType unused3) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 380 | { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 381 | int trampoline = ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 382 | return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 383 | } |
| 384 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 385 | int nextInterfaceCallInsnWithAccessCheck(CompilationUnit* cUnit, |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 386 | CallInfo* info, int state, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 387 | uint32_t dexIdx, uint32_t unused, |
| 388 | uintptr_t unused2, uintptr_t unused3, |
| 389 | InvokeType unused4) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 390 | { |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 391 | int trampoline = ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 392 | return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 393 | } |
| 394 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 395 | int loadArgRegs(CompilationUnit* cUnit, CallInfo* info, int callState, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 396 | NextCallInsn nextCallInsn, uint32_t dexIdx, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 397 | uint32_t methodIdx, uintptr_t directCode, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 398 | uintptr_t directMethod, InvokeType type, bool skipThis) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 399 | { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 400 | int lastArgReg = targetReg(kArg3); |
| 401 | int nextReg = targetReg(kArg1); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 402 | int nextArg = 0; |
| 403 | if (skipThis) { |
| 404 | nextReg++; |
| 405 | nextArg++; |
| 406 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 407 | for (; (nextReg <= lastArgReg) && (nextArg < info->numArgWords); nextReg++) { |
| 408 | RegLocation rlArg = info->args[nextArg++]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 409 | rlArg = oatUpdateRawLoc(cUnit, rlArg); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 410 | if (rlArg.wide && (nextReg <= targetReg(kArg2))) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 411 | loadValueDirectWideFixed(cUnit, rlArg, nextReg, nextReg + 1); |
| 412 | nextReg++; |
| 413 | nextArg++; |
| 414 | } else { |
| 415 | rlArg.wide = false; |
| 416 | loadValueDirectFixed(cUnit, rlArg, nextReg); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 417 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 418 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 419 | directCode, directMethod, type); |
| 420 | } |
| 421 | return callState; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | /* |
| 425 | * Load up to 5 arguments, the first three of which will be in |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 426 | * kArg1 .. kArg3. On entry kArg0 contains the current method pointer, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 427 | * and as part of the load sequence, it must be replaced with |
| 428 | * the target method pointer. Note, this may also be called |
| 429 | * for "range" variants if the number of arguments is 5 or fewer. |
| 430 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 431 | int genDalvikArgsNoRange(CompilationUnit* cUnit, CallInfo* info, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 432 | int callState, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 433 | LIR** pcrLabel, NextCallInsn nextCallInsn, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 434 | uint32_t dexIdx, uint32_t methodIdx, |
| 435 | uintptr_t directCode, uintptr_t directMethod, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 436 | InvokeType type, bool skipThis) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 437 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 438 | RegLocation rlArg; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 439 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 440 | /* If no arguments, just return */ |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 441 | if (info->numArgWords == 0) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 442 | return callState; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 443 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 444 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 445 | directCode, directMethod, type); |
| 446 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 447 | DCHECK_LE(info->numArgWords, 5); |
| 448 | if (info->numArgWords > 3) { |
| 449 | int32_t nextUse = 3; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 450 | //Detect special case of wide arg spanning arg3/arg4 |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 451 | RegLocation rlUse0 = info->args[0]; |
| 452 | RegLocation rlUse1 = info->args[1]; |
| 453 | RegLocation rlUse2 = info->args[2]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 454 | if (((!rlUse0.wide && !rlUse1.wide) || rlUse0.wide) && |
| 455 | rlUse2.wide) { |
| 456 | int reg = -1; |
| 457 | // Wide spans, we need the 2nd half of uses[2]. |
| 458 | rlArg = oatUpdateLocWide(cUnit, rlUse2); |
| 459 | if (rlArg.location == kLocPhysReg) { |
| 460 | reg = rlArg.highReg; |
| 461 | } else { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 462 | // kArg2 & rArg3 can safely be used here |
| 463 | reg = targetReg(kArg3); |
| 464 | loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, rlArg.sRegLow) + 4, reg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 465 | callState = nextCallInsn(cUnit, info, callState, dexIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 466 | methodIdx, directCode, directMethod, type); |
| 467 | } |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 468 | storeBaseDisp(cUnit, targetReg(kSp), (nextUse + 1) * 4, reg, kWord); |
| 469 | storeBaseDisp(cUnit, targetReg(kSp), 16 /* (3+1)*4 */, reg, kWord); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 470 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 471 | directCode, directMethod, type); |
| 472 | nextUse++; |
| 473 | } |
| 474 | // Loop through the rest |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 475 | while (nextUse < info->numArgWords) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 476 | int lowReg; |
| 477 | int highReg = -1; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 478 | rlArg = info->args[nextUse]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 479 | rlArg = oatUpdateRawLoc(cUnit, rlArg); |
| 480 | if (rlArg.location == kLocPhysReg) { |
| 481 | lowReg = rlArg.lowReg; |
| 482 | highReg = rlArg.highReg; |
| 483 | } else { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 484 | lowReg = targetReg(kArg2); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 485 | if (rlArg.wide) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 486 | highReg = targetReg(kArg3); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 487 | loadValueDirectWideFixed(cUnit, rlArg, lowReg, highReg); |
| 488 | } else { |
| 489 | loadValueDirectFixed(cUnit, rlArg, lowReg); |
| 490 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 491 | callState = nextCallInsn(cUnit, info, callState, dexIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 492 | methodIdx, directCode, directMethod, type); |
| 493 | } |
| 494 | int outsOffset = (nextUse + 1) * 4; |
| 495 | if (rlArg.wide) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 496 | storeBaseDispWide(cUnit, targetReg(kSp), outsOffset, lowReg, highReg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 497 | nextUse += 2; |
| 498 | } else { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 499 | storeWordDisp(cUnit, targetReg(kSp), outsOffset, lowReg); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 500 | nextUse++; |
| 501 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 502 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 503 | directCode, directMethod, type); |
| 504 | } |
| 505 | } |
| 506 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 507 | callState = loadArgRegs(cUnit, info, callState, nextCallInsn, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 508 | dexIdx, methodIdx, directCode, directMethod, |
| 509 | type, skipThis); |
| 510 | |
| 511 | if (pcrLabel) { |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 512 | *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 513 | } |
| 514 | return callState; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | /* |
| 518 | * May have 0+ arguments (also used for jumbo). Note that |
| 519 | * source virtual registers may be in physical registers, so may |
| 520 | * need to be flushed to home location before copying. This |
| 521 | * applies to arg3 and above (see below). |
| 522 | * |
| 523 | * Two general strategies: |
| 524 | * If < 20 arguments |
| 525 | * Pass args 3-18 using vldm/vstm block copy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 526 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 527 | * If 20+ arguments |
| 528 | * Pass args arg19+ using memcpy block copy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 529 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 530 | * |
| 531 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 532 | int genDalvikArgsRange(CompilationUnit* cUnit, CallInfo* info, int callState, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 533 | LIR** pcrLabel, NextCallInsn nextCallInsn, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 534 | uint32_t dexIdx, uint32_t methodIdx, |
| 535 | uintptr_t directCode, uintptr_t directMethod, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 536 | InvokeType type, bool skipThis) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 537 | { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 538 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 539 | // If we can treat it as non-range (Jumbo ops will use range form) |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 540 | if (info->numArgWords <= 5) |
| 541 | return genDalvikArgsNoRange(cUnit, info, callState, pcrLabel, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 542 | nextCallInsn, dexIdx, methodIdx, |
| 543 | directCode, directMethod, type, skipThis); |
| 544 | /* |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 545 | * First load the non-register arguments. Both forms expect all |
| 546 | * of the source arguments to be in their home frame location, so |
| 547 | * scan the sReg names and flush any that have been promoted to |
| 548 | * frame backing storage. |
| 549 | */ |
| 550 | // Scan the rest of the args - if in physReg flush to memory |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 551 | for (int nextArg = 0; nextArg < info->numArgWords;) { |
| 552 | RegLocation loc = info->args[nextArg]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 553 | if (loc.wide) { |
| 554 | loc = oatUpdateLocWide(cUnit, loc); |
| 555 | if ((nextArg >= 2) && (loc.location == kLocPhysReg)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 556 | storeBaseDispWide(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 557 | loc.lowReg, loc.highReg); |
| 558 | } |
| 559 | nextArg += 2; |
| 560 | } else { |
| 561 | loc = oatUpdateLoc(cUnit, loc); |
| 562 | if ((nextArg >= 3) && (loc.location == kLocPhysReg)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 563 | storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 564 | loc.lowReg, kWord); |
| 565 | } |
| 566 | nextArg++; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 567 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 568 | } |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 569 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 570 | int startOffset = oatSRegOffset(cUnit, info->args[3].sRegLow); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 571 | int outsOffset = 4 /* Method* */ + (3 * 4); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 572 | if (cUnit->instructionSet != kThumb2) { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 573 | // Generate memcpy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 574 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg0), targetReg(kSp), outsOffset); |
| 575 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg1), targetReg(kSp), startOffset); |
| 576 | callRuntimeHelperRegRegImm(cUnit, ENTRYPOINT_OFFSET(pMemcpy), targetReg(kArg0), |
| 577 | targetReg(kArg1), (info->numArgWords - 3) * 4, false); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 578 | } else { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 579 | if (info->numArgWords >= 20) { |
| 580 | // Generate memcpy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 581 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg0), targetReg(kSp), outsOffset); |
| 582 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg1), targetReg(kSp), startOffset); |
| 583 | callRuntimeHelperRegRegImm(cUnit, ENTRYPOINT_OFFSET(pMemcpy), targetReg(kArg0), |
| 584 | targetReg(kArg1), (info->numArgWords - 3) * 4, false); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 585 | } else { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 586 | // Use vldm/vstm pair using kArg3 as a temp |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 587 | int regsLeft = std::min(info->numArgWords - 3, 16); |
| 588 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 589 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 590 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), startOffset); |
| 591 | LIR* ld = opVldm(cUnit, targetReg(kArg3), regsLeft); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 592 | //TUNING: loosen barrier |
| 593 | ld->defMask = ENCODE_ALL; |
| 594 | setMemRefType(ld, true /* isLoad */, kDalvikReg); |
| 595 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 596 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 597 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), 4 /* Method* */ + (3 * 4)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 598 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 599 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 600 | LIR* st = opVstm(cUnit, targetReg(kArg3), regsLeft); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 601 | setMemRefType(st, false /* isLoad */, kDalvikReg); |
| 602 | st->defMask = ENCODE_ALL; |
| 603 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 604 | directCode, directMethod, type); |
| 605 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 606 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 607 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 608 | callState = loadArgRegs(cUnit, info, callState, nextCallInsn, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 609 | dexIdx, methodIdx, directCode, directMethod, |
| 610 | type, skipThis); |
| 611 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 612 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 613 | directCode, directMethod, type); |
| 614 | if (pcrLabel) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 615 | *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 616 | info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 617 | } |
| 618 | return callState; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 619 | } |
| 620 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 621 | RegLocation inlineTarget(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 622 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 623 | RegLocation res; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 624 | if (info->result.location == kLocInvalid) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 625 | res = oatGetReturn(cUnit, false); |
| 626 | } else { |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 627 | res = info->result; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 628 | } |
| 629 | return res; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 630 | } |
| 631 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 632 | RegLocation inlineTargetWide(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 633 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 634 | RegLocation res; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 635 | if (info->result.location == kLocInvalid) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 636 | res = oatGetReturnWide(cUnit, false); |
| 637 | } else { |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 638 | res = info->result; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 639 | } |
| 640 | return res; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 641 | } |
| 642 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 643 | bool genInlinedCharAt(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 644 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 645 | if (cUnit->instructionSet == kMips) { |
| 646 | // TODO - add Mips implementation |
| 647 | return false; |
| 648 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 649 | // Location of reference to data array |
| 650 | int valueOffset = String::ValueOffset().Int32Value(); |
| 651 | // Location of count |
| 652 | int countOffset = String::CountOffset().Int32Value(); |
| 653 | // Starting offset within data array |
| 654 | int offsetOffset = String::OffsetOffset().Int32Value(); |
| 655 | // Start of char data with array_ |
| 656 | int dataOffset = Array::DataOffset(sizeof(uint16_t)).Int32Value(); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 657 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 658 | RegLocation rlObj = info->args[0]; |
| 659 | RegLocation rlIdx = info->args[1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 660 | rlObj = loadValue(cUnit, rlObj, kCoreReg); |
| 661 | rlIdx = loadValue(cUnit, rlIdx, kCoreReg); |
| 662 | int regMax; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 663 | genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags); |
| 664 | bool rangeCheck = (!(info->optFlags & MIR_IGNORE_RANGE_CHECK)); |
jeffhao | 634ea28 | 2012-08-10 13:04:01 -0700 | [diff] [blame] | 665 | LIR* launchPad = NULL; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 666 | int regOff = INVALID_REG; |
| 667 | int regPtr = INVALID_REG; |
| 668 | if (cUnit->instructionSet != kX86) { |
| 669 | regOff = oatAllocTemp(cUnit); |
| 670 | regPtr = oatAllocTemp(cUnit); |
| 671 | if (rangeCheck) { |
| 672 | regMax = oatAllocTemp(cUnit); |
| 673 | loadWordDisp(cUnit, rlObj.lowReg, countOffset, regMax); |
| 674 | } |
| 675 | loadWordDisp(cUnit, rlObj.lowReg, offsetOffset, regOff); |
| 676 | loadWordDisp(cUnit, rlObj.lowReg, valueOffset, regPtr); |
| 677 | if (rangeCheck) { |
| 678 | // Set up a launch pad to allow retry in case of bounds violation */ |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 679 | launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 680 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 681 | reinterpret_cast<uintptr_t>(launchPad)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 682 | opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax); |
| 683 | oatFreeTemp(cUnit, regMax); |
| 684 | opCondBranch(cUnit, kCondCs, launchPad); |
| 685 | } |
| 686 | } else { |
| 687 | if (rangeCheck) { |
| 688 | regMax = oatAllocTemp(cUnit); |
| 689 | loadWordDisp(cUnit, rlObj.lowReg, countOffset, regMax); |
| 690 | // Set up a launch pad to allow retry in case of bounds violation */ |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 691 | launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 692 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 693 | reinterpret_cast<uintptr_t>(launchPad)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 694 | opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax); |
| 695 | oatFreeTemp(cUnit, regMax); |
| 696 | opCondBranch(cUnit, kCondCc, launchPad); |
| 697 | } |
| 698 | regOff = oatAllocTemp(cUnit); |
| 699 | regPtr = oatAllocTemp(cUnit); |
| 700 | loadWordDisp(cUnit, rlObj.lowReg, offsetOffset, regOff); |
| 701 | loadWordDisp(cUnit, rlObj.lowReg, valueOffset, regPtr); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 702 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 703 | opRegImm(cUnit, kOpAdd, regPtr, dataOffset); |
| 704 | opRegReg(cUnit, kOpAdd, regOff, rlIdx.lowReg); |
jeffhao | 634ea28 | 2012-08-10 13:04:01 -0700 | [diff] [blame] | 705 | oatFreeTemp(cUnit, rlObj.lowReg); |
| 706 | oatFreeTemp(cUnit, rlIdx.lowReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 707 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 708 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 709 | loadBaseIndexed(cUnit, regPtr, regOff, rlResult.lowReg, 1, kUnsignedHalf); |
| 710 | oatFreeTemp(cUnit, regOff); |
| 711 | oatFreeTemp(cUnit, regPtr); |
| 712 | storeValue(cUnit, rlDest, rlResult); |
| 713 | if (rangeCheck) { |
Elliott Hughes | 6023456 | 2012-06-01 12:25:59 -0700 | [diff] [blame] | 714 | launchPad->operands[2] = 0; // no resumption |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 715 | } |
| 716 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 717 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 718 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | // Generates an inlined String.isEmpty or String.length. |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 722 | bool genInlinedStringIsEmptyOrLength(CompilationUnit* cUnit, CallInfo* info, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 723 | bool isEmpty) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 724 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 725 | if (cUnit->instructionSet == kMips) { |
| 726 | // TODO - add Mips implementation |
| 727 | return false; |
| 728 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 729 | // dst = src.length(); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 730 | RegLocation rlObj = info->args[0]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 731 | rlObj = loadValue(cUnit, rlObj, kCoreReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 732 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 733 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 734 | genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 735 | loadWordDisp(cUnit, rlObj.lowReg, String::CountOffset().Int32Value(), |
| 736 | rlResult.lowReg); |
| 737 | if (isEmpty) { |
| 738 | // dst = (dst == 0); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 739 | if (cUnit->instructionSet == kThumb2) { |
| 740 | int tReg = oatAllocTemp(cUnit); |
| 741 | opRegReg(cUnit, kOpNeg, tReg, rlResult.lowReg); |
| 742 | opRegRegReg(cUnit, kOpAdc, rlResult.lowReg, rlResult.lowReg, tReg); |
| 743 | } else { |
| 744 | DCHECK_EQ(cUnit->instructionSet, kX86); |
| 745 | opRegImm(cUnit, kOpSub, rlResult.lowReg, 1); |
| 746 | opRegImm(cUnit, kOpLsr, rlResult.lowReg, 31); |
| 747 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 748 | } |
| 749 | storeValue(cUnit, rlDest, rlResult); |
| 750 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 751 | } |
| 752 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 753 | bool genInlinedAbsInt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 754 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 755 | if (cUnit->instructionSet == kMips) { |
| 756 | // TODO - add Mips implementation |
| 757 | return false; |
| 758 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 759 | RegLocation rlSrc = info->args[0]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 760 | rlSrc = loadValue(cUnit, rlSrc, kCoreReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 761 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 762 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 763 | int signReg = oatAllocTemp(cUnit); |
| 764 | // abs(x) = y<=x>>31, (x+y)^y. |
| 765 | opRegRegImm(cUnit, kOpAsr, signReg, rlSrc.lowReg, 31); |
| 766 | opRegRegReg(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, signReg); |
| 767 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 768 | storeValue(cUnit, rlDest, rlResult); |
| 769 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 770 | } |
| 771 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 772 | bool genInlinedAbsLong(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 773 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 774 | if (cUnit->instructionSet == kMips) { |
| 775 | // TODO - add Mips implementation |
| 776 | return false; |
| 777 | } |
| 778 | if (cUnit->instructionSet == kThumb2) { |
| 779 | RegLocation rlSrc = info->args[0]; |
| 780 | rlSrc = loadValueWide(cUnit, rlSrc, kCoreReg); |
| 781 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
| 782 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 783 | int signReg = oatAllocTemp(cUnit); |
| 784 | // abs(x) = y<=x>>31, (x+y)^y. |
| 785 | opRegRegImm(cUnit, kOpAsr, signReg, rlSrc.highReg, 31); |
| 786 | opRegRegReg(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, signReg); |
| 787 | opRegRegReg(cUnit, kOpAdc, rlResult.highReg, rlSrc.highReg, signReg); |
| 788 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 789 | opRegReg(cUnit, kOpXor, rlResult.highReg, signReg); |
| 790 | storeValueWide(cUnit, rlDest, rlResult); |
| 791 | return true; |
| 792 | } else { |
| 793 | DCHECK_EQ(cUnit->instructionSet, kX86); |
| 794 | // Reuse source registers to avoid running out of temps |
| 795 | RegLocation rlSrc = info->args[0]; |
| 796 | rlSrc = loadValueWide(cUnit, rlSrc, kCoreReg); |
| 797 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
| 798 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 799 | opRegCopyWide(cUnit, rlResult.lowReg, rlResult.highReg, rlSrc.lowReg, rlSrc.highReg); |
| 800 | oatFreeTemp(cUnit, rlSrc.lowReg); |
| 801 | oatFreeTemp(cUnit, rlSrc.highReg); |
| 802 | int signReg = oatAllocTemp(cUnit); |
| 803 | // abs(x) = y<=x>>31, (x+y)^y. |
| 804 | opRegRegImm(cUnit, kOpAsr, signReg, rlResult.highReg, 31); |
| 805 | opRegReg(cUnit, kOpAdd, rlResult.lowReg, signReg); |
| 806 | opRegReg(cUnit, kOpAdc, rlResult.highReg, signReg); |
| 807 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 808 | opRegReg(cUnit, kOpXor, rlResult.highReg, signReg); |
| 809 | storeValueWide(cUnit, rlDest, rlResult); |
| 810 | return true; |
| 811 | } |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 812 | } |
| 813 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 814 | bool genInlinedFloatCvt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 815 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 816 | if (cUnit->instructionSet == kMips) { |
| 817 | // TODO - add Mips implementation |
| 818 | return false; |
| 819 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 820 | RegLocation rlSrc = info->args[0]; |
| 821 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 822 | storeValue(cUnit, rlDest, rlSrc); |
| 823 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 824 | } |
| 825 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 826 | bool genInlinedDoubleCvt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 827 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 828 | if (cUnit->instructionSet == kMips) { |
| 829 | // TODO - add Mips implementation |
| 830 | return false; |
| 831 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 832 | RegLocation rlSrc = info->args[0]; |
| 833 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 834 | storeValueWide(cUnit, rlDest, rlSrc); |
| 835 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | /* |
| 839 | * Fast string.indexOf(I) & (II). Tests for simple case of char <= 0xffff, |
| 840 | * otherwise bails to standard library code. |
| 841 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 842 | bool genInlinedIndexOf(CompilationUnit* cUnit, CallInfo* info, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 843 | bool zeroBased) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 844 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 845 | if (cUnit->instructionSet == kMips) { |
| 846 | // TODO - add Mips implementation |
| 847 | return false; |
| 848 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 849 | oatClobberCalleeSave(cUnit); |
| 850 | oatLockCallTemps(cUnit); // Using fixed registers |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 851 | int regPtr = targetReg(kArg0); |
| 852 | int regChar = targetReg(kArg1); |
| 853 | int regStart = targetReg(kArg2); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 854 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 855 | RegLocation rlObj = info->args[0]; |
| 856 | RegLocation rlChar = info->args[1]; |
| 857 | RegLocation rlStart = info->args[2]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 858 | loadValueDirectFixed(cUnit, rlObj, regPtr); |
| 859 | loadValueDirectFixed(cUnit, rlChar, regChar); |
| 860 | if (zeroBased) { |
| 861 | loadConstant(cUnit, regStart, 0); |
| 862 | } else { |
| 863 | loadValueDirectFixed(cUnit, rlStart, regStart); |
| 864 | } |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 865 | int rTgt = (cUnit->instructionSet != kX86) ? loadHelper(cUnit, ENTRYPOINT_OFFSET(pIndexOf)) : 0; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 866 | genNullCheck(cUnit, rlObj.sRegLow, regPtr, info->optFlags); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 867 | LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info)); |
| 868 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, reinterpret_cast<uintptr_t>(launchPad)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 869 | opCmpImmBranch(cUnit, kCondGt, regChar, 0xFFFF, launchPad); |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 870 | // NOTE: not a safepoint |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 871 | if (cUnit->instructionSet != kX86) { |
| 872 | opReg(cUnit, kOpBlx, rTgt); |
| 873 | } else { |
| 874 | opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pIndexOf)); |
| 875 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 876 | LIR* resumeTgt = newLIR0(cUnit, kPseudoTargetLabel); |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 877 | launchPad->operands[2] = reinterpret_cast<uintptr_t>(resumeTgt); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 878 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 879 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
| 880 | RegLocation rlReturn = oatGetReturn(cUnit, false); |
| 881 | RegLocation rlDest = inlineTarget(cUnit, info); |
| 882 | storeValue(cUnit, rlDest, rlReturn); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 883 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | /* Fast string.compareTo(Ljava/lang/string;)I. */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 887 | bool genInlinedStringCompareTo(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 888 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 889 | if (cUnit->instructionSet == kMips) { |
| 890 | // TODO - add Mips implementation |
| 891 | return false; |
| 892 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 893 | oatClobberCalleeSave(cUnit); |
| 894 | oatLockCallTemps(cUnit); // Using fixed registers |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 895 | int regThis = targetReg(kArg0); |
| 896 | int regCmp = targetReg(kArg1); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 897 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 898 | RegLocation rlThis = info->args[0]; |
| 899 | RegLocation rlCmp = info->args[1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 900 | loadValueDirectFixed(cUnit, rlThis, regThis); |
| 901 | loadValueDirectFixed(cUnit, rlCmp, regCmp); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 902 | int rTgt = (cUnit->instructionSet != kX86) ? |
| 903 | loadHelper(cUnit, ENTRYPOINT_OFFSET(pStringCompareTo)) : 0; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 904 | genNullCheck(cUnit, rlThis.sRegLow, regThis, info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 905 | //TUNING: check if rlCmp.sRegLow is already null checked |
buzbee | cbd6d44 | 2012-11-17 14:11:25 -0800 | [diff] [blame] | 906 | LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info)); |
| 907 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, reinterpret_cast<uintptr_t>(launchPad)); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 908 | opCmpImmBranch(cUnit, kCondEq, regCmp, 0, launchPad); |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 909 | // NOTE: not a safepoint |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 910 | if (cUnit->instructionSet != kX86) { |
| 911 | opReg(cUnit, kOpBlx, rTgt); |
| 912 | } else { |
| 913 | opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pStringCompareTo)); |
| 914 | } |
Elliott Hughes | 6023456 | 2012-06-01 12:25:59 -0700 | [diff] [blame] | 915 | launchPad->operands[2] = 0; // No return possible |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 916 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 917 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
| 918 | RegLocation rlReturn = oatGetReturn(cUnit, false); |
| 919 | RegLocation rlDest = inlineTarget(cUnit, info); |
| 920 | storeValue(cUnit, rlDest, rlReturn); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 921 | return true; |
Ian Rogers | 0183dd7 | 2012-09-17 23:06:51 -0700 | [diff] [blame] | 922 | } |
| 923 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 924 | bool genIntrinsic(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 925 | { |
Ian Rogers | e13eafa | 2012-09-07 11:24:27 -0700 | [diff] [blame] | 926 | if (info->optFlags & MIR_INLINED) { |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 927 | return false; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 928 | } |
| 929 | /* |
| 930 | * TODO: move these to a target-specific structured constant array |
| 931 | * and use a generic match function. The list of intrinsics may be |
| 932 | * slightly different depending on target. |
| 933 | * TODO: Fold this into a matching function that runs during |
| 934 | * basic block building. This should be part of the action for |
| 935 | * small method inlining and recognition of the special object init |
| 936 | * method. By doing this during basic block construction, we can also |
| 937 | * take advantage of/generate new useful dataflow info. |
| 938 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 939 | std::string tgtMethod(PrettyMethod(info->index, *cUnit->dex_file)); |
Ian Rogers | 0183dd7 | 2012-09-17 23:06:51 -0700 | [diff] [blame] | 940 | if (tgtMethod.find(" java.lang") != std::string::npos) { |
| 941 | if (tgtMethod == "long java.lang.Double.doubleToRawLongBits(double)") { |
| 942 | return genInlinedDoubleCvt(cUnit, info); |
| 943 | } |
| 944 | if (tgtMethod == "double java.lang.Double.longBitsToDouble(long)") { |
| 945 | return genInlinedDoubleCvt(cUnit, info); |
| 946 | } |
| 947 | if (tgtMethod == "int java.lang.Float.floatToRawIntBits(float)") { |
| 948 | return genInlinedFloatCvt(cUnit, info); |
| 949 | } |
| 950 | if (tgtMethod == "float java.lang.Float.intBitsToFloat(int)") { |
| 951 | return genInlinedFloatCvt(cUnit, info); |
| 952 | } |
| 953 | if (tgtMethod == "int java.lang.Math.abs(int)" || |
| 954 | tgtMethod == "int java.lang.StrictMath.abs(int)") { |
| 955 | return genInlinedAbsInt(cUnit, info); |
| 956 | } |
| 957 | if (tgtMethod == "long java.lang.Math.abs(long)" || |
| 958 | tgtMethod == "long java.lang.StrictMath.abs(long)") { |
| 959 | return genInlinedAbsLong(cUnit, info); |
| 960 | } |
| 961 | if (tgtMethod == "int java.lang.Math.max(int, int)" || |
| 962 | tgtMethod == "int java.lang.StrictMath.max(int, int)") { |
| 963 | return genInlinedMinMaxInt(cUnit, info, false /* isMin */); |
| 964 | } |
| 965 | if (tgtMethod == "int java.lang.Math.min(int, int)" || |
| 966 | tgtMethod == "int java.lang.StrictMath.min(int, int)") { |
| 967 | return genInlinedMinMaxInt(cUnit, info, true /* isMin */); |
| 968 | } |
| 969 | if (tgtMethod == "double java.lang.Math.sqrt(double)" || |
| 970 | tgtMethod == "double java.lang.StrictMath.sqrt(double)") { |
| 971 | return genInlinedSqrt(cUnit, info); |
| 972 | } |
| 973 | if (tgtMethod == "char java.lang.String.charAt(int)") { |
| 974 | return genInlinedCharAt(cUnit, info); |
| 975 | } |
| 976 | if (tgtMethod == "int java.lang.String.compareTo(java.lang.String)") { |
| 977 | return genInlinedStringCompareTo(cUnit, info); |
| 978 | } |
| 979 | if (tgtMethod == "boolean java.lang.String.isEmpty()") { |
| 980 | return genInlinedStringIsEmptyOrLength(cUnit, info, true /* isEmpty */); |
| 981 | } |
| 982 | if (tgtMethod == "int java.lang.String.indexOf(int, int)") { |
| 983 | return genInlinedIndexOf(cUnit, info, false /* base 0 */); |
| 984 | } |
| 985 | if (tgtMethod == "int java.lang.String.indexOf(int)") { |
| 986 | return genInlinedIndexOf(cUnit, info, true /* base 0 */); |
| 987 | } |
| 988 | if (tgtMethod == "int java.lang.String.length()") { |
| 989 | return genInlinedStringIsEmptyOrLength(cUnit, info, false /* isEmpty */); |
| 990 | } |
| 991 | } else if (tgtMethod.find("boolean sun.misc.Unsafe.compareAndSwap") != std::string::npos) { |
| 992 | if (tgtMethod == "boolean sun.misc.Unsafe.compareAndSwapInt(java.lang.Object, long, int, int)") { |
| 993 | return genInlinedCas32(cUnit, info, false); |
| 994 | } |
| 995 | if (tgtMethod == "boolean sun.misc.Unsafe.compareAndSwapObject(java.lang.Object, long, java.lang.Object, java.lang.Object)") { |
| 996 | return genInlinedCas32(cUnit, info, true); |
| 997 | } |
Ian Rogers | e13eafa | 2012-09-07 11:24:27 -0700 | [diff] [blame] | 998 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 999 | return false; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 1003 | } // namespace art |