blob: 72eb8a173561e7ffeb9684349e5546b7d1fac59a [file] [log] [blame]
buzbee67bf8852011-08-17 17:51:35 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "Dalvik.h"
18#include "CompilerInternals.h"
19#include "Dataflow.h"
Ian Rogers0571d352011-11-03 19:51:38 -070020#include "leb128.h"
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -070021#include "object.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070022#include "runtime.h"
buzbee67bf8852011-08-17 17:51:35 -070023
buzbee4df2bbd2012-10-11 14:46:06 -070024#if defined(ART_USE_QUICK_COMPILER)
25#include <llvm/Support/Threading.h>
26
27namespace {
28 pthread_once_t llvm_multi_init = PTHREAD_ONCE_INIT;
29 void InitializeLLVMForQuick() {
30 llvm::llvm_start_multithreaded();
31 }
32}
33#endif
34
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080035namespace art {
36
buzbee692be802012-08-29 15:52:59 -070037#if defined(ART_USE_QUICK_COMPILER)
buzbee4df2bbd2012-10-11 14:46:06 -070038LLVMInfo::LLVMInfo() {
39#if !defined(ART_USE_LLVM_COMPILER)
40 pthread_once(&llvm_multi_init, InitializeLLVMForQuick);
41#endif
buzbee692be802012-08-29 15:52:59 -070042 // Create context, module, intrinsic helper & ir builder
43 llvm_context_.reset(new llvm::LLVMContext());
TDYa12755e5e6c2012-09-11 15:14:42 -070044 llvm_module_ = new llvm::Module("art", *llvm_context_);
buzbee692be802012-08-29 15:52:59 -070045 llvm::StructType::create(*llvm_context_, "JavaObject");
buzbee692be802012-08-29 15:52:59 -070046 intrinsic_helper_.reset( new greenland::IntrinsicHelper(*llvm_context_, *llvm_module_));
47 ir_builder_.reset(new greenland::IRBuilder(*llvm_context_, *llvm_module_, *intrinsic_helper_));
48}
49
buzbee4df2bbd2012-10-11 14:46:06 -070050LLVMInfo::~LLVMInfo() {
buzbee692be802012-08-29 15:52:59 -070051}
52
53extern "C" void ArtInitQuickCompilerContext(art::Compiler& compiler) {
54 CHECK(compiler.GetCompilerContext() == NULL);
buzbee4df2bbd2012-10-11 14:46:06 -070055 LLVMInfo* llvmInfo = new LLVMInfo();
56 compiler.SetCompilerContext(llvmInfo);
buzbee692be802012-08-29 15:52:59 -070057}
58
59extern "C" void ArtUnInitQuickCompilerContext(art::Compiler& compiler) {
buzbee4df2bbd2012-10-11 14:46:06 -070060 delete reinterpret_cast<LLVMInfo*>(compiler.GetCompilerContext());
buzbee692be802012-08-29 15:52:59 -070061 compiler.SetCompilerContext(NULL);
62}
63#endif
64
buzbeece302932011-10-04 14:32:18 -070065/* Default optimizer/debug setting for the compiler. */
Elliott Hughese52e49b2012-04-02 16:05:44 -070066static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations
Bill Buzbeea114add2012-05-03 15:00:40 -070067 //(1 << kLoadStoreElimination) |
68 //(1 << kLoadHoisting) |
69 //(1 << kSuppressLoads) |
70 //(1 << kNullCheckElimination) |
71 //(1 << kPromoteRegs) |
72 //(1 << kTrackLiveTemps) |
73 //(1 << kSkipLargeMethodOptimization) |
74 //(1 << kSafeOptimizations) |
75 //(1 << kBBOpt) |
76 //(1 << kMatch) |
77 //(1 << kPromoteCompilerTemps) |
78 0;
buzbeece302932011-10-04 14:32:18 -070079
Elliott Hughese52e49b2012-04-02 16:05:44 -070080static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes
Bill Buzbeea114add2012-05-03 15:00:40 -070081 //(1 << kDebugDisplayMissingTargets) |
82 //(1 << kDebugVerbose) |
83 //(1 << kDebugDumpCFG) |
84 //(1 << kDebugSlowFieldPath) |
85 //(1 << kDebugSlowInvokePath) |
86 //(1 << kDebugSlowStringPath) |
87 //(1 << kDebugSlowestFieldPath) |
88 //(1 << kDebugSlowestStringPath) |
89 //(1 << kDebugExerciseResolveMethod) |
90 //(1 << kDebugVerifyDataflow) |
91 //(1 << kDebugShowMemoryUsage) |
92 //(1 << kDebugShowNops) |
93 //(1 << kDebugCountOpcodes) |
buzbeed1643e42012-09-05 14:06:51 -070094 //(1 << kDebugDumpCheckStats) |
buzbeead8f15e2012-06-18 14:49:45 -070095#if defined(ART_USE_QUICK_COMPILER)
96 //(1 << kDebugDumpBitcodeFile) |
Bill Buzbeec9f40dd2012-08-15 11:35:25 -070097 //(1 << kDebugVerifyBitcode) |
buzbeead8f15e2012-06-18 14:49:45 -070098#endif
Bill Buzbeea114add2012-05-03 15:00:40 -070099 0;
buzbeece302932011-10-04 14:32:18 -0700100
buzbee31a4a6f2012-02-28 15:36:15 -0800101inline bool contentIsInsn(const u2* codePtr) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700102 u2 instr = *codePtr;
103 Instruction::Code opcode = (Instruction::Code)(instr & 0xff);
buzbee67bf8852011-08-17 17:51:35 -0700104
Bill Buzbeea114add2012-05-03 15:00:40 -0700105 /*
106 * Since the low 8-bit in metadata may look like NOP, we need to check
107 * both the low and whole sub-word to determine whether it is code or data.
108 */
109 return (opcode != Instruction::NOP || instr == 0);
buzbee67bf8852011-08-17 17:51:35 -0700110}
111
112/*
113 * Parse an instruction, return the length of the instruction
114 */
buzbee31a4a6f2012-02-28 15:36:15 -0800115inline int parseInsn(CompilationUnit* cUnit, const u2* codePtr,
Bill Buzbeea114add2012-05-03 15:00:40 -0700116 DecodedInstruction* decoded_instruction, bool printMe)
buzbee67bf8852011-08-17 17:51:35 -0700117{
Elliott Hughesadb8c672012-03-06 16:49:32 -0800118 // Don't parse instruction data
119 if (!contentIsInsn(codePtr)) {
120 return 0;
121 }
buzbee67bf8852011-08-17 17:51:35 -0700122
Elliott Hughesadb8c672012-03-06 16:49:32 -0800123 const Instruction* instruction = Instruction::At(codePtr);
124 *decoded_instruction = DecodedInstruction(instruction);
buzbee67bf8852011-08-17 17:51:35 -0700125
Elliott Hughesadb8c672012-03-06 16:49:32 -0800126 if (printMe) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700127 char* decodedString = oatGetDalvikDisassembly(cUnit, *decoded_instruction,
128 NULL);
129 LOG(INFO) << codePtr << ": 0x"
130 << std::hex << static_cast<int>(decoded_instruction->opcode)
Elliott Hughesadb8c672012-03-06 16:49:32 -0800131 << " " << decodedString;
132 }
133 return instruction->SizeInCodeUnits();
buzbee67bf8852011-08-17 17:51:35 -0700134}
135
136#define UNKNOWN_TARGET 0xffffffff
137
Elliott Hughesadb8c672012-03-06 16:49:32 -0800138inline bool isGoto(MIR* insn) {
139 switch (insn->dalvikInsn.opcode) {
140 case Instruction::GOTO:
141 case Instruction::GOTO_16:
142 case Instruction::GOTO_32:
143 return true;
144 default:
145 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -0700146 }
buzbee67bf8852011-08-17 17:51:35 -0700147}
148
149/*
150 * Identify unconditional branch instructions
151 */
Elliott Hughesadb8c672012-03-06 16:49:32 -0800152inline bool isUnconditionalBranch(MIR* insn) {
153 switch (insn->dalvikInsn.opcode) {
154 case Instruction::RETURN_VOID:
155 case Instruction::RETURN:
156 case Instruction::RETURN_WIDE:
157 case Instruction::RETURN_OBJECT:
158 return true;
Bill Buzbeea114add2012-05-03 15:00:40 -0700159 default:
160 return isGoto(insn);
Elliott Hughesadb8c672012-03-06 16:49:32 -0800161 }
buzbee67bf8852011-08-17 17:51:35 -0700162}
163
164/* Split an existing block from the specified code offset into two */
buzbee31a4a6f2012-02-28 15:36:15 -0800165BasicBlock *splitBlock(CompilationUnit* cUnit, unsigned int codeOffset,
Bill Buzbeea114add2012-05-03 15:00:40 -0700166 BasicBlock* origBlock, BasicBlock** immedPredBlockP)
buzbee67bf8852011-08-17 17:51:35 -0700167{
Bill Buzbeea114add2012-05-03 15:00:40 -0700168 MIR* insn = origBlock->firstMIRInsn;
169 while (insn) {
170 if (insn->offset == codeOffset) break;
171 insn = insn->next;
172 }
173 if (insn == NULL) {
174 LOG(FATAL) << "Break split failed";
175 }
176 BasicBlock *bottomBlock = oatNewBB(cUnit, kDalvikByteCode,
177 cUnit->numBlocks++);
178 oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bottomBlock);
buzbee67bf8852011-08-17 17:51:35 -0700179
Bill Buzbeea114add2012-05-03 15:00:40 -0700180 bottomBlock->startOffset = codeOffset;
181 bottomBlock->firstMIRInsn = insn;
182 bottomBlock->lastMIRInsn = origBlock->lastMIRInsn;
buzbee67bf8852011-08-17 17:51:35 -0700183
Bill Buzbeea114add2012-05-03 15:00:40 -0700184 /* Add it to the quick lookup cache */
185 cUnit->blockMap.Put(bottomBlock->startOffset, bottomBlock);
buzbee5b537102012-01-17 17:33:47 -0800186
Bill Buzbeea114add2012-05-03 15:00:40 -0700187 /* Handle the taken path */
188 bottomBlock->taken = origBlock->taken;
189 if (bottomBlock->taken) {
190 origBlock->taken = NULL;
191 oatDeleteGrowableList(bottomBlock->taken->predecessors,
buzbeeba938cb2012-02-03 14:47:55 -0800192 (intptr_t)origBlock);
Bill Buzbeea114add2012-05-03 15:00:40 -0700193 oatInsertGrowableList(cUnit, bottomBlock->taken->predecessors,
194 (intptr_t)bottomBlock);
195 }
196
197 /* Handle the fallthrough path */
Bill Buzbeea114add2012-05-03 15:00:40 -0700198 bottomBlock->fallThrough = origBlock->fallThrough;
199 origBlock->fallThrough = bottomBlock;
Bill Buzbeea114add2012-05-03 15:00:40 -0700200 oatInsertGrowableList(cUnit, bottomBlock->predecessors,
201 (intptr_t)origBlock);
202 if (bottomBlock->fallThrough) {
203 oatDeleteGrowableList(bottomBlock->fallThrough->predecessors,
204 (intptr_t)origBlock);
205 oatInsertGrowableList(cUnit, bottomBlock->fallThrough->predecessors,
206 (intptr_t)bottomBlock);
207 }
208
209 /* Handle the successor list */
210 if (origBlock->successorBlockList.blockListType != kNotUsed) {
211 bottomBlock->successorBlockList = origBlock->successorBlockList;
212 origBlock->successorBlockList.blockListType = kNotUsed;
213 GrowableListIterator iterator;
214
215 oatGrowableListIteratorInit(&bottomBlock->successorBlockList.blocks,
216 &iterator);
217 while (true) {
218 SuccessorBlockInfo *successorBlockInfo =
219 (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
220 if (successorBlockInfo == NULL) break;
221 BasicBlock *bb = successorBlockInfo->block;
222 oatDeleteGrowableList(bb->predecessors, (intptr_t)origBlock);
223 oatInsertGrowableList(cUnit, bb->predecessors, (intptr_t)bottomBlock);
buzbee67bf8852011-08-17 17:51:35 -0700224 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700225 }
buzbee67bf8852011-08-17 17:51:35 -0700226
Bill Buzbeea114add2012-05-03 15:00:40 -0700227 origBlock->lastMIRInsn = insn->prev;
buzbee67bf8852011-08-17 17:51:35 -0700228
Bill Buzbeea114add2012-05-03 15:00:40 -0700229 insn->prev->next = NULL;
230 insn->prev = NULL;
231 /*
232 * Update the immediate predecessor block pointer so that outgoing edges
233 * can be applied to the proper block.
234 */
235 if (immedPredBlockP) {
236 DCHECK_EQ(*immedPredBlockP, origBlock);
237 *immedPredBlockP = bottomBlock;
238 }
239 return bottomBlock;
buzbee67bf8852011-08-17 17:51:35 -0700240}
241
242/*
243 * Given a code offset, find out the block that starts with it. If the offset
buzbee9ab05de2012-01-18 15:43:48 -0800244 * is in the middle of an existing block, split it into two. If immedPredBlockP
245 * is not non-null and is the block being split, update *immedPredBlockP to
246 * point to the bottom block so that outgoing edges can be set up properly
247 * (by the caller)
buzbee5b537102012-01-17 17:33:47 -0800248 * Utilizes a map for fast lookup of the typical cases.
buzbee67bf8852011-08-17 17:51:35 -0700249 */
buzbee31a4a6f2012-02-28 15:36:15 -0800250BasicBlock *findBlock(CompilationUnit* cUnit, unsigned int codeOffset,
251 bool split, bool create, BasicBlock** immedPredBlockP)
buzbee67bf8852011-08-17 17:51:35 -0700252{
Bill Buzbeea114add2012-05-03 15:00:40 -0700253 GrowableList* blockList = &cUnit->blockList;
254 BasicBlock* bb;
255 unsigned int i;
256 SafeMap<unsigned int, BasicBlock*>::iterator it;
buzbee67bf8852011-08-17 17:51:35 -0700257
Bill Buzbeea114add2012-05-03 15:00:40 -0700258 it = cUnit->blockMap.find(codeOffset);
259 if (it != cUnit->blockMap.end()) {
260 return it->second;
261 } else if (!create) {
262 return NULL;
263 }
264
265 if (split) {
266 for (i = 0; i < blockList->numUsed; i++) {
267 bb = (BasicBlock *) blockList->elemList[i];
268 if (bb->blockType != kDalvikByteCode) continue;
269 /* Check if a branch jumps into the middle of an existing block */
270 if ((codeOffset > bb->startOffset) && (bb->lastMIRInsn != NULL) &&
271 (codeOffset <= bb->lastMIRInsn->offset)) {
272 BasicBlock *newBB = splitBlock(cUnit, codeOffset, bb,
273 bb == *immedPredBlockP ?
274 immedPredBlockP : NULL);
275 return newBB;
276 }
buzbee5b537102012-01-17 17:33:47 -0800277 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700278 }
buzbee5b537102012-01-17 17:33:47 -0800279
Bill Buzbeea114add2012-05-03 15:00:40 -0700280 /* Create a new one */
281 bb = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++);
282 oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bb);
283 bb->startOffset = codeOffset;
284 cUnit->blockMap.Put(bb->startOffset, bb);
285 return bb;
buzbee67bf8852011-08-17 17:51:35 -0700286}
287
buzbeef58c12c2012-07-03 15:06:29 -0700288/* Find existing block */
289BasicBlock* oatFindBlock(CompilationUnit* cUnit, unsigned int codeOffset)
290{
291 return findBlock(cUnit, codeOffset, false, false, NULL);
292}
293
buzbeead8f15e2012-06-18 14:49:45 -0700294/* Turn method name into a legal Linux file name */
295void oatReplaceSpecialChars(std::string& str)
296{
297 static const struct { const char before; const char after; } match[] =
298 {{'/','-'}, {';','#'}, {' ','#'}, {'$','+'},
299 {'(','@'}, {')','@'}, {'<','='}, {'>','='}};
300 for (unsigned int i = 0; i < sizeof(match)/sizeof(match[0]); i++) {
301 std::replace(str.begin(), str.end(), match[i].before, match[i].after);
302 }
303}
304
buzbee67bf8852011-08-17 17:51:35 -0700305/* Dump the CFG into a DOT graph */
306void oatDumpCFG(CompilationUnit* cUnit, const char* dirPrefix)
307{
Bill Buzbeea114add2012-05-03 15:00:40 -0700308 FILE* file;
buzbeead8f15e2012-06-18 14:49:45 -0700309 std::string fname(PrettyMethod(cUnit->method_idx, *cUnit->dex_file));
310 oatReplaceSpecialChars(fname);
311 fname = StringPrintf("%s%s%x.dot", dirPrefix, fname.c_str(),
312 cUnit->entryBlock->fallThrough->startOffset);
313 file = fopen(fname.c_str(), "w");
Bill Buzbeea114add2012-05-03 15:00:40 -0700314 if (file == NULL) {
315 return;
316 }
317 fprintf(file, "digraph G {\n");
318
319 fprintf(file, " rankdir=TB\n");
320
321 int numReachableBlocks = cUnit->numReachableBlocks;
322 int idx;
323 const GrowableList *blockList = &cUnit->blockList;
324
325 for (idx = 0; idx < numReachableBlocks; idx++) {
326 int blockIdx = cUnit->dfsOrder.elemList[idx];
327 BasicBlock *bb = (BasicBlock *) oatGrowableListGetElement(blockList,
328 blockIdx);
329 if (bb == NULL) break;
buzbeed1643e42012-09-05 14:06:51 -0700330 if (bb->blockType == kDead) continue;
Bill Buzbeea114add2012-05-03 15:00:40 -0700331 if (bb->blockType == kEntryBlock) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700332 fprintf(file, " entry_%d [shape=Mdiamond];\n", bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700333 } else if (bb->blockType == kExitBlock) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700334 fprintf(file, " exit_%d [shape=Mdiamond];\n", bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700335 } else if (bb->blockType == kDalvikByteCode) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700336 fprintf(file, " block%04x_%d [shape=record,label = \"{ \\\n",
337 bb->startOffset, bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700338 const MIR *mir;
339 fprintf(file, " {block id %d\\l}%s\\\n", bb->id,
340 bb->firstMIRInsn ? " | " : " ");
341 for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
342 fprintf(file, " {%04x %s\\l}%s\\\n", mir->offset,
343 mir->ssaRep ? oatFullDisassembler(cUnit, mir) :
344 Instruction::Name(mir->dalvikInsn.opcode),
345 mir->next ? " | " : " ");
346 }
347 fprintf(file, " }\"];\n\n");
348 } else if (bb->blockType == kExceptionHandling) {
349 char blockName[BLOCK_NAME_LEN];
350
351 oatGetBlockName(bb, blockName);
352 fprintf(file, " %s [shape=invhouse];\n", blockName);
buzbee67bf8852011-08-17 17:51:35 -0700353 }
buzbee67bf8852011-08-17 17:51:35 -0700354
Bill Buzbeea114add2012-05-03 15:00:40 -0700355 char blockName1[BLOCK_NAME_LEN], blockName2[BLOCK_NAME_LEN];
buzbee67bf8852011-08-17 17:51:35 -0700356
Bill Buzbeea114add2012-05-03 15:00:40 -0700357 if (bb->taken) {
358 oatGetBlockName(bb, blockName1);
359 oatGetBlockName(bb->taken, blockName2);
360 fprintf(file, " %s:s -> %s:n [style=dotted]\n",
361 blockName1, blockName2);
buzbee67bf8852011-08-17 17:51:35 -0700362 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700363 if (bb->fallThrough) {
364 oatGetBlockName(bb, blockName1);
365 oatGetBlockName(bb->fallThrough, blockName2);
366 fprintf(file, " %s:s -> %s:n\n", blockName1, blockName2);
367 }
368
369 if (bb->successorBlockList.blockListType != kNotUsed) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700370 fprintf(file, " succ%04x_%d [shape=%s,label = \"{ \\\n",
371 bb->startOffset, bb->id,
Bill Buzbeea114add2012-05-03 15:00:40 -0700372 (bb->successorBlockList.blockListType == kCatch) ?
373 "Mrecord" : "record");
374 GrowableListIterator iterator;
375 oatGrowableListIteratorInit(&bb->successorBlockList.blocks,
376 &iterator);
377 SuccessorBlockInfo *successorBlockInfo =
378 (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
379
380 int succId = 0;
381 while (true) {
382 if (successorBlockInfo == NULL) break;
383
384 BasicBlock *destBlock = successorBlockInfo->block;
385 SuccessorBlockInfo *nextSuccessorBlockInfo =
386 (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
387
388 fprintf(file, " {<f%d> %04x: %04x\\l}%s\\\n",
389 succId++,
390 successorBlockInfo->key,
391 destBlock->startOffset,
392 (nextSuccessorBlockInfo != NULL) ? " | " : " ");
393
394 successorBlockInfo = nextSuccessorBlockInfo;
395 }
396 fprintf(file, " }\"];\n\n");
397
398 oatGetBlockName(bb, blockName1);
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700399 fprintf(file, " %s:s -> succ%04x_%d:n [style=dashed]\n",
400 blockName1, bb->startOffset, bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700401
402 if (bb->successorBlockList.blockListType == kPackedSwitch ||
403 bb->successorBlockList.blockListType == kSparseSwitch) {
404
405 oatGrowableListIteratorInit(&bb->successorBlockList.blocks,
406 &iterator);
407
408 succId = 0;
409 while (true) {
410 SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
411 oatGrowableListIteratorNext(&iterator);
412 if (successorBlockInfo == NULL) break;
413
414 BasicBlock *destBlock = successorBlockInfo->block;
415
416 oatGetBlockName(destBlock, blockName2);
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700417 fprintf(file, " succ%04x_%d:f%d:e -> %s:n\n", bb->startOffset,
418 bb->id, succId++, blockName2);
Bill Buzbeea114add2012-05-03 15:00:40 -0700419 }
420 }
421 }
422 fprintf(file, "\n");
423
424 /* Display the dominator tree */
425 oatGetBlockName(bb, blockName1);
426 fprintf(file, " cfg%s [label=\"%s\", shape=none];\n",
427 blockName1, blockName1);
428 if (bb->iDom) {
429 oatGetBlockName(bb->iDom, blockName2);
430 fprintf(file, " cfg%s:s -> cfg%s:n\n\n", blockName2, blockName1);
431 }
432 }
433 fprintf(file, "}\n");
434 fclose(file);
buzbee67bf8852011-08-17 17:51:35 -0700435}
436
437/* Verify if all the successor is connected with all the claimed predecessors */
buzbee31a4a6f2012-02-28 15:36:15 -0800438bool verifyPredInfo(CompilationUnit* cUnit, BasicBlock* bb)
buzbee67bf8852011-08-17 17:51:35 -0700439{
Bill Buzbeea114add2012-05-03 15:00:40 -0700440 GrowableListIterator iter;
buzbee67bf8852011-08-17 17:51:35 -0700441
Bill Buzbeea114add2012-05-03 15:00:40 -0700442 oatGrowableListIteratorInit(bb->predecessors, &iter);
443 while (true) {
444 BasicBlock *predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
445 if (!predBB) break;
446 bool found = false;
447 if (predBB->taken == bb) {
448 found = true;
449 } else if (predBB->fallThrough == bb) {
450 found = true;
451 } else if (predBB->successorBlockList.blockListType != kNotUsed) {
452 GrowableListIterator iterator;
453 oatGrowableListIteratorInit(&predBB->successorBlockList.blocks,
454 &iterator);
455 while (true) {
456 SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
457 oatGrowableListIteratorNext(&iterator);
458 if (successorBlockInfo == NULL) break;
459 BasicBlock *succBB = successorBlockInfo->block;
460 if (succBB == bb) {
buzbee67bf8852011-08-17 17:51:35 -0700461 found = true;
Bill Buzbeea114add2012-05-03 15:00:40 -0700462 break;
buzbee67bf8852011-08-17 17:51:35 -0700463 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700464 }
buzbee67bf8852011-08-17 17:51:35 -0700465 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700466 if (found == false) {
467 char blockName1[BLOCK_NAME_LEN], blockName2[BLOCK_NAME_LEN];
468 oatGetBlockName(bb, blockName1);
469 oatGetBlockName(predBB, blockName2);
470 oatDumpCFG(cUnit, "/sdcard/cfg/");
471 LOG(FATAL) << "Successor " << blockName1 << "not found from "
472 << blockName2;
473 }
474 }
475 return true;
buzbee67bf8852011-08-17 17:51:35 -0700476}
477
478/* Identify code range in try blocks and set up the empty catch blocks */
buzbee31a4a6f2012-02-28 15:36:15 -0800479void processTryCatchBlocks(CompilationUnit* cUnit)
buzbee67bf8852011-08-17 17:51:35 -0700480{
Bill Buzbeea114add2012-05-03 15:00:40 -0700481 const DexFile::CodeItem* code_item = cUnit->code_item;
482 int triesSize = code_item->tries_size_;
483 int offset;
buzbee67bf8852011-08-17 17:51:35 -0700484
Bill Buzbeea114add2012-05-03 15:00:40 -0700485 if (triesSize == 0) {
486 return;
487 }
488
489 ArenaBitVector* tryBlockAddr = cUnit->tryBlockAddr;
490
491 for (int i = 0; i < triesSize; i++) {
492 const DexFile::TryItem* pTry =
493 DexFile::GetTryItems(*code_item, i);
494 int startOffset = pTry->start_addr_;
495 int endOffset = startOffset + pTry->insn_count_;
496 for (offset = startOffset; offset < endOffset; offset++) {
497 oatSetBit(cUnit, tryBlockAddr, offset);
buzbee67bf8852011-08-17 17:51:35 -0700498 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700499 }
buzbee67bf8852011-08-17 17:51:35 -0700500
Bill Buzbeea114add2012-05-03 15:00:40 -0700501 // Iterate over each of the handlers to enqueue the empty Catch blocks
502 const byte* handlers_ptr = DexFile::GetCatchHandlerData(*code_item, 0);
503 uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr);
504 for (uint32_t idx = 0; idx < handlers_size; idx++) {
505 CatchHandlerIterator iterator(handlers_ptr);
506 for (; iterator.HasNext(); iterator.Next()) {
507 uint32_t address = iterator.GetHandlerAddress();
508 findBlock(cUnit, address, false /* split */, true /*create*/,
509 /* immedPredBlockP */ NULL);
buzbee67bf8852011-08-17 17:51:35 -0700510 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700511 handlers_ptr = iterator.EndDataPointer();
512 }
buzbee67bf8852011-08-17 17:51:35 -0700513}
514
Elliott Hughesadb8c672012-03-06 16:49:32 -0800515/* Process instructions with the kBranch flag */
buzbee31a4a6f2012-02-28 15:36:15 -0800516BasicBlock* processCanBranch(CompilationUnit* cUnit, BasicBlock* curBlock,
Bill Buzbeea114add2012-05-03 15:00:40 -0700517 MIR* insn, int curOffset, int width, int flags,
518 const u2* codePtr, const u2* codeEnd)
buzbee67bf8852011-08-17 17:51:35 -0700519{
Bill Buzbeea114add2012-05-03 15:00:40 -0700520 int target = curOffset;
521 switch (insn->dalvikInsn.opcode) {
522 case Instruction::GOTO:
523 case Instruction::GOTO_16:
524 case Instruction::GOTO_32:
525 target += (int) insn->dalvikInsn.vA;
526 break;
527 case Instruction::IF_EQ:
528 case Instruction::IF_NE:
529 case Instruction::IF_LT:
530 case Instruction::IF_GE:
531 case Instruction::IF_GT:
532 case Instruction::IF_LE:
buzbee0967a252012-09-14 10:43:54 -0700533 curBlock->conditionalBranch = true;
Bill Buzbeea114add2012-05-03 15:00:40 -0700534 target += (int) insn->dalvikInsn.vC;
535 break;
536 case Instruction::IF_EQZ:
537 case Instruction::IF_NEZ:
538 case Instruction::IF_LTZ:
539 case Instruction::IF_GEZ:
540 case Instruction::IF_GTZ:
541 case Instruction::IF_LEZ:
buzbee0967a252012-09-14 10:43:54 -0700542 curBlock->conditionalBranch = true;
Bill Buzbeea114add2012-05-03 15:00:40 -0700543 target += (int) insn->dalvikInsn.vB;
544 break;
545 default:
546 LOG(FATAL) << "Unexpected opcode(" << (int)insn->dalvikInsn.opcode
547 << ") with kBranch set";
548 }
549 BasicBlock *takenBlock = findBlock(cUnit, target,
550 /* split */
551 true,
552 /* create */
553 true,
554 /* immedPredBlockP */
555 &curBlock);
556 curBlock->taken = takenBlock;
557 oatInsertGrowableList(cUnit, takenBlock->predecessors, (intptr_t)curBlock);
buzbee67bf8852011-08-17 17:51:35 -0700558
Bill Buzbeea114add2012-05-03 15:00:40 -0700559 /* Always terminate the current block for conditional branches */
560 if (flags & Instruction::kContinue) {
561 BasicBlock *fallthroughBlock = findBlock(cUnit,
562 curOffset + width,
563 /*
564 * If the method is processed
565 * in sequential order from the
566 * beginning, we don't need to
567 * specify split for continue
568 * blocks. However, this
569 * routine can be called by
570 * compileLoop, which starts
571 * parsing the method from an
572 * arbitrary address in the
573 * method body.
574 */
575 true,
576 /* create */
577 true,
578 /* immedPredBlockP */
579 &curBlock);
580 curBlock->fallThrough = fallthroughBlock;
581 oatInsertGrowableList(cUnit, fallthroughBlock->predecessors,
582 (intptr_t)curBlock);
583 } else if (codePtr < codeEnd) {
584 /* Create a fallthrough block for real instructions (incl. NOP) */
585 if (contentIsInsn(codePtr)) {
586 findBlock(cUnit, curOffset + width,
587 /* split */
588 false,
589 /* create */
590 true,
591 /* immedPredBlockP */
592 NULL);
buzbee67bf8852011-08-17 17:51:35 -0700593 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700594 }
595 return curBlock;
buzbee67bf8852011-08-17 17:51:35 -0700596}
597
Elliott Hughesadb8c672012-03-06 16:49:32 -0800598/* Process instructions with the kSwitch flag */
buzbee31a4a6f2012-02-28 15:36:15 -0800599void processCanSwitch(CompilationUnit* cUnit, BasicBlock* curBlock,
600 MIR* insn, int curOffset, int width, int flags)
buzbee67bf8852011-08-17 17:51:35 -0700601{
Bill Buzbeea114add2012-05-03 15:00:40 -0700602 u2* switchData= (u2 *) (cUnit->insns + curOffset + insn->dalvikInsn.vB);
603 int size;
604 int* keyTable;
605 int* targetTable;
606 int i;
607 int firstKey;
buzbee67bf8852011-08-17 17:51:35 -0700608
Bill Buzbeea114add2012-05-03 15:00:40 -0700609 /*
610 * Packed switch data format:
611 * ushort ident = 0x0100 magic value
612 * ushort size number of entries in the table
613 * int first_key first (and lowest) switch case value
614 * int targets[size] branch targets, relative to switch opcode
615 *
616 * Total size is (4+size*2) 16-bit code units.
617 */
618 if (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) {
619 DCHECK_EQ(static_cast<int>(switchData[0]),
620 static_cast<int>(Instruction::kPackedSwitchSignature));
621 size = switchData[1];
622 firstKey = switchData[2] | (switchData[3] << 16);
623 targetTable = (int *) &switchData[4];
624 keyTable = NULL; // Make the compiler happy
625 /*
626 * Sparse switch data format:
627 * ushort ident = 0x0200 magic value
628 * ushort size number of entries in the table; > 0
629 * int keys[size] keys, sorted low-to-high; 32-bit aligned
630 * int targets[size] branch targets, relative to switch opcode
631 *
632 * Total size is (2+size*4) 16-bit code units.
633 */
634 } else {
635 DCHECK_EQ(static_cast<int>(switchData[0]),
636 static_cast<int>(Instruction::kSparseSwitchSignature));
637 size = switchData[1];
638 keyTable = (int *) &switchData[2];
639 targetTable = (int *) &switchData[2 + size*2];
640 firstKey = 0; // To make the compiler happy
641 }
buzbee67bf8852011-08-17 17:51:35 -0700642
Bill Buzbeea114add2012-05-03 15:00:40 -0700643 if (curBlock->successorBlockList.blockListType != kNotUsed) {
644 LOG(FATAL) << "Successor block list already in use: "
645 << (int)curBlock->successorBlockList.blockListType;
646 }
647 curBlock->successorBlockList.blockListType =
648 (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ?
649 kPackedSwitch : kSparseSwitch;
650 oatInitGrowableList(cUnit, &curBlock->successorBlockList.blocks, size,
651 kListSuccessorBlocks);
652
653 for (i = 0; i < size; i++) {
654 BasicBlock *caseBlock = findBlock(cUnit, curOffset + targetTable[i],
655 /* split */
656 true,
657 /* create */
658 true,
659 /* immedPredBlockP */
660 &curBlock);
661 SuccessorBlockInfo *successorBlockInfo =
662 (SuccessorBlockInfo *) oatNew(cUnit, sizeof(SuccessorBlockInfo),
663 false, kAllocSuccessor);
664 successorBlockInfo->block = caseBlock;
665 successorBlockInfo->key =
Elliott Hughesadb8c672012-03-06 16:49:32 -0800666 (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ?
Bill Buzbeea114add2012-05-03 15:00:40 -0700667 firstKey + i : keyTable[i];
668 oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks,
669 (intptr_t) successorBlockInfo);
670 oatInsertGrowableList(cUnit, caseBlock->predecessors,
buzbeeba938cb2012-02-03 14:47:55 -0800671 (intptr_t)curBlock);
Bill Buzbeea114add2012-05-03 15:00:40 -0700672 }
673
674 /* Fall-through case */
675 BasicBlock* fallthroughBlock = findBlock(cUnit,
676 curOffset + width,
677 /* split */
678 false,
679 /* create */
680 true,
681 /* immedPredBlockP */
682 NULL);
683 curBlock->fallThrough = fallthroughBlock;
684 oatInsertGrowableList(cUnit, fallthroughBlock->predecessors,
685 (intptr_t)curBlock);
buzbee67bf8852011-08-17 17:51:35 -0700686}
687
Elliott Hughesadb8c672012-03-06 16:49:32 -0800688/* Process instructions with the kThrow flag */
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700689BasicBlock* processCanThrow(CompilationUnit* cUnit, BasicBlock* curBlock,
690 MIR* insn, int curOffset, int width, int flags,
691 ArenaBitVector* tryBlockAddr, const u2* codePtr,
692 const u2* codeEnd)
buzbee67bf8852011-08-17 17:51:35 -0700693{
Bill Buzbeea114add2012-05-03 15:00:40 -0700694 const DexFile::CodeItem* code_item = cUnit->code_item;
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700695 bool inTryBlock = oatIsBitSet(tryBlockAddr, curOffset);
buzbee67bf8852011-08-17 17:51:35 -0700696
Bill Buzbeea114add2012-05-03 15:00:40 -0700697 /* In try block */
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700698 if (inTryBlock) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700699 CatchHandlerIterator iterator(*code_item, curOffset);
buzbee67bf8852011-08-17 17:51:35 -0700700
Bill Buzbeea114add2012-05-03 15:00:40 -0700701 if (curBlock->successorBlockList.blockListType != kNotUsed) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700702 LOG(INFO) << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
Bill Buzbeea114add2012-05-03 15:00:40 -0700703 LOG(FATAL) << "Successor block list already in use: "
704 << (int)curBlock->successorBlockList.blockListType;
buzbee67bf8852011-08-17 17:51:35 -0700705 }
706
Bill Buzbeea114add2012-05-03 15:00:40 -0700707 curBlock->successorBlockList.blockListType = kCatch;
708 oatInitGrowableList(cUnit, &curBlock->successorBlockList.blocks, 2,
709 kListSuccessorBlocks);
710
711 for (;iterator.HasNext(); iterator.Next()) {
712 BasicBlock *catchBlock = findBlock(cUnit, iterator.GetHandlerAddress(),
713 false /* split*/,
714 false /* creat */,
715 NULL /* immedPredBlockP */);
716 catchBlock->catchEntry = true;
buzbee6459e7c2012-10-02 14:42:41 -0700717 cUnit->catches.insert(catchBlock->startOffset);
Bill Buzbeea114add2012-05-03 15:00:40 -0700718 SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
719 oatNew(cUnit, sizeof(SuccessorBlockInfo), false, kAllocSuccessor);
720 successorBlockInfo->block = catchBlock;
721 successorBlockInfo->key = iterator.GetHandlerTypeIndex();
722 oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks,
723 (intptr_t) successorBlockInfo);
724 oatInsertGrowableList(cUnit, catchBlock->predecessors,
725 (intptr_t)curBlock);
buzbee67bf8852011-08-17 17:51:35 -0700726 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700727 } else {
728 BasicBlock *ehBlock = oatNewBB(cUnit, kExceptionHandling,
729 cUnit->numBlocks++);
730 curBlock->taken = ehBlock;
731 oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) ehBlock);
732 ehBlock->startOffset = curOffset;
733 oatInsertGrowableList(cUnit, ehBlock->predecessors, (intptr_t)curBlock);
734 }
735
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700736 if (insn->dalvikInsn.opcode == Instruction::THROW){
buzbee0967a252012-09-14 10:43:54 -0700737 curBlock->explicitThrow = true;
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700738 if ((codePtr < codeEnd) && contentIsInsn(codePtr)) {
739 // Force creation of new block following THROW via side-effect
740 findBlock(cUnit, curOffset + width, /* split */ false,
741 /* create */ true, /* immedPredBlockP */ NULL);
742 }
743 if (!inTryBlock) {
744 // Don't split a THROW that can't rethrow - we're done.
745 return curBlock;
Bill Buzbeea114add2012-05-03 15:00:40 -0700746 }
747 }
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700748
749 /*
750 * Split the potentially-throwing instruction into two parts.
751 * The first half will be a pseudo-op that captures the exception
752 * edges and terminates the basic block. It always falls through.
753 * Then, create a new basic block that begins with the throwing instruction
754 * (minus exceptions). Note: this new basic block must NOT be entered into
755 * the blockMap. If the potentially-throwing instruction is the target of a
756 * future branch, we need to find the check psuedo half. The new
757 * basic block containing the work portion of the instruction should
758 * only be entered via fallthrough from the block containing the
759 * pseudo exception edge MIR. Note also that this new block is
760 * not automatically terminated after the work portion, and may
761 * contain following instructions.
762 */
763 BasicBlock *newBlock = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++);
764 oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t)newBlock);
765 newBlock->startOffset = insn->offset;
766 curBlock->fallThrough = newBlock;
767 oatInsertGrowableList(cUnit, newBlock->predecessors, (intptr_t)curBlock);
768 MIR* newInsn = (MIR*)oatNew(cUnit, sizeof(MIR), true, kAllocMIR);
769 *newInsn = *insn;
770 insn->dalvikInsn.opcode =
771 static_cast<Instruction::Code>(kMirOpCheck);
772 // Associate the two halves
773 insn->meta.throwInsn = newInsn;
774 newInsn->meta.throwInsn = insn;
775 oatAppendMIR(newBlock, newInsn);
776 return newBlock;
buzbee67bf8852011-08-17 17:51:35 -0700777}
778
Elliott Hughesb3bd5f02012-03-08 21:05:27 -0800779void oatInit(CompilationUnit* cUnit, const Compiler& compiler) {
780 if (!oatArchInit()) {
781 LOG(FATAL) << "Failed to initialize oat";
782 }
783 if (!oatHeapInit(cUnit)) {
784 LOG(FATAL) << "Failed to initialize oat heap";
785 }
786}
787
buzbeeabc4c6b2012-08-23 08:17:15 -0700788CompiledMethod* compileMethod(Compiler& compiler,
789 const DexFile::CodeItem* code_item,
790 uint32_t access_flags, InvokeType invoke_type,
791 uint32_t method_idx, jobject class_loader,
792 const DexFile& dex_file
793#if defined(ART_USE_QUICK_COMPILER)
buzbee4df2bbd2012-10-11 14:46:06 -0700794 , LLVMInfo* llvm_info,
buzbeeabc4c6b2012-08-23 08:17:15 -0700795 bool gbcOnly
796#endif
797 )
buzbee67bf8852011-08-17 17:51:35 -0700798{
Bill Buzbeea114add2012-05-03 15:00:40 -0700799 VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "...";
Brian Carlstrom94496d32011-08-22 09:22:47 -0700800
Bill Buzbeea114add2012-05-03 15:00:40 -0700801 const u2* codePtr = code_item->insns_;
802 const u2* codeEnd = code_item->insns_ + code_item->insns_size_in_code_units_;
803 int numBlocks = 0;
804 unsigned int curOffset = 0;
buzbee67bf8852011-08-17 17:51:35 -0700805
Bill Buzbeea114add2012-05-03 15:00:40 -0700806 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
807 UniquePtr<CompilationUnit> cUnit(new CompilationUnit);
buzbeeba938cb2012-02-03 14:47:55 -0800808
Bill Buzbeea114add2012-05-03 15:00:40 -0700809 oatInit(cUnit.get(), compiler);
Elliott Hughesb3bd5f02012-03-08 21:05:27 -0800810
Bill Buzbeea114add2012-05-03 15:00:40 -0700811 cUnit->compiler = &compiler;
812 cUnit->class_linker = class_linker;
813 cUnit->dex_file = &dex_file;
Bill Buzbeea114add2012-05-03 15:00:40 -0700814 cUnit->method_idx = method_idx;
815 cUnit->code_item = code_item;
816 cUnit->access_flags = access_flags;
Ian Rogers08f753d2012-08-24 14:35:25 -0700817 cUnit->invoke_type = invoke_type;
Bill Buzbeea114add2012-05-03 15:00:40 -0700818 cUnit->shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx));
819 cUnit->instructionSet = compiler.GetInstructionSet();
820 cUnit->insns = code_item->insns_;
821 cUnit->insnsSize = code_item->insns_size_in_code_units_;
822 cUnit->numIns = code_item->ins_size_;
823 cUnit->numRegs = code_item->registers_size_ - cUnit->numIns;
824 cUnit->numOuts = code_item->outs_size_;
buzbee2cfc6392012-05-07 14:51:40 -0700825#if defined(ART_USE_QUICK_COMPILER)
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700826 DCHECK((cUnit->instructionSet == kThumb2) ||
827 (cUnit->instructionSet == kX86) ||
828 (cUnit->instructionSet == kMips));
buzbee4df2bbd2012-10-11 14:46:06 -0700829 cUnit->llvm_info = llvm_info;
Bill Buzbeec9f40dd2012-08-15 11:35:25 -0700830 if (cUnit->instructionSet == kThumb2) {
831 // TODO: remove this once x86 is tested
buzbee85eee022012-07-16 22:12:38 -0700832 cUnit->genBitcode = true;
833 }
buzbee2a83e8f2012-07-13 16:42:30 -0700834#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700835 /* Adjust this value accordingly once inlining is performed */
836 cUnit->numDalvikRegisters = code_item->registers_size_;
837 // TODO: set this from command line
838 cUnit->compilerFlipMatch = false;
839 bool useMatch = !cUnit->compilerMethodMatch.empty();
840 bool match = useMatch && (cUnit->compilerFlipMatch ^
841 (PrettyMethod(method_idx, dex_file).find(cUnit->compilerMethodMatch) !=
842 std::string::npos));
843 if (!useMatch || match) {
844 cUnit->disableOpt = kCompilerOptimizerDisableFlags;
845 cUnit->enableDebug = kCompilerDebugFlags;
846 cUnit->printMe = VLOG_IS_ON(compiler) ||
847 (cUnit->enableDebug & (1 << kDebugVerbose));
848 }
buzbee2cfc6392012-05-07 14:51:40 -0700849#if defined(ART_USE_QUICK_COMPILER)
buzbee6969d502012-06-15 16:40:31 -0700850 if (cUnit->genBitcode) {
buzbee6459e7c2012-10-02 14:42:41 -0700851#ifndef NDEBUG
852 cUnit->enableDebug |= (1 << kDebugVerifyBitcode);
853#endif
buzbee2a83e8f2012-07-13 16:42:30 -0700854 //cUnit->printMe = true;
855 //cUnit->enableDebug |= (1 << kDebugDumpBitcodeFile);
buzbee6969d502012-06-15 16:40:31 -0700856 }
buzbee2cfc6392012-05-07 14:51:40 -0700857#endif
jeffhao7fbee072012-08-24 17:56:54 -0700858 if (cUnit->instructionSet == kMips) {
859 // Disable some optimizations for mips for now
860 cUnit->disableOpt |= (
861 (1 << kLoadStoreElimination) |
862 (1 << kLoadHoisting) |
863 (1 << kSuppressLoads) |
864 (1 << kNullCheckElimination) |
865 (1 << kPromoteRegs) |
866 (1 << kTrackLiveTemps) |
867 (1 << kSkipLargeMethodOptimization) |
868 (1 << kSafeOptimizations) |
869 (1 << kBBOpt) |
870 (1 << kMatch) |
871 (1 << kPromoteCompilerTemps));
872 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700873 /* Are we generating code for the debugger? */
874 if (compiler.IsDebuggingSupported()) {
875 cUnit->genDebugger = true;
876 // Yes, disable most optimizations
877 cUnit->disableOpt |= (
878 (1 << kLoadStoreElimination) |
879 (1 << kLoadHoisting) |
880 (1 << kSuppressLoads) |
881 (1 << kPromoteRegs) |
882 (1 << kBBOpt) |
883 (1 << kMatch) |
884 (1 << kTrackLiveTemps));
885 }
886
887 /* Gathering opcode stats? */
888 if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) {
889 cUnit->opcodeCount = (int*)oatNew(cUnit.get(),
890 kNumPackedOpcodes * sizeof(int), true, kAllocMisc);
891 }
892
893 /* Assume non-throwing leaf */
894 cUnit->attrs = (METHOD_IS_LEAF | METHOD_IS_THROW_FREE);
895
896 /* Initialize the block list, estimate size based on insnsSize */
897 oatInitGrowableList(cUnit.get(), &cUnit->blockList, cUnit->insnsSize,
898 kListBlockList);
899
900 /* Initialize the switchTables list */
901 oatInitGrowableList(cUnit.get(), &cUnit->switchTables, 4,
902 kListSwitchTables);
903
904 /* Intialize the fillArrayData list */
905 oatInitGrowableList(cUnit.get(), &cUnit->fillArrayData, 4,
906 kListFillArrayData);
907
908 /* Intialize the throwLaunchpads list, estimate size based on insnsSize */
909 oatInitGrowableList(cUnit.get(), &cUnit->throwLaunchpads, cUnit->insnsSize,
910 kListThrowLaunchPads);
911
912 /* Intialize the instrinsicLaunchpads list */
913 oatInitGrowableList(cUnit.get(), &cUnit->intrinsicLaunchpads, 4,
914 kListMisc);
915
916
917 /* Intialize the suspendLaunchpads list */
918 oatInitGrowableList(cUnit.get(), &cUnit->suspendLaunchpads, 2048,
919 kListSuspendLaunchPads);
920
921 /* Allocate the bit-vector to track the beginning of basic blocks */
922 ArenaBitVector *tryBlockAddr = oatAllocBitVector(cUnit.get(),
923 cUnit->insnsSize,
924 true /* expandable */);
925 cUnit->tryBlockAddr = tryBlockAddr;
926
927 /* Create the default entry and exit blocks and enter them to the list */
928 BasicBlock *entryBlock = oatNewBB(cUnit.get(), kEntryBlock, numBlocks++);
929 BasicBlock *exitBlock = oatNewBB(cUnit.get(), kExitBlock, numBlocks++);
930
931 cUnit->entryBlock = entryBlock;
932 cUnit->exitBlock = exitBlock;
933
934 oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) entryBlock);
935 oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) exitBlock);
936
937 /* Current block to record parsed instructions */
938 BasicBlock *curBlock = oatNewBB(cUnit.get(), kDalvikByteCode, numBlocks++);
939 curBlock->startOffset = 0;
940 oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) curBlock);
941 /* Add first block to the fast lookup cache */
942 cUnit->blockMap.Put(curBlock->startOffset, curBlock);
943 entryBlock->fallThrough = curBlock;
944 oatInsertGrowableList(cUnit.get(), curBlock->predecessors,
945 (intptr_t)entryBlock);
946
947 /*
948 * Store back the number of blocks since new blocks may be created of
949 * accessing cUnit.
950 */
951 cUnit->numBlocks = numBlocks;
952
953 /* Identify code range in try blocks and set up the empty catch blocks */
954 processTryCatchBlocks(cUnit.get());
955
956 /* Set up for simple method detection */
957 int numPatterns = sizeof(specialPatterns)/sizeof(specialPatterns[0]);
958 bool livePattern = (numPatterns > 0) && !(cUnit->disableOpt & (1 << kMatch));
Elliott Hughesabe64aa2012-05-30 17:34:45 -0700959 bool* deadPattern = (bool*)oatNew(cUnit.get(), sizeof(bool) * numPatterns, true,
Bill Buzbeea114add2012-05-03 15:00:40 -0700960 kAllocMisc);
961 SpecialCaseHandler specialCase = kNoHandler;
962 int patternPos = 0;
963
964 /* Parse all instructions and put them into containing basic blocks */
965 while (codePtr < codeEnd) {
966 MIR *insn = (MIR *) oatNew(cUnit.get(), sizeof(MIR), true, kAllocMIR);
967 insn->offset = curOffset;
968 int width = parseInsn(cUnit.get(), codePtr, &insn->dalvikInsn, false);
969 insn->width = width;
970 Instruction::Code opcode = insn->dalvikInsn.opcode;
971 if (cUnit->opcodeCount != NULL) {
972 cUnit->opcodeCount[static_cast<int>(opcode)]++;
buzbee44b412b2012-02-04 08:50:53 -0800973 }
974
Bill Buzbeea114add2012-05-03 15:00:40 -0700975 /* Terminate when the data section is seen */
976 if (width == 0)
977 break;
978
979 /* Possible simple method? */
980 if (livePattern) {
981 livePattern = false;
982 specialCase = kNoHandler;
983 for (int i = 0; i < numPatterns; i++) {
984 if (!deadPattern[i]) {
985 if (specialPatterns[i].opcodes[patternPos] == opcode) {
986 livePattern = true;
987 specialCase = specialPatterns[i].handlerCode;
988 } else {
989 deadPattern[i] = true;
990 }
991 }
992 }
993 patternPos++;
buzbeea7c12682012-03-19 13:13:53 -0700994 }
995
Bill Buzbeea114add2012-05-03 15:00:40 -0700996 oatAppendMIR(curBlock, insn);
buzbeecefd1872011-09-09 09:59:52 -0700997
Bill Buzbeea114add2012-05-03 15:00:40 -0700998 codePtr += width;
Ian Rogersa75a0132012-09-28 11:41:42 -0700999 int flags = Instruction::FlagsOf(insn->dalvikInsn.opcode);
buzbee67bf8852011-08-17 17:51:35 -07001000
Bill Buzbeea114add2012-05-03 15:00:40 -07001001 int dfFlags = oatDataFlowAttributes[insn->dalvikInsn.opcode];
buzbee67bf8852011-08-17 17:51:35 -07001002
Bill Buzbeea114add2012-05-03 15:00:40 -07001003 if (dfFlags & DF_HAS_DEFS) {
buzbeebff24652012-05-06 16:22:05 -07001004 cUnit->defCount += (dfFlags & DF_A_WIDE) ? 2 : 1;
Bill Buzbeea114add2012-05-03 15:00:40 -07001005 }
buzbee67bf8852011-08-17 17:51:35 -07001006
Bill Buzbeea114add2012-05-03 15:00:40 -07001007 if (flags & Instruction::kBranch) {
1008 curBlock = processCanBranch(cUnit.get(), curBlock, insn, curOffset,
1009 width, flags, codePtr, codeEnd);
1010 } else if (flags & Instruction::kReturn) {
1011 curBlock->fallThrough = exitBlock;
1012 oatInsertGrowableList(cUnit.get(), exitBlock->predecessors,
1013 (intptr_t)curBlock);
1014 /*
1015 * Terminate the current block if there are instructions
1016 * afterwards.
1017 */
1018 if (codePtr < codeEnd) {
1019 /*
1020 * Create a fallthrough block for real instructions
1021 * (incl. NOP).
1022 */
1023 if (contentIsInsn(codePtr)) {
1024 findBlock(cUnit.get(), curOffset + width,
1025 /* split */
1026 false,
1027 /* create */
1028 true,
1029 /* immedPredBlockP */
1030 NULL);
1031 }
1032 }
1033 } else if (flags & Instruction::kThrow) {
Bill Buzbeec9f40dd2012-08-15 11:35:25 -07001034 curBlock = processCanThrow(cUnit.get(), curBlock, insn, curOffset,
1035 width, flags, tryBlockAddr, codePtr, codeEnd);
Bill Buzbeea114add2012-05-03 15:00:40 -07001036 } else if (flags & Instruction::kSwitch) {
1037 processCanSwitch(cUnit.get(), curBlock, insn, curOffset, width, flags);
1038 }
1039 curOffset += width;
1040 BasicBlock *nextBlock = findBlock(cUnit.get(), curOffset,
1041 /* split */
1042 false,
1043 /* create */
1044 false,
1045 /* immedPredBlockP */
1046 NULL);
1047 if (nextBlock) {
1048 /*
1049 * The next instruction could be the target of a previously parsed
1050 * forward branch so a block is already created. If the current
1051 * instruction is not an unconditional branch, connect them through
1052 * the fall-through link.
1053 */
1054 DCHECK(curBlock->fallThrough == NULL ||
1055 curBlock->fallThrough == nextBlock ||
1056 curBlock->fallThrough == exitBlock);
buzbee5ade1d22011-09-09 14:44:52 -07001057
Bill Buzbeea114add2012-05-03 15:00:40 -07001058 if ((curBlock->fallThrough == NULL) && (flags & Instruction::kContinue)) {
1059 curBlock->fallThrough = nextBlock;
1060 oatInsertGrowableList(cUnit.get(), nextBlock->predecessors,
1061 (intptr_t)curBlock);
1062 }
1063 curBlock = nextBlock;
1064 }
1065 }
buzbeefc9e6fa2012-03-23 15:14:29 -07001066
Bill Buzbeea114add2012-05-03 15:00:40 -07001067 if (!(cUnit->disableOpt & (1 << kSkipLargeMethodOptimization))) {
1068 if ((cUnit->numBlocks > MANY_BLOCKS) ||
1069 ((cUnit->numBlocks > MANY_BLOCKS_INITIALIZER) &&
1070 PrettyMethod(method_idx, dex_file, false).find("init>") !=
1071 std::string::npos)) {
1072 cUnit->qdMode = true;
1073 }
1074 }
buzbeefc9e6fa2012-03-23 15:14:29 -07001075
Bill Buzbeea114add2012-05-03 15:00:40 -07001076 if (cUnit->qdMode) {
buzbeed1643e42012-09-05 14:06:51 -07001077#if !defined(ART_USE_QUICK_COMPILER)
1078 // Bitcode generation requires full dataflow analysis
Bill Buzbeea114add2012-05-03 15:00:40 -07001079 cUnit->disableDataflow = true;
buzbeed1643e42012-09-05 14:06:51 -07001080#endif
Bill Buzbeea114add2012-05-03 15:00:40 -07001081 // Disable optimization which require dataflow/ssa
1082 cUnit->disableOpt |=
buzbeed1643e42012-09-05 14:06:51 -07001083#if !defined(ART_USE_QUICK_COMPILER)
Bill Buzbeea114add2012-05-03 15:00:40 -07001084 (1 << kNullCheckElimination) |
buzbeed1643e42012-09-05 14:06:51 -07001085#endif
Bill Buzbeea114add2012-05-03 15:00:40 -07001086 (1 << kBBOpt) |
1087 (1 << kPromoteRegs);
1088 if (cUnit->printMe) {
1089 LOG(INFO) << "QD mode enabled: "
1090 << PrettyMethod(method_idx, dex_file)
1091 << " too big: " << cUnit->numBlocks;
1092 }
1093 }
buzbeec1f45042011-09-21 16:03:19 -07001094
Bill Buzbeea114add2012-05-03 15:00:40 -07001095 if (cUnit->printMe) {
1096 oatDumpCompilationUnit(cUnit.get());
1097 }
buzbee67bf8852011-08-17 17:51:35 -07001098
buzbee0967a252012-09-14 10:43:54 -07001099 /* Do a code layout pass */
1100 oatMethodCodeLayout(cUnit.get());
1101
Bill Buzbeea114add2012-05-03 15:00:40 -07001102 if (cUnit->enableDebug & (1 << kDebugVerifyDataflow)) {
1103 /* Verify if all blocks are connected as claimed */
1104 oatDataFlowAnalysisDispatcher(cUnit.get(), verifyPredInfo, kAllNodes,
1105 false /* isIterative */);
1106 }
buzbee67bf8852011-08-17 17:51:35 -07001107
Bill Buzbeea114add2012-05-03 15:00:40 -07001108 /* Perform SSA transformation for the whole method */
1109 oatMethodSSATransformation(cUnit.get());
buzbee67bf8852011-08-17 17:51:35 -07001110
buzbee2cfc6392012-05-07 14:51:40 -07001111 /* Do constant propagation */
1112 // TODO: Probably need to make these expandable to support new ssa names
1113 // introducted during MIR optimization passes
1114 cUnit->isConstantV = oatAllocBitVector(cUnit.get(), cUnit->numSSARegs,
1115 false /* not expandable */);
1116 cUnit->constantValues =
1117 (int*)oatNew(cUnit.get(), sizeof(int) * cUnit->numSSARegs, true,
1118 kAllocDFInfo);
1119 oatDataFlowAnalysisDispatcher(cUnit.get(), oatDoConstantPropagation,
1120 kAllNodes,
1121 false /* isIterative */);
1122
Bill Buzbeea114add2012-05-03 15:00:40 -07001123 /* Detect loops */
1124 oatMethodLoopDetection(cUnit.get());
buzbee67bf8852011-08-17 17:51:35 -07001125
Bill Buzbeea114add2012-05-03 15:00:40 -07001126 /* Count uses */
1127 oatMethodUseCount(cUnit.get());
buzbee67bf8852011-08-17 17:51:35 -07001128
Bill Buzbeea114add2012-05-03 15:00:40 -07001129 /* Perform null check elimination */
1130 oatMethodNullCheckElimination(cUnit.get());
1131
buzbeed1643e42012-09-05 14:06:51 -07001132 /* Combine basic blocks where possible */
1133 oatMethodBasicBlockCombine(cUnit.get());
1134
Bill Buzbeea114add2012-05-03 15:00:40 -07001135 /* Do some basic block optimizations */
1136 oatMethodBasicBlockOptimization(cUnit.get());
1137
buzbeed1643e42012-09-05 14:06:51 -07001138 if (cUnit->enableDebug & (1 << kDebugDumpCheckStats)) {
1139 oatDumpCheckStats(cUnit.get());
1140 }
1141
Bill Buzbeea114add2012-05-03 15:00:40 -07001142 oatInitializeRegAlloc(cUnit.get()); // Needs to happen after SSA naming
1143
1144 /* Allocate Registers using simple local allocation scheme */
1145 oatSimpleRegAlloc(cUnit.get());
1146
buzbee2cfc6392012-05-07 14:51:40 -07001147#if defined(ART_USE_QUICK_COMPILER)
1148 /* Go the LLVM path? */
1149 if (cUnit->genBitcode) {
1150 // MIR->Bitcode
1151 oatMethodMIR2Bitcode(cUnit.get());
TDYa12755e5e6c2012-09-11 15:14:42 -07001152 if (gbcOnly) {
buzbeeabc4c6b2012-08-23 08:17:15 -07001153 // all done
1154 oatArenaReset(cUnit.get());
1155 return NULL;
1156 }
buzbee2cfc6392012-05-07 14:51:40 -07001157 // Bitcode->LIR
1158 oatMethodBitcode2LIR(cUnit.get());
1159 } else {
1160#endif
1161 if (specialCase != kNoHandler) {
1162 /*
1163 * Custom codegen for special cases. If for any reason the
1164 * special codegen doesn't succeed, cUnit->firstLIRInsn will
1165 * set to NULL;
1166 */
1167 oatSpecialMIR2LIR(cUnit.get(), specialCase);
1168 }
buzbee67bf8852011-08-17 17:51:35 -07001169
buzbee2cfc6392012-05-07 14:51:40 -07001170 /* Convert MIR to LIR, etc. */
1171 if (cUnit->firstLIRInsn == NULL) {
1172 oatMethodMIR2LIR(cUnit.get());
1173 }
1174#if defined(ART_USE_QUICK_COMPILER)
Bill Buzbeea114add2012-05-03 15:00:40 -07001175 }
buzbee2cfc6392012-05-07 14:51:40 -07001176#endif
buzbee67bf8852011-08-17 17:51:35 -07001177
Bill Buzbeea114add2012-05-03 15:00:40 -07001178 // Debugging only
1179 if (cUnit->enableDebug & (1 << kDebugDumpCFG)) {
1180 oatDumpCFG(cUnit.get(), "/sdcard/cfg/");
1181 }
buzbee16da88c2012-03-20 10:38:17 -07001182
Bill Buzbeea114add2012-05-03 15:00:40 -07001183 /* Method is not empty */
1184 if (cUnit->firstLIRInsn) {
buzbee67bf8852011-08-17 17:51:35 -07001185
Bill Buzbeea114add2012-05-03 15:00:40 -07001186 // mark the targets of switch statement case labels
1187 oatProcessSwitchTables(cUnit.get());
buzbee67bf8852011-08-17 17:51:35 -07001188
Bill Buzbeea114add2012-05-03 15:00:40 -07001189 /* Convert LIR into machine code. */
1190 oatAssembleLIR(cUnit.get());
buzbee99ba9642012-01-25 14:23:14 -08001191
Elliott Hughes3b6baaa2011-10-14 19:13:56 -07001192 if (cUnit->printMe) {
Bill Buzbeea114add2012-05-03 15:00:40 -07001193 oatCodegenDump(cUnit.get());
buzbee67bf8852011-08-17 17:51:35 -07001194 }
1195
Bill Buzbeea114add2012-05-03 15:00:40 -07001196 if (cUnit->opcodeCount != NULL) {
1197 LOG(INFO) << "Opcode Count";
1198 for (int i = 0; i < kNumPackedOpcodes; i++) {
1199 if (cUnit->opcodeCount[i] != 0) {
1200 LOG(INFO) << "-C- "
1201 << Instruction::Name(static_cast<Instruction::Code>(i))
1202 << " " << cUnit->opcodeCount[i];
buzbee67bf8852011-08-17 17:51:35 -07001203 }
Bill Buzbeea114add2012-05-03 15:00:40 -07001204 }
1205 }
1206 }
buzbeea7c12682012-03-19 13:13:53 -07001207
Bill Buzbeea114add2012-05-03 15:00:40 -07001208 // Combine vmap tables - core regs, then fp regs - into vmapTable
1209 std::vector<uint16_t> vmapTable;
buzbeeca7a5e42012-08-20 11:12:18 -07001210 // Core regs may have been inserted out of order - sort first
1211 std::sort(cUnit->coreVmapTable.begin(), cUnit->coreVmapTable.end());
Bill Buzbeea114add2012-05-03 15:00:40 -07001212 for (size_t i = 0 ; i < cUnit->coreVmapTable.size(); i++) {
buzbeeca7a5e42012-08-20 11:12:18 -07001213 // Copy, stripping out the phys register sort key
1214 vmapTable.push_back(~(-1 << VREG_NUM_WIDTH) & cUnit->coreVmapTable[i]);
Bill Buzbeea114add2012-05-03 15:00:40 -07001215 }
1216 // If we have a frame, push a marker to take place of lr
1217 if (cUnit->frameSize > 0) {
1218 vmapTable.push_back(INVALID_VREG);
1219 } else {
1220 DCHECK_EQ(__builtin_popcount(cUnit->coreSpillMask), 0);
1221 DCHECK_EQ(__builtin_popcount(cUnit->fpSpillMask), 0);
1222 }
buzbeeca7a5e42012-08-20 11:12:18 -07001223 // Combine vmap tables - core regs, then fp regs. fp regs already sorted
Bill Buzbeea114add2012-05-03 15:00:40 -07001224 for (uint32_t i = 0; i < cUnit->fpVmapTable.size(); i++) {
1225 vmapTable.push_back(cUnit->fpVmapTable[i]);
1226 }
1227 CompiledMethod* result =
1228 new CompiledMethod(cUnit->instructionSet, cUnit->codeBuffer,
Bill Buzbeea5b30242012-09-28 07:19:44 -07001229 cUnit->frameSize, cUnit->coreSpillMask, cUnit->fpSpillMask,
1230 cUnit->combinedMappingTable, vmapTable, cUnit->nativeGcMap);
buzbee67bf8852011-08-17 17:51:35 -07001231
Bill Buzbeea114add2012-05-03 15:00:40 -07001232 VLOG(compiler) << "Compiled " << PrettyMethod(method_idx, dex_file)
1233 << " (" << (cUnit->codeBuffer.size() * sizeof(cUnit->codeBuffer[0]))
1234 << " bytes)";
buzbee5abfa3e2012-01-31 17:01:43 -08001235
1236#ifdef WITH_MEMSTATS
Bill Buzbeea114add2012-05-03 15:00:40 -07001237 if (cUnit->enableDebug & (1 << kDebugShowMemoryUsage)) {
1238 oatDumpMemStats(cUnit.get());
1239 }
buzbee5abfa3e2012-01-31 17:01:43 -08001240#endif
buzbee67bf8852011-08-17 17:51:35 -07001241
Bill Buzbeea114add2012-05-03 15:00:40 -07001242 oatArenaReset(cUnit.get());
buzbeeba938cb2012-02-03 14:47:55 -08001243
Bill Buzbeea114add2012-05-03 15:00:40 -07001244 return result;
buzbee67bf8852011-08-17 17:51:35 -07001245}
1246
buzbeeabc4c6b2012-08-23 08:17:15 -07001247#if defined(ART_USE_QUICK_COMPILER)
1248CompiledMethod* oatCompileMethod(Compiler& compiler,
1249 const DexFile::CodeItem* code_item,
1250 uint32_t access_flags, InvokeType invoke_type,
1251 uint32_t method_idx, jobject class_loader,
1252 const DexFile& dex_file)
1253{
1254 return compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
TDYa12755e5e6c2012-09-11 15:14:42 -07001255 dex_file, NULL, false);
buzbeeabc4c6b2012-08-23 08:17:15 -07001256}
1257
1258/*
1259 * Given existing llvm module, context, intrinsic_helper and IRBuilder,
1260 * add the bitcode for the method described by code_item to the module.
1261 */
1262void oatCompileMethodToGBC(Compiler& compiler,
1263 const DexFile::CodeItem* code_item,
1264 uint32_t access_flags, InvokeType invoke_type,
1265 uint32_t method_idx, jobject class_loader,
1266 const DexFile& dex_file,
buzbee4df2bbd2012-10-11 14:46:06 -07001267 LLVMInfo* llvm_info)
buzbeeabc4c6b2012-08-23 08:17:15 -07001268{
1269 compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
buzbee4df2bbd2012-10-11 14:46:06 -07001270 dex_file, llvm_info, true);
buzbeeabc4c6b2012-08-23 08:17:15 -07001271}
1272#else
1273CompiledMethod* oatCompileMethod(Compiler& compiler,
1274 const DexFile::CodeItem* code_item,
1275 uint32_t access_flags, InvokeType invoke_type,
1276 uint32_t method_idx, jobject class_loader,
1277 const DexFile& dex_file)
1278{
1279 return compileMethod(compiler, code_item, access_flags, invoke_type, method_idx, class_loader,
1280 dex_file);
1281}
1282#endif
1283
Elliott Hughes11d1b0c2012-01-23 16:57:47 -08001284} // namespace art
Elliott Hughesb3bd5f02012-03-08 21:05:27 -08001285
Shih-wei Liao46bde5c2012-08-31 11:28:16 -07001286#if !defined(ART_USE_LLVM_COMPILER)
Bill Buzbeea114add2012-05-03 15:00:40 -07001287extern "C" art::CompiledMethod*
1288 ArtCompileMethod(art::Compiler& compiler,
1289 const art::DexFile::CodeItem* code_item,
Ian Rogers08f753d2012-08-24 14:35:25 -07001290 uint32_t access_flags, art::InvokeType invoke_type,
1291 uint32_t method_idx, jobject class_loader,
Bill Buzbeea114add2012-05-03 15:00:40 -07001292 const art::DexFile& dex_file)
Elliott Hughesb3bd5f02012-03-08 21:05:27 -08001293{
1294 CHECK_EQ(compiler.GetInstructionSet(), art::oatInstructionSet());
Ian Rogers08f753d2012-08-24 14:35:25 -07001295 return art::oatCompileMethod(compiler, code_item, access_flags, invoke_type,
1296 method_idx, class_loader, dex_file);
Elliott Hughesb3bd5f02012-03-08 21:05:27 -08001297}
Shih-wei Liao46bde5c2012-08-31 11:28:16 -07001298#endif