buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
| 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 Rogers | 0571d35 | 2011-11-03 19:51:38 -0700 | [diff] [blame] | 20 | #include "leb128.h" |
Brian Carlstrom | 9baa4ae | 2011-09-01 21:14:14 -0700 | [diff] [blame] | 21 | #include "object.h" |
Brian Carlstrom | 1f87008 | 2011-08-23 16:02:11 -0700 | [diff] [blame] | 22 | #include "runtime.h" |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 23 | |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 24 | #include <llvm/Support/Threading.h> |
| 25 | |
| 26 | namespace { |
Shih-wei Liao | 215a926 | 2012-10-12 10:29:46 -0700 | [diff] [blame] | 27 | #if !defined(ART_USE_LLVM_COMPILER) |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 28 | pthread_once_t llvm_multi_init = PTHREAD_ONCE_INIT; |
Shih-wei Liao | 215a926 | 2012-10-12 10:29:46 -0700 | [diff] [blame] | 29 | #endif |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 30 | void InitializeLLVMForQuick() { |
| 31 | llvm::llvm_start_multithreaded(); |
| 32 | } |
| 33 | } |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 34 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 35 | namespace art { |
| 36 | |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 37 | LLVMInfo::LLVMInfo() { |
| 38 | #if !defined(ART_USE_LLVM_COMPILER) |
| 39 | pthread_once(&llvm_multi_init, InitializeLLVMForQuick); |
| 40 | #endif |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 41 | // Create context, module, intrinsic helper & ir builder |
| 42 | llvm_context_.reset(new llvm::LLVMContext()); |
TDYa127 | 55e5e6c | 2012-09-11 15:14:42 -0700 | [diff] [blame] | 43 | llvm_module_ = new llvm::Module("art", *llvm_context_); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 44 | llvm::StructType::create(*llvm_context_, "JavaObject"); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 45 | intrinsic_helper_.reset( new greenland::IntrinsicHelper(*llvm_context_, *llvm_module_)); |
| 46 | ir_builder_.reset(new greenland::IRBuilder(*llvm_context_, *llvm_module_, *intrinsic_helper_)); |
| 47 | } |
| 48 | |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 49 | LLVMInfo::~LLVMInfo() { |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | extern "C" void ArtInitQuickCompilerContext(art::Compiler& compiler) { |
| 53 | CHECK(compiler.GetCompilerContext() == NULL); |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 54 | LLVMInfo* llvmInfo = new LLVMInfo(); |
| 55 | compiler.SetCompilerContext(llvmInfo); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | extern "C" void ArtUnInitQuickCompilerContext(art::Compiler& compiler) { |
buzbee | 4df2bbd | 2012-10-11 14:46:06 -0700 | [diff] [blame] | 59 | delete reinterpret_cast<LLVMInfo*>(compiler.GetCompilerContext()); |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 60 | compiler.SetCompilerContext(NULL); |
| 61 | } |
buzbee | 692be80 | 2012-08-29 15:52:59 -0700 | [diff] [blame] | 62 | |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 63 | /* Default optimizer/debug setting for the compiler. */ |
Elliott Hughes | e52e49b | 2012-04-02 16:05:44 -0700 | [diff] [blame] | 64 | static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 65 | //(1 << kLoadStoreElimination) | |
| 66 | //(1 << kLoadHoisting) | |
| 67 | //(1 << kSuppressLoads) | |
| 68 | //(1 << kNullCheckElimination) | |
| 69 | //(1 << kPromoteRegs) | |
| 70 | //(1 << kTrackLiveTemps) | |
| 71 | //(1 << kSkipLargeMethodOptimization) | |
| 72 | //(1 << kSafeOptimizations) | |
| 73 | //(1 << kBBOpt) | |
| 74 | //(1 << kMatch) | |
| 75 | //(1 << kPromoteCompilerTemps) | |
| 76 | 0; |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 77 | |
Elliott Hughes | e52e49b | 2012-04-02 16:05:44 -0700 | [diff] [blame] | 78 | static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 79 | //(1 << kDebugDisplayMissingTargets) | |
| 80 | //(1 << kDebugVerbose) | |
| 81 | //(1 << kDebugDumpCFG) | |
| 82 | //(1 << kDebugSlowFieldPath) | |
| 83 | //(1 << kDebugSlowInvokePath) | |
| 84 | //(1 << kDebugSlowStringPath) | |
| 85 | //(1 << kDebugSlowestFieldPath) | |
| 86 | //(1 << kDebugSlowestStringPath) | |
| 87 | //(1 << kDebugExerciseResolveMethod) | |
| 88 | //(1 << kDebugVerifyDataflow) | |
| 89 | //(1 << kDebugShowMemoryUsage) | |
| 90 | //(1 << kDebugShowNops) | |
| 91 | //(1 << kDebugCountOpcodes) | |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 92 | //(1 << kDebugDumpCheckStats) | |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 93 | //(1 << kDebugDumpBitcodeFile) | |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 94 | //(1 << kDebugVerifyBitcode) | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 95 | 0; |
buzbee | ce30293 | 2011-10-04 14:32:18 -0700 | [diff] [blame] | 96 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 97 | inline bool contentIsInsn(const u2* codePtr) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 98 | u2 instr = *codePtr; |
| 99 | Instruction::Code opcode = (Instruction::Code)(instr & 0xff); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 100 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 101 | /* |
| 102 | * Since the low 8-bit in metadata may look like NOP, we need to check |
| 103 | * both the low and whole sub-word to determine whether it is code or data. |
| 104 | */ |
| 105 | return (opcode != Instruction::NOP || instr == 0); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Parse an instruction, return the length of the instruction |
| 110 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 111 | inline int parseInsn(CompilationUnit* cUnit, const u2* codePtr, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 112 | DecodedInstruction* decoded_instruction, bool printMe) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 113 | { |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 114 | // Don't parse instruction data |
| 115 | if (!contentIsInsn(codePtr)) { |
| 116 | return 0; |
| 117 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 118 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 119 | const Instruction* instruction = Instruction::At(codePtr); |
| 120 | *decoded_instruction = DecodedInstruction(instruction); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 121 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 122 | if (printMe) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 123 | char* decodedString = oatGetDalvikDisassembly(cUnit, *decoded_instruction, |
| 124 | NULL); |
| 125 | LOG(INFO) << codePtr << ": 0x" |
| 126 | << std::hex << static_cast<int>(decoded_instruction->opcode) |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 127 | << " " << decodedString; |
| 128 | } |
| 129 | return instruction->SizeInCodeUnits(); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | #define UNKNOWN_TARGET 0xffffffff |
| 133 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 134 | inline bool isGoto(MIR* insn) { |
| 135 | switch (insn->dalvikInsn.opcode) { |
| 136 | case Instruction::GOTO: |
| 137 | case Instruction::GOTO_16: |
| 138 | case Instruction::GOTO_32: |
| 139 | return true; |
| 140 | default: |
| 141 | return false; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 142 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /* |
| 146 | * Identify unconditional branch instructions |
| 147 | */ |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 148 | inline bool isUnconditionalBranch(MIR* insn) { |
| 149 | switch (insn->dalvikInsn.opcode) { |
| 150 | case Instruction::RETURN_VOID: |
| 151 | case Instruction::RETURN: |
| 152 | case Instruction::RETURN_WIDE: |
| 153 | case Instruction::RETURN_OBJECT: |
| 154 | return true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 155 | default: |
| 156 | return isGoto(insn); |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 157 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* Split an existing block from the specified code offset into two */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 161 | BasicBlock *splitBlock(CompilationUnit* cUnit, unsigned int codeOffset, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 162 | BasicBlock* origBlock, BasicBlock** immedPredBlockP) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 163 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 164 | MIR* insn = origBlock->firstMIRInsn; |
| 165 | while (insn) { |
| 166 | if (insn->offset == codeOffset) break; |
| 167 | insn = insn->next; |
| 168 | } |
| 169 | if (insn == NULL) { |
| 170 | LOG(FATAL) << "Break split failed"; |
| 171 | } |
| 172 | BasicBlock *bottomBlock = oatNewBB(cUnit, kDalvikByteCode, |
| 173 | cUnit->numBlocks++); |
| 174 | oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bottomBlock); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 175 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 176 | bottomBlock->startOffset = codeOffset; |
| 177 | bottomBlock->firstMIRInsn = insn; |
| 178 | bottomBlock->lastMIRInsn = origBlock->lastMIRInsn; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 179 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 180 | /* Add it to the quick lookup cache */ |
| 181 | cUnit->blockMap.Put(bottomBlock->startOffset, bottomBlock); |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 182 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 183 | /* Handle the taken path */ |
| 184 | bottomBlock->taken = origBlock->taken; |
| 185 | if (bottomBlock->taken) { |
| 186 | origBlock->taken = NULL; |
| 187 | oatDeleteGrowableList(bottomBlock->taken->predecessors, |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 188 | (intptr_t)origBlock); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 189 | oatInsertGrowableList(cUnit, bottomBlock->taken->predecessors, |
| 190 | (intptr_t)bottomBlock); |
| 191 | } |
| 192 | |
| 193 | /* Handle the fallthrough path */ |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 194 | bottomBlock->fallThrough = origBlock->fallThrough; |
| 195 | origBlock->fallThrough = bottomBlock; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 196 | oatInsertGrowableList(cUnit, bottomBlock->predecessors, |
| 197 | (intptr_t)origBlock); |
| 198 | if (bottomBlock->fallThrough) { |
| 199 | oatDeleteGrowableList(bottomBlock->fallThrough->predecessors, |
| 200 | (intptr_t)origBlock); |
| 201 | oatInsertGrowableList(cUnit, bottomBlock->fallThrough->predecessors, |
| 202 | (intptr_t)bottomBlock); |
| 203 | } |
| 204 | |
| 205 | /* Handle the successor list */ |
| 206 | if (origBlock->successorBlockList.blockListType != kNotUsed) { |
| 207 | bottomBlock->successorBlockList = origBlock->successorBlockList; |
| 208 | origBlock->successorBlockList.blockListType = kNotUsed; |
| 209 | GrowableListIterator iterator; |
| 210 | |
| 211 | oatGrowableListIteratorInit(&bottomBlock->successorBlockList.blocks, |
| 212 | &iterator); |
| 213 | while (true) { |
| 214 | SuccessorBlockInfo *successorBlockInfo = |
| 215 | (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator); |
| 216 | if (successorBlockInfo == NULL) break; |
| 217 | BasicBlock *bb = successorBlockInfo->block; |
| 218 | oatDeleteGrowableList(bb->predecessors, (intptr_t)origBlock); |
| 219 | oatInsertGrowableList(cUnit, bb->predecessors, (intptr_t)bottomBlock); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 220 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 221 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 222 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 223 | origBlock->lastMIRInsn = insn->prev; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 224 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 225 | insn->prev->next = NULL; |
| 226 | insn->prev = NULL; |
| 227 | /* |
| 228 | * Update the immediate predecessor block pointer so that outgoing edges |
| 229 | * can be applied to the proper block. |
| 230 | */ |
| 231 | if (immedPredBlockP) { |
| 232 | DCHECK_EQ(*immedPredBlockP, origBlock); |
| 233 | *immedPredBlockP = bottomBlock; |
| 234 | } |
| 235 | return bottomBlock; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* |
| 239 | * Given a code offset, find out the block that starts with it. If the offset |
buzbee | 9ab05de | 2012-01-18 15:43:48 -0800 | [diff] [blame] | 240 | * is in the middle of an existing block, split it into two. If immedPredBlockP |
| 241 | * is not non-null and is the block being split, update *immedPredBlockP to |
| 242 | * point to the bottom block so that outgoing edges can be set up properly |
| 243 | * (by the caller) |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 244 | * Utilizes a map for fast lookup of the typical cases. |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 245 | */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 246 | BasicBlock *findBlock(CompilationUnit* cUnit, unsigned int codeOffset, |
| 247 | bool split, bool create, BasicBlock** immedPredBlockP) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 248 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 249 | GrowableList* blockList = &cUnit->blockList; |
| 250 | BasicBlock* bb; |
| 251 | unsigned int i; |
| 252 | SafeMap<unsigned int, BasicBlock*>::iterator it; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 253 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 254 | it = cUnit->blockMap.find(codeOffset); |
| 255 | if (it != cUnit->blockMap.end()) { |
| 256 | return it->second; |
| 257 | } else if (!create) { |
| 258 | return NULL; |
| 259 | } |
| 260 | |
| 261 | if (split) { |
| 262 | for (i = 0; i < blockList->numUsed; i++) { |
| 263 | bb = (BasicBlock *) blockList->elemList[i]; |
| 264 | if (bb->blockType != kDalvikByteCode) continue; |
| 265 | /* Check if a branch jumps into the middle of an existing block */ |
| 266 | if ((codeOffset > bb->startOffset) && (bb->lastMIRInsn != NULL) && |
| 267 | (codeOffset <= bb->lastMIRInsn->offset)) { |
| 268 | BasicBlock *newBB = splitBlock(cUnit, codeOffset, bb, |
| 269 | bb == *immedPredBlockP ? |
| 270 | immedPredBlockP : NULL); |
| 271 | return newBB; |
| 272 | } |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 273 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 274 | } |
buzbee | 5b53710 | 2012-01-17 17:33:47 -0800 | [diff] [blame] | 275 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 276 | /* Create a new one */ |
| 277 | bb = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++); |
| 278 | oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bb); |
| 279 | bb->startOffset = codeOffset; |
| 280 | cUnit->blockMap.Put(bb->startOffset, bb); |
| 281 | return bb; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 282 | } |
| 283 | |
buzbee | f58c12c | 2012-07-03 15:06:29 -0700 | [diff] [blame] | 284 | /* Find existing block */ |
| 285 | BasicBlock* oatFindBlock(CompilationUnit* cUnit, unsigned int codeOffset) |
| 286 | { |
| 287 | return findBlock(cUnit, codeOffset, false, false, NULL); |
| 288 | } |
| 289 | |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 290 | /* Turn method name into a legal Linux file name */ |
| 291 | void oatReplaceSpecialChars(std::string& str) |
| 292 | { |
| 293 | static const struct { const char before; const char after; } match[] = |
| 294 | {{'/','-'}, {';','#'}, {' ','#'}, {'$','+'}, |
| 295 | {'(','@'}, {')','@'}, {'<','='}, {'>','='}}; |
| 296 | for (unsigned int i = 0; i < sizeof(match)/sizeof(match[0]); i++) { |
| 297 | std::replace(str.begin(), str.end(), match[i].before, match[i].after); |
| 298 | } |
| 299 | } |
| 300 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 301 | /* Dump the CFG into a DOT graph */ |
| 302 | void oatDumpCFG(CompilationUnit* cUnit, const char* dirPrefix) |
| 303 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 304 | FILE* file; |
buzbee | ad8f15e | 2012-06-18 14:49:45 -0700 | [diff] [blame] | 305 | std::string fname(PrettyMethod(cUnit->method_idx, *cUnit->dex_file)); |
| 306 | oatReplaceSpecialChars(fname); |
| 307 | fname = StringPrintf("%s%s%x.dot", dirPrefix, fname.c_str(), |
| 308 | cUnit->entryBlock->fallThrough->startOffset); |
| 309 | file = fopen(fname.c_str(), "w"); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 310 | if (file == NULL) { |
| 311 | return; |
| 312 | } |
| 313 | fprintf(file, "digraph G {\n"); |
| 314 | |
| 315 | fprintf(file, " rankdir=TB\n"); |
| 316 | |
| 317 | int numReachableBlocks = cUnit->numReachableBlocks; |
| 318 | int idx; |
| 319 | const GrowableList *blockList = &cUnit->blockList; |
| 320 | |
| 321 | for (idx = 0; idx < numReachableBlocks; idx++) { |
| 322 | int blockIdx = cUnit->dfsOrder.elemList[idx]; |
| 323 | BasicBlock *bb = (BasicBlock *) oatGrowableListGetElement(blockList, |
| 324 | blockIdx); |
| 325 | if (bb == NULL) break; |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 326 | if (bb->blockType == kDead) continue; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 327 | if (bb->blockType == kEntryBlock) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 328 | fprintf(file, " entry_%d [shape=Mdiamond];\n", bb->id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 329 | } else if (bb->blockType == kExitBlock) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 330 | fprintf(file, " exit_%d [shape=Mdiamond];\n", bb->id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 331 | } else if (bb->blockType == kDalvikByteCode) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 332 | fprintf(file, " block%04x_%d [shape=record,label = \"{ \\\n", |
| 333 | bb->startOffset, bb->id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 334 | const MIR *mir; |
| 335 | fprintf(file, " {block id %d\\l}%s\\\n", bb->id, |
| 336 | bb->firstMIRInsn ? " | " : " "); |
| 337 | for (mir = bb->firstMIRInsn; mir; mir = mir->next) { |
| 338 | fprintf(file, " {%04x %s\\l}%s\\\n", mir->offset, |
| 339 | mir->ssaRep ? oatFullDisassembler(cUnit, mir) : |
| 340 | Instruction::Name(mir->dalvikInsn.opcode), |
| 341 | mir->next ? " | " : " "); |
| 342 | } |
| 343 | fprintf(file, " }\"];\n\n"); |
| 344 | } else if (bb->blockType == kExceptionHandling) { |
| 345 | char blockName[BLOCK_NAME_LEN]; |
| 346 | |
| 347 | oatGetBlockName(bb, blockName); |
| 348 | fprintf(file, " %s [shape=invhouse];\n", blockName); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 349 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 350 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 351 | char blockName1[BLOCK_NAME_LEN], blockName2[BLOCK_NAME_LEN]; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 352 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 353 | if (bb->taken) { |
| 354 | oatGetBlockName(bb, blockName1); |
| 355 | oatGetBlockName(bb->taken, blockName2); |
| 356 | fprintf(file, " %s:s -> %s:n [style=dotted]\n", |
| 357 | blockName1, blockName2); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 358 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 359 | if (bb->fallThrough) { |
| 360 | oatGetBlockName(bb, blockName1); |
| 361 | oatGetBlockName(bb->fallThrough, blockName2); |
| 362 | fprintf(file, " %s:s -> %s:n\n", blockName1, blockName2); |
| 363 | } |
| 364 | |
| 365 | if (bb->successorBlockList.blockListType != kNotUsed) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 366 | fprintf(file, " succ%04x_%d [shape=%s,label = \"{ \\\n", |
| 367 | bb->startOffset, bb->id, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 368 | (bb->successorBlockList.blockListType == kCatch) ? |
| 369 | "Mrecord" : "record"); |
| 370 | GrowableListIterator iterator; |
| 371 | oatGrowableListIteratorInit(&bb->successorBlockList.blocks, |
| 372 | &iterator); |
| 373 | SuccessorBlockInfo *successorBlockInfo = |
| 374 | (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator); |
| 375 | |
| 376 | int succId = 0; |
| 377 | while (true) { |
| 378 | if (successorBlockInfo == NULL) break; |
| 379 | |
| 380 | BasicBlock *destBlock = successorBlockInfo->block; |
| 381 | SuccessorBlockInfo *nextSuccessorBlockInfo = |
| 382 | (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator); |
| 383 | |
| 384 | fprintf(file, " {<f%d> %04x: %04x\\l}%s\\\n", |
| 385 | succId++, |
| 386 | successorBlockInfo->key, |
| 387 | destBlock->startOffset, |
| 388 | (nextSuccessorBlockInfo != NULL) ? " | " : " "); |
| 389 | |
| 390 | successorBlockInfo = nextSuccessorBlockInfo; |
| 391 | } |
| 392 | fprintf(file, " }\"];\n\n"); |
| 393 | |
| 394 | oatGetBlockName(bb, blockName1); |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 395 | fprintf(file, " %s:s -> succ%04x_%d:n [style=dashed]\n", |
| 396 | blockName1, bb->startOffset, bb->id); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 397 | |
| 398 | if (bb->successorBlockList.blockListType == kPackedSwitch || |
| 399 | bb->successorBlockList.blockListType == kSparseSwitch) { |
| 400 | |
| 401 | oatGrowableListIteratorInit(&bb->successorBlockList.blocks, |
| 402 | &iterator); |
| 403 | |
| 404 | succId = 0; |
| 405 | while (true) { |
| 406 | SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *) |
| 407 | oatGrowableListIteratorNext(&iterator); |
| 408 | if (successorBlockInfo == NULL) break; |
| 409 | |
| 410 | BasicBlock *destBlock = successorBlockInfo->block; |
| 411 | |
| 412 | oatGetBlockName(destBlock, blockName2); |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 413 | fprintf(file, " succ%04x_%d:f%d:e -> %s:n\n", bb->startOffset, |
| 414 | bb->id, succId++, blockName2); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | } |
| 418 | fprintf(file, "\n"); |
| 419 | |
| 420 | /* Display the dominator tree */ |
| 421 | oatGetBlockName(bb, blockName1); |
| 422 | fprintf(file, " cfg%s [label=\"%s\", shape=none];\n", |
| 423 | blockName1, blockName1); |
| 424 | if (bb->iDom) { |
| 425 | oatGetBlockName(bb->iDom, blockName2); |
| 426 | fprintf(file, " cfg%s:s -> cfg%s:n\n\n", blockName2, blockName1); |
| 427 | } |
| 428 | } |
| 429 | fprintf(file, "}\n"); |
| 430 | fclose(file); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /* Verify if all the successor is connected with all the claimed predecessors */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 434 | bool verifyPredInfo(CompilationUnit* cUnit, BasicBlock* bb) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 435 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 436 | GrowableListIterator iter; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 437 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 438 | oatGrowableListIteratorInit(bb->predecessors, &iter); |
| 439 | while (true) { |
| 440 | BasicBlock *predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); |
| 441 | if (!predBB) break; |
| 442 | bool found = false; |
| 443 | if (predBB->taken == bb) { |
| 444 | found = true; |
| 445 | } else if (predBB->fallThrough == bb) { |
| 446 | found = true; |
| 447 | } else if (predBB->successorBlockList.blockListType != kNotUsed) { |
| 448 | GrowableListIterator iterator; |
| 449 | oatGrowableListIteratorInit(&predBB->successorBlockList.blocks, |
| 450 | &iterator); |
| 451 | while (true) { |
| 452 | SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *) |
| 453 | oatGrowableListIteratorNext(&iterator); |
| 454 | if (successorBlockInfo == NULL) break; |
| 455 | BasicBlock *succBB = successorBlockInfo->block; |
| 456 | if (succBB == bb) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 457 | found = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 458 | break; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 459 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 460 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 461 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 462 | if (found == false) { |
| 463 | char blockName1[BLOCK_NAME_LEN], blockName2[BLOCK_NAME_LEN]; |
| 464 | oatGetBlockName(bb, blockName1); |
| 465 | oatGetBlockName(predBB, blockName2); |
| 466 | oatDumpCFG(cUnit, "/sdcard/cfg/"); |
| 467 | LOG(FATAL) << "Successor " << blockName1 << "not found from " |
| 468 | << blockName2; |
| 469 | } |
| 470 | } |
| 471 | return true; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | /* Identify code range in try blocks and set up the empty catch blocks */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 475 | void processTryCatchBlocks(CompilationUnit* cUnit) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 476 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 477 | const DexFile::CodeItem* code_item = cUnit->code_item; |
| 478 | int triesSize = code_item->tries_size_; |
| 479 | int offset; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 480 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 481 | if (triesSize == 0) { |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | ArenaBitVector* tryBlockAddr = cUnit->tryBlockAddr; |
| 486 | |
| 487 | for (int i = 0; i < triesSize; i++) { |
| 488 | const DexFile::TryItem* pTry = |
| 489 | DexFile::GetTryItems(*code_item, i); |
| 490 | int startOffset = pTry->start_addr_; |
| 491 | int endOffset = startOffset + pTry->insn_count_; |
| 492 | for (offset = startOffset; offset < endOffset; offset++) { |
| 493 | oatSetBit(cUnit, tryBlockAddr, offset); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 494 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 495 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 496 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 497 | // Iterate over each of the handlers to enqueue the empty Catch blocks |
| 498 | const byte* handlers_ptr = DexFile::GetCatchHandlerData(*code_item, 0); |
| 499 | uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr); |
| 500 | for (uint32_t idx = 0; idx < handlers_size; idx++) { |
| 501 | CatchHandlerIterator iterator(handlers_ptr); |
| 502 | for (; iterator.HasNext(); iterator.Next()) { |
| 503 | uint32_t address = iterator.GetHandlerAddress(); |
| 504 | findBlock(cUnit, address, false /* split */, true /*create*/, |
| 505 | /* immedPredBlockP */ NULL); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 506 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 507 | handlers_ptr = iterator.EndDataPointer(); |
| 508 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 511 | /* Process instructions with the kBranch flag */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 512 | BasicBlock* processCanBranch(CompilationUnit* cUnit, BasicBlock* curBlock, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 513 | MIR* insn, int curOffset, int width, int flags, |
| 514 | const u2* codePtr, const u2* codeEnd) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 515 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 516 | int target = curOffset; |
| 517 | switch (insn->dalvikInsn.opcode) { |
| 518 | case Instruction::GOTO: |
| 519 | case Instruction::GOTO_16: |
| 520 | case Instruction::GOTO_32: |
| 521 | target += (int) insn->dalvikInsn.vA; |
| 522 | break; |
| 523 | case Instruction::IF_EQ: |
| 524 | case Instruction::IF_NE: |
| 525 | case Instruction::IF_LT: |
| 526 | case Instruction::IF_GE: |
| 527 | case Instruction::IF_GT: |
| 528 | case Instruction::IF_LE: |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 529 | curBlock->conditionalBranch = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 530 | target += (int) insn->dalvikInsn.vC; |
| 531 | break; |
| 532 | case Instruction::IF_EQZ: |
| 533 | case Instruction::IF_NEZ: |
| 534 | case Instruction::IF_LTZ: |
| 535 | case Instruction::IF_GEZ: |
| 536 | case Instruction::IF_GTZ: |
| 537 | case Instruction::IF_LEZ: |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 538 | curBlock->conditionalBranch = true; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 539 | target += (int) insn->dalvikInsn.vB; |
| 540 | break; |
| 541 | default: |
| 542 | LOG(FATAL) << "Unexpected opcode(" << (int)insn->dalvikInsn.opcode |
| 543 | << ") with kBranch set"; |
| 544 | } |
| 545 | BasicBlock *takenBlock = findBlock(cUnit, target, |
| 546 | /* split */ |
| 547 | true, |
| 548 | /* create */ |
| 549 | true, |
| 550 | /* immedPredBlockP */ |
| 551 | &curBlock); |
| 552 | curBlock->taken = takenBlock; |
| 553 | oatInsertGrowableList(cUnit, takenBlock->predecessors, (intptr_t)curBlock); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 554 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 555 | /* Always terminate the current block for conditional branches */ |
| 556 | if (flags & Instruction::kContinue) { |
| 557 | BasicBlock *fallthroughBlock = findBlock(cUnit, |
| 558 | curOffset + width, |
| 559 | /* |
| 560 | * If the method is processed |
| 561 | * in sequential order from the |
| 562 | * beginning, we don't need to |
| 563 | * specify split for continue |
| 564 | * blocks. However, this |
| 565 | * routine can be called by |
| 566 | * compileLoop, which starts |
| 567 | * parsing the method from an |
| 568 | * arbitrary address in the |
| 569 | * method body. |
| 570 | */ |
| 571 | true, |
| 572 | /* create */ |
| 573 | true, |
| 574 | /* immedPredBlockP */ |
| 575 | &curBlock); |
| 576 | curBlock->fallThrough = fallthroughBlock; |
| 577 | oatInsertGrowableList(cUnit, fallthroughBlock->predecessors, |
| 578 | (intptr_t)curBlock); |
| 579 | } else if (codePtr < codeEnd) { |
| 580 | /* Create a fallthrough block for real instructions (incl. NOP) */ |
| 581 | if (contentIsInsn(codePtr)) { |
| 582 | findBlock(cUnit, curOffset + width, |
| 583 | /* split */ |
| 584 | false, |
| 585 | /* create */ |
| 586 | true, |
| 587 | /* immedPredBlockP */ |
| 588 | NULL); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 589 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 590 | } |
| 591 | return curBlock; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 594 | /* Process instructions with the kSwitch flag */ |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 595 | void processCanSwitch(CompilationUnit* cUnit, BasicBlock* curBlock, |
| 596 | MIR* insn, int curOffset, int width, int flags) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 597 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 598 | u2* switchData= (u2 *) (cUnit->insns + curOffset + insn->dalvikInsn.vB); |
| 599 | int size; |
| 600 | int* keyTable; |
| 601 | int* targetTable; |
| 602 | int i; |
| 603 | int firstKey; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 604 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 605 | /* |
| 606 | * Packed switch data format: |
| 607 | * ushort ident = 0x0100 magic value |
| 608 | * ushort size number of entries in the table |
| 609 | * int first_key first (and lowest) switch case value |
| 610 | * int targets[size] branch targets, relative to switch opcode |
| 611 | * |
| 612 | * Total size is (4+size*2) 16-bit code units. |
| 613 | */ |
| 614 | if (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) { |
| 615 | DCHECK_EQ(static_cast<int>(switchData[0]), |
| 616 | static_cast<int>(Instruction::kPackedSwitchSignature)); |
| 617 | size = switchData[1]; |
| 618 | firstKey = switchData[2] | (switchData[3] << 16); |
| 619 | targetTable = (int *) &switchData[4]; |
| 620 | keyTable = NULL; // Make the compiler happy |
| 621 | /* |
| 622 | * Sparse switch data format: |
| 623 | * ushort ident = 0x0200 magic value |
| 624 | * ushort size number of entries in the table; > 0 |
| 625 | * int keys[size] keys, sorted low-to-high; 32-bit aligned |
| 626 | * int targets[size] branch targets, relative to switch opcode |
| 627 | * |
| 628 | * Total size is (2+size*4) 16-bit code units. |
| 629 | */ |
| 630 | } else { |
| 631 | DCHECK_EQ(static_cast<int>(switchData[0]), |
| 632 | static_cast<int>(Instruction::kSparseSwitchSignature)); |
| 633 | size = switchData[1]; |
| 634 | keyTable = (int *) &switchData[2]; |
| 635 | targetTable = (int *) &switchData[2 + size*2]; |
| 636 | firstKey = 0; // To make the compiler happy |
| 637 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 638 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 639 | if (curBlock->successorBlockList.blockListType != kNotUsed) { |
| 640 | LOG(FATAL) << "Successor block list already in use: " |
| 641 | << (int)curBlock->successorBlockList.blockListType; |
| 642 | } |
| 643 | curBlock->successorBlockList.blockListType = |
| 644 | (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? |
| 645 | kPackedSwitch : kSparseSwitch; |
| 646 | oatInitGrowableList(cUnit, &curBlock->successorBlockList.blocks, size, |
| 647 | kListSuccessorBlocks); |
| 648 | |
| 649 | for (i = 0; i < size; i++) { |
| 650 | BasicBlock *caseBlock = findBlock(cUnit, curOffset + targetTable[i], |
| 651 | /* split */ |
| 652 | true, |
| 653 | /* create */ |
| 654 | true, |
| 655 | /* immedPredBlockP */ |
| 656 | &curBlock); |
| 657 | SuccessorBlockInfo *successorBlockInfo = |
| 658 | (SuccessorBlockInfo *) oatNew(cUnit, sizeof(SuccessorBlockInfo), |
| 659 | false, kAllocSuccessor); |
| 660 | successorBlockInfo->block = caseBlock; |
| 661 | successorBlockInfo->key = |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 662 | (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 663 | firstKey + i : keyTable[i]; |
| 664 | oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks, |
| 665 | (intptr_t) successorBlockInfo); |
| 666 | oatInsertGrowableList(cUnit, caseBlock->predecessors, |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 667 | (intptr_t)curBlock); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | /* Fall-through case */ |
| 671 | BasicBlock* fallthroughBlock = findBlock(cUnit, |
| 672 | curOffset + width, |
| 673 | /* split */ |
| 674 | false, |
| 675 | /* create */ |
| 676 | true, |
| 677 | /* immedPredBlockP */ |
| 678 | NULL); |
| 679 | curBlock->fallThrough = fallthroughBlock; |
| 680 | oatInsertGrowableList(cUnit, fallthroughBlock->predecessors, |
| 681 | (intptr_t)curBlock); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Elliott Hughes | adb8c67 | 2012-03-06 16:49:32 -0800 | [diff] [blame] | 684 | /* Process instructions with the kThrow flag */ |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 685 | BasicBlock* processCanThrow(CompilationUnit* cUnit, BasicBlock* curBlock, |
| 686 | MIR* insn, int curOffset, int width, int flags, |
| 687 | ArenaBitVector* tryBlockAddr, const u2* codePtr, |
| 688 | const u2* codeEnd) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 689 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 690 | const DexFile::CodeItem* code_item = cUnit->code_item; |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 691 | bool inTryBlock = oatIsBitSet(tryBlockAddr, curOffset); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 692 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 693 | /* In try block */ |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 694 | if (inTryBlock) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 695 | CatchHandlerIterator iterator(*code_item, curOffset); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 696 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 697 | if (curBlock->successorBlockList.blockListType != kNotUsed) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 698 | LOG(INFO) << PrettyMethod(cUnit->method_idx, *cUnit->dex_file); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 699 | LOG(FATAL) << "Successor block list already in use: " |
| 700 | << (int)curBlock->successorBlockList.blockListType; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 703 | curBlock->successorBlockList.blockListType = kCatch; |
| 704 | oatInitGrowableList(cUnit, &curBlock->successorBlockList.blocks, 2, |
| 705 | kListSuccessorBlocks); |
| 706 | |
| 707 | for (;iterator.HasNext(); iterator.Next()) { |
| 708 | BasicBlock *catchBlock = findBlock(cUnit, iterator.GetHandlerAddress(), |
| 709 | false /* split*/, |
| 710 | false /* creat */, |
| 711 | NULL /* immedPredBlockP */); |
| 712 | catchBlock->catchEntry = true; |
buzbee | 6459e7c | 2012-10-02 14:42:41 -0700 | [diff] [blame] | 713 | cUnit->catches.insert(catchBlock->startOffset); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 714 | SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *) |
| 715 | oatNew(cUnit, sizeof(SuccessorBlockInfo), false, kAllocSuccessor); |
| 716 | successorBlockInfo->block = catchBlock; |
| 717 | successorBlockInfo->key = iterator.GetHandlerTypeIndex(); |
| 718 | oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks, |
| 719 | (intptr_t) successorBlockInfo); |
| 720 | oatInsertGrowableList(cUnit, catchBlock->predecessors, |
| 721 | (intptr_t)curBlock); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 722 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 723 | } else { |
| 724 | BasicBlock *ehBlock = oatNewBB(cUnit, kExceptionHandling, |
| 725 | cUnit->numBlocks++); |
| 726 | curBlock->taken = ehBlock; |
| 727 | oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) ehBlock); |
| 728 | ehBlock->startOffset = curOffset; |
| 729 | oatInsertGrowableList(cUnit, ehBlock->predecessors, (intptr_t)curBlock); |
| 730 | } |
| 731 | |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 732 | if (insn->dalvikInsn.opcode == Instruction::THROW){ |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 733 | curBlock->explicitThrow = true; |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 734 | if ((codePtr < codeEnd) && contentIsInsn(codePtr)) { |
| 735 | // Force creation of new block following THROW via side-effect |
| 736 | findBlock(cUnit, curOffset + width, /* split */ false, |
| 737 | /* create */ true, /* immedPredBlockP */ NULL); |
| 738 | } |
| 739 | if (!inTryBlock) { |
| 740 | // Don't split a THROW that can't rethrow - we're done. |
| 741 | return curBlock; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 742 | } |
| 743 | } |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 744 | |
| 745 | /* |
| 746 | * Split the potentially-throwing instruction into two parts. |
| 747 | * The first half will be a pseudo-op that captures the exception |
| 748 | * edges and terminates the basic block. It always falls through. |
| 749 | * Then, create a new basic block that begins with the throwing instruction |
| 750 | * (minus exceptions). Note: this new basic block must NOT be entered into |
| 751 | * the blockMap. If the potentially-throwing instruction is the target of a |
| 752 | * future branch, we need to find the check psuedo half. The new |
| 753 | * basic block containing the work portion of the instruction should |
| 754 | * only be entered via fallthrough from the block containing the |
| 755 | * pseudo exception edge MIR. Note also that this new block is |
| 756 | * not automatically terminated after the work portion, and may |
| 757 | * contain following instructions. |
| 758 | */ |
| 759 | BasicBlock *newBlock = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++); |
| 760 | oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t)newBlock); |
| 761 | newBlock->startOffset = insn->offset; |
| 762 | curBlock->fallThrough = newBlock; |
| 763 | oatInsertGrowableList(cUnit, newBlock->predecessors, (intptr_t)curBlock); |
| 764 | MIR* newInsn = (MIR*)oatNew(cUnit, sizeof(MIR), true, kAllocMIR); |
| 765 | *newInsn = *insn; |
| 766 | insn->dalvikInsn.opcode = |
| 767 | static_cast<Instruction::Code>(kMirOpCheck); |
| 768 | // Associate the two halves |
| 769 | insn->meta.throwInsn = newInsn; |
| 770 | newInsn->meta.throwInsn = insn; |
| 771 | oatAppendMIR(newBlock, newInsn); |
| 772 | return newBlock; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 773 | } |
| 774 | |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 775 | void oatInit(CompilationUnit* cUnit, const Compiler& compiler) { |
| 776 | if (!oatArchInit()) { |
| 777 | LOG(FATAL) << "Failed to initialize oat"; |
| 778 | } |
| 779 | if (!oatHeapInit(cUnit)) { |
| 780 | LOG(FATAL) << "Failed to initialize oat heap"; |
| 781 | } |
| 782 | } |
| 783 | |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 784 | CompiledMethod* compileMethod(Compiler& compiler, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 785 | const CompilerBackend compilerBackend, |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 786 | const DexFile::CodeItem* code_item, |
| 787 | uint32_t access_flags, InvokeType invoke_type, |
| 788 | uint32_t method_idx, jobject class_loader, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 789 | const DexFile& dex_file, |
| 790 | LLVMInfo* llvm_info |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 791 | ) |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 792 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 793 | VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "..."; |
Brian Carlstrom | 94496d3 | 2011-08-22 09:22:47 -0700 | [diff] [blame] | 794 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 795 | const u2* codePtr = code_item->insns_; |
| 796 | const u2* codeEnd = code_item->insns_ + code_item->insns_size_in_code_units_; |
| 797 | int numBlocks = 0; |
| 798 | unsigned int curOffset = 0; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 799 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 800 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 801 | UniquePtr<CompilationUnit> cUnit(new CompilationUnit); |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 802 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 803 | oatInit(cUnit.get(), compiler); |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 804 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 805 | cUnit->compiler = &compiler; |
| 806 | cUnit->class_linker = class_linker; |
| 807 | cUnit->dex_file = &dex_file; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 808 | cUnit->method_idx = method_idx; |
| 809 | cUnit->code_item = code_item; |
| 810 | cUnit->access_flags = access_flags; |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 811 | cUnit->invoke_type = invoke_type; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 812 | cUnit->shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx)); |
| 813 | cUnit->instructionSet = compiler.GetInstructionSet(); |
| 814 | cUnit->insns = code_item->insns_; |
| 815 | cUnit->insnsSize = code_item->insns_size_in_code_units_; |
| 816 | cUnit->numIns = code_item->ins_size_; |
| 817 | cUnit->numRegs = code_item->registers_size_ - cUnit->numIns; |
| 818 | cUnit->numOuts = code_item->outs_size_; |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 819 | DCHECK((cUnit->instructionSet == kThumb2) || |
| 820 | (cUnit->instructionSet == kX86) || |
| 821 | (cUnit->instructionSet == kMips)); |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 822 | if ((compilerBackend == kQuickGBC) || (compilerBackend == kPortable)) { |
buzbee | 85eee02 | 2012-07-16 22:12:38 -0700 | [diff] [blame] | 823 | cUnit->genBitcode = true; |
| 824 | } |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 825 | DCHECK_NE(compilerBackend, kIceland); // TODO: remove when Portable/Iceland merge complete |
| 826 | // TODO: remove this once x86 is tested |
| 827 | if (cUnit->genBitcode && (cUnit->instructionSet != kThumb2)) { |
| 828 | UNIMPLEMENTED(WARNING) << "GBC generation untested for non-Thumb targets"; |
| 829 | } |
| 830 | cUnit->llvm_info = llvm_info; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 831 | /* Adjust this value accordingly once inlining is performed */ |
| 832 | cUnit->numDalvikRegisters = code_item->registers_size_; |
| 833 | // TODO: set this from command line |
| 834 | cUnit->compilerFlipMatch = false; |
| 835 | bool useMatch = !cUnit->compilerMethodMatch.empty(); |
| 836 | bool match = useMatch && (cUnit->compilerFlipMatch ^ |
| 837 | (PrettyMethod(method_idx, dex_file).find(cUnit->compilerMethodMatch) != |
| 838 | std::string::npos)); |
| 839 | if (!useMatch || match) { |
| 840 | cUnit->disableOpt = kCompilerOptimizerDisableFlags; |
| 841 | cUnit->enableDebug = kCompilerDebugFlags; |
| 842 | cUnit->printMe = VLOG_IS_ON(compiler) || |
| 843 | (cUnit->enableDebug & (1 << kDebugVerbose)); |
| 844 | } |
buzbee | 6459e7c | 2012-10-02 14:42:41 -0700 | [diff] [blame] | 845 | #ifndef NDEBUG |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 846 | if (cUnit->genBitcode) { |
buzbee | 6459e7c | 2012-10-02 14:42:41 -0700 | [diff] [blame] | 847 | cUnit->enableDebug |= (1 << kDebugVerifyBitcode); |
buzbee | 6969d50 | 2012-06-15 16:40:31 -0700 | [diff] [blame] | 848 | } |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 849 | #endif |
buzbee | 9281f00 | 2012-10-24 12:17:24 -0700 | [diff] [blame] | 850 | |
| 851 | #if 1 |
| 852 | // *** Temporary **** |
| 853 | // For use in debugging issue 7250540. Disable optimization in problem method |
| 854 | // to see if monkey results change. Should be removed after monkey runs |
| 855 | // complete. |
| 856 | if (PrettyMethod(method_idx, dex_file).find("void com.android.inputmethod.keyboard.Key.<init>(android.content.res.Resources, com.android.inputmethod.keyboard.Keyboard$Params, com.android.inputmethod.keyboard.Keyboard$Builder$Row, org.xmlpull.v1.XmlPullParser)") != std::string::npos) { |
| 857 | cUnit->disableOpt |= ( |
| 858 | (1 << kLoadStoreElimination) | |
| 859 | (1 << kLoadHoisting) | |
| 860 | (1 << kSuppressLoads) | |
| 861 | (1 << kNullCheckElimination) | |
| 862 | (1 << kPromoteRegs) | |
| 863 | (1 << kTrackLiveTemps) | |
| 864 | (1 << kSkipLargeMethodOptimization) | |
| 865 | (1 << kSafeOptimizations) | |
| 866 | (1 << kBBOpt) | |
| 867 | (1 << kMatch) | |
| 868 | (1 << kPromoteCompilerTemps)); |
| 869 | } |
| 870 | #endif |
| 871 | |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 872 | if (cUnit->instructionSet == kMips) { |
| 873 | // Disable some optimizations for mips for now |
| 874 | cUnit->disableOpt |= ( |
| 875 | (1 << kLoadStoreElimination) | |
| 876 | (1 << kLoadHoisting) | |
| 877 | (1 << kSuppressLoads) | |
| 878 | (1 << kNullCheckElimination) | |
| 879 | (1 << kPromoteRegs) | |
| 880 | (1 << kTrackLiveTemps) | |
| 881 | (1 << kSkipLargeMethodOptimization) | |
| 882 | (1 << kSafeOptimizations) | |
| 883 | (1 << kBBOpt) | |
| 884 | (1 << kMatch) | |
| 885 | (1 << kPromoteCompilerTemps)); |
| 886 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 887 | /* Are we generating code for the debugger? */ |
| 888 | if (compiler.IsDebuggingSupported()) { |
| 889 | cUnit->genDebugger = true; |
| 890 | // Yes, disable most optimizations |
| 891 | cUnit->disableOpt |= ( |
| 892 | (1 << kLoadStoreElimination) | |
| 893 | (1 << kLoadHoisting) | |
| 894 | (1 << kSuppressLoads) | |
| 895 | (1 << kPromoteRegs) | |
| 896 | (1 << kBBOpt) | |
| 897 | (1 << kMatch) | |
| 898 | (1 << kTrackLiveTemps)); |
| 899 | } |
| 900 | |
| 901 | /* Gathering opcode stats? */ |
| 902 | if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { |
| 903 | cUnit->opcodeCount = (int*)oatNew(cUnit.get(), |
| 904 | kNumPackedOpcodes * sizeof(int), true, kAllocMisc); |
| 905 | } |
| 906 | |
| 907 | /* Assume non-throwing leaf */ |
| 908 | cUnit->attrs = (METHOD_IS_LEAF | METHOD_IS_THROW_FREE); |
| 909 | |
| 910 | /* Initialize the block list, estimate size based on insnsSize */ |
| 911 | oatInitGrowableList(cUnit.get(), &cUnit->blockList, cUnit->insnsSize, |
| 912 | kListBlockList); |
| 913 | |
| 914 | /* Initialize the switchTables list */ |
| 915 | oatInitGrowableList(cUnit.get(), &cUnit->switchTables, 4, |
| 916 | kListSwitchTables); |
| 917 | |
| 918 | /* Intialize the fillArrayData list */ |
| 919 | oatInitGrowableList(cUnit.get(), &cUnit->fillArrayData, 4, |
| 920 | kListFillArrayData); |
| 921 | |
| 922 | /* Intialize the throwLaunchpads list, estimate size based on insnsSize */ |
| 923 | oatInitGrowableList(cUnit.get(), &cUnit->throwLaunchpads, cUnit->insnsSize, |
| 924 | kListThrowLaunchPads); |
| 925 | |
| 926 | /* Intialize the instrinsicLaunchpads list */ |
| 927 | oatInitGrowableList(cUnit.get(), &cUnit->intrinsicLaunchpads, 4, |
| 928 | kListMisc); |
| 929 | |
| 930 | |
| 931 | /* Intialize the suspendLaunchpads list */ |
| 932 | oatInitGrowableList(cUnit.get(), &cUnit->suspendLaunchpads, 2048, |
| 933 | kListSuspendLaunchPads); |
| 934 | |
| 935 | /* Allocate the bit-vector to track the beginning of basic blocks */ |
| 936 | ArenaBitVector *tryBlockAddr = oatAllocBitVector(cUnit.get(), |
| 937 | cUnit->insnsSize, |
| 938 | true /* expandable */); |
| 939 | cUnit->tryBlockAddr = tryBlockAddr; |
| 940 | |
| 941 | /* Create the default entry and exit blocks and enter them to the list */ |
| 942 | BasicBlock *entryBlock = oatNewBB(cUnit.get(), kEntryBlock, numBlocks++); |
| 943 | BasicBlock *exitBlock = oatNewBB(cUnit.get(), kExitBlock, numBlocks++); |
| 944 | |
| 945 | cUnit->entryBlock = entryBlock; |
| 946 | cUnit->exitBlock = exitBlock; |
| 947 | |
| 948 | oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) entryBlock); |
| 949 | oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) exitBlock); |
| 950 | |
| 951 | /* Current block to record parsed instructions */ |
| 952 | BasicBlock *curBlock = oatNewBB(cUnit.get(), kDalvikByteCode, numBlocks++); |
| 953 | curBlock->startOffset = 0; |
| 954 | oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) curBlock); |
| 955 | /* Add first block to the fast lookup cache */ |
| 956 | cUnit->blockMap.Put(curBlock->startOffset, curBlock); |
| 957 | entryBlock->fallThrough = curBlock; |
| 958 | oatInsertGrowableList(cUnit.get(), curBlock->predecessors, |
| 959 | (intptr_t)entryBlock); |
| 960 | |
| 961 | /* |
| 962 | * Store back the number of blocks since new blocks may be created of |
| 963 | * accessing cUnit. |
| 964 | */ |
| 965 | cUnit->numBlocks = numBlocks; |
| 966 | |
| 967 | /* Identify code range in try blocks and set up the empty catch blocks */ |
| 968 | processTryCatchBlocks(cUnit.get()); |
| 969 | |
| 970 | /* Set up for simple method detection */ |
| 971 | int numPatterns = sizeof(specialPatterns)/sizeof(specialPatterns[0]); |
| 972 | bool livePattern = (numPatterns > 0) && !(cUnit->disableOpt & (1 << kMatch)); |
Elliott Hughes | abe64aa | 2012-05-30 17:34:45 -0700 | [diff] [blame] | 973 | bool* deadPattern = (bool*)oatNew(cUnit.get(), sizeof(bool) * numPatterns, true, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 974 | kAllocMisc); |
| 975 | SpecialCaseHandler specialCase = kNoHandler; |
| 976 | int patternPos = 0; |
| 977 | |
| 978 | /* Parse all instructions and put them into containing basic blocks */ |
| 979 | while (codePtr < codeEnd) { |
| 980 | MIR *insn = (MIR *) oatNew(cUnit.get(), sizeof(MIR), true, kAllocMIR); |
| 981 | insn->offset = curOffset; |
| 982 | int width = parseInsn(cUnit.get(), codePtr, &insn->dalvikInsn, false); |
| 983 | insn->width = width; |
| 984 | Instruction::Code opcode = insn->dalvikInsn.opcode; |
| 985 | if (cUnit->opcodeCount != NULL) { |
| 986 | cUnit->opcodeCount[static_cast<int>(opcode)]++; |
buzbee | 44b412b | 2012-02-04 08:50:53 -0800 | [diff] [blame] | 987 | } |
| 988 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 989 | /* Terminate when the data section is seen */ |
| 990 | if (width == 0) |
| 991 | break; |
| 992 | |
| 993 | /* Possible simple method? */ |
| 994 | if (livePattern) { |
| 995 | livePattern = false; |
| 996 | specialCase = kNoHandler; |
| 997 | for (int i = 0; i < numPatterns; i++) { |
| 998 | if (!deadPattern[i]) { |
| 999 | if (specialPatterns[i].opcodes[patternPos] == opcode) { |
| 1000 | livePattern = true; |
| 1001 | specialCase = specialPatterns[i].handlerCode; |
| 1002 | } else { |
| 1003 | deadPattern[i] = true; |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | patternPos++; |
buzbee | a7c1268 | 2012-03-19 13:13:53 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1010 | oatAppendMIR(curBlock, insn); |
buzbee | cefd187 | 2011-09-09 09:59:52 -0700 | [diff] [blame] | 1011 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1012 | codePtr += width; |
Ian Rogers | a75a013 | 2012-09-28 11:41:42 -0700 | [diff] [blame] | 1013 | int flags = Instruction::FlagsOf(insn->dalvikInsn.opcode); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1014 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1015 | int dfFlags = oatDataFlowAttributes[insn->dalvikInsn.opcode]; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1016 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1017 | if (dfFlags & DF_HAS_DEFS) { |
buzbee | bff2465 | 2012-05-06 16:22:05 -0700 | [diff] [blame] | 1018 | cUnit->defCount += (dfFlags & DF_A_WIDE) ? 2 : 1; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1019 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1020 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1021 | if (flags & Instruction::kBranch) { |
| 1022 | curBlock = processCanBranch(cUnit.get(), curBlock, insn, curOffset, |
| 1023 | width, flags, codePtr, codeEnd); |
| 1024 | } else if (flags & Instruction::kReturn) { |
| 1025 | curBlock->fallThrough = exitBlock; |
| 1026 | oatInsertGrowableList(cUnit.get(), exitBlock->predecessors, |
| 1027 | (intptr_t)curBlock); |
| 1028 | /* |
| 1029 | * Terminate the current block if there are instructions |
| 1030 | * afterwards. |
| 1031 | */ |
| 1032 | if (codePtr < codeEnd) { |
| 1033 | /* |
| 1034 | * Create a fallthrough block for real instructions |
| 1035 | * (incl. NOP). |
| 1036 | */ |
| 1037 | if (contentIsInsn(codePtr)) { |
| 1038 | findBlock(cUnit.get(), curOffset + width, |
| 1039 | /* split */ |
| 1040 | false, |
| 1041 | /* create */ |
| 1042 | true, |
| 1043 | /* immedPredBlockP */ |
| 1044 | NULL); |
| 1045 | } |
| 1046 | } |
| 1047 | } else if (flags & Instruction::kThrow) { |
Bill Buzbee | c9f40dd | 2012-08-15 11:35:25 -0700 | [diff] [blame] | 1048 | curBlock = processCanThrow(cUnit.get(), curBlock, insn, curOffset, |
| 1049 | width, flags, tryBlockAddr, codePtr, codeEnd); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1050 | } else if (flags & Instruction::kSwitch) { |
| 1051 | processCanSwitch(cUnit.get(), curBlock, insn, curOffset, width, flags); |
| 1052 | } |
| 1053 | curOffset += width; |
| 1054 | BasicBlock *nextBlock = findBlock(cUnit.get(), curOffset, |
| 1055 | /* split */ |
| 1056 | false, |
| 1057 | /* create */ |
| 1058 | false, |
| 1059 | /* immedPredBlockP */ |
| 1060 | NULL); |
| 1061 | if (nextBlock) { |
| 1062 | /* |
| 1063 | * The next instruction could be the target of a previously parsed |
| 1064 | * forward branch so a block is already created. If the current |
| 1065 | * instruction is not an unconditional branch, connect them through |
| 1066 | * the fall-through link. |
| 1067 | */ |
| 1068 | DCHECK(curBlock->fallThrough == NULL || |
| 1069 | curBlock->fallThrough == nextBlock || |
| 1070 | curBlock->fallThrough == exitBlock); |
buzbee | 5ade1d2 | 2011-09-09 14:44:52 -0700 | [diff] [blame] | 1071 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1072 | if ((curBlock->fallThrough == NULL) && (flags & Instruction::kContinue)) { |
| 1073 | curBlock->fallThrough = nextBlock; |
| 1074 | oatInsertGrowableList(cUnit.get(), nextBlock->predecessors, |
| 1075 | (intptr_t)curBlock); |
| 1076 | } |
| 1077 | curBlock = nextBlock; |
| 1078 | } |
| 1079 | } |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 1080 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1081 | if (!(cUnit->disableOpt & (1 << kSkipLargeMethodOptimization))) { |
| 1082 | if ((cUnit->numBlocks > MANY_BLOCKS) || |
| 1083 | ((cUnit->numBlocks > MANY_BLOCKS_INITIALIZER) && |
| 1084 | PrettyMethod(method_idx, dex_file, false).find("init>") != |
| 1085 | std::string::npos)) { |
| 1086 | cUnit->qdMode = true; |
| 1087 | } |
| 1088 | } |
buzbee | fc9e6fa | 2012-03-23 15:14:29 -0700 | [diff] [blame] | 1089 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1090 | if (cUnit->qdMode) { |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 1091 | // Bitcode generation requires full dataflow analysis |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1092 | cUnit->disableDataflow = !cUnit->genBitcode; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1093 | // Disable optimization which require dataflow/ssa |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1094 | cUnit->disableOpt |= (1 << kBBOpt) | (1 << kPromoteRegs) | (1 << kNullCheckElimination); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1095 | if (cUnit->printMe) { |
| 1096 | LOG(INFO) << "QD mode enabled: " |
| 1097 | << PrettyMethod(method_idx, dex_file) |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1098 | << " num blocks: " << cUnit->numBlocks; |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1099 | } |
| 1100 | } |
buzbee | c1f4504 | 2011-09-21 16:03:19 -0700 | [diff] [blame] | 1101 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1102 | if (cUnit->printMe) { |
| 1103 | oatDumpCompilationUnit(cUnit.get()); |
| 1104 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1105 | |
buzbee | 0967a25 | 2012-09-14 10:43:54 -0700 | [diff] [blame] | 1106 | /* Do a code layout pass */ |
| 1107 | oatMethodCodeLayout(cUnit.get()); |
| 1108 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1109 | if (cUnit->enableDebug & (1 << kDebugVerifyDataflow)) { |
| 1110 | /* Verify if all blocks are connected as claimed */ |
| 1111 | oatDataFlowAnalysisDispatcher(cUnit.get(), verifyPredInfo, kAllNodes, |
| 1112 | false /* isIterative */); |
| 1113 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1114 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1115 | /* Perform SSA transformation for the whole method */ |
| 1116 | oatMethodSSATransformation(cUnit.get()); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1117 | |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 1118 | /* Do constant propagation */ |
| 1119 | // TODO: Probably need to make these expandable to support new ssa names |
| 1120 | // introducted during MIR optimization passes |
| 1121 | cUnit->isConstantV = oatAllocBitVector(cUnit.get(), cUnit->numSSARegs, |
| 1122 | false /* not expandable */); |
| 1123 | cUnit->constantValues = |
| 1124 | (int*)oatNew(cUnit.get(), sizeof(int) * cUnit->numSSARegs, true, |
| 1125 | kAllocDFInfo); |
| 1126 | oatDataFlowAnalysisDispatcher(cUnit.get(), oatDoConstantPropagation, |
| 1127 | kAllNodes, |
| 1128 | false /* isIterative */); |
| 1129 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1130 | /* Detect loops */ |
| 1131 | oatMethodLoopDetection(cUnit.get()); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1132 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1133 | /* Count uses */ |
| 1134 | oatMethodUseCount(cUnit.get()); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1135 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1136 | /* Perform null check elimination */ |
| 1137 | oatMethodNullCheckElimination(cUnit.get()); |
| 1138 | |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 1139 | /* Combine basic blocks where possible */ |
| 1140 | oatMethodBasicBlockCombine(cUnit.get()); |
| 1141 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1142 | /* Do some basic block optimizations */ |
| 1143 | oatMethodBasicBlockOptimization(cUnit.get()); |
| 1144 | |
buzbee | d1643e4 | 2012-09-05 14:06:51 -0700 | [diff] [blame] | 1145 | if (cUnit->enableDebug & (1 << kDebugDumpCheckStats)) { |
| 1146 | oatDumpCheckStats(cUnit.get()); |
| 1147 | } |
| 1148 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1149 | oatInitializeRegAlloc(cUnit.get()); // Needs to happen after SSA naming |
| 1150 | |
| 1151 | /* Allocate Registers using simple local allocation scheme */ |
| 1152 | oatSimpleRegAlloc(cUnit.get()); |
| 1153 | |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 1154 | /* Go the LLVM path? */ |
| 1155 | if (cUnit->genBitcode) { |
| 1156 | // MIR->Bitcode |
| 1157 | oatMethodMIR2Bitcode(cUnit.get()); |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1158 | if (compilerBackend == kPortable) { |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 1159 | // all done |
| 1160 | oatArenaReset(cUnit.get()); |
| 1161 | return NULL; |
| 1162 | } |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 1163 | // Bitcode->LIR |
| 1164 | oatMethodBitcode2LIR(cUnit.get()); |
| 1165 | } else { |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 1166 | if (specialCase != kNoHandler) { |
| 1167 | /* |
| 1168 | * Custom codegen for special cases. If for any reason the |
| 1169 | * special codegen doesn't succeed, cUnit->firstLIRInsn will |
| 1170 | * set to NULL; |
| 1171 | */ |
| 1172 | oatSpecialMIR2LIR(cUnit.get(), specialCase); |
| 1173 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1174 | |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 1175 | /* Convert MIR to LIR, etc. */ |
| 1176 | if (cUnit->firstLIRInsn == NULL) { |
| 1177 | oatMethodMIR2LIR(cUnit.get()); |
| 1178 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1179 | } |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1180 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1181 | // Debugging only |
| 1182 | if (cUnit->enableDebug & (1 << kDebugDumpCFG)) { |
| 1183 | oatDumpCFG(cUnit.get(), "/sdcard/cfg/"); |
| 1184 | } |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 1185 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1186 | /* Method is not empty */ |
| 1187 | if (cUnit->firstLIRInsn) { |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1188 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1189 | // mark the targets of switch statement case labels |
| 1190 | oatProcessSwitchTables(cUnit.get()); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1191 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1192 | /* Convert LIR into machine code. */ |
| 1193 | oatAssembleLIR(cUnit.get()); |
buzbee | 99ba964 | 2012-01-25 14:23:14 -0800 | [diff] [blame] | 1194 | |
Elliott Hughes | 3b6baaa | 2011-10-14 19:13:56 -0700 | [diff] [blame] | 1195 | if (cUnit->printMe) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1196 | oatCodegenDump(cUnit.get()); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1199 | if (cUnit->opcodeCount != NULL) { |
| 1200 | LOG(INFO) << "Opcode Count"; |
| 1201 | for (int i = 0; i < kNumPackedOpcodes; i++) { |
| 1202 | if (cUnit->opcodeCount[i] != 0) { |
| 1203 | LOG(INFO) << "-C- " |
| 1204 | << Instruction::Name(static_cast<Instruction::Code>(i)) |
| 1205 | << " " << cUnit->opcodeCount[i]; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1206 | } |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1207 | } |
| 1208 | } |
| 1209 | } |
buzbee | a7c1268 | 2012-03-19 13:13:53 -0700 | [diff] [blame] | 1210 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1211 | // Combine vmap tables - core regs, then fp regs - into vmapTable |
| 1212 | std::vector<uint16_t> vmapTable; |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 1213 | // Core regs may have been inserted out of order - sort first |
| 1214 | std::sort(cUnit->coreVmapTable.begin(), cUnit->coreVmapTable.end()); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1215 | for (size_t i = 0 ; i < cUnit->coreVmapTable.size(); i++) { |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 1216 | // Copy, stripping out the phys register sort key |
| 1217 | vmapTable.push_back(~(-1 << VREG_NUM_WIDTH) & cUnit->coreVmapTable[i]); |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1218 | } |
| 1219 | // If we have a frame, push a marker to take place of lr |
| 1220 | if (cUnit->frameSize > 0) { |
| 1221 | vmapTable.push_back(INVALID_VREG); |
| 1222 | } else { |
| 1223 | DCHECK_EQ(__builtin_popcount(cUnit->coreSpillMask), 0); |
| 1224 | DCHECK_EQ(__builtin_popcount(cUnit->fpSpillMask), 0); |
| 1225 | } |
buzbee | ca7a5e4 | 2012-08-20 11:12:18 -0700 | [diff] [blame] | 1226 | // Combine vmap tables - core regs, then fp regs. fp regs already sorted |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1227 | for (uint32_t i = 0; i < cUnit->fpVmapTable.size(); i++) { |
| 1228 | vmapTable.push_back(cUnit->fpVmapTable[i]); |
| 1229 | } |
| 1230 | CompiledMethod* result = |
| 1231 | new CompiledMethod(cUnit->instructionSet, cUnit->codeBuffer, |
Bill Buzbee | a5b3024 | 2012-09-28 07:19:44 -0700 | [diff] [blame] | 1232 | cUnit->frameSize, cUnit->coreSpillMask, cUnit->fpSpillMask, |
| 1233 | cUnit->combinedMappingTable, vmapTable, cUnit->nativeGcMap); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1234 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1235 | VLOG(compiler) << "Compiled " << PrettyMethod(method_idx, dex_file) |
| 1236 | << " (" << (cUnit->codeBuffer.size() * sizeof(cUnit->codeBuffer[0])) |
| 1237 | << " bytes)"; |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 1238 | |
| 1239 | #ifdef WITH_MEMSTATS |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1240 | if (cUnit->enableDebug & (1 << kDebugShowMemoryUsage)) { |
| 1241 | oatDumpMemStats(cUnit.get()); |
| 1242 | } |
buzbee | 5abfa3e | 2012-01-31 17:01:43 -0800 | [diff] [blame] | 1243 | #endif |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1244 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1245 | oatArenaReset(cUnit.get()); |
buzbee | ba938cb | 2012-02-03 14:47:55 -0800 | [diff] [blame] | 1246 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1247 | return result; |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1248 | } |
| 1249 | |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 1250 | CompiledMethod* oatCompileMethod(Compiler& compiler, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1251 | const CompilerBackend backend, |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 1252 | const DexFile::CodeItem* code_item, |
| 1253 | uint32_t access_flags, InvokeType invoke_type, |
| 1254 | uint32_t method_idx, jobject class_loader, |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1255 | const DexFile& dex_file, |
| 1256 | LLVMInfo* llvmInfo) |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 1257 | { |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1258 | return compileMethod(compiler, backend, code_item, access_flags, invoke_type, method_idx, class_loader, |
| 1259 | dex_file, llvmInfo); |
buzbee | abc4c6b | 2012-08-23 08:17:15 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 1262 | } // namespace art |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 1263 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 1264 | extern "C" art::CompiledMethod* |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1265 | ArtQuickCompileMethod(art::Compiler& compiler, |
| 1266 | const art::DexFile::CodeItem* code_item, |
| 1267 | uint32_t access_flags, art::InvokeType invoke_type, |
| 1268 | uint32_t method_idx, jobject class_loader, |
| 1269 | const art::DexFile& dex_file) |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 1270 | { |
| 1271 | CHECK_EQ(compiler.GetInstructionSet(), art::oatInstructionSet()); |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame^] | 1272 | // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default |
| 1273 | art::CompilerBackend backend = compiler.GetCompilerBackend(); |
| 1274 | return art::oatCompileMethod(compiler, backend, code_item, access_flags, invoke_type, |
| 1275 | method_idx, class_loader, dex_file, NULL /* use thread llvmInfo */); |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 1276 | } |