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