blob: efd4f5ae6a13db037a4d5569bb520e3c7cb37fee [file] [log] [blame]
buzbee31a4a6f2012-02-28 15:36:15 -08001/*
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 Rogers57b86d42012-03-27 16:05:41 -070017#include "oat/runtime/oat_support_entrypoints.h"
18
buzbee31a4a6f2012-02-28 15:36:15 -080019namespace 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
buzbee3b3dbdd2012-06-13 13:39:34 -070027typedef int (*NextCallInsn)(CompilationUnit*, CallInfo*, int, uint32_t dexIdx,
Ian Rogers2ed3b952012-03-17 11:49:39 -070028 uint32_t methodIdx, uintptr_t directCode,
Brian Carlstromf5822582012-03-19 22:34:31 -070029 uintptr_t directMethod, InvokeType type);
buzbeefc9e6fa2012-03-23 15:14:29 -070030LIR* opCondBranch(CompilationUnit* cUnit, ConditionCode cc, LIR* target);
31
buzbee31a4a6f2012-02-28 15:36:15 -080032/*
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.
buzbeead8f15e2012-06-18 14:49:45 -070036 *
37 * argLocs is an array of location records describing the incoming arguments
38 * with one location record per word of argument.
buzbee31a4a6f2012-02-28 15:36:15 -080039 */
buzbeead8f15e2012-06-18 14:49:45 -070040void flushIns(CompilationUnit* cUnit, RegLocation* argLocs, RegLocation rlMethod)
buzbee31a4a6f2012-02-28 15:36:15 -080041{
Bill Buzbeea114add2012-05-03 15:00:40 -070042 /*
43 * Dummy up a RegLocation for the incoming Method*
buzbeef0504cd2012-11-13 16:31:10 -080044 * It will attempt to keep kArg0 live (or copy it to home location
Bill Buzbeea114add2012-05-03 15:00:40 -070045 * if promoted).
46 */
buzbeead8f15e2012-06-18 14:49:45 -070047 RegLocation rlSrc = rlMethod;
Bill Buzbeea114add2012-05-03 15:00:40 -070048 rlSrc.location = kLocPhysReg;
buzbeef0504cd2012-11-13 16:31:10 -080049 rlSrc.lowReg = targetReg(kArg0);
Bill Buzbeea114add2012-05-03 15:00:40 -070050 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) {
buzbeef0504cd2012-11-13 16:31:10 -080055 storeWordDisp(cUnit, targetReg(kSp), 0, targetReg(kArg0));
Bill Buzbeea114add2012-05-03 15:00:40 -070056 }
buzbee9c044ce2012-03-18 13:24:07 -070057
Bill Buzbeea114add2012-05-03 15:00:40 -070058 if (cUnit->numIns == 0)
59 return;
60 const int numArgRegs = 3;
buzbeef0504cd2012-11-13 16:31:10 -080061 static SpecialTargetRegister argRegs[] = {kArg1, kArg2, kArg3};
Bill Buzbeea114add2012-05-03 15:00:40 -070062 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;
buzbeead8f15e2012-06-18 14:49:45 -070080 RegLocation* tLoc = &argLocs[i];
Bill Buzbeea114add2012-05-03 15:00:40 -070081 if ((vMap->coreLocation == kLocPhysReg) && !tLoc->fp) {
buzbeef0504cd2012-11-13 16:31:10 -080082 opRegCopy(cUnit, vMap->coreReg, targetReg(argRegs[i]));
Bill Buzbeea114add2012-05-03 15:00:40 -070083 needFlush = false;
84 } else if ((vMap->fpLocation == kLocPhysReg) && tLoc->fp) {
buzbeef0504cd2012-11-13 16:31:10 -080085 opRegCopy(cUnit, vMap->fpReg, targetReg(argRegs[i]));
Bill Buzbeea114add2012-05-03 15:00:40 -070086 needFlush = false;
87 } else {
88 needFlush = true;
89 }
buzbee86a4bce2012-03-06 18:15:00 -080090
Bill Buzbeea114add2012-05-03 15:00:40 -070091 // 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) {
buzbeef0504cd2012-11-13 16:31:10 -080098 storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i),
99 targetReg(argRegs[i]), kWord);
Bill Buzbeea114add2012-05-03 15:00:40 -0700100 }
101 } else {
102 // If arriving in frame & promoted
103 if (vMap->coreLocation == kLocPhysReg) {
buzbeef0504cd2012-11-13 16:31:10 -0800104 loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i),
Bill Buzbeea114add2012-05-03 15:00:40 -0700105 vMap->coreReg);
106 }
107 if (vMap->fpLocation == kLocPhysReg) {
buzbeef0504cd2012-11-13 16:31:10 -0800108 loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, startVReg + i),
Bill Buzbeea114add2012-05-03 15:00:40 -0700109 vMap->fpReg);
110 }
buzbee31a4a6f2012-02-28 15:36:15 -0800111 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700112 }
buzbee31a4a6f2012-02-28 15:36:15 -0800113}
114
Ian Rogers3fa13792012-03-18 15:53:45 -0700115void scanMethodLiteralPool(CompilationUnit* cUnit, LIR** methodTarget, LIR** codeTarget, const DexFile* dexFile, uint32_t dexMethodIdx)
116{
Bill Buzbeea114add2012-05-03 15:00:40 -0700117 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 Rogers3fa13792012-03-18 15:53:45 -0700128 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700129 curTarget = nextTarget->next;
130 nextTarget = curTarget != NULL ? curTarget->next : NULL;
131 }
Ian Rogers3fa13792012-03-18 15:53:45 -0700132}
133
buzbee31a4a6f2012-02-28 15:36:15 -0800134/*
Elliott Hughesbdf6c3d2012-03-20 13:43:53 -0700135 * Bit of a hack here - in the absence of a real scheduling pass,
buzbee31a4a6f2012-02-28 15:36:15 -0800136 * emit the next instruction in static & direct invoke sequences.
137 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700138int nextSDCallInsn(CompilationUnit* cUnit, CallInfo* info,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700139 int state, uint32_t dexIdx, uint32_t unused,
Brian Carlstromf5822582012-03-19 22:34:31 -0700140 uintptr_t directCode, uintptr_t directMethod,
141 InvokeType type)
buzbee31a4a6f2012-02-28 15:36:15 -0800142{
buzbeeb046e162012-10-30 15:48:42 -0700143 if (cUnit->instructionSet != kThumb2) {
144 // Disable sharpening
145 directCode = 0;
146 directMethod = 0;
147 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700148 if (directCode != 0 && directMethod != 0) {
149 switch (state) {
buzbeef0504cd2012-11-13 16:31:10 -0800150 case 0: // Get the current Method* [sets kArg0]
Bill Buzbeea114add2012-05-03 15:00:40 -0700151 if (directCode != (uintptr_t)-1) {
buzbeef0504cd2012-11-13 16:31:10 -0800152 loadConstant(cUnit, targetReg(kInvokeTgt), directCode);
Bill Buzbeea114add2012-05-03 15:00:40 -0700153 } 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 Rogers2ed3b952012-03-17 11:49:39 -0700158 }
buzbeef0504cd2012-11-13 16:31:10 -0800159 LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget);
Bill Buzbeea114add2012-05-03 15:00:40 -0700160 oatAppendLIR(cUnit, loadPcRel);
buzbeeb046e162012-10-30 15:48:42 -0700161 DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
Bill Buzbeea114add2012-05-03 15:00:40 -0700162 }
163 if (directMethod != (uintptr_t)-1) {
buzbeef0504cd2012-11-13 16:31:10 -0800164 loadConstant(cUnit, targetReg(kArg0), directMethod);
Bill Buzbeea114add2012-05-03 15:00:40 -0700165 } 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 }
buzbeef0504cd2012-11-13 16:31:10 -0800171 LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget);
Bill Buzbeea114add2012-05-03 15:00:40 -0700172 oatAppendLIR(cUnit, loadPcRel);
buzbeeb046e162012-10-30 15:48:42 -0700173 DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
Bill Buzbeea114add2012-05-03 15:00:40 -0700174 }
175 break;
176 default:
177 return -1;
buzbee31a4a6f2012-02-28 15:36:15 -0800178 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700179 } else {
180 switch (state) {
buzbeef0504cd2012-11-13 16:31:10 -0800181 case 0: // Get the current Method* [sets kArg0]
Ian Rogers137e88f2012-10-08 17:46:47 -0700182 // TUNING: we can save a reg copy if Method* has been promoted.
buzbeef0504cd2012-11-13 16:31:10 -0800183 loadCurrMethodDirect(cUnit, targetReg(kArg0));
Bill Buzbeea114add2012-05-03 15:00:40 -0700184 break;
185 case 1: // Get method->dex_cache_resolved_methods_
buzbeef0504cd2012-11-13 16:31:10 -0800186 loadWordDisp(cUnit, targetReg(kArg0),
187 AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), targetReg(kArg0));
Bill Buzbeea114add2012-05-03 15:00:40 -0700188 // Set up direct code if known.
189 if (directCode != 0) {
190 if (directCode != (uintptr_t)-1) {
buzbeef0504cd2012-11-13 16:31:10 -0800191 loadConstant(cUnit, targetReg(kInvokeTgt), directCode);
Bill Buzbeea114add2012-05-03 15:00:40 -0700192 } 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 }
buzbeef0504cd2012-11-13 16:31:10 -0800198 LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget);
Bill Buzbeea114add2012-05-03 15:00:40 -0700199 oatAppendLIR(cUnit, loadPcRel);
buzbeeb046e162012-10-30 15:48:42 -0700200 DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
Bill Buzbeea114add2012-05-03 15:00:40 -0700201 }
202 }
203 break;
204 case 2: // Grab target method*
buzbeef0504cd2012-11-13 16:31:10 -0800205 loadWordDisp(cUnit, targetReg(kArg0),
206 Array::DataOffset(sizeof(Object*)).Int32Value() + dexIdx * 4, targetReg(kArg0));
Bill Buzbeea114add2012-05-03 15:00:40 -0700207 break;
Bill Buzbeea114add2012-05-03 15:00:40 -0700208 case 3: // Grab the code from the method*
buzbeeb046e162012-10-30 15:48:42 -0700209 if (cUnit->instructionSet != kX86) {
210 if (directCode == 0) {
buzbeef0504cd2012-11-13 16:31:10 -0800211 loadWordDisp(cUnit, targetReg(kArg0), AbstractMethod::GetCodeOffset().Int32Value(),
212 targetReg(kInvokeTgt));
buzbeeb046e162012-10-30 15:48:42 -0700213 }
214 break;
Bill Buzbeea114add2012-05-03 15:00:40 -0700215 }
buzbeeb046e162012-10-30 15:48:42 -0700216 // Intentional fallthrough for x86
Bill Buzbeea114add2012-05-03 15:00:40 -0700217 default:
218 return -1;
219 }
220 }
221 return state + 1;
buzbee31a4a6f2012-02-28 15:36:15 -0800222}
223
224/*
Elliott Hughesbdf6c3d2012-03-20 13:43:53 -0700225 * Bit of a hack here - in the absence of a real scheduling pass,
buzbee31a4a6f2012-02-28 15:36:15 -0800226 * emit the next instruction in a virtual invoke sequence.
buzbeef0504cd2012-11-13 16:31:10 -0800227 * We can use kLr as a temp prior to target address loading
buzbee31a4a6f2012-02-28 15:36:15 -0800228 * Note also that we'll load the first argument ("this") into
buzbeef0504cd2012-11-13 16:31:10 -0800229 * kArg1 here rather than the standard loadArgRegs.
buzbee31a4a6f2012-02-28 15:36:15 -0800230 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700231int nextVCallInsn(CompilationUnit* cUnit, CallInfo* info,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700232 int state, uint32_t dexIdx, uint32_t methodIdx,
Brian Carlstromf5822582012-03-19 22:34:31 -0700233 uintptr_t unused, uintptr_t unused2, InvokeType unused3)
buzbee31a4a6f2012-02-28 15:36:15 -0800234{
Bill Buzbeea114add2012-05-03 15:00:40 -0700235 /*
236 * This is the fast path in which the target virtual method is
237 * fully resolved at compile time.
238 */
239 switch (state) {
buzbeef0504cd2012-11-13 16:31:10 -0800240 case 0: { // Get "this" [set kArg1]
Ian Rogers137e88f2012-10-08 17:46:47 -0700241 RegLocation rlArg = info->args[0];
buzbeef0504cd2012-11-13 16:31:10 -0800242 loadValueDirectFixed(cUnit, rlArg, targetReg(kArg1));
Bill Buzbeea114add2012-05-03 15:00:40 -0700243 break;
Ian Rogers137e88f2012-10-08 17:46:47 -0700244 }
buzbeef0504cd2012-11-13 16:31:10 -0800245 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 Buzbeea114add2012-05-03 15:00:40 -0700250 break;
buzbeef0504cd2012-11-13 16:31:10 -0800251 case 2: // Get this->klass_->vtable [usr kInvokeTgt, set kInvokeTgt]
252 loadWordDisp(cUnit, targetReg(kInvokeTgt), Class::VTableOffset().Int32Value(),
253 targetReg(kInvokeTgt));
Bill Buzbeea114add2012-05-03 15:00:40 -0700254 break;
buzbeef0504cd2012-11-13 16:31:10 -0800255 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 Buzbeea114add2012-05-03 15:00:40 -0700258 break;
buzbeef0504cd2012-11-13 16:31:10 -0800259 case 4: // Get the compiled code address [uses kArg0, sets kInvokeTgt]
buzbeeb046e162012-10-30 15:48:42 -0700260 if (cUnit->instructionSet != kX86) {
buzbeef0504cd2012-11-13 16:31:10 -0800261 loadWordDisp(cUnit, targetReg(kArg0), AbstractMethod::GetCodeOffset().Int32Value(),
262 targetReg(kInvokeTgt));
buzbeeb046e162012-10-30 15:48:42 -0700263 break;
264 }
265 // Intentional fallthrough for X86
Bill Buzbeea114add2012-05-03 15:00:40 -0700266 default:
267 return -1;
268 }
269 return state + 1;
buzbee31a4a6f2012-02-28 15:36:15 -0800270}
271
Ian Rogers137e88f2012-10-08 17:46:47 -0700272/*
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 */
276int nextInterfaceCallInsn(CompilationUnit* cUnit, CallInfo* info, int state,
277 uint32_t dexIdx, uint32_t unused, uintptr_t unused2,
278 uintptr_t directMethod, InvokeType unused4)
279{
buzbeeb046e162012-10-30 15:48:42 -0700280 if (cUnit->instructionSet != kThumb2) {
281 // Disable sharpening
282 directMethod = 0;
283 }
284 int trampoline = (cUnit->instructionSet == kX86) ? 0
285 : ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline);
Ian Rogers137e88f2012-10-08 17:46:47 -0700286
287 if (directMethod != 0) {
288 switch (state) {
buzbeef0504cd2012-11-13 16:31:10 -0800289 case 0: // Load the trampoline target [sets kInvokeTgt].
buzbeeb046e162012-10-30 15:48:42 -0700290 if (cUnit->instructionSet != kX86) {
buzbeef0504cd2012-11-13 16:31:10 -0800291 loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt));
buzbeeb046e162012-10-30 15:48:42 -0700292 }
buzbeef0504cd2012-11-13 16:31:10 -0800293 // Get the interface Method* [sets kArg0]
Ian Rogers137e88f2012-10-08 17:46:47 -0700294 if (directMethod != (uintptr_t)-1) {
buzbeef0504cd2012-11-13 16:31:10 -0800295 loadConstant(cUnit, targetReg(kArg0), directMethod);
Ian Rogers137e88f2012-10-08 17:46:47 -0700296 } 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 }
buzbeef0504cd2012-11-13 16:31:10 -0800302 LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget);
Ian Rogers137e88f2012-10-08 17:46:47 -0700303 oatAppendLIR(cUnit, loadPcRel);
buzbeeb046e162012-10-30 15:48:42 -0700304 DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
Ian Rogers137e88f2012-10-08 17:46:47 -0700305 }
306 break;
307 default:
308 return -1;
309 }
310 } else {
311 switch (state) {
312 case 0:
buzbeef0504cd2012-11-13 16:31:10 -0800313 // 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].
buzbeeb046e162012-10-30 15:48:42 -0700316 if (cUnit->instructionSet != kX86) {
buzbeef0504cd2012-11-13 16:31:10 -0800317 loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt));
buzbeeb046e162012-10-30 15:48:42 -0700318 }
Ian Rogers137e88f2012-10-08 17:46:47 -0700319 break;
buzbeef0504cd2012-11-13 16:31:10 -0800320 case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0]
321 loadWordDisp(cUnit, targetReg(kArg0),
Ian Rogers137e88f2012-10-08 17:46:47 -0700322 AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(),
buzbeef0504cd2012-11-13 16:31:10 -0800323 targetReg(kArg0));
Ian Rogers137e88f2012-10-08 17:46:47 -0700324 break;
buzbeef0504cd2012-11-13 16:31:10 -0800325 case 2: // Grab target method* [set/use kArg0]
326 loadWordDisp(cUnit, targetReg(kArg0),
Ian Rogers137e88f2012-10-08 17:46:47 -0700327 Array::DataOffset(sizeof(Object*)).Int32Value() + dexIdx * 4,
buzbeef0504cd2012-11-13 16:31:10 -0800328 targetReg(kArg0));
Ian Rogers137e88f2012-10-08 17:46:47 -0700329 break;
330 default:
331 return -1;
332 }
333 }
334 return state + 1;
335}
336
buzbee3b3dbdd2012-06-13 13:39:34 -0700337int nextInvokeInsnSP(CompilationUnit* cUnit, CallInfo* info, int trampoline,
buzbee31a4a6f2012-02-28 15:36:15 -0800338 int state, uint32_t dexIdx, uint32_t methodIdx)
339{
Bill Buzbeea114add2012-05-03 15:00:40 -0700340 /*
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) {
buzbeeb046e162012-10-30 15:48:42 -0700345 if (cUnit->instructionSet != kX86) {
346 // Load trampoline target
buzbeef0504cd2012-11-13 16:31:10 -0800347 loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt));
buzbeeb046e162012-10-30 15:48:42 -0700348 }
buzbeef0504cd2012-11-13 16:31:10 -0800349 // Load kArg0 with method index
350 loadConstant(cUnit, targetReg(kArg0), dexIdx);
Bill Buzbeea114add2012-05-03 15:00:40 -0700351 return 1;
352 }
353 return -1;
buzbee31a4a6f2012-02-28 15:36:15 -0800354}
355
buzbee3b3dbdd2012-06-13 13:39:34 -0700356int nextStaticCallInsnSP(CompilationUnit* cUnit, CallInfo* info,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700357 int state, uint32_t dexIdx, uint32_t methodIdx,
Brian Carlstromf5822582012-03-19 22:34:31 -0700358 uintptr_t unused, uintptr_t unused2,
359 InvokeType unused3)
buzbee31a4a6f2012-02-28 15:36:15 -0800360{
Ian Rogers57b86d42012-03-27 16:05:41 -0700361 int trampoline = ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck);
buzbee15bf9802012-06-12 17:49:27 -0700362 return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0);
buzbee31a4a6f2012-02-28 15:36:15 -0800363}
364
buzbee3b3dbdd2012-06-13 13:39:34 -0700365int nextDirectCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700366 uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused,
Brian Carlstromf5822582012-03-19 22:34:31 -0700367 uintptr_t unused2, InvokeType unused3)
buzbee31a4a6f2012-02-28 15:36:15 -0800368{
Ian Rogers57b86d42012-03-27 16:05:41 -0700369 int trampoline = ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck);
buzbee15bf9802012-06-12 17:49:27 -0700370 return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0);
buzbee31a4a6f2012-02-28 15:36:15 -0800371}
372
buzbee3b3dbdd2012-06-13 13:39:34 -0700373int nextSuperCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700374 uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused,
Brian Carlstromf5822582012-03-19 22:34:31 -0700375 uintptr_t unused2, InvokeType unused3)
buzbee31a4a6f2012-02-28 15:36:15 -0800376{
Ian Rogers57b86d42012-03-27 16:05:41 -0700377 int trampoline = ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck);
buzbee15bf9802012-06-12 17:49:27 -0700378 return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0);
buzbee31a4a6f2012-02-28 15:36:15 -0800379}
380
buzbee3b3dbdd2012-06-13 13:39:34 -0700381int nextVCallInsnSP(CompilationUnit* cUnit, CallInfo* info, int state,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700382 uint32_t dexIdx, uint32_t methodIdx, uintptr_t unused,
Brian Carlstromf5822582012-03-19 22:34:31 -0700383 uintptr_t unused2, InvokeType unused3)
buzbee31a4a6f2012-02-28 15:36:15 -0800384{
Ian Rogers57b86d42012-03-27 16:05:41 -0700385 int trampoline = ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck);
buzbee15bf9802012-06-12 17:49:27 -0700386 return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0);
buzbee31a4a6f2012-02-28 15:36:15 -0800387}
388
buzbee15bf9802012-06-12 17:49:27 -0700389int nextInterfaceCallInsnWithAccessCheck(CompilationUnit* cUnit,
buzbee3b3dbdd2012-06-13 13:39:34 -0700390 CallInfo* info, int state,
buzbee15bf9802012-06-12 17:49:27 -0700391 uint32_t dexIdx, uint32_t unused,
392 uintptr_t unused2, uintptr_t unused3,
393 InvokeType unused4)
buzbee31a4a6f2012-02-28 15:36:15 -0800394{
Ian Rogers57b86d42012-03-27 16:05:41 -0700395 int trampoline = ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck);
buzbee15bf9802012-06-12 17:49:27 -0700396 return nextInvokeInsnSP(cUnit, info, trampoline, state, dexIdx, 0);
buzbee31a4a6f2012-02-28 15:36:15 -0800397}
398
buzbee3b3dbdd2012-06-13 13:39:34 -0700399int loadArgRegs(CompilationUnit* cUnit, CallInfo* info, int callState,
buzbee15bf9802012-06-12 17:49:27 -0700400 NextCallInsn nextCallInsn, uint32_t dexIdx,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700401 uint32_t methodIdx, uintptr_t directCode,
Brian Carlstromf5822582012-03-19 22:34:31 -0700402 uintptr_t directMethod, InvokeType type, bool skipThis)
buzbee31a4a6f2012-02-28 15:36:15 -0800403{
buzbeef0504cd2012-11-13 16:31:10 -0800404 int lastArgReg = targetReg(kArg3);
405 int nextReg = targetReg(kArg1);
Bill Buzbeea114add2012-05-03 15:00:40 -0700406 int nextArg = 0;
407 if (skipThis) {
408 nextReg++;
409 nextArg++;
410 }
buzbee15bf9802012-06-12 17:49:27 -0700411 for (; (nextReg <= lastArgReg) && (nextArg < info->numArgWords); nextReg++) {
412 RegLocation rlArg = info->args[nextArg++];
Bill Buzbeea114add2012-05-03 15:00:40 -0700413 rlArg = oatUpdateRawLoc(cUnit, rlArg);
buzbeef0504cd2012-11-13 16:31:10 -0800414 if (rlArg.wide && (nextReg <= targetReg(kArg2))) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700415 loadValueDirectWideFixed(cUnit, rlArg, nextReg, nextReg + 1);
416 nextReg++;
417 nextArg++;
418 } else {
419 rlArg.wide = false;
420 loadValueDirectFixed(cUnit, rlArg, nextReg);
buzbee31a4a6f2012-02-28 15:36:15 -0800421 }
buzbee15bf9802012-06-12 17:49:27 -0700422 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700423 directCode, directMethod, type);
424 }
425 return callState;
buzbee31a4a6f2012-02-28 15:36:15 -0800426}
427
428/*
429 * Load up to 5 arguments, the first three of which will be in
buzbeef0504cd2012-11-13 16:31:10 -0800430 * kArg1 .. kArg3. On entry kArg0 contains the current method pointer,
buzbee31a4a6f2012-02-28 15:36:15 -0800431 * 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 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700435int genDalvikArgsNoRange(CompilationUnit* cUnit, CallInfo* info,
buzbee15bf9802012-06-12 17:49:27 -0700436 int callState,
buzbee31a4a6f2012-02-28 15:36:15 -0800437 LIR** pcrLabel, NextCallInsn nextCallInsn,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700438 uint32_t dexIdx, uint32_t methodIdx,
439 uintptr_t directCode, uintptr_t directMethod,
Brian Carlstromf5822582012-03-19 22:34:31 -0700440 InvokeType type, bool skipThis)
buzbee31a4a6f2012-02-28 15:36:15 -0800441{
Bill Buzbeea114add2012-05-03 15:00:40 -0700442 RegLocation rlArg;
buzbee31a4a6f2012-02-28 15:36:15 -0800443
Bill Buzbeea114add2012-05-03 15:00:40 -0700444 /* If no arguments, just return */
buzbee15bf9802012-06-12 17:49:27 -0700445 if (info->numArgWords == 0)
buzbee31a4a6f2012-02-28 15:36:15 -0800446 return callState;
Bill Buzbeea114add2012-05-03 15:00:40 -0700447
buzbee15bf9802012-06-12 17:49:27 -0700448 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700449 directCode, directMethod, type);
450
buzbee15bf9802012-06-12 17:49:27 -0700451 DCHECK_LE(info->numArgWords, 5);
452 if (info->numArgWords > 3) {
453 int32_t nextUse = 3;
Bill Buzbeea114add2012-05-03 15:00:40 -0700454 //Detect special case of wide arg spanning arg3/arg4
buzbee15bf9802012-06-12 17:49:27 -0700455 RegLocation rlUse0 = info->args[0];
456 RegLocation rlUse1 = info->args[1];
457 RegLocation rlUse2 = info->args[2];
Bill Buzbeea114add2012-05-03 15:00:40 -0700458 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 {
buzbeef0504cd2012-11-13 16:31:10 -0800466 // kArg2 & rArg3 can safely be used here
467 reg = targetReg(kArg3);
468 loadWordDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, rlArg.sRegLow) + 4, reg);
buzbee15bf9802012-06-12 17:49:27 -0700469 callState = nextCallInsn(cUnit, info, callState, dexIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700470 methodIdx, directCode, directMethod, type);
471 }
buzbeef0504cd2012-11-13 16:31:10 -0800472 storeBaseDisp(cUnit, targetReg(kSp), (nextUse + 1) * 4, reg, kWord);
473 storeBaseDisp(cUnit, targetReg(kSp), 16 /* (3+1)*4 */, reg, kWord);
buzbee15bf9802012-06-12 17:49:27 -0700474 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700475 directCode, directMethod, type);
476 nextUse++;
477 }
478 // Loop through the rest
buzbee15bf9802012-06-12 17:49:27 -0700479 while (nextUse < info->numArgWords) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700480 int lowReg;
481 int highReg = -1;
buzbee15bf9802012-06-12 17:49:27 -0700482 rlArg = info->args[nextUse];
Bill Buzbeea114add2012-05-03 15:00:40 -0700483 rlArg = oatUpdateRawLoc(cUnit, rlArg);
484 if (rlArg.location == kLocPhysReg) {
485 lowReg = rlArg.lowReg;
486 highReg = rlArg.highReg;
487 } else {
buzbeef0504cd2012-11-13 16:31:10 -0800488 lowReg = targetReg(kArg2);
Bill Buzbeea114add2012-05-03 15:00:40 -0700489 if (rlArg.wide) {
buzbeef0504cd2012-11-13 16:31:10 -0800490 highReg = targetReg(kArg3);
Bill Buzbeea114add2012-05-03 15:00:40 -0700491 loadValueDirectWideFixed(cUnit, rlArg, lowReg, highReg);
492 } else {
493 loadValueDirectFixed(cUnit, rlArg, lowReg);
494 }
buzbee15bf9802012-06-12 17:49:27 -0700495 callState = nextCallInsn(cUnit, info, callState, dexIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700496 methodIdx, directCode, directMethod, type);
497 }
498 int outsOffset = (nextUse + 1) * 4;
499 if (rlArg.wide) {
buzbeef0504cd2012-11-13 16:31:10 -0800500 storeBaseDispWide(cUnit, targetReg(kSp), outsOffset, lowReg, highReg);
Bill Buzbeea114add2012-05-03 15:00:40 -0700501 nextUse += 2;
502 } else {
buzbeef0504cd2012-11-13 16:31:10 -0800503 storeWordDisp(cUnit, targetReg(kSp), outsOffset, lowReg);
Bill Buzbeea114add2012-05-03 15:00:40 -0700504 nextUse++;
505 }
buzbee15bf9802012-06-12 17:49:27 -0700506 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700507 directCode, directMethod, type);
508 }
509 }
510
buzbee15bf9802012-06-12 17:49:27 -0700511 callState = loadArgRegs(cUnit, info, callState, nextCallInsn,
Bill Buzbeea114add2012-05-03 15:00:40 -0700512 dexIdx, methodIdx, directCode, directMethod,
513 type, skipThis);
514
515 if (pcrLabel) {
buzbeef0504cd2012-11-13 16:31:10 -0800516 *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1),
buzbee15bf9802012-06-12 17:49:27 -0700517 info->optFlags);
Bill Buzbeea114add2012-05-03 15:00:40 -0700518 }
519 return callState;
buzbee31a4a6f2012-02-28 15:36:15 -0800520}
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
buzbeef0504cd2012-11-13 16:31:10 -0800531 * Pass arg0, arg1 & arg2 in kArg1-kArg3
buzbee31a4a6f2012-02-28 15:36:15 -0800532 * If 20+ arguments
533 * Pass args arg19+ using memcpy block copy
buzbeef0504cd2012-11-13 16:31:10 -0800534 * Pass arg0, arg1 & arg2 in kArg1-kArg3
buzbee31a4a6f2012-02-28 15:36:15 -0800535 *
536 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700537int genDalvikArgsRange(CompilationUnit* cUnit, CallInfo* info, int callState,
buzbee31a4a6f2012-02-28 15:36:15 -0800538 LIR** pcrLabel, NextCallInsn nextCallInsn,
Ian Rogers2ed3b952012-03-17 11:49:39 -0700539 uint32_t dexIdx, uint32_t methodIdx,
540 uintptr_t directCode, uintptr_t directMethod,
Brian Carlstromf5822582012-03-19 22:34:31 -0700541 InvokeType type, bool skipThis)
buzbee31a4a6f2012-02-28 15:36:15 -0800542{
buzbee31a4a6f2012-02-28 15:36:15 -0800543
Bill Buzbeea114add2012-05-03 15:00:40 -0700544 // If we can treat it as non-range (Jumbo ops will use range form)
buzbee15bf9802012-06-12 17:49:27 -0700545 if (info->numArgWords <= 5)
546 return genDalvikArgsNoRange(cUnit, info, callState, pcrLabel,
Bill Buzbeea114add2012-05-03 15:00:40 -0700547 nextCallInsn, dexIdx, methodIdx,
548 directCode, directMethod, type, skipThis);
549 /*
Bill Buzbeea114add2012-05-03 15:00:40 -0700550 * 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
buzbee15bf9802012-06-12 17:49:27 -0700556 for (int nextArg = 0; nextArg < info->numArgWords;) {
557 RegLocation loc = info->args[nextArg];
Bill Buzbeea114add2012-05-03 15:00:40 -0700558 if (loc.wide) {
559 loc = oatUpdateLocWide(cUnit, loc);
560 if ((nextArg >= 2) && (loc.location == kLocPhysReg)) {
buzbeef0504cd2012-11-13 16:31:10 -0800561 storeBaseDispWide(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow),
Bill Buzbeea114add2012-05-03 15:00:40 -0700562 loc.lowReg, loc.highReg);
563 }
564 nextArg += 2;
565 } else {
566 loc = oatUpdateLoc(cUnit, loc);
567 if ((nextArg >= 3) && (loc.location == kLocPhysReg)) {
buzbeef0504cd2012-11-13 16:31:10 -0800568 storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, loc.sRegLow),
Bill Buzbeea114add2012-05-03 15:00:40 -0700569 loc.lowReg, kWord);
570 }
571 nextArg++;
buzbee31a4a6f2012-02-28 15:36:15 -0800572 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700573 }
buzbee31a4a6f2012-02-28 15:36:15 -0800574
buzbee15bf9802012-06-12 17:49:27 -0700575 int startOffset = oatSRegOffset(cUnit, info->args[3].sRegLow);
Bill Buzbeea114add2012-05-03 15:00:40 -0700576 int outsOffset = 4 /* Method* */ + (3 * 4);
buzbeeb046e162012-10-30 15:48:42 -0700577 if (cUnit->instructionSet != kThumb2) {
buzbee31a4a6f2012-02-28 15:36:15 -0800578 // Generate memcpy
buzbeef0504cd2012-11-13 16:31:10 -0800579 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 Buzbeea114add2012-05-03 15:00:40 -0700583 } else {
buzbeeb046e162012-10-30 15:48:42 -0700584 if (info->numArgWords >= 20) {
585 // Generate memcpy
buzbeef0504cd2012-11-13 16:31:10 -0800586 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);
buzbeeb046e162012-10-30 15:48:42 -0700590 } else {
buzbeef0504cd2012-11-13 16:31:10 -0800591 // Use vldm/vstm pair using kArg3 as a temp
buzbeeb046e162012-10-30 15:48:42 -0700592 int regsLeft = std::min(info->numArgWords - 3, 16);
593 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
594 directCode, directMethod, type);
buzbeef0504cd2012-11-13 16:31:10 -0800595 opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), startOffset);
596 LIR* ld = opVldm(cUnit, targetReg(kArg3), regsLeft);
buzbeeb046e162012-10-30 15:48:42 -0700597 //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);
buzbeef0504cd2012-11-13 16:31:10 -0800602 opRegRegImm(cUnit, kOpAdd, targetReg(kArg3), targetReg(kSp), 4 /* Method* */ + (3 * 4));
buzbeeb046e162012-10-30 15:48:42 -0700603 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
604 directCode, directMethod, type);
buzbeef0504cd2012-11-13 16:31:10 -0800605 LIR* st = opVstm(cUnit, targetReg(kArg3), regsLeft);
buzbeeb046e162012-10-30 15:48:42 -0700606 setMemRefType(st, false /* isLoad */, kDalvikReg);
607 st->defMask = ENCODE_ALL;
608 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
609 directCode, directMethod, type);
610 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700611 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700612
buzbee15bf9802012-06-12 17:49:27 -0700613 callState = loadArgRegs(cUnit, info, callState, nextCallInsn,
Bill Buzbeea114add2012-05-03 15:00:40 -0700614 dexIdx, methodIdx, directCode, directMethod,
615 type, skipThis);
616
buzbee15bf9802012-06-12 17:49:27 -0700617 callState = nextCallInsn(cUnit, info, callState, dexIdx, methodIdx,
Bill Buzbeea114add2012-05-03 15:00:40 -0700618 directCode, directMethod, type);
619 if (pcrLabel) {
buzbeef0504cd2012-11-13 16:31:10 -0800620 *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1),
buzbee15bf9802012-06-12 17:49:27 -0700621 info->optFlags);
Bill Buzbeea114add2012-05-03 15:00:40 -0700622 }
623 return callState;
buzbee31a4a6f2012-02-28 15:36:15 -0800624}
625
buzbee3b3dbdd2012-06-13 13:39:34 -0700626RegLocation inlineTarget(CompilationUnit* cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700627{
Bill Buzbeea114add2012-05-03 15:00:40 -0700628 RegLocation res;
buzbee15bf9802012-06-12 17:49:27 -0700629 if (info->result.location == kLocInvalid) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700630 res = oatGetReturn(cUnit, false);
631 } else {
buzbee15bf9802012-06-12 17:49:27 -0700632 res = info->result;
Bill Buzbeea114add2012-05-03 15:00:40 -0700633 }
634 return res;
buzbeefc9e6fa2012-03-23 15:14:29 -0700635}
636
buzbee3b3dbdd2012-06-13 13:39:34 -0700637RegLocation inlineTargetWide(CompilationUnit* cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700638{
Bill Buzbeea114add2012-05-03 15:00:40 -0700639 RegLocation res;
buzbee15bf9802012-06-12 17:49:27 -0700640 if (info->result.location == kLocInvalid) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700641 res = oatGetReturnWide(cUnit, false);
642 } else {
buzbee15bf9802012-06-12 17:49:27 -0700643 res = info->result;
Bill Buzbeea114add2012-05-03 15:00:40 -0700644 }
645 return res;
buzbeefc9e6fa2012-03-23 15:14:29 -0700646}
647
buzbee3b3dbdd2012-06-13 13:39:34 -0700648bool genInlinedCharAt(CompilationUnit* cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700649{
buzbeeb046e162012-10-30 15:48:42 -0700650 if (cUnit->instructionSet == kMips) {
651 // TODO - add Mips implementation
652 return false;
653 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700654 // 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();
buzbeefc9e6fa2012-03-23 15:14:29 -0700662
buzbee15bf9802012-06-12 17:49:27 -0700663 RegLocation rlObj = info->args[0];
664 RegLocation rlIdx = info->args[1];
Bill Buzbeea114add2012-05-03 15:00:40 -0700665 rlObj = loadValue(cUnit, rlObj, kCoreReg);
666 rlIdx = loadValue(cUnit, rlIdx, kCoreReg);
667 int regMax;
buzbee15bf9802012-06-12 17:49:27 -0700668 genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags);
669 bool rangeCheck = (!(info->optFlags & MIR_IGNORE_RANGE_CHECK));
jeffhao634ea282012-08-10 13:04:01 -0700670 LIR* launchPad = NULL;
buzbeeb046e162012-10-30 15:48:42 -0700671 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 Buzbeea114add2012-05-03 15:00:40 -0700707 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700708 opRegImm(cUnit, kOpAdd, regPtr, dataOffset);
709 opRegReg(cUnit, kOpAdd, regOff, rlIdx.lowReg);
jeffhao634ea282012-08-10 13:04:01 -0700710 oatFreeTemp(cUnit, rlObj.lowReg);
711 oatFreeTemp(cUnit, rlIdx.lowReg);
buzbee15bf9802012-06-12 17:49:27 -0700712 RegLocation rlDest = inlineTarget(cUnit, info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700713 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 Hughes60234562012-06-01 12:25:59 -0700719 launchPad->operands[2] = 0; // no resumption
Bill Buzbeea114add2012-05-03 15:00:40 -0700720 }
721 // Record that we've already inlined & null checked
buzbee15bf9802012-06-12 17:49:27 -0700722 info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK);
Bill Buzbeea114add2012-05-03 15:00:40 -0700723 return true;
buzbeefc9e6fa2012-03-23 15:14:29 -0700724}
725
726// Generates an inlined String.isEmpty or String.length.
buzbee3b3dbdd2012-06-13 13:39:34 -0700727bool genInlinedStringIsEmptyOrLength(CompilationUnit* cUnit, CallInfo* info,
buzbee15bf9802012-06-12 17:49:27 -0700728 bool isEmpty)
buzbeefc9e6fa2012-03-23 15:14:29 -0700729{
buzbeeb046e162012-10-30 15:48:42 -0700730 if (cUnit->instructionSet == kMips) {
731 // TODO - add Mips implementation
732 return false;
733 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700734 // dst = src.length();
buzbee15bf9802012-06-12 17:49:27 -0700735 RegLocation rlObj = info->args[0];
Bill Buzbeea114add2012-05-03 15:00:40 -0700736 rlObj = loadValue(cUnit, rlObj, kCoreReg);
buzbee15bf9802012-06-12 17:49:27 -0700737 RegLocation rlDest = inlineTarget(cUnit, info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700738 RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true);
buzbee15bf9802012-06-12 17:49:27 -0700739 genNullCheck(cUnit, rlObj.sRegLow, rlObj.lowReg, info->optFlags);
Bill Buzbeea114add2012-05-03 15:00:40 -0700740 loadWordDisp(cUnit, rlObj.lowReg, String::CountOffset().Int32Value(),
741 rlResult.lowReg);
742 if (isEmpty) {
743 // dst = (dst == 0);
buzbeeb046e162012-10-30 15:48:42 -0700744 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 Buzbeea114add2012-05-03 15:00:40 -0700753 }
754 storeValue(cUnit, rlDest, rlResult);
755 return true;
buzbeefc9e6fa2012-03-23 15:14:29 -0700756}
757
buzbee3b3dbdd2012-06-13 13:39:34 -0700758bool genInlinedAbsInt(CompilationUnit *cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700759{
buzbeeb046e162012-10-30 15:48:42 -0700760 if (cUnit->instructionSet == kMips) {
761 // TODO - add Mips implementation
762 return false;
763 }
buzbee15bf9802012-06-12 17:49:27 -0700764 RegLocation rlSrc = info->args[0];
Bill Buzbeea114add2012-05-03 15:00:40 -0700765 rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
buzbee15bf9802012-06-12 17:49:27 -0700766 RegLocation rlDest = inlineTarget(cUnit, info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700767 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;
buzbeefc9e6fa2012-03-23 15:14:29 -0700775}
776
buzbee3b3dbdd2012-06-13 13:39:34 -0700777bool genInlinedAbsLong(CompilationUnit *cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700778{
buzbeeb046e162012-10-30 15:48:42 -0700779 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 }
buzbeefc9e6fa2012-03-23 15:14:29 -0700817}
818
buzbee3b3dbdd2012-06-13 13:39:34 -0700819bool genInlinedFloatCvt(CompilationUnit *cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700820{
buzbeeb046e162012-10-30 15:48:42 -0700821 if (cUnit->instructionSet == kMips) {
822 // TODO - add Mips implementation
823 return false;
824 }
buzbee15bf9802012-06-12 17:49:27 -0700825 RegLocation rlSrc = info->args[0];
826 RegLocation rlDest = inlineTarget(cUnit, info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700827 storeValue(cUnit, rlDest, rlSrc);
828 return true;
buzbeefc9e6fa2012-03-23 15:14:29 -0700829}
830
buzbee3b3dbdd2012-06-13 13:39:34 -0700831bool genInlinedDoubleCvt(CompilationUnit *cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700832{
buzbeeb046e162012-10-30 15:48:42 -0700833 if (cUnit->instructionSet == kMips) {
834 // TODO - add Mips implementation
835 return false;
836 }
buzbee15bf9802012-06-12 17:49:27 -0700837 RegLocation rlSrc = info->args[0];
838 RegLocation rlDest = inlineTargetWide(cUnit, info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700839 storeValueWide(cUnit, rlDest, rlSrc);
840 return true;
buzbeefc9e6fa2012-03-23 15:14:29 -0700841}
842
843/*
844 * Fast string.indexOf(I) & (II). Tests for simple case of char <= 0xffff,
845 * otherwise bails to standard library code.
846 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700847bool genInlinedIndexOf(CompilationUnit* cUnit, CallInfo* info,
buzbee15bf9802012-06-12 17:49:27 -0700848 bool zeroBased)
buzbeefc9e6fa2012-03-23 15:14:29 -0700849{
buzbeeb046e162012-10-30 15:48:42 -0700850 if (cUnit->instructionSet == kMips) {
851 // TODO - add Mips implementation
852 return false;
853 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700854 oatClobberCalleeSave(cUnit);
855 oatLockCallTemps(cUnit); // Using fixed registers
buzbeef0504cd2012-11-13 16:31:10 -0800856 int regPtr = targetReg(kArg0);
857 int regChar = targetReg(kArg1);
858 int regStart = targetReg(kArg2);
buzbeefc9e6fa2012-03-23 15:14:29 -0700859
buzbee15bf9802012-06-12 17:49:27 -0700860 RegLocation rlObj = info->args[0];
861 RegLocation rlChar = info->args[1];
862 RegLocation rlStart = info->args[2];
Bill Buzbeea114add2012-05-03 15:00:40 -0700863 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 }
buzbeeb046e162012-10-30 15:48:42 -0700870 int rTgt = (cUnit->instructionSet != kX86) ? loadHelper(cUnit, ENTRYPOINT_OFFSET(pIndexOf)) : 0;
buzbee15bf9802012-06-12 17:49:27 -0700871 genNullCheck(cUnit, rlObj.sRegLow, regPtr, info->optFlags);
872 LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700873 oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
874 (intptr_t)launchPad);
875 opCmpImmBranch(cUnit, kCondGt, regChar, 0xFFFF, launchPad);
buzbee8320f382012-09-11 16:29:42 -0700876 // NOTE: not a safepoint
buzbeeb046e162012-10-30 15:48:42 -0700877 if (cUnit->instructionSet != kX86) {
878 opReg(cUnit, kOpBlx, rTgt);
879 } else {
880 opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pIndexOf));
881 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700882 LIR* resumeTgt = newLIR0(cUnit, kPseudoTargetLabel);
883 launchPad->operands[2] = (uintptr_t)resumeTgt;
Bill Buzbeea114add2012-05-03 15:00:40 -0700884 // Record that we've already inlined & null checked
buzbee15bf9802012-06-12 17:49:27 -0700885 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 Buzbeea114add2012-05-03 15:00:40 -0700889 return true;
buzbeefc9e6fa2012-03-23 15:14:29 -0700890}
891
892/* Fast string.compareTo(Ljava/lang/string;)I. */
buzbee3b3dbdd2012-06-13 13:39:34 -0700893bool genInlinedStringCompareTo(CompilationUnit* cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700894{
buzbeeb046e162012-10-30 15:48:42 -0700895 if (cUnit->instructionSet == kMips) {
896 // TODO - add Mips implementation
897 return false;
898 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700899 oatClobberCalleeSave(cUnit);
900 oatLockCallTemps(cUnit); // Using fixed registers
buzbeef0504cd2012-11-13 16:31:10 -0800901 int regThis = targetReg(kArg0);
902 int regCmp = targetReg(kArg1);
buzbeefc9e6fa2012-03-23 15:14:29 -0700903
buzbee15bf9802012-06-12 17:49:27 -0700904 RegLocation rlThis = info->args[0];
905 RegLocation rlCmp = info->args[1];
Bill Buzbeea114add2012-05-03 15:00:40 -0700906 loadValueDirectFixed(cUnit, rlThis, regThis);
907 loadValueDirectFixed(cUnit, rlCmp, regCmp);
buzbeeb046e162012-10-30 15:48:42 -0700908 int rTgt = (cUnit->instructionSet != kX86) ?
909 loadHelper(cUnit, ENTRYPOINT_OFFSET(pStringCompareTo)) : 0;
buzbee15bf9802012-06-12 17:49:27 -0700910 genNullCheck(cUnit, rlThis.sRegLow, regThis, info->optFlags);
Bill Buzbeea114add2012-05-03 15:00:40 -0700911 //TUNING: check if rlCmp.sRegLow is already null checked
buzbee15bf9802012-06-12 17:49:27 -0700912 LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
Bill Buzbeea114add2012-05-03 15:00:40 -0700913 oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
Elliott Hughes60234562012-06-01 12:25:59 -0700914 (intptr_t)launchPad);
Bill Buzbeea114add2012-05-03 15:00:40 -0700915 opCmpImmBranch(cUnit, kCondEq, regCmp, 0, launchPad);
buzbee8320f382012-09-11 16:29:42 -0700916 // NOTE: not a safepoint
buzbeeb046e162012-10-30 15:48:42 -0700917 if (cUnit->instructionSet != kX86) {
918 opReg(cUnit, kOpBlx, rTgt);
919 } else {
920 opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pStringCompareTo));
921 }
Elliott Hughes60234562012-06-01 12:25:59 -0700922 launchPad->operands[2] = 0; // No return possible
Bill Buzbeea114add2012-05-03 15:00:40 -0700923 // Record that we've already inlined & null checked
buzbee15bf9802012-06-12 17:49:27 -0700924 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 Buzbeea114add2012-05-03 15:00:40 -0700928 return true;
Ian Rogers0183dd72012-09-17 23:06:51 -0700929}
930
buzbee3b3dbdd2012-06-13 13:39:34 -0700931bool genIntrinsic(CompilationUnit* cUnit, CallInfo* info)
buzbeefc9e6fa2012-03-23 15:14:29 -0700932{
Ian Rogerse13eafa2012-09-07 11:24:27 -0700933 if (info->optFlags & MIR_INLINED) {
buzbeefc9e6fa2012-03-23 15:14:29 -0700934 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -0700935 }
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 */
buzbee3b3dbdd2012-06-13 13:39:34 -0700946 std::string tgtMethod(PrettyMethod(info->index, *cUnit->dex_file));
Ian Rogers0183dd72012-09-17 23:06:51 -0700947 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 Rogerse13eafa2012-09-07 11:24:27 -07001005 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001006 return false;
buzbeefc9e6fa2012-03-23 15:14:29 -07001007}
1008
1009
buzbee31a4a6f2012-02-28 15:36:15 -08001010} // namespace art