buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Ian Rogers | 6282dc1 | 2013-04-18 15:54:02 -0700 | [diff] [blame] | 17 | #include "base/stl_util.h" |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 18 | #include "compiler_internals.h" |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 19 | #include "dex_file-inl.h" |
Ian Rogers | 6282dc1 | 2013-04-18 15:54:02 -0700 | [diff] [blame] | 20 | #include "leb128.h" |
| 21 | #include "mir_graph.h" |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 22 | |
Vladimir Marko | 5816ed4 | 2013-11-27 17:04:20 +0000 | [diff] [blame] | 23 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
| 24 | #include "dex/quick/dex_file_method_inliner.h" |
| 25 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 26 | namespace art { |
| 27 | |
| 28 | #define MAX_PATTERN_LEN 5 |
| 29 | |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 30 | const char* MIRGraph::extended_mir_op_names_[kMirOpLast - kMirOpFirst] = { |
| 31 | "Phi", |
| 32 | "Copy", |
| 33 | "FusedCmplFloat", |
| 34 | "FusedCmpgFloat", |
| 35 | "FusedCmplDouble", |
| 36 | "FusedCmpgDouble", |
| 37 | "FusedCmpLong", |
| 38 | "Nop", |
| 39 | "OpNullCheck", |
| 40 | "OpRangeCheck", |
| 41 | "OpDivZeroCheck", |
| 42 | "Check1", |
| 43 | "Check2", |
| 44 | "Select", |
| 45 | }; |
| 46 | |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 47 | MIRGraph::MIRGraph(CompilationUnit* cu, ArenaAllocator* arena) |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 48 | : reg_location_(NULL), |
| 49 | cu_(cu), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 50 | ssa_base_vregs_(NULL), |
| 51 | ssa_subscripts_(NULL), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 52 | vreg_to_ssa_map_(NULL), |
| 53 | ssa_last_defs_(NULL), |
| 54 | is_constant_v_(NULL), |
| 55 | constant_values_(NULL), |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 56 | use_counts_(arena, 256, kGrowableArrayMisc), |
| 57 | raw_use_counts_(arena, 256, kGrowableArrayMisc), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 58 | num_reachable_blocks_(0), |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 59 | dfs_order_(NULL), |
| 60 | dfs_post_order_(NULL), |
| 61 | dom_post_order_traversal_(NULL), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 62 | i_dom_list_(NULL), |
| 63 | def_block_matrix_(NULL), |
| 64 | temp_block_v_(NULL), |
| 65 | temp_dalvik_register_v_(NULL), |
| 66 | temp_ssa_register_v_(NULL), |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 67 | block_list_(arena, 100, kGrowableArrayBlockList), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 68 | try_block_addr_(NULL), |
| 69 | entry_block_(NULL), |
| 70 | exit_block_(NULL), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 71 | num_blocks_(0), |
| 72 | current_code_item_(NULL), |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 73 | dex_pc_to_block_map_(arena, 0, kGrowableArrayMisc), |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 74 | current_method_(kInvalidEntry), |
| 75 | current_offset_(kInvalidEntry), |
| 76 | def_count_(0), |
| 77 | opcode_count_(NULL), |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 78 | num_ssa_regs_(0), |
| 79 | method_sreg_(0), |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 80 | attributes_(METHOD_IS_LEAF), // Start with leaf assumption, change on encountering invoke. |
| 81 | checkstats_(NULL), |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 82 | arena_(arena), |
| 83 | backward_branches_(0), |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 84 | forward_branches_(0), |
| 85 | compiler_temps_(arena, 6, kGrowableArrayMisc), |
| 86 | num_non_special_compiler_temps_(0), |
| 87 | max_available_non_special_compiler_temps_(0) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 88 | try_block_addr_ = new (arena_) ArenaBitVector(arena_, 0, true /* expandable */); |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 89 | max_available_special_compiler_temps_ = std::abs(static_cast<int>(kVRegNonSpecialTempBaseReg)) |
| 90 | - std::abs(static_cast<int>(kVRegTempBaseReg)); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 91 | } |
| 92 | |
Ian Rogers | 6282dc1 | 2013-04-18 15:54:02 -0700 | [diff] [blame] | 93 | MIRGraph::~MIRGraph() { |
| 94 | STLDeleteElements(&m_units_); |
| 95 | } |
| 96 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 97 | /* |
| 98 | * Parse an instruction, return the length of the instruction |
| 99 | */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 100 | int MIRGraph::ParseInsn(const uint16_t* code_ptr, DecodedInstruction* decoded_instruction) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 101 | const Instruction* instruction = Instruction::At(code_ptr); |
| 102 | *decoded_instruction = DecodedInstruction(instruction); |
| 103 | |
| 104 | return instruction->SizeInCodeUnits(); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /* Split an existing block from the specified code offset into two */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 109 | BasicBlock* MIRGraph::SplitBlock(DexOffset code_offset, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 110 | BasicBlock* orig_block, BasicBlock** immed_pred_block_p) { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 111 | DCHECK_GT(code_offset, orig_block->start_offset); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 112 | MIR* insn = orig_block->first_mir_insn; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 113 | MIR* prev = NULL; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 114 | while (insn) { |
| 115 | if (insn->offset == code_offset) break; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 116 | prev = insn; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 117 | insn = insn->next; |
| 118 | } |
| 119 | if (insn == NULL) { |
| 120 | LOG(FATAL) << "Break split failed"; |
| 121 | } |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 122 | BasicBlock *bottom_block = NewMemBB(kDalvikByteCode, num_blocks_++); |
| 123 | block_list_.Insert(bottom_block); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 124 | |
| 125 | bottom_block->start_offset = code_offset; |
| 126 | bottom_block->first_mir_insn = insn; |
| 127 | bottom_block->last_mir_insn = orig_block->last_mir_insn; |
| 128 | |
| 129 | /* If this block was terminated by a return, the flag needs to go with the bottom block */ |
| 130 | bottom_block->terminated_by_return = orig_block->terminated_by_return; |
| 131 | orig_block->terminated_by_return = false; |
| 132 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 133 | /* Handle the taken path */ |
| 134 | bottom_block->taken = orig_block->taken; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 135 | if (bottom_block->taken != NullBasicBlockId) { |
| 136 | orig_block->taken = NullBasicBlockId; |
| 137 | BasicBlock* bb_taken = GetBasicBlock(bottom_block->taken); |
| 138 | bb_taken->predecessors->Delete(orig_block->id); |
| 139 | bb_taken->predecessors->Insert(bottom_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* Handle the fallthrough path */ |
| 143 | bottom_block->fall_through = orig_block->fall_through; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 144 | orig_block->fall_through = bottom_block->id; |
| 145 | bottom_block->predecessors->Insert(orig_block->id); |
| 146 | if (bottom_block->fall_through != NullBasicBlockId) { |
| 147 | BasicBlock* bb_fall_through = GetBasicBlock(bottom_block->fall_through); |
| 148 | bb_fall_through->predecessors->Delete(orig_block->id); |
| 149 | bb_fall_through->predecessors->Insert(bottom_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /* Handle the successor list */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 153 | if (orig_block->successor_block_list_type != kNotUsed) { |
| 154 | bottom_block->successor_block_list_type = orig_block->successor_block_list_type; |
| 155 | bottom_block->successor_blocks = orig_block->successor_blocks; |
| 156 | orig_block->successor_block_list_type = kNotUsed; |
| 157 | orig_block->successor_blocks = NULL; |
| 158 | GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bottom_block->successor_blocks); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 159 | while (true) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 160 | SuccessorBlockInfo *successor_block_info = iterator.Next(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 161 | if (successor_block_info == NULL) break; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 162 | BasicBlock *bb = GetBasicBlock(successor_block_info->block); |
| 163 | bb->predecessors->Delete(orig_block->id); |
| 164 | bb->predecessors->Insert(bottom_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 168 | orig_block->last_mir_insn = prev; |
| 169 | prev->next = NULL; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 170 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 171 | /* |
| 172 | * Update the immediate predecessor block pointer so that outgoing edges |
| 173 | * can be applied to the proper block. |
| 174 | */ |
| 175 | if (immed_pred_block_p) { |
| 176 | DCHECK_EQ(*immed_pred_block_p, orig_block); |
| 177 | *immed_pred_block_p = bottom_block; |
| 178 | } |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 179 | |
| 180 | // Associate dex instructions in the bottom block with the new container. |
Vladimir Marko | 4376c87 | 2014-01-23 12:39:29 +0000 | [diff] [blame] | 181 | DCHECK(insn != nullptr); |
| 182 | DCHECK(insn != orig_block->first_mir_insn); |
| 183 | DCHECK(insn == bottom_block->first_mir_insn); |
| 184 | DCHECK_EQ(insn->offset, bottom_block->start_offset); |
| 185 | DCHECK(static_cast<int>(insn->dalvikInsn.opcode) == kMirOpCheck || |
| 186 | !IsPseudoMirOp(insn->dalvikInsn.opcode)); |
| 187 | DCHECK_EQ(dex_pc_to_block_map_.Get(insn->offset), orig_block->id); |
| 188 | MIR* p = insn; |
| 189 | dex_pc_to_block_map_.Put(p->offset, bottom_block->id); |
| 190 | while (p != bottom_block->last_mir_insn) { |
| 191 | p = p->next; |
| 192 | DCHECK(p != nullptr); |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 193 | int opcode = p->dalvikInsn.opcode; |
| 194 | /* |
| 195 | * Some messiness here to ensure that we only enter real opcodes and only the |
| 196 | * first half of a potentially throwing instruction that has been split into |
Vladimir Marko | 4376c87 | 2014-01-23 12:39:29 +0000 | [diff] [blame] | 197 | * CHECK and work portions. Since the 2nd half of a split operation is always |
| 198 | * the first in a BasicBlock, we can't hit it here. |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 199 | */ |
Vladimir Marko | 4376c87 | 2014-01-23 12:39:29 +0000 | [diff] [blame] | 200 | if ((opcode == kMirOpCheck) || !IsPseudoMirOp(opcode)) { |
| 201 | DCHECK_EQ(dex_pc_to_block_map_.Get(p->offset), orig_block->id); |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 202 | dex_pc_to_block_map_.Put(p->offset, bottom_block->id); |
| 203 | } |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 204 | } |
| 205 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 206 | return bottom_block; |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * Given a code offset, find out the block that starts with it. If the offset |
| 211 | * is in the middle of an existing block, split it into two. If immed_pred_block_p |
| 212 | * is not non-null and is the block being split, update *immed_pred_block_p to |
| 213 | * point to the bottom block so that outgoing edges can be set up properly |
| 214 | * (by the caller) |
| 215 | * Utilizes a map for fast lookup of the typical cases. |
| 216 | */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 217 | BasicBlock* MIRGraph::FindBlock(DexOffset code_offset, bool split, bool create, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 218 | BasicBlock** immed_pred_block_p) { |
buzbee | bd663de | 2013-09-10 15:41:31 -0700 | [diff] [blame] | 219 | if (code_offset >= cu_->code_item->insns_size_in_code_units_) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 220 | return NULL; |
| 221 | } |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 222 | |
| 223 | int block_id = dex_pc_to_block_map_.Get(code_offset); |
| 224 | BasicBlock* bb = (block_id == 0) ? NULL : block_list_.Get(block_id); |
| 225 | |
| 226 | if ((bb != NULL) && (bb->start_offset == code_offset)) { |
| 227 | // Does this containing block start with the desired instruction? |
buzbee | bd663de | 2013-09-10 15:41:31 -0700 | [diff] [blame] | 228 | return bb; |
| 229 | } |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 230 | |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 231 | // No direct hit. |
| 232 | if (!create) { |
| 233 | return NULL; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 234 | } |
| 235 | |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 236 | if (bb != NULL) { |
| 237 | // The target exists somewhere in an existing block. |
| 238 | return SplitBlock(code_offset, bb, bb == *immed_pred_block_p ? immed_pred_block_p : NULL); |
| 239 | } |
| 240 | |
| 241 | // Create a new block. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 242 | bb = NewMemBB(kDalvikByteCode, num_blocks_++); |
| 243 | block_list_.Insert(bb); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 244 | bb->start_offset = code_offset; |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 245 | dex_pc_to_block_map_.Put(bb->start_offset, bb->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 246 | return bb; |
| 247 | } |
| 248 | |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 249 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 250 | /* Identify code range in try blocks and set up the empty catch blocks */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 251 | void MIRGraph::ProcessTryCatchBlocks() { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 252 | int tries_size = current_code_item_->tries_size_; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 253 | DexOffset offset; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 254 | |
| 255 | if (tries_size == 0) { |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | for (int i = 0; i < tries_size; i++) { |
| 260 | const DexFile::TryItem* pTry = |
| 261 | DexFile::GetTryItems(*current_code_item_, i); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 262 | DexOffset start_offset = pTry->start_addr_; |
| 263 | DexOffset end_offset = start_offset + pTry->insn_count_; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 264 | for (offset = start_offset; offset < end_offset; offset++) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 265 | try_block_addr_->SetBit(offset); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | |
| 269 | // Iterate over each of the handlers to enqueue the empty Catch blocks |
| 270 | const byte* handlers_ptr = DexFile::GetCatchHandlerData(*current_code_item_, 0); |
| 271 | uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr); |
| 272 | for (uint32_t idx = 0; idx < handlers_size; idx++) { |
| 273 | CatchHandlerIterator iterator(handlers_ptr); |
| 274 | for (; iterator.HasNext(); iterator.Next()) { |
| 275 | uint32_t address = iterator.GetHandlerAddress(); |
| 276 | FindBlock(address, false /* split */, true /*create*/, |
| 277 | /* immed_pred_block_p */ NULL); |
| 278 | } |
| 279 | handlers_ptr = iterator.EndDataPointer(); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | /* Process instructions with the kBranch flag */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 284 | BasicBlock* MIRGraph::ProcessCanBranch(BasicBlock* cur_block, MIR* insn, DexOffset cur_offset, |
| 285 | int width, int flags, const uint16_t* code_ptr, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 286 | const uint16_t* code_end) { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 287 | DexOffset target = cur_offset; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 288 | switch (insn->dalvikInsn.opcode) { |
| 289 | case Instruction::GOTO: |
| 290 | case Instruction::GOTO_16: |
| 291 | case Instruction::GOTO_32: |
| 292 | target += insn->dalvikInsn.vA; |
| 293 | break; |
| 294 | case Instruction::IF_EQ: |
| 295 | case Instruction::IF_NE: |
| 296 | case Instruction::IF_LT: |
| 297 | case Instruction::IF_GE: |
| 298 | case Instruction::IF_GT: |
| 299 | case Instruction::IF_LE: |
| 300 | cur_block->conditional_branch = true; |
| 301 | target += insn->dalvikInsn.vC; |
| 302 | break; |
| 303 | case Instruction::IF_EQZ: |
| 304 | case Instruction::IF_NEZ: |
| 305 | case Instruction::IF_LTZ: |
| 306 | case Instruction::IF_GEZ: |
| 307 | case Instruction::IF_GTZ: |
| 308 | case Instruction::IF_LEZ: |
| 309 | cur_block->conditional_branch = true; |
| 310 | target += insn->dalvikInsn.vB; |
| 311 | break; |
| 312 | default: |
| 313 | LOG(FATAL) << "Unexpected opcode(" << insn->dalvikInsn.opcode << ") with kBranch set"; |
| 314 | } |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 315 | CountBranch(target); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 316 | BasicBlock *taken_block = FindBlock(target, /* split */ true, /* create */ true, |
| 317 | /* immed_pred_block_p */ &cur_block); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 318 | cur_block->taken = taken_block->id; |
| 319 | taken_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 320 | |
| 321 | /* Always terminate the current block for conditional branches */ |
| 322 | if (flags & Instruction::kContinue) { |
| 323 | BasicBlock *fallthrough_block = FindBlock(cur_offset + width, |
| 324 | /* |
| 325 | * If the method is processed |
| 326 | * in sequential order from the |
| 327 | * beginning, we don't need to |
| 328 | * specify split for continue |
| 329 | * blocks. However, this |
| 330 | * routine can be called by |
| 331 | * compileLoop, which starts |
| 332 | * parsing the method from an |
| 333 | * arbitrary address in the |
| 334 | * method body. |
| 335 | */ |
| 336 | true, |
| 337 | /* create */ |
| 338 | true, |
| 339 | /* immed_pred_block_p */ |
| 340 | &cur_block); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 341 | cur_block->fall_through = fallthrough_block->id; |
| 342 | fallthrough_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 343 | } else if (code_ptr < code_end) { |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 344 | FindBlock(cur_offset + width, /* split */ false, /* create */ true, |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 345 | /* immed_pred_block_p */ NULL); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 346 | } |
| 347 | return cur_block; |
| 348 | } |
| 349 | |
| 350 | /* Process instructions with the kSwitch flag */ |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 351 | BasicBlock* MIRGraph::ProcessCanSwitch(BasicBlock* cur_block, MIR* insn, DexOffset cur_offset, |
| 352 | int width, int flags) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 353 | const uint16_t* switch_data = |
| 354 | reinterpret_cast<const uint16_t*>(GetCurrentInsns() + cur_offset + insn->dalvikInsn.vB); |
| 355 | int size; |
| 356 | const int* keyTable; |
| 357 | const int* target_table; |
| 358 | int i; |
| 359 | int first_key; |
| 360 | |
| 361 | /* |
| 362 | * Packed switch data format: |
| 363 | * ushort ident = 0x0100 magic value |
| 364 | * ushort size number of entries in the table |
| 365 | * int first_key first (and lowest) switch case value |
| 366 | * int targets[size] branch targets, relative to switch opcode |
| 367 | * |
| 368 | * Total size is (4+size*2) 16-bit code units. |
| 369 | */ |
| 370 | if (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) { |
| 371 | DCHECK_EQ(static_cast<int>(switch_data[0]), |
| 372 | static_cast<int>(Instruction::kPackedSwitchSignature)); |
| 373 | size = switch_data[1]; |
| 374 | first_key = switch_data[2] | (switch_data[3] << 16); |
| 375 | target_table = reinterpret_cast<const int*>(&switch_data[4]); |
| 376 | keyTable = NULL; // Make the compiler happy |
| 377 | /* |
| 378 | * Sparse switch data format: |
| 379 | * ushort ident = 0x0200 magic value |
| 380 | * ushort size number of entries in the table; > 0 |
| 381 | * int keys[size] keys, sorted low-to-high; 32-bit aligned |
| 382 | * int targets[size] branch targets, relative to switch opcode |
| 383 | * |
| 384 | * Total size is (2+size*4) 16-bit code units. |
| 385 | */ |
| 386 | } else { |
| 387 | DCHECK_EQ(static_cast<int>(switch_data[0]), |
| 388 | static_cast<int>(Instruction::kSparseSwitchSignature)); |
| 389 | size = switch_data[1]; |
| 390 | keyTable = reinterpret_cast<const int*>(&switch_data[2]); |
| 391 | target_table = reinterpret_cast<const int*>(&switch_data[2 + size*2]); |
| 392 | first_key = 0; // To make the compiler happy |
| 393 | } |
| 394 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 395 | if (cur_block->successor_block_list_type != kNotUsed) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 396 | LOG(FATAL) << "Successor block list already in use: " |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 397 | << static_cast<int>(cur_block->successor_block_list_type); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 398 | } |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 399 | cur_block->successor_block_list_type = |
| 400 | (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? kPackedSwitch : kSparseSwitch; |
| 401 | cur_block->successor_blocks = |
Brian Carlstrom | df62950 | 2013-07-17 22:39:56 -0700 | [diff] [blame] | 402 | new (arena_) GrowableArray<SuccessorBlockInfo*>(arena_, size, kGrowableArraySuccessorBlocks); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 403 | |
| 404 | for (i = 0; i < size; i++) { |
| 405 | BasicBlock *case_block = FindBlock(cur_offset + target_table[i], /* split */ true, |
| 406 | /* create */ true, /* immed_pred_block_p */ &cur_block); |
| 407 | SuccessorBlockInfo *successor_block_info = |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 408 | static_cast<SuccessorBlockInfo*>(arena_->Alloc(sizeof(SuccessorBlockInfo), |
| 409 | ArenaAllocator::kAllocSuccessor)); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 410 | successor_block_info->block = case_block->id; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 411 | successor_block_info->key = |
| 412 | (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? |
| 413 | first_key + i : keyTable[i]; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 414 | cur_block->successor_blocks->Insert(successor_block_info); |
| 415 | case_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /* Fall-through case */ |
Brian Carlstrom | df62950 | 2013-07-17 22:39:56 -0700 | [diff] [blame] | 419 | BasicBlock* fallthrough_block = FindBlock(cur_offset + width, /* split */ false, |
| 420 | /* create */ true, /* immed_pred_block_p */ NULL); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 421 | cur_block->fall_through = fallthrough_block->id; |
| 422 | fallthrough_block->predecessors->Insert(cur_block->id); |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 423 | return cur_block; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* Process instructions with the kThrow flag */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 427 | BasicBlock* MIRGraph::ProcessCanThrow(BasicBlock* cur_block, MIR* insn, DexOffset cur_offset, |
| 428 | int width, int flags, ArenaBitVector* try_block_addr, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 429 | const uint16_t* code_ptr, const uint16_t* code_end) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 430 | bool in_try_block = try_block_addr->IsBitSet(cur_offset); |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 431 | bool is_throw = (insn->dalvikInsn.opcode == Instruction::THROW); |
| 432 | bool build_all_edges = |
| 433 | (cu_->disable_opt & (1 << kSuppressExceptionEdges)) || is_throw || in_try_block; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 434 | |
| 435 | /* In try block */ |
| 436 | if (in_try_block) { |
| 437 | CatchHandlerIterator iterator(*current_code_item_, cur_offset); |
| 438 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 439 | if (cur_block->successor_block_list_type != kNotUsed) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 440 | LOG(INFO) << PrettyMethod(cu_->method_idx, *cu_->dex_file); |
| 441 | LOG(FATAL) << "Successor block list already in use: " |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 442 | << static_cast<int>(cur_block->successor_block_list_type); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 443 | } |
| 444 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 445 | cur_block->successor_block_list_type = kCatch; |
| 446 | cur_block->successor_blocks = |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 447 | new (arena_) GrowableArray<SuccessorBlockInfo*>(arena_, 2, kGrowableArraySuccessorBlocks); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 448 | |
Brian Carlstrom | 02c8cc6 | 2013-07-18 15:54:44 -0700 | [diff] [blame] | 449 | for (; iterator.HasNext(); iterator.Next()) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 450 | BasicBlock *catch_block = FindBlock(iterator.GetHandlerAddress(), false /* split*/, |
| 451 | false /* creat */, NULL /* immed_pred_block_p */); |
| 452 | catch_block->catch_entry = true; |
| 453 | if (kIsDebugBuild) { |
| 454 | catches_.insert(catch_block->start_offset); |
| 455 | } |
| 456 | SuccessorBlockInfo *successor_block_info = reinterpret_cast<SuccessorBlockInfo*> |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 457 | (arena_->Alloc(sizeof(SuccessorBlockInfo), ArenaAllocator::kAllocSuccessor)); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 458 | successor_block_info->block = catch_block->id; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 459 | successor_block_info->key = iterator.GetHandlerTypeIndex(); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 460 | cur_block->successor_blocks->Insert(successor_block_info); |
| 461 | catch_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 462 | } |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 463 | } else if (build_all_edges) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 464 | BasicBlock *eh_block = NewMemBB(kExceptionHandling, num_blocks_++); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 465 | cur_block->taken = eh_block->id; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 466 | block_list_.Insert(eh_block); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 467 | eh_block->start_offset = cur_offset; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 468 | eh_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 469 | } |
| 470 | |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 471 | if (is_throw) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 472 | cur_block->explicit_throw = true; |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 473 | if (code_ptr < code_end) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 474 | // Force creation of new block following THROW via side-effect |
| 475 | FindBlock(cur_offset + width, /* split */ false, /* create */ true, |
| 476 | /* immed_pred_block_p */ NULL); |
| 477 | } |
| 478 | if (!in_try_block) { |
| 479 | // Don't split a THROW that can't rethrow - we're done. |
| 480 | return cur_block; |
| 481 | } |
| 482 | } |
| 483 | |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 484 | if (!build_all_edges) { |
| 485 | /* |
| 486 | * Even though there is an exception edge here, control cannot return to this |
| 487 | * method. Thus, for the purposes of dataflow analysis and optimization, we can |
| 488 | * ignore the edge. Doing this reduces compile time, and increases the scope |
| 489 | * of the basic-block level optimization pass. |
| 490 | */ |
| 491 | return cur_block; |
| 492 | } |
| 493 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 494 | /* |
| 495 | * Split the potentially-throwing instruction into two parts. |
| 496 | * The first half will be a pseudo-op that captures the exception |
| 497 | * edges and terminates the basic block. It always falls through. |
| 498 | * Then, create a new basic block that begins with the throwing instruction |
| 499 | * (minus exceptions). Note: this new basic block must NOT be entered into |
| 500 | * the block_map. If the potentially-throwing instruction is the target of a |
| 501 | * future branch, we need to find the check psuedo half. The new |
| 502 | * basic block containing the work portion of the instruction should |
| 503 | * only be entered via fallthrough from the block containing the |
| 504 | * pseudo exception edge MIR. Note also that this new block is |
| 505 | * not automatically terminated after the work portion, and may |
| 506 | * contain following instructions. |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 507 | * |
| 508 | * Note also that the dex_pc_to_block_map_ entry for the potentially |
| 509 | * throwing instruction will refer to the original basic block. |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 510 | */ |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 511 | BasicBlock *new_block = NewMemBB(kDalvikByteCode, num_blocks_++); |
| 512 | block_list_.Insert(new_block); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 513 | new_block->start_offset = insn->offset; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 514 | cur_block->fall_through = new_block->id; |
| 515 | new_block->predecessors->Insert(cur_block->id); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 516 | MIR* new_insn = static_cast<MIR*>(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocMIR)); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 517 | *new_insn = *insn; |
| 518 | insn->dalvikInsn.opcode = |
| 519 | static_cast<Instruction::Code>(kMirOpCheck); |
| 520 | // Associate the two halves |
| 521 | insn->meta.throw_insn = new_insn; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 522 | AppendMIR(new_block, new_insn); |
| 523 | return new_block; |
| 524 | } |
| 525 | |
| 526 | /* Parse a Dex method and insert it into the MIRGraph at the current insert point. */ |
| 527 | void MIRGraph::InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 528 | InvokeType invoke_type, uint16_t class_def_idx, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 529 | uint32_t method_idx, jobject class_loader, const DexFile& dex_file) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 530 | current_code_item_ = code_item; |
| 531 | method_stack_.push_back(std::make_pair(current_method_, current_offset_)); |
| 532 | current_method_ = m_units_.size(); |
| 533 | current_offset_ = 0; |
| 534 | // TODO: will need to snapshot stack image and use that as the mir context identification. |
| 535 | m_units_.push_back(new DexCompilationUnit(cu_, class_loader, Runtime::Current()->GetClassLinker(), |
Vladimir Marko | 2730db0 | 2014-01-27 11:15:17 +0000 | [diff] [blame] | 536 | dex_file, current_code_item_, class_def_idx, method_idx, access_flags, |
| 537 | cu_->compiler_driver->GetVerifiedMethod(&dex_file, method_idx))); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 538 | const uint16_t* code_ptr = current_code_item_->insns_; |
| 539 | const uint16_t* code_end = |
| 540 | current_code_item_->insns_ + current_code_item_->insns_size_in_code_units_; |
| 541 | |
| 542 | // TODO: need to rework expansion of block list & try_block_addr when inlining activated. |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 543 | // TUNING: use better estimate of basic blocks for following resize. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 544 | block_list_.Resize(block_list_.Size() + current_code_item_->insns_size_in_code_units_); |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 545 | dex_pc_to_block_map_.SetSize(dex_pc_to_block_map_.Size() + current_code_item_->insns_size_in_code_units_); |
buzbee | bd663de | 2013-09-10 15:41:31 -0700 | [diff] [blame] | 546 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 547 | // TODO: replace with explicit resize routine. Using automatic extension side effect for now. |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 548 | try_block_addr_->SetBit(current_code_item_->insns_size_in_code_units_); |
| 549 | try_block_addr_->ClearBit(current_code_item_->insns_size_in_code_units_); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 550 | |
| 551 | // If this is the first method, set up default entry and exit blocks. |
| 552 | if (current_method_ == 0) { |
| 553 | DCHECK(entry_block_ == NULL); |
| 554 | DCHECK(exit_block_ == NULL); |
Brian Carlstrom | 4274889 | 2013-07-18 18:04:08 -0700 | [diff] [blame] | 555 | DCHECK_EQ(num_blocks_, 0); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 556 | // Use id 0 to represent a null block. |
| 557 | BasicBlock* null_block = NewMemBB(kNullBlock, num_blocks_++); |
| 558 | DCHECK_EQ(null_block->id, NullBasicBlockId); |
| 559 | null_block->hidden = true; |
| 560 | block_list_.Insert(null_block); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 561 | entry_block_ = NewMemBB(kEntryBlock, num_blocks_++); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 562 | block_list_.Insert(entry_block_); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 563 | exit_block_ = NewMemBB(kExitBlock, num_blocks_++); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 564 | block_list_.Insert(exit_block_); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 565 | // TODO: deprecate all "cu->" fields; move what's left to wherever CompilationUnit is allocated. |
| 566 | cu_->dex_file = &dex_file; |
| 567 | cu_->class_def_idx = class_def_idx; |
| 568 | cu_->method_idx = method_idx; |
| 569 | cu_->access_flags = access_flags; |
| 570 | cu_->invoke_type = invoke_type; |
| 571 | cu_->shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx)); |
| 572 | cu_->num_ins = current_code_item_->ins_size_; |
| 573 | cu_->num_regs = current_code_item_->registers_size_ - cu_->num_ins; |
| 574 | cu_->num_outs = current_code_item_->outs_size_; |
| 575 | cu_->num_dalvik_registers = current_code_item_->registers_size_; |
| 576 | cu_->insns = current_code_item_->insns_; |
| 577 | cu_->code_item = current_code_item_; |
| 578 | } else { |
| 579 | UNIMPLEMENTED(FATAL) << "Nested inlining not implemented."; |
| 580 | /* |
| 581 | * Will need to manage storage for ins & outs, push prevous state and update |
| 582 | * insert point. |
| 583 | */ |
| 584 | } |
| 585 | |
| 586 | /* Current block to record parsed instructions */ |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 587 | BasicBlock *cur_block = NewMemBB(kDalvikByteCode, num_blocks_++); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 588 | DCHECK_EQ(current_offset_, 0U); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 589 | cur_block->start_offset = current_offset_; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 590 | block_list_.Insert(cur_block); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 591 | // TODO: for inlining support, insert at the insert point rather than entry block. |
| 592 | entry_block_->fall_through = cur_block->id; |
| 593 | cur_block->predecessors->Insert(entry_block_->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 594 | |
| 595 | /* Identify code range in try blocks and set up the empty catch blocks */ |
| 596 | ProcessTryCatchBlocks(); |
| 597 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 598 | /* Parse all instructions and put them into containing basic blocks */ |
| 599 | while (code_ptr < code_end) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 600 | MIR *insn = static_cast<MIR *>(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocMIR)); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 601 | insn->offset = current_offset_; |
| 602 | insn->m_unit_index = current_method_; |
| 603 | int width = ParseInsn(code_ptr, &insn->dalvikInsn); |
| 604 | insn->width = width; |
| 605 | Instruction::Code opcode = insn->dalvikInsn.opcode; |
| 606 | if (opcode_count_ != NULL) { |
| 607 | opcode_count_[static_cast<int>(opcode)]++; |
| 608 | } |
| 609 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 610 | int flags = Instruction::FlagsOf(insn->dalvikInsn.opcode); |
| 611 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 612 | uint64_t df_flags = oat_data_flow_attributes_[insn->dalvikInsn.opcode]; |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 613 | |
| 614 | if (df_flags & DF_HAS_DEFS) { |
| 615 | def_count_ += (df_flags & DF_A_WIDE) ? 2 : 1; |
| 616 | } |
| 617 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 618 | if (df_flags & DF_LVN) { |
| 619 | cur_block->use_lvn = true; // Run local value numbering on this basic block. |
| 620 | } |
| 621 | |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 622 | // Check for inline data block signatures |
| 623 | if (opcode == Instruction::NOP) { |
| 624 | // A simple NOP will have a width of 1 at this point, embedded data NOP > 1. |
| 625 | if ((width == 1) && ((current_offset_ & 0x1) == 0x1) && ((code_end - code_ptr) > 1)) { |
| 626 | // Could be an aligning nop. If an embedded data NOP follows, treat pair as single unit. |
| 627 | uint16_t following_raw_instruction = code_ptr[1]; |
| 628 | if ((following_raw_instruction == Instruction::kSparseSwitchSignature) || |
| 629 | (following_raw_instruction == Instruction::kPackedSwitchSignature) || |
| 630 | (following_raw_instruction == Instruction::kArrayDataSignature)) { |
| 631 | width += Instruction::At(code_ptr + 1)->SizeInCodeUnits(); |
| 632 | } |
| 633 | } |
| 634 | if (width == 1) { |
| 635 | // It is a simple nop - treat normally. |
| 636 | AppendMIR(cur_block, insn); |
| 637 | } else { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 638 | DCHECK(cur_block->fall_through == NullBasicBlockId); |
| 639 | DCHECK(cur_block->taken == NullBasicBlockId); |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 640 | // Unreachable instruction, mark for no continuation. |
| 641 | flags &= ~Instruction::kContinue; |
| 642 | } |
| 643 | } else { |
| 644 | AppendMIR(cur_block, insn); |
| 645 | } |
| 646 | |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 647 | // Associate the starting dex_pc for this opcode with its containing basic block. |
| 648 | dex_pc_to_block_map_.Put(insn->offset, cur_block->id); |
| 649 | |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 650 | code_ptr += width; |
| 651 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 652 | if (flags & Instruction::kBranch) { |
| 653 | cur_block = ProcessCanBranch(cur_block, insn, current_offset_, |
| 654 | width, flags, code_ptr, code_end); |
| 655 | } else if (flags & Instruction::kReturn) { |
| 656 | cur_block->terminated_by_return = true; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 657 | cur_block->fall_through = exit_block_->id; |
| 658 | exit_block_->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 659 | /* |
| 660 | * Terminate the current block if there are instructions |
| 661 | * afterwards. |
| 662 | */ |
| 663 | if (code_ptr < code_end) { |
| 664 | /* |
| 665 | * Create a fallthrough block for real instructions |
| 666 | * (incl. NOP). |
| 667 | */ |
buzbee | 2724776 | 2013-07-28 12:03:58 -0700 | [diff] [blame] | 668 | FindBlock(current_offset_ + width, /* split */ false, /* create */ true, |
| 669 | /* immed_pred_block_p */ NULL); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 670 | } |
| 671 | } else if (flags & Instruction::kThrow) { |
| 672 | cur_block = ProcessCanThrow(cur_block, insn, current_offset_, width, flags, try_block_addr_, |
| 673 | code_ptr, code_end); |
| 674 | } else if (flags & Instruction::kSwitch) { |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 675 | cur_block = ProcessCanSwitch(cur_block, insn, current_offset_, width, flags); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 676 | } |
| 677 | current_offset_ += width; |
| 678 | BasicBlock *next_block = FindBlock(current_offset_, /* split */ false, /* create */ |
| 679 | false, /* immed_pred_block_p */ NULL); |
| 680 | if (next_block) { |
| 681 | /* |
| 682 | * The next instruction could be the target of a previously parsed |
| 683 | * forward branch so a block is already created. If the current |
| 684 | * instruction is not an unconditional branch, connect them through |
| 685 | * the fall-through link. |
| 686 | */ |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 687 | DCHECK(cur_block->fall_through == NullBasicBlockId || |
| 688 | GetBasicBlock(cur_block->fall_through) == next_block || |
| 689 | GetBasicBlock(cur_block->fall_through) == exit_block_); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 690 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 691 | if ((cur_block->fall_through == NullBasicBlockId) && (flags & Instruction::kContinue)) { |
| 692 | cur_block->fall_through = next_block->id; |
| 693 | next_block->predecessors->Insert(cur_block->id); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 694 | } |
| 695 | cur_block = next_block; |
| 696 | } |
| 697 | } |
Vladimir Marko | 5816ed4 | 2013-11-27 17:04:20 +0000 | [diff] [blame] | 698 | |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 699 | if (cu_->enable_debug & (1 << kDebugDumpCFG)) { |
| 700 | DumpCFG("/sdcard/1_post_parse_cfg/", true); |
| 701 | } |
| 702 | |
| 703 | if (cu_->verbose) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 704 | DumpMIRGraph(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 705 | } |
| 706 | } |
| 707 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 708 | void MIRGraph::ShowOpcodeStats() { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 709 | DCHECK(opcode_count_ != NULL); |
| 710 | LOG(INFO) << "Opcode Count"; |
| 711 | for (int i = 0; i < kNumPackedOpcodes; i++) { |
| 712 | if (opcode_count_[i] != 0) { |
| 713 | LOG(INFO) << "-C- " << Instruction::Name(static_cast<Instruction::Code>(i)) |
| 714 | << " " << opcode_count_[i]; |
| 715 | } |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | // TODO: use a configurable base prefix, and adjust callers to supply pass name. |
| 720 | /* Dump the CFG into a DOT graph */ |
Jean Christophe Beyler | d0a5155 | 2014-01-10 14:18:31 -0800 | [diff] [blame] | 721 | void MIRGraph::DumpCFG(const char* dir_prefix, bool all_blocks, const char *suffix) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 722 | FILE* file; |
| 723 | std::string fname(PrettyMethod(cu_->method_idx, *cu_->dex_file)); |
| 724 | ReplaceSpecialChars(fname); |
Jean Christophe Beyler | d0a5155 | 2014-01-10 14:18:31 -0800 | [diff] [blame] | 725 | fname = StringPrintf("%s%s%x%s.dot", dir_prefix, fname.c_str(), |
| 726 | GetBasicBlock(GetEntryBlock()->fall_through)->start_offset, |
| 727 | suffix == nullptr ? "" : suffix); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 728 | file = fopen(fname.c_str(), "w"); |
| 729 | if (file == NULL) { |
| 730 | return; |
| 731 | } |
| 732 | fprintf(file, "digraph G {\n"); |
| 733 | |
| 734 | fprintf(file, " rankdir=TB\n"); |
| 735 | |
| 736 | int num_blocks = all_blocks ? GetNumBlocks() : num_reachable_blocks_; |
| 737 | int idx; |
| 738 | |
| 739 | for (idx = 0; idx < num_blocks; idx++) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 740 | int block_idx = all_blocks ? idx : dfs_order_->Get(idx); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 741 | BasicBlock *bb = GetBasicBlock(block_idx); |
| 742 | if (bb == NULL) break; |
| 743 | if (bb->block_type == kDead) continue; |
| 744 | if (bb->block_type == kEntryBlock) { |
| 745 | fprintf(file, " entry_%d [shape=Mdiamond];\n", bb->id); |
| 746 | } else if (bb->block_type == kExitBlock) { |
| 747 | fprintf(file, " exit_%d [shape=Mdiamond];\n", bb->id); |
| 748 | } else if (bb->block_type == kDalvikByteCode) { |
| 749 | fprintf(file, " block%04x_%d [shape=record,label = \"{ \\\n", |
| 750 | bb->start_offset, bb->id); |
| 751 | const MIR *mir; |
| 752 | fprintf(file, " {block id %d\\l}%s\\\n", bb->id, |
| 753 | bb->first_mir_insn ? " | " : " "); |
| 754 | for (mir = bb->first_mir_insn; mir; mir = mir->next) { |
| 755 | int opcode = mir->dalvikInsn.opcode; |
| 756 | fprintf(file, " {%04x %s %s %s\\l}%s\\\n", mir->offset, |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 757 | mir->ssa_rep ? GetDalvikDisassembly(mir) : |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 758 | (opcode < kMirOpFirst) ? Instruction::Name(mir->dalvikInsn.opcode) : |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 759 | extended_mir_op_names_[opcode - kMirOpFirst], |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 760 | (mir->optimization_flags & MIR_IGNORE_RANGE_CHECK) != 0 ? " no_rangecheck" : " ", |
| 761 | (mir->optimization_flags & MIR_IGNORE_NULL_CHECK) != 0 ? " no_nullcheck" : " ", |
| 762 | mir->next ? " | " : " "); |
| 763 | } |
| 764 | fprintf(file, " }\"];\n\n"); |
| 765 | } else if (bb->block_type == kExceptionHandling) { |
| 766 | char block_name[BLOCK_NAME_LEN]; |
| 767 | |
| 768 | GetBlockName(bb, block_name); |
| 769 | fprintf(file, " %s [shape=invhouse];\n", block_name); |
| 770 | } |
| 771 | |
| 772 | char block_name1[BLOCK_NAME_LEN], block_name2[BLOCK_NAME_LEN]; |
| 773 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 774 | if (bb->taken != NullBasicBlockId) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 775 | GetBlockName(bb, block_name1); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 776 | GetBlockName(GetBasicBlock(bb->taken), block_name2); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 777 | fprintf(file, " %s:s -> %s:n [style=dotted]\n", |
| 778 | block_name1, block_name2); |
| 779 | } |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 780 | if (bb->fall_through != NullBasicBlockId) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 781 | GetBlockName(bb, block_name1); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 782 | GetBlockName(GetBasicBlock(bb->fall_through), block_name2); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 783 | fprintf(file, " %s:s -> %s:n\n", block_name1, block_name2); |
| 784 | } |
| 785 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 786 | if (bb->successor_block_list_type != kNotUsed) { |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 787 | fprintf(file, " succ%04x_%d [shape=%s,label = \"{ \\\n", |
| 788 | bb->start_offset, bb->id, |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 789 | (bb->successor_block_list_type == kCatch) ? "Mrecord" : "record"); |
| 790 | GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 791 | SuccessorBlockInfo *successor_block_info = iterator.Next(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 792 | |
| 793 | int succ_id = 0; |
| 794 | while (true) { |
| 795 | if (successor_block_info == NULL) break; |
| 796 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 797 | BasicBlock *dest_block = GetBasicBlock(successor_block_info->block); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 798 | SuccessorBlockInfo *next_successor_block_info = iterator.Next(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 799 | |
| 800 | fprintf(file, " {<f%d> %04x: %04x\\l}%s\\\n", |
| 801 | succ_id++, |
| 802 | successor_block_info->key, |
| 803 | dest_block->start_offset, |
| 804 | (next_successor_block_info != NULL) ? " | " : " "); |
| 805 | |
| 806 | successor_block_info = next_successor_block_info; |
| 807 | } |
| 808 | fprintf(file, " }\"];\n\n"); |
| 809 | |
| 810 | GetBlockName(bb, block_name1); |
| 811 | fprintf(file, " %s:s -> succ%04x_%d:n [style=dashed]\n", |
| 812 | block_name1, bb->start_offset, bb->id); |
| 813 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 814 | if (bb->successor_block_list_type == kPackedSwitch || |
| 815 | bb->successor_block_list_type == kSparseSwitch) { |
| 816 | GrowableArray<SuccessorBlockInfo*>::Iterator iter(bb->successor_blocks); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 817 | |
| 818 | succ_id = 0; |
| 819 | while (true) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 820 | SuccessorBlockInfo *successor_block_info = iter.Next(); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 821 | if (successor_block_info == NULL) break; |
| 822 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 823 | BasicBlock* dest_block = GetBasicBlock(successor_block_info->block); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 824 | |
| 825 | GetBlockName(dest_block, block_name2); |
| 826 | fprintf(file, " succ%04x_%d:f%d:e -> %s:n\n", bb->start_offset, |
| 827 | bb->id, succ_id++, block_name2); |
| 828 | } |
| 829 | } |
| 830 | } |
| 831 | fprintf(file, "\n"); |
| 832 | |
| 833 | if (cu_->verbose) { |
| 834 | /* Display the dominator tree */ |
| 835 | GetBlockName(bb, block_name1); |
| 836 | fprintf(file, " cfg%s [label=\"%s\", shape=none];\n", |
| 837 | block_name1, block_name1); |
| 838 | if (bb->i_dom) { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 839 | GetBlockName(GetBasicBlock(bb->i_dom), block_name2); |
buzbee | 311ca16 | 2013-02-28 15:56:43 -0800 | [diff] [blame] | 840 | fprintf(file, " cfg%s:s -> cfg%s:n\n\n", block_name2, block_name1); |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | fprintf(file, "}\n"); |
| 845 | fclose(file); |
| 846 | } |
| 847 | |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 848 | /* Insert an MIR instruction to the end of a basic block */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 849 | void MIRGraph::AppendMIR(BasicBlock* bb, MIR* mir) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 850 | if (bb->first_mir_insn == NULL) { |
| 851 | DCHECK(bb->last_mir_insn == NULL); |
| 852 | bb->last_mir_insn = bb->first_mir_insn = mir; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 853 | mir->next = NULL; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 854 | } else { |
| 855 | bb->last_mir_insn->next = mir; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 856 | mir->next = NULL; |
| 857 | bb->last_mir_insn = mir; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | /* Insert an MIR instruction to the head of a basic block */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 862 | void MIRGraph::PrependMIR(BasicBlock* bb, MIR* mir) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 863 | if (bb->first_mir_insn == NULL) { |
| 864 | DCHECK(bb->last_mir_insn == NULL); |
| 865 | bb->last_mir_insn = bb->first_mir_insn = mir; |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 866 | mir->next = NULL; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 867 | } else { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 868 | mir->next = bb->first_mir_insn; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 869 | bb->first_mir_insn = mir; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | /* Insert a MIR instruction after the specified MIR */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 874 | void MIRGraph::InsertMIRAfter(BasicBlock* bb, MIR* current_mir, MIR* new_mir) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 875 | new_mir->next = current_mir->next; |
| 876 | current_mir->next = new_mir; |
| 877 | |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 878 | if (bb->last_mir_insn == current_mir) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 879 | /* Is the last MIR in the block */ |
| 880 | bb->last_mir_insn = new_mir; |
| 881 | } |
| 882 | } |
| 883 | |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame^] | 884 | MIR* MIRGraph::GetNextUnconditionalMir(BasicBlock* bb, MIR* current) { |
| 885 | MIR* next_mir = nullptr; |
| 886 | |
| 887 | if (current != nullptr) { |
| 888 | next_mir = current->next; |
| 889 | } |
| 890 | |
| 891 | if (next_mir == nullptr) { |
| 892 | // Only look for next MIR that follows unconditionally. |
| 893 | if ((bb->taken == NullBasicBlockId) && (bb->fall_through != NullBasicBlockId)) { |
| 894 | next_mir = GetBasicBlock(bb->fall_through)->first_mir_insn; |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | return next_mir; |
| 899 | } |
| 900 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 901 | char* MIRGraph::GetDalvikDisassembly(const MIR* mir) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 902 | DecodedInstruction insn = mir->dalvikInsn; |
| 903 | std::string str; |
| 904 | int flags = 0; |
| 905 | int opcode = insn.opcode; |
| 906 | char* ret; |
| 907 | bool nop = false; |
| 908 | SSARepresentation* ssa_rep = mir->ssa_rep; |
| 909 | Instruction::Format dalvik_format = Instruction::k10x; // Default to no-operand format |
| 910 | int defs = (ssa_rep != NULL) ? ssa_rep->num_defs : 0; |
| 911 | int uses = (ssa_rep != NULL) ? ssa_rep->num_uses : 0; |
| 912 | |
| 913 | // Handle special cases. |
| 914 | if ((opcode == kMirOpCheck) || (opcode == kMirOpCheckPart2)) { |
| 915 | str.append(extended_mir_op_names_[opcode - kMirOpFirst]); |
| 916 | str.append(": "); |
| 917 | // Recover the original Dex instruction |
| 918 | insn = mir->meta.throw_insn->dalvikInsn; |
| 919 | ssa_rep = mir->meta.throw_insn->ssa_rep; |
| 920 | defs = ssa_rep->num_defs; |
| 921 | uses = ssa_rep->num_uses; |
| 922 | opcode = insn.opcode; |
| 923 | } else if (opcode == kMirOpNop) { |
| 924 | str.append("["); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 925 | // Recover original opcode. |
| 926 | insn.opcode = Instruction::At(current_code_item_->insns_ + mir->offset)->Opcode(); |
| 927 | opcode = insn.opcode; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 928 | nop = true; |
| 929 | } |
| 930 | |
| 931 | if (opcode >= kMirOpFirst) { |
| 932 | str.append(extended_mir_op_names_[opcode - kMirOpFirst]); |
| 933 | } else { |
| 934 | dalvik_format = Instruction::FormatOf(insn.opcode); |
| 935 | flags = Instruction::FlagsOf(insn.opcode); |
| 936 | str.append(Instruction::Name(insn.opcode)); |
| 937 | } |
| 938 | |
| 939 | if (opcode == kMirOpPhi) { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 940 | BasicBlockId* incoming = mir->meta.phi_incoming; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 941 | str.append(StringPrintf(" %s = (%s", |
| 942 | GetSSANameWithConst(ssa_rep->defs[0], true).c_str(), |
| 943 | GetSSANameWithConst(ssa_rep->uses[0], true).c_str())); |
Brian Carlstrom | b1eba21 | 2013-07-17 18:07:19 -0700 | [diff] [blame] | 944 | str.append(StringPrintf(":%d", incoming[0])); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 945 | int i; |
| 946 | for (i = 1; i < uses; i++) { |
| 947 | str.append(StringPrintf(", %s:%d", |
| 948 | GetSSANameWithConst(ssa_rep->uses[i], true).c_str(), |
| 949 | incoming[i])); |
| 950 | } |
| 951 | str.append(")"); |
| 952 | } else if ((flags & Instruction::kBranch) != 0) { |
| 953 | // For branches, decode the instructions to print out the branch targets. |
| 954 | int offset = 0; |
| 955 | switch (dalvik_format) { |
| 956 | case Instruction::k21t: |
| 957 | str.append(StringPrintf(" %s,", GetSSANameWithConst(ssa_rep->uses[0], false).c_str())); |
| 958 | offset = insn.vB; |
| 959 | break; |
| 960 | case Instruction::k22t: |
| 961 | str.append(StringPrintf(" %s, %s,", GetSSANameWithConst(ssa_rep->uses[0], false).c_str(), |
| 962 | GetSSANameWithConst(ssa_rep->uses[1], false).c_str())); |
| 963 | offset = insn.vC; |
| 964 | break; |
| 965 | case Instruction::k10t: |
| 966 | case Instruction::k20t: |
| 967 | case Instruction::k30t: |
| 968 | offset = insn.vA; |
| 969 | break; |
| 970 | default: |
| 971 | LOG(FATAL) << "Unexpected branch format " << dalvik_format << " from " << insn.opcode; |
| 972 | } |
| 973 | str.append(StringPrintf(" 0x%x (%c%x)", mir->offset + offset, |
| 974 | offset > 0 ? '+' : '-', offset > 0 ? offset : -offset)); |
| 975 | } else { |
| 976 | // For invokes-style formats, treat wide regs as a pair of singles |
| 977 | bool show_singles = ((dalvik_format == Instruction::k35c) || |
| 978 | (dalvik_format == Instruction::k3rc)); |
| 979 | if (defs != 0) { |
| 980 | str.append(StringPrintf(" %s", GetSSANameWithConst(ssa_rep->defs[0], false).c_str())); |
| 981 | if (uses != 0) { |
| 982 | str.append(", "); |
| 983 | } |
| 984 | } |
| 985 | for (int i = 0; i < uses; i++) { |
| 986 | str.append( |
| 987 | StringPrintf(" %s", GetSSANameWithConst(ssa_rep->uses[i], show_singles).c_str())); |
| 988 | if (!show_singles && (reg_location_ != NULL) && reg_location_[i].wide) { |
| 989 | // For the listing, skip the high sreg. |
| 990 | i++; |
| 991 | } |
| 992 | if (i != (uses -1)) { |
| 993 | str.append(","); |
| 994 | } |
| 995 | } |
| 996 | switch (dalvik_format) { |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 997 | case Instruction::k11n: // Add one immediate from vB |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 998 | case Instruction::k21s: |
| 999 | case Instruction::k31i: |
| 1000 | case Instruction::k21h: |
| 1001 | str.append(StringPrintf(", #%d", insn.vB)); |
| 1002 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1003 | case Instruction::k51l: // Add one wide immediate |
Ian Rogers | 23b03b5 | 2014-01-24 11:10:03 -0800 | [diff] [blame] | 1004 | str.append(StringPrintf(", #%" PRId64, insn.vB_wide)); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1005 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1006 | case Instruction::k21c: // One register, one string/type/method index |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1007 | case Instruction::k31c: |
| 1008 | str.append(StringPrintf(", index #%d", insn.vB)); |
| 1009 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1010 | case Instruction::k22c: // Two registers, one string/type/method index |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1011 | str.append(StringPrintf(", index #%d", insn.vC)); |
| 1012 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1013 | case Instruction::k22s: // Add one immediate from vC |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1014 | case Instruction::k22b: |
| 1015 | str.append(StringPrintf(", #%d", insn.vC)); |
| 1016 | break; |
Brian Carlstrom | 02c8cc6 | 2013-07-18 15:54:44 -0700 | [diff] [blame] | 1017 | default: { |
| 1018 | // Nothing left to print |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1019 | } |
Brian Carlstrom | 02c8cc6 | 2013-07-18 15:54:44 -0700 | [diff] [blame] | 1020 | } |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1021 | } |
| 1022 | if (nop) { |
| 1023 | str.append("]--optimized away"); |
| 1024 | } |
| 1025 | int length = str.length() + 1; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 1026 | ret = static_cast<char*>(arena_->Alloc(length, ArenaAllocator::kAllocDFInfo)); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1027 | strncpy(ret, str.c_str(), length); |
| 1028 | return ret; |
| 1029 | } |
| 1030 | |
| 1031 | /* Turn method name into a legal Linux file name */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1032 | void MIRGraph::ReplaceSpecialChars(std::string& str) { |
Brian Carlstrom | 9b7085a | 2013-07-18 15:15:21 -0700 | [diff] [blame] | 1033 | static const struct { const char before; const char after; } match[] = { |
| 1034 | {'/', '-'}, {';', '#'}, {' ', '#'}, {'$', '+'}, |
| 1035 | {'(', '@'}, {')', '@'}, {'<', '='}, {'>', '='} |
| 1036 | }; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1037 | for (unsigned int i = 0; i < sizeof(match)/sizeof(match[0]); i++) { |
| 1038 | std::replace(str.begin(), str.end(), match[i].before, match[i].after); |
| 1039 | } |
| 1040 | } |
| 1041 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1042 | std::string MIRGraph::GetSSAName(int ssa_reg) { |
Ian Rogers | 39ebcb8 | 2013-05-30 16:57:23 -0700 | [diff] [blame] | 1043 | // TODO: This value is needed for LLVM and debugging. Currently, we compute this and then copy to |
| 1044 | // the arena. We should be smarter and just place straight into the arena, or compute the |
| 1045 | // value more lazily. |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1046 | return StringPrintf("v%d_%d", SRegToVReg(ssa_reg), GetSSASubscript(ssa_reg)); |
| 1047 | } |
| 1048 | |
| 1049 | // Similar to GetSSAName, but if ssa name represents an immediate show that as well. |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1050 | std::string MIRGraph::GetSSANameWithConst(int ssa_reg, bool singles_only) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1051 | if (reg_location_ == NULL) { |
| 1052 | // Pre-SSA - just use the standard name |
| 1053 | return GetSSAName(ssa_reg); |
| 1054 | } |
| 1055 | if (IsConst(reg_location_[ssa_reg])) { |
| 1056 | if (!singles_only && reg_location_[ssa_reg].wide) { |
Ian Rogers | 23b03b5 | 2014-01-24 11:10:03 -0800 | [diff] [blame] | 1057 | return StringPrintf("v%d_%d#0x%" PRIx64, SRegToVReg(ssa_reg), GetSSASubscript(ssa_reg), |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1058 | ConstantValueWide(reg_location_[ssa_reg])); |
| 1059 | } else { |
Brian Carlstrom | b1eba21 | 2013-07-17 18:07:19 -0700 | [diff] [blame] | 1060 | return StringPrintf("v%d_%d#0x%x", SRegToVReg(ssa_reg), GetSSASubscript(ssa_reg), |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1061 | ConstantValue(reg_location_[ssa_reg])); |
| 1062 | } |
| 1063 | } else { |
| 1064 | return StringPrintf("v%d_%d", SRegToVReg(ssa_reg), GetSSASubscript(ssa_reg)); |
| 1065 | } |
| 1066 | } |
| 1067 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1068 | void MIRGraph::GetBlockName(BasicBlock* bb, char* name) { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1069 | switch (bb->block_type) { |
| 1070 | case kEntryBlock: |
| 1071 | snprintf(name, BLOCK_NAME_LEN, "entry_%d", bb->id); |
| 1072 | break; |
| 1073 | case kExitBlock: |
| 1074 | snprintf(name, BLOCK_NAME_LEN, "exit_%d", bb->id); |
| 1075 | break; |
| 1076 | case kDalvikByteCode: |
| 1077 | snprintf(name, BLOCK_NAME_LEN, "block%04x_%d", bb->start_offset, bb->id); |
| 1078 | break; |
| 1079 | case kExceptionHandling: |
| 1080 | snprintf(name, BLOCK_NAME_LEN, "exception%04x_%d", bb->start_offset, |
| 1081 | bb->id); |
| 1082 | break; |
| 1083 | default: |
| 1084 | snprintf(name, BLOCK_NAME_LEN, "_%d", bb->id); |
| 1085 | break; |
| 1086 | } |
| 1087 | } |
| 1088 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1089 | const char* MIRGraph::GetShortyFromTargetIdx(int target_idx) { |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 1090 | // TODO: for inlining support, use current code unit. |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1091 | const DexFile::MethodId& method_id = cu_->dex_file->GetMethodId(target_idx); |
| 1092 | return cu_->dex_file->GetShorty(method_id.proto_idx_); |
| 1093 | } |
| 1094 | |
| 1095 | /* Debug Utility - dump a compilation unit */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1096 | void MIRGraph::DumpMIRGraph() { |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1097 | BasicBlock* bb; |
| 1098 | const char* block_type_names[] = { |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 1099 | "Null Block", |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1100 | "Entry Block", |
| 1101 | "Code Block", |
| 1102 | "Exit Block", |
| 1103 | "Exception Handling", |
| 1104 | "Catch Block" |
| 1105 | }; |
| 1106 | |
| 1107 | LOG(INFO) << "Compiling " << PrettyMethod(cu_->method_idx, *cu_->dex_file); |
| 1108 | LOG(INFO) << cu_->insns << " insns"; |
| 1109 | LOG(INFO) << GetNumBlocks() << " blocks in total"; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1110 | GrowableArray<BasicBlock*>::Iterator iterator(&block_list_); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1111 | |
| 1112 | while (true) { |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1113 | bb = iterator.Next(); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1114 | if (bb == NULL) break; |
| 1115 | LOG(INFO) << StringPrintf("Block %d (%s) (insn %04x - %04x%s)", |
| 1116 | bb->id, |
| 1117 | block_type_names[bb->block_type], |
| 1118 | bb->start_offset, |
| 1119 | bb->last_mir_insn ? bb->last_mir_insn->offset : bb->start_offset, |
| 1120 | bb->last_mir_insn ? "" : " empty"); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 1121 | if (bb->taken != NullBasicBlockId) { |
| 1122 | LOG(INFO) << " Taken branch: block " << bb->taken |
| 1123 | << "(0x" << std::hex << GetBasicBlock(bb->taken)->start_offset << ")"; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1124 | } |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 1125 | if (bb->fall_through != NullBasicBlockId) { |
| 1126 | LOG(INFO) << " Fallthrough : block " << bb->fall_through |
| 1127 | << " (0x" << std::hex << GetBasicBlock(bb->fall_through)->start_offset << ")"; |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1128 | } |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | /* |
| 1133 | * Build an array of location records for the incoming arguments. |
| 1134 | * Note: one location record per word of arguments, with dummy |
| 1135 | * high-word loc for wide arguments. Also pull up any following |
| 1136 | * MOVE_RESULT and incorporate it into the invoke. |
| 1137 | */ |
| 1138 | CallInfo* MIRGraph::NewMemCallInfo(BasicBlock* bb, MIR* mir, InvokeType type, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1139 | bool is_range) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 1140 | CallInfo* info = static_cast<CallInfo*>(arena_->Alloc(sizeof(CallInfo), |
| 1141 | ArenaAllocator::kAllocMisc)); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1142 | MIR* move_result_mir = FindMoveResult(bb, mir); |
| 1143 | if (move_result_mir == NULL) { |
| 1144 | info->result.location = kLocInvalid; |
| 1145 | } else { |
| 1146 | info->result = GetRawDest(move_result_mir); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1147 | move_result_mir->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpNop); |
| 1148 | } |
| 1149 | info->num_arg_words = mir->ssa_rep->num_uses; |
| 1150 | info->args = (info->num_arg_words == 0) ? NULL : static_cast<RegLocation*> |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 1151 | (arena_->Alloc(sizeof(RegLocation) * info->num_arg_words, ArenaAllocator::kAllocMisc)); |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1152 | for (int i = 0; i < info->num_arg_words; i++) { |
| 1153 | info->args[i] = GetRawSrc(mir, i); |
| 1154 | } |
| 1155 | info->opt_flags = mir->optimization_flags; |
| 1156 | info->type = type; |
| 1157 | info->is_range = is_range; |
| 1158 | info->index = mir->dalvikInsn.vB; |
| 1159 | info->offset = mir->offset; |
| 1160 | return info; |
| 1161 | } |
| 1162 | |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1163 | // Allocate a new basic block. |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1164 | BasicBlock* MIRGraph::NewMemBB(BBType block_type, int block_id) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 1165 | BasicBlock* bb = static_cast<BasicBlock*>(arena_->Alloc(sizeof(BasicBlock), |
| 1166 | ArenaAllocator::kAllocBB)); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1167 | bb->block_type = block_type; |
| 1168 | bb->id = block_id; |
| 1169 | // TUNING: better estimate of the exit block predecessors? |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 1170 | bb->predecessors = new (arena_) GrowableArray<BasicBlockId>(arena_, |
Brian Carlstrom | df62950 | 2013-07-17 22:39:56 -0700 | [diff] [blame] | 1171 | (block_type == kExitBlock) ? 2048 : 2, |
| 1172 | kGrowableArrayPredecessors); |
buzbee | 0d82948 | 2013-10-11 15:24:55 -0700 | [diff] [blame] | 1173 | bb->successor_block_list_type = kNotUsed; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1174 | block_id_map_.Put(block_id, block_id); |
| 1175 | return bb; |
| 1176 | } |
buzbee | 1fd3346 | 2013-03-25 13:40:45 -0700 | [diff] [blame] | 1177 | |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 1178 | void MIRGraph::InitializeConstantPropagation() { |
| 1179 | is_constant_v_ = new (arena_) ArenaBitVector(arena_, GetNumSSARegs(), false); |
| 1180 | constant_values_ = static_cast<int*>(arena_->Alloc(sizeof(int) * GetNumSSARegs(), ArenaAllocator::kAllocDFInfo)); |
| 1181 | } |
| 1182 | |
| 1183 | void MIRGraph::InitializeMethodUses() { |
| 1184 | // The gate starts by initializing the use counts |
| 1185 | int num_ssa_regs = GetNumSSARegs(); |
| 1186 | use_counts_.Resize(num_ssa_regs + 32); |
| 1187 | raw_use_counts_.Resize(num_ssa_regs + 32); |
| 1188 | // Initialize list |
| 1189 | for (int i = 0; i < num_ssa_regs; i++) { |
| 1190 | use_counts_.Insert(0); |
| 1191 | raw_use_counts_.Insert(0); |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | void MIRGraph::InitializeSSATransformation() { |
| 1196 | /* Compute the DFS order */ |
| 1197 | ComputeDFSOrders(); |
| 1198 | |
| 1199 | /* Compute the dominator info */ |
| 1200 | ComputeDominators(); |
| 1201 | |
| 1202 | /* Allocate data structures in preparation for SSA conversion */ |
| 1203 | CompilerInitializeSSAConversion(); |
| 1204 | |
| 1205 | /* Find out the "Dalvik reg def x block" relation */ |
| 1206 | ComputeDefBlockMatrix(); |
| 1207 | |
| 1208 | /* Insert phi nodes to dominance frontiers for all variables */ |
| 1209 | InsertPhiNodes(); |
| 1210 | |
| 1211 | /* Rename register names by local defs and phi nodes */ |
| 1212 | ClearAllVisitedFlags(); |
| 1213 | DoDFSPreOrderSSARename(GetEntryBlock()); |
| 1214 | |
| 1215 | /* |
| 1216 | * Shared temp bit vector used by each block to count the number of defs |
| 1217 | * from all the predecessor blocks. |
| 1218 | */ |
| 1219 | temp_ssa_register_v_ = |
| 1220 | new (arena_) ArenaBitVector(arena_, GetNumSSARegs(), false, kBitMapTempSSARegisterV); |
| 1221 | } |
| 1222 | |
| 1223 | void MIRGraph::CheckSSARegisterVector() { |
| 1224 | DCHECK(temp_ssa_register_v_ != nullptr); |
| 1225 | } |
| 1226 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1227 | } // namespace art |