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) { |
| 116 | if (curTarget->operands[0] == (int)dexFile && |
| 117 | nextTarget->operands[0] == (int)dexMethodIdx) { |
| 118 | *codeTarget = curTarget; |
| 119 | *methodTarget = nextTarget; |
| 120 | DCHECK((*codeTarget)->next == *methodTarget); |
| 121 | DCHECK_EQ((*codeTarget)->operands[0], (int)dexFile); |
| 122 | DCHECK_EQ((*methodTarget)->operands[0], (int)dexMethodIdx); |
| 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] |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 147 | if (directCode != (uintptr_t)-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 | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 157 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 158 | } |
| 159 | if (directMethod != (uintptr_t)-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 | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 169 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << (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) { |
| 186 | if (directCode != (uintptr_t)-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 | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 196 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << (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] |
Ian Rogers | 137e88f | 2012-10-08 17:46:47 -0700 | [diff] [blame] | 290 | if (directMethod != (uintptr_t)-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 | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 300 | DCHECK_EQ(cUnit->instructionSet, kThumb2) << (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 | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 512 | *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 513 | info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 514 | } |
| 515 | return callState; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | /* |
| 519 | * May have 0+ arguments (also used for jumbo). Note that |
| 520 | * source virtual registers may be in physical registers, so may |
| 521 | * need to be flushed to home location before copying. This |
| 522 | * applies to arg3 and above (see below). |
| 523 | * |
| 524 | * Two general strategies: |
| 525 | * If < 20 arguments |
| 526 | * Pass args 3-18 using vldm/vstm block copy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 527 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 528 | * If 20+ arguments |
| 529 | * Pass args arg19+ using memcpy block copy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 530 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 531 | * |
| 532 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 533 | int genDalvikArgsRange(CompilationUnit* cUnit, CallInfo* info, int callState, |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 534 | LIR** pcrLabel, NextCallInsn nextCallInsn, |
Ian Rogers | 2ed3b95 | 2012-03-17 11:49:39 -0700 | [diff] [blame] | 535 | uint32_t dexIdx, uint32_t methodIdx, |
| 536 | uintptr_t directCode, uintptr_t directMethod, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 537 | InvokeType type, bool skipThis) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 538 | { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 539 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 540 | // 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] | 541 | if (info->numArgWords <= 5) |
| 542 | return genDalvikArgsNoRange(cUnit, info, callState, pcrLabel, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 543 | nextCallInsn, dexIdx, methodIdx, |
| 544 | directCode, directMethod, type, skipThis); |
| 545 | /* |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 546 | * First load the non-register arguments. Both forms expect all |
| 547 | * of the source arguments to be in their home frame location, so |
| 548 | * scan the sReg names and flush any that have been promoted to |
| 549 | * frame backing storage. |
| 550 | */ |
| 551 | // Scan the rest of the args - if in physReg flush to memory |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 552 | for (int nextArg = 0; nextArg < info->numArgWords;) { |
| 553 | RegLocation loc = info->args[nextArg]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 554 | if (loc.wide) { |
| 555 | loc = oatUpdateLocWide(cUnit, loc); |
| 556 | if ((nextArg >= 2) && (loc.location == kLocPhysReg)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 557 | storeBaseDispWide(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 558 | loc.lowReg, loc.highReg); |
| 559 | } |
| 560 | nextArg += 2; |
| 561 | } else { |
| 562 | loc = oatUpdateLoc(cUnit, loc); |
| 563 | if ((nextArg >= 3) && (loc.location == kLocPhysReg)) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 564 | storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow), |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 565 | loc.lowReg, kWord); |
| 566 | } |
| 567 | nextArg++; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 568 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 569 | } |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 570 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 571 | int startOffset = oatSRegOffset(cUnit, info->args[3].sRegLow); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 572 | int outsOffset = 4 /* Method* */ + (3 * 4); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 573 | if (cUnit->instructionSet != kThumb2) { |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 574 | // Generate memcpy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 575 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg0), targetReg(kSp), outsOffset); |
| 576 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg1), targetReg(kSp), startOffset); |
| 577 | callRuntimeHelperRegRegImm(cUnit, ENTRYPOINT_OFFSET(pMemcpy), targetReg(kArg0), |
| 578 | targetReg(kArg1), (info->numArgWords - 3) * 4, false); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 579 | } else { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 580 | if (info->numArgWords >= 20) { |
| 581 | // Generate memcpy |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 582 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg0), targetReg(kSp), outsOffset); |
| 583 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg1), targetReg(kSp), startOffset); |
| 584 | callRuntimeHelperRegRegImm(cUnit, ENTRYPOINT_OFFSET(pMemcpy), targetReg(kArg0), |
| 585 | targetReg(kArg1), (info->numArgWords - 3) * 4, false); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 586 | } else { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 587 | // Use vldm/vstm pair using kArg3 as a temp |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 588 | int regsLeft = std::min(info->numArgWords - 3, 16); |
| 589 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 590 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 591 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), startOffset); |
| 592 | LIR* ld = opVldm(cUnit, targetReg(kArg3), regsLeft); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 593 | //TUNING: loosen barrier |
| 594 | ld->defMask = ENCODE_ALL; |
| 595 | setMemRefType(ld, true /* isLoad */, kDalvikReg); |
| 596 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 597 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 598 | opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), 4 /* Method* */ + (3 * 4)); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 599 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 600 | directCode, directMethod, type); |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 601 | LIR* st = opVstm(cUnit, targetReg(kArg3), regsLeft); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 602 | setMemRefType(st, false /* isLoad */, kDalvikReg); |
| 603 | st->defMask = ENCODE_ALL; |
| 604 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
| 605 | directCode, directMethod, type); |
| 606 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 607 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 608 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 609 | callState = loadArgRegs(cUnit, info, callState, nextCallInsn, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 610 | dexIdx, methodIdx, directCode, directMethod, |
| 611 | type, skipThis); |
| 612 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 613 | callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 614 | directCode, directMethod, type); |
| 615 | if (pcrLabel) { |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 616 | *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 617 | info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 618 | } |
| 619 | return callState; |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 620 | } |
| 621 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 622 | RegLocation inlineTarget(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 623 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 624 | RegLocation res; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 625 | if (info->result.location == kLocInvalid) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 626 | res = oatGetReturn(cUnit, false); |
| 627 | } else { |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 628 | res = info->result; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 629 | } |
| 630 | return res; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 631 | } |
| 632 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 633 | RegLocation inlineTargetWide(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 634 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 635 | RegLocation res; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 636 | if (info->result.location == kLocInvalid) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 637 | res = oatGetReturnWide(cUnit, false); |
| 638 | } else { |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 639 | res = info->result; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 640 | } |
| 641 | return res; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 642 | } |
| 643 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 644 | bool genInlinedCharAt(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 645 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 646 | if (cUnit->instructionSet == kMips) { |
| 647 | // TODO - add Mips implementation |
| 648 | return false; |
| 649 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 650 | // Location of reference to data array |
| 651 | int valueOffset = String::ValueOffset().Int32Value(); |
| 652 | // Location of count |
| 653 | int countOffset = String::CountOffset().Int32Value(); |
| 654 | // Starting offset within data array |
| 655 | int offsetOffset = String::OffsetOffset().Int32Value(); |
| 656 | // Start of char data with array_ |
| 657 | int dataOffset = Array::DataOffset(sizeof(uint16_t)).Int32Value(); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 658 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 659 | RegLocation rlObj = info->args[0]; |
| 660 | RegLocation rlIdx = info->args[1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 661 | rlObj = loadValue(cUnit, rlObj, kCoreReg); |
| 662 | rlIdx = loadValue(cUnit, rlIdx, kCoreReg); |
| 663 | int regMax; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 664 | genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags); |
| 665 | bool rangeCheck = (!(info->optFlags & MIR_IGNORE_RANGE_CHECK)); |
jeffhao | 634ea28 | 2012-08-10 13:04:01 -0700 | [diff] [blame] | 666 | LIR* launchPad = NULL; |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 667 | int regOff = INVALID_REG; |
| 668 | int regPtr = INVALID_REG; |
| 669 | if (cUnit->instructionSet != kX86) { |
| 670 | regOff = oatAllocTemp(cUnit); |
| 671 | regPtr = oatAllocTemp(cUnit); |
| 672 | if (rangeCheck) { |
| 673 | regMax = oatAllocTemp(cUnit); |
| 674 | loadWordDisp(cUnit, rlObj.lowReg, countOffset, regMax); |
| 675 | } |
| 676 | loadWordDisp(cUnit, rlObj.lowReg, offsetOffset, regOff); |
| 677 | loadWordDisp(cUnit, rlObj.lowReg, valueOffset, regPtr); |
| 678 | if (rangeCheck) { |
| 679 | // Set up a launch pad to allow retry in case of bounds violation */ |
| 680 | launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info); |
| 681 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
| 682 | (intptr_t)launchPad); |
| 683 | opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax); |
| 684 | oatFreeTemp(cUnit, regMax); |
| 685 | opCondBranch(cUnit, kCondCs, launchPad); |
| 686 | } |
| 687 | } else { |
| 688 | if (rangeCheck) { |
| 689 | regMax = oatAllocTemp(cUnit); |
| 690 | loadWordDisp(cUnit, rlObj.lowReg, countOffset, regMax); |
| 691 | // Set up a launch pad to allow retry in case of bounds violation */ |
| 692 | launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info); |
| 693 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
| 694 | (intptr_t)launchPad); |
| 695 | opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax); |
| 696 | oatFreeTemp(cUnit, regMax); |
| 697 | opCondBranch(cUnit, kCondCc, launchPad); |
| 698 | } |
| 699 | regOff = oatAllocTemp(cUnit); |
| 700 | regPtr = oatAllocTemp(cUnit); |
| 701 | loadWordDisp(cUnit, rlObj.lowReg, offsetOffset, regOff); |
| 702 | loadWordDisp(cUnit, rlObj.lowReg, valueOffset, regPtr); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 703 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 704 | opRegImm(cUnit, kOpAdd, regPtr, dataOffset); |
| 705 | opRegReg(cUnit, kOpAdd, regOff, rlIdx.lowReg); |
jeffhao | 634ea28 | 2012-08-10 13:04:01 -0700 | [diff] [blame] | 706 | oatFreeTemp(cUnit, rlObj.lowReg); |
| 707 | oatFreeTemp(cUnit, rlIdx.lowReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 708 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 709 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 710 | loadBaseIndexed(cUnit, regPtr, regOff, rlResult.lowReg, 1, kUnsignedHalf); |
| 711 | oatFreeTemp(cUnit, regOff); |
| 712 | oatFreeTemp(cUnit, regPtr); |
| 713 | storeValue(cUnit, rlDest, rlResult); |
| 714 | if (rangeCheck) { |
Elliott Hughes | 6023456 | 2012-06-01 12:25:59 -0700 | [diff] [blame] | 715 | launchPad->operands[2] = 0; // no resumption |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 716 | } |
| 717 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 718 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 719 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | // Generates an inlined String.isEmpty or String.length. |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 723 | bool genInlinedStringIsEmptyOrLength(CompilationUnit* cUnit, CallInfo* info, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 724 | bool isEmpty) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 725 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 726 | if (cUnit->instructionSet == kMips) { |
| 727 | // TODO - add Mips implementation |
| 728 | return false; |
| 729 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 730 | // dst = src.length(); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 731 | RegLocation rlObj = info->args[0]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 732 | rlObj = loadValue(cUnit, rlObj, kCoreReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 733 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 734 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 735 | genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 736 | loadWordDisp(cUnit, rlObj.lowReg, String::CountOffset().Int32Value(), |
| 737 | rlResult.lowReg); |
| 738 | if (isEmpty) { |
| 739 | // dst = (dst == 0); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 740 | if (cUnit->instructionSet == kThumb2) { |
| 741 | int tReg = oatAllocTemp(cUnit); |
| 742 | opRegReg(cUnit, kOpNeg, tReg, rlResult.lowReg); |
| 743 | opRegRegReg(cUnit, kOpAdc, rlResult.lowReg, rlResult.lowReg, tReg); |
| 744 | } else { |
| 745 | DCHECK_EQ(cUnit->instructionSet, kX86); |
| 746 | opRegImm(cUnit, kOpSub, rlResult.lowReg, 1); |
| 747 | opRegImm(cUnit, kOpLsr, rlResult.lowReg, 31); |
| 748 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 749 | } |
| 750 | storeValue(cUnit, rlDest, rlResult); |
| 751 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 752 | } |
| 753 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 754 | bool genInlinedAbsInt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 755 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 756 | if (cUnit->instructionSet == kMips) { |
| 757 | // TODO - add Mips implementation |
| 758 | return false; |
| 759 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 760 | RegLocation rlSrc = info->args[0]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 761 | rlSrc = loadValue(cUnit, rlSrc, kCoreReg); |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 762 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 763 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 764 | int signReg = oatAllocTemp(cUnit); |
| 765 | // abs(x) = y<=x>>31, (x+y)^y. |
| 766 | opRegRegImm(cUnit, kOpAsr, signReg, rlSrc.lowReg, 31); |
| 767 | opRegRegReg(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, signReg); |
| 768 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 769 | storeValue(cUnit, rlDest, rlResult); |
| 770 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 771 | } |
| 772 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 773 | bool genInlinedAbsLong(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 774 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 775 | if (cUnit->instructionSet == kMips) { |
| 776 | // TODO - add Mips implementation |
| 777 | return false; |
| 778 | } |
| 779 | if (cUnit->instructionSet == kThumb2) { |
| 780 | RegLocation rlSrc = info->args[0]; |
| 781 | rlSrc = loadValueWide(cUnit, rlSrc, kCoreReg); |
| 782 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
| 783 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 784 | int signReg = oatAllocTemp(cUnit); |
| 785 | // abs(x) = y<=x>>31, (x+y)^y. |
| 786 | opRegRegImm(cUnit, kOpAsr, signReg, rlSrc.highReg, 31); |
| 787 | opRegRegReg(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, signReg); |
| 788 | opRegRegReg(cUnit, kOpAdc, rlResult.highReg, rlSrc.highReg, signReg); |
| 789 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 790 | opRegReg(cUnit, kOpXor, rlResult.highReg, signReg); |
| 791 | storeValueWide(cUnit, rlDest, rlResult); |
| 792 | return true; |
| 793 | } else { |
| 794 | DCHECK_EQ(cUnit->instructionSet, kX86); |
| 795 | // Reuse source registers to avoid running out of temps |
| 796 | RegLocation rlSrc = info->args[0]; |
| 797 | rlSrc = loadValueWide(cUnit, rlSrc, kCoreReg); |
| 798 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
| 799 | RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); |
| 800 | opRegCopyWide(cUnit, rlResult.lowReg, rlResult.highReg, rlSrc.lowReg, rlSrc.highReg); |
| 801 | oatFreeTemp(cUnit, rlSrc.lowReg); |
| 802 | oatFreeTemp(cUnit, rlSrc.highReg); |
| 803 | int signReg = oatAllocTemp(cUnit); |
| 804 | // abs(x) = y<=x>>31, (x+y)^y. |
| 805 | opRegRegImm(cUnit, kOpAsr, signReg, rlResult.highReg, 31); |
| 806 | opRegReg(cUnit, kOpAdd, rlResult.lowReg, signReg); |
| 807 | opRegReg(cUnit, kOpAdc, rlResult.highReg, signReg); |
| 808 | opRegReg(cUnit, kOpXor, rlResult.lowReg, signReg); |
| 809 | opRegReg(cUnit, kOpXor, rlResult.highReg, signReg); |
| 810 | storeValueWide(cUnit, rlDest, rlResult); |
| 811 | return true; |
| 812 | } |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 813 | } |
| 814 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 815 | bool genInlinedFloatCvt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 816 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 817 | if (cUnit->instructionSet == kMips) { |
| 818 | // TODO - add Mips implementation |
| 819 | return false; |
| 820 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 821 | RegLocation rlSrc = info->args[0]; |
| 822 | RegLocation rlDest = inlineTarget(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 823 | storeValue(cUnit, rlDest, rlSrc); |
| 824 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 825 | } |
| 826 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 827 | bool genInlinedDoubleCvt(CompilationUnit *cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 828 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 829 | if (cUnit->instructionSet == kMips) { |
| 830 | // TODO - add Mips implementation |
| 831 | return false; |
| 832 | } |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 833 | RegLocation rlSrc = info->args[0]; |
| 834 | RegLocation rlDest = inlineTargetWide(cUnit, info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 835 | storeValueWide(cUnit, rlDest, rlSrc); |
| 836 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | /* |
| 840 | * Fast string.indexOf(I) & (II). Tests for simple case of char <= 0xffff, |
| 841 | * otherwise bails to standard library code. |
| 842 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 843 | bool genInlinedIndexOf(CompilationUnit* cUnit, CallInfo* info, |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 844 | bool zeroBased) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 845 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 846 | if (cUnit->instructionSet == kMips) { |
| 847 | // TODO - add Mips implementation |
| 848 | return false; |
| 849 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 850 | oatClobberCalleeSave(cUnit); |
| 851 | oatLockCallTemps(cUnit); // Using fixed registers |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 852 | int regPtr = targetReg(kArg0); |
| 853 | int regChar = targetReg(kArg1); |
| 854 | int regStart = targetReg(kArg2); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 855 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 856 | RegLocation rlObj = info->args[0]; |
| 857 | RegLocation rlChar = info->args[1]; |
| 858 | RegLocation rlStart = info->args[2]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 859 | loadValueDirectFixed(cUnit, rlObj, regPtr); |
| 860 | loadValueDirectFixed(cUnit, rlChar, regChar); |
| 861 | if (zeroBased) { |
| 862 | loadConstant(cUnit, regStart, 0); |
| 863 | } else { |
| 864 | loadValueDirectFixed(cUnit, rlStart, regStart); |
| 865 | } |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 866 | int rTgt = (cUnit->instructionSet != kX86) ? loadHelper(cUnit, ENTRYPOINT_OFFSET(pIndexOf)) : 0; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 867 | genNullCheck(cUnit, rlObj.sRegLow, regPtr, info->optFlags); |
| 868 | LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 869 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
| 870 | (intptr_t)launchPad); |
| 871 | opCmpImmBranch(cUnit, kCondGt, regChar, 0xFFFF, launchPad); |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 872 | // NOTE: not a safepoint |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 873 | if (cUnit->instructionSet != kX86) { |
| 874 | opReg(cUnit, kOpBlx, rTgt); |
| 875 | } else { |
| 876 | opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pIndexOf)); |
| 877 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 878 | LIR* resumeTgt = newLIR0(cUnit, kPseudoTargetLabel); |
| 879 | launchPad->operands[2] = (uintptr_t)resumeTgt; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 880 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 881 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
| 882 | RegLocation rlReturn = oatGetReturn(cUnit, false); |
| 883 | RegLocation rlDest = inlineTarget(cUnit, info); |
| 884 | storeValue(cUnit, rlDest, rlReturn); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 885 | return true; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 886 | } |
| 887 | |
| 888 | /* Fast string.compareTo(Ljava/lang/string;)I. */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 889 | bool genInlinedStringCompareTo(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 890 | { |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 891 | if (cUnit->instructionSet == kMips) { |
| 892 | // TODO - add Mips implementation |
| 893 | return false; |
| 894 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 895 | oatClobberCalleeSave(cUnit); |
| 896 | oatLockCallTemps(cUnit); // Using fixed registers |
buzbee | f0504cd | 2012-11-13 16:31:10 -0800 | [diff] [blame] | 897 | int regThis = targetReg(kArg0); |
| 898 | int regCmp = targetReg(kArg1); |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 899 | |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 900 | RegLocation rlThis = info->args[0]; |
| 901 | RegLocation rlCmp = info->args[1]; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 902 | loadValueDirectFixed(cUnit, rlThis, regThis); |
| 903 | loadValueDirectFixed(cUnit, rlCmp, regCmp); |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 904 | int rTgt = (cUnit->instructionSet != kX86) ? |
| 905 | loadHelper(cUnit, ENTRYPOINT_OFFSET(pStringCompareTo)) : 0; |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 906 | genNullCheck(cUnit, rlThis.sRegLow, regThis, info->optFlags); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 907 | //TUNING: check if rlCmp.sRegLow is already null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 908 | LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 909 | oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, |
Elliott Hughes | 6023456 | 2012-06-01 12:25:59 -0700 | [diff] [blame] | 910 | (intptr_t)launchPad); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 911 | opCmpImmBranch(cUnit, kCondEq, regCmp, 0, launchPad); |
buzbee | 8320f38 | 2012-09-11 16:29:42 -0700 | [diff] [blame] | 912 | // NOTE: not a safepoint |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 913 | if (cUnit->instructionSet != kX86) { |
| 914 | opReg(cUnit, kOpBlx, rTgt); |
| 915 | } else { |
| 916 | opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pStringCompareTo)); |
| 917 | } |
Elliott Hughes | 6023456 | 2012-06-01 12:25:59 -0700 | [diff] [blame] | 918 | launchPad->operands[2] = 0; // No return possible |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 919 | // Record that we've already inlined & null checked |
buzbee | 15bf980 | 2012-06-12 17:49:27 -0700 | [diff] [blame] | 920 | info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK); |
| 921 | RegLocation rlReturn = oatGetReturn(cUnit, false); |
| 922 | RegLocation rlDest = inlineTarget(cUnit, info); |
| 923 | storeValue(cUnit, rlDest, rlReturn); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 924 | return true; |
Ian Rogers | 0183dd7 | 2012-09-17 23:06:51 -0700 | [diff] [blame] | 925 | } |
| 926 | |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 927 | bool genIntrinsic(CompilationUnit* cUnit, CallInfo* info) |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 928 | { |
Ian Rogers | e13eafa | 2012-09-07 11:24:27 -0700 | [diff] [blame] | 929 | if (info->optFlags & MIR_INLINED) { |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 930 | return false; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 931 | } |
| 932 | /* |
| 933 | * TODO: move these to a target-specific structured constant array |
| 934 | * and use a generic match function. The list of intrinsics may be |
| 935 | * slightly different depending on target. |
| 936 | * TODO: Fold this into a matching function that runs during |
| 937 | * basic block building. This should be part of the action for |
| 938 | * small method inlining and recognition of the special object init |
| 939 | * method. By doing this during basic block construction, we can also |
| 940 | * take advantage of/generate new useful dataflow info. |
| 941 | */ |
buzbee | 3b3dbdd | 2012-06-13 13:39:34 -0700 | [diff] [blame] | 942 | std::string tgtMethod(PrettyMethod(info->index, *cUnit->dex_file)); |
Ian Rogers | 0183dd7 | 2012-09-17 23:06:51 -0700 | [diff] [blame] | 943 | if (tgtMethod.find(" java.lang") != std::string::npos) { |
| 944 | if (tgtMethod == "long java.lang.Double.doubleToRawLongBits(double)") { |
| 945 | return genInlinedDoubleCvt(cUnit, info); |
| 946 | } |
| 947 | if (tgtMethod == "double java.lang.Double.longBitsToDouble(long)") { |
| 948 | return genInlinedDoubleCvt(cUnit, info); |
| 949 | } |
| 950 | if (tgtMethod == "int java.lang.Float.floatToRawIntBits(float)") { |
| 951 | return genInlinedFloatCvt(cUnit, info); |
| 952 | } |
| 953 | if (tgtMethod == "float java.lang.Float.intBitsToFloat(int)") { |
| 954 | return genInlinedFloatCvt(cUnit, info); |
| 955 | } |
| 956 | if (tgtMethod == "int java.lang.Math.abs(int)" || |
| 957 | tgtMethod == "int java.lang.StrictMath.abs(int)") { |
| 958 | return genInlinedAbsInt(cUnit, info); |
| 959 | } |
| 960 | if (tgtMethod == "long java.lang.Math.abs(long)" || |
| 961 | tgtMethod == "long java.lang.StrictMath.abs(long)") { |
| 962 | return genInlinedAbsLong(cUnit, info); |
| 963 | } |
| 964 | if (tgtMethod == "int java.lang.Math.max(int, int)" || |
| 965 | tgtMethod == "int java.lang.StrictMath.max(int, int)") { |
| 966 | return genInlinedMinMaxInt(cUnit, info, false /* isMin */); |
| 967 | } |
| 968 | if (tgtMethod == "int java.lang.Math.min(int, int)" || |
| 969 | tgtMethod == "int java.lang.StrictMath.min(int, int)") { |
| 970 | return genInlinedMinMaxInt(cUnit, info, true /* isMin */); |
| 971 | } |
| 972 | if (tgtMethod == "double java.lang.Math.sqrt(double)" || |
| 973 | tgtMethod == "double java.lang.StrictMath.sqrt(double)") { |
| 974 | return genInlinedSqrt(cUnit, info); |
| 975 | } |
| 976 | if (tgtMethod == "char java.lang.String.charAt(int)") { |
| 977 | return genInlinedCharAt(cUnit, info); |
| 978 | } |
| 979 | if (tgtMethod == "int java.lang.String.compareTo(java.lang.String)") { |
| 980 | return genInlinedStringCompareTo(cUnit, info); |
| 981 | } |
| 982 | if (tgtMethod == "boolean java.lang.String.isEmpty()") { |
| 983 | return genInlinedStringIsEmptyOrLength(cUnit, info, true /* isEmpty */); |
| 984 | } |
| 985 | if (tgtMethod == "int java.lang.String.indexOf(int, int)") { |
| 986 | return genInlinedIndexOf(cUnit, info, false /* base 0 */); |
| 987 | } |
| 988 | if (tgtMethod == "int java.lang.String.indexOf(int)") { |
| 989 | return genInlinedIndexOf(cUnit, info, true /* base 0 */); |
| 990 | } |
| 991 | if (tgtMethod == "int java.lang.String.length()") { |
| 992 | return genInlinedStringIsEmptyOrLength(cUnit, info, false /* isEmpty */); |
| 993 | } |
| 994 | } else if (tgtMethod.find("boolean sun.misc.Unsafe.compareAndSwap") != std::string::npos) { |
| 995 | if (tgtMethod == "boolean sun.misc.Unsafe.compareAndSwapInt(java.lang.Object, long, int, int)") { |
| 996 | return genInlinedCas32(cUnit, info, false); |
| 997 | } |
| 998 | if (tgtMethod == "boolean sun.misc.Unsafe.compareAndSwapObject(java.lang.Object, long, java.lang.Object, java.lang.Object)") { |
| 999 | return genInlinedCas32(cUnit, info, true); |
| 1000 | } |
Ian Rogers | e13eafa | 2012-09-07 11:24:27 -0700 | [diff] [blame] | 1001 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1002 | return false; |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 1006 | } // namespace art |