blob: 58f591bd1ea3085025835c58999f5c1a6839f0be [file] [log] [blame]
David Brazdil86ea7ee2016-02-16 09:26:07 +00001/*
2 * Copyright (C) 2016 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 "block_builder.h"
18
Andreas Gampe57943812017-12-06 21:39:13 -080019#include "base/logging.h" // FOR VLOG.
David Brazdil86ea7ee2016-02-16 09:26:07 +000020#include "bytecode_utils.h"
Mathieu Chartierde4b08f2017-07-10 14:13:41 -070021#include "quicken_info.h"
David Brazdil86ea7ee2016-02-16 09:26:07 +000022
23namespace art {
24
25HBasicBlock* HBasicBlockBuilder::MaybeCreateBlockAt(uint32_t dex_pc) {
26 return MaybeCreateBlockAt(dex_pc, dex_pc);
27}
28
29HBasicBlock* HBasicBlockBuilder::MaybeCreateBlockAt(uint32_t semantic_dex_pc,
30 uint32_t store_dex_pc) {
31 HBasicBlock* block = branch_targets_[store_dex_pc];
32 if (block == nullptr) {
Vladimir Marko69d310e2017-10-09 14:12:23 +010033 block = new (allocator_) HBasicBlock(graph_, semantic_dex_pc);
David Brazdil86ea7ee2016-02-16 09:26:07 +000034 branch_targets_[store_dex_pc] = block;
35 }
36 DCHECK_EQ(block->GetDexPc(), semantic_dex_pc);
37 return block;
38}
39
40bool HBasicBlockBuilder::CreateBranchTargets() {
41 // Create the first block for the dex instructions, single successor of the entry block.
42 MaybeCreateBlockAt(0u);
43
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000044 if (code_item_->tries_size_ != 0) {
David Brazdil86ea7ee2016-02-16 09:26:07 +000045 // Create branch targets at the start/end of the TryItem range. These are
46 // places where the program might fall through into/out of the a block and
47 // where TryBoundary instructions will be inserted later. Other edges which
48 // enter/exit the try blocks are a result of branches/switches.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000049 for (size_t idx = 0; idx < code_item_->tries_size_; ++idx) {
50 const DexFile::TryItem* try_item = DexFile::GetTryItems(*code_item_, idx);
David Brazdil86ea7ee2016-02-16 09:26:07 +000051 uint32_t dex_pc_start = try_item->start_addr_;
52 uint32_t dex_pc_end = dex_pc_start + try_item->insn_count_;
53 MaybeCreateBlockAt(dex_pc_start);
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000054 if (dex_pc_end < code_item_->insns_size_in_code_units_) {
David Brazdil86ea7ee2016-02-16 09:26:07 +000055 // TODO: Do not create block if the last instruction cannot fall through.
56 MaybeCreateBlockAt(dex_pc_end);
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000057 } else if (dex_pc_end == code_item_->insns_size_in_code_units_) {
David Brazdil86ea7ee2016-02-16 09:26:07 +000058 // The TryItem spans until the very end of the CodeItem and therefore
59 // cannot have any code afterwards.
60 } else {
61 // The TryItem spans beyond the end of the CodeItem. This is invalid code.
Nicolas Geoffraydbb9aef2017-11-23 10:44:11 +000062 VLOG(compiler) << "Not compiled: TryItem spans beyond the end of the CodeItem";
David Brazdil86ea7ee2016-02-16 09:26:07 +000063 return false;
64 }
65 }
66
67 // Create branch targets for exception handlers.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000068 const uint8_t* handlers_ptr = DexFile::GetCatchHandlerData(*code_item_, 0);
David Brazdil86ea7ee2016-02-16 09:26:07 +000069 uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr);
70 for (uint32_t idx = 0; idx < handlers_size; ++idx) {
71 CatchHandlerIterator iterator(handlers_ptr);
72 for (; iterator.HasNext(); iterator.Next()) {
73 MaybeCreateBlockAt(iterator.GetHandlerAddress());
74 }
75 handlers_ptr = iterator.EndDataPointer();
76 }
77 }
78
79 // Iterate over all instructions and find branching instructions. Create blocks for
80 // the locations these instructions branch to.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +000081 IterationRange<DexInstructionIterator> instructions = code_item_->Instructions();
Mathieu Chartier0021feb2017-11-07 00:08:52 -080082 for (const DexInstructionPcPair& pair : instructions) {
83 const uint32_t dex_pc = pair.DexPc();
84 const Instruction& instruction = pair.Inst();
David Brazdil86ea7ee2016-02-16 09:26:07 +000085
86 if (instruction.IsBranch()) {
87 number_of_branches_++;
88 MaybeCreateBlockAt(dex_pc + instruction.GetTargetOffset());
89 } else if (instruction.IsSwitch()) {
90 DexSwitchTable table(instruction, dex_pc);
91 for (DexSwitchTableIterator s_it(table); !s_it.Done(); s_it.Advance()) {
92 MaybeCreateBlockAt(dex_pc + s_it.CurrentTargetOffset());
93
94 // Create N-1 blocks where we will insert comparisons of the input value
95 // against the Switch's case keys.
96 if (table.ShouldBuildDecisionTree() && !s_it.IsLast()) {
97 // Store the block under dex_pc of the current key at the switch data
98 // instruction for uniqueness but give it the dex_pc of the SWITCH
99 // instruction which it semantically belongs to.
100 MaybeCreateBlockAt(dex_pc, s_it.GetDexPcForCurrentIndex());
101 }
102 }
103 } else if (instruction.Opcode() == Instruction::MOVE_EXCEPTION) {
104 // End the basic block after MOVE_EXCEPTION. This simplifies the later
105 // stage of TryBoundary-block insertion.
106 } else {
107 continue;
108 }
109
110 if (instruction.CanFlowThrough()) {
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800111 DexInstructionIterator next(std::next(DexInstructionIterator(pair)));
112 if (next == instructions.end()) {
David Brazdil86ea7ee2016-02-16 09:26:07 +0000113 // In the normal case we should never hit this but someone can artificially forge a dex
114 // file to fall-through out the method code. In this case we bail out compilation.
Nicolas Geoffraydbb9aef2017-11-23 10:44:11 +0000115 VLOG(compiler) << "Not compiled: Fall-through beyond the CodeItem";
David Brazdil86ea7ee2016-02-16 09:26:07 +0000116 return false;
David Brazdil86ea7ee2016-02-16 09:26:07 +0000117 }
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800118 MaybeCreateBlockAt(next.DexPc());
David Brazdil86ea7ee2016-02-16 09:26:07 +0000119 }
120 }
121
122 return true;
123}
124
125void HBasicBlockBuilder::ConnectBasicBlocks() {
126 HBasicBlock* block = graph_->GetEntryBlock();
127 graph_->AddBlock(block);
128
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700129 size_t quicken_index = 0;
David Brazdil86ea7ee2016-02-16 09:26:07 +0000130 bool is_throwing_block = false;
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700131 // Calculate the qucikening index here instead of CreateBranchTargets since it's easier to
132 // calculate in dex_pc order.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000133 for (const DexInstructionPcPair& pair : code_item_->Instructions()) {
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800134 const uint32_t dex_pc = pair.DexPc();
135 const Instruction& instruction = pair.Inst();
David Brazdil86ea7ee2016-02-16 09:26:07 +0000136
137 // Check if this dex_pc address starts a new basic block.
138 HBasicBlock* next_block = GetBlockAt(dex_pc);
139 if (next_block != nullptr) {
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700140 // We only need quicken index entries for basic block boundaries.
141 quicken_index_for_dex_pc_.Put(dex_pc, quicken_index);
David Brazdil86ea7ee2016-02-16 09:26:07 +0000142 if (block != nullptr) {
143 // Last instruction did not end its basic block but a new one starts here.
144 // It must have been a block falling through into the next one.
145 block->AddSuccessor(next_block);
146 }
147 block = next_block;
148 is_throwing_block = false;
149 graph_->AddBlock(block);
150 }
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700151 // Make sure to increment this before the continues.
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800152 if (QuickenInfoTable::NeedsIndexForInstruction(&instruction)) {
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700153 ++quicken_index;
154 }
David Brazdil86ea7ee2016-02-16 09:26:07 +0000155
156 if (block == nullptr) {
157 // Ignore dead code.
158 continue;
159 }
160
David Brazdil86ea7ee2016-02-16 09:26:07 +0000161 if (!is_throwing_block && IsThrowingDexInstruction(instruction)) {
162 DCHECK(!ContainsElement(throwing_blocks_, block));
163 is_throwing_block = true;
164 throwing_blocks_.push_back(block);
165 }
166
167 if (instruction.IsBranch()) {
168 uint32_t target_dex_pc = dex_pc + instruction.GetTargetOffset();
169 block->AddSuccessor(GetBlockAt(target_dex_pc));
170 } else if (instruction.IsReturn() || (instruction.Opcode() == Instruction::THROW)) {
171 block->AddSuccessor(graph_->GetExitBlock());
172 } else if (instruction.IsSwitch()) {
173 DexSwitchTable table(instruction, dex_pc);
174 for (DexSwitchTableIterator s_it(table); !s_it.Done(); s_it.Advance()) {
175 uint32_t target_dex_pc = dex_pc + s_it.CurrentTargetOffset();
176 block->AddSuccessor(GetBlockAt(target_dex_pc));
177
178 if (table.ShouldBuildDecisionTree() && !s_it.IsLast()) {
179 uint32_t next_case_dex_pc = s_it.GetDexPcForCurrentIndex();
180 HBasicBlock* next_case_block = GetBlockAt(next_case_dex_pc);
181 block->AddSuccessor(next_case_block);
182 block = next_case_block;
183 graph_->AddBlock(block);
184 }
185 }
186 } else {
187 // Remaining code only applies to instructions which end their basic block.
188 continue;
189 }
190
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800191 // Go to the next instruction in case we read dex PC below.
David Brazdil86ea7ee2016-02-16 09:26:07 +0000192 if (instruction.CanFlowThrough()) {
Mathieu Chartier0021feb2017-11-07 00:08:52 -0800193 block->AddSuccessor(GetBlockAt(std::next(DexInstructionIterator(pair)).DexPc()));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000194 }
195
196 // The basic block ends here. Do not add any more instructions.
197 block = nullptr;
198 }
199
200 graph_->AddBlock(graph_->GetExitBlock());
201}
202
203// Returns the TryItem stored for `block` or nullptr if there is no info for it.
204static const DexFile::TryItem* GetTryItem(
205 HBasicBlock* block,
Vladimir Marko69d310e2017-10-09 14:12:23 +0100206 const ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*>& try_block_info) {
David Brazdil86ea7ee2016-02-16 09:26:07 +0000207 auto iterator = try_block_info.find(block->GetBlockId());
208 return (iterator == try_block_info.end()) ? nullptr : iterator->second;
209}
210
211// Iterates over the exception handlers of `try_item`, finds the corresponding
212// catch blocks and makes them successors of `try_boundary`. The order of
213// successors matches the order in which runtime exception delivery searches
214// for a handler.
215static void LinkToCatchBlocks(HTryBoundary* try_boundary,
216 const DexFile::CodeItem& code_item,
217 const DexFile::TryItem* try_item,
Vladimir Marko69d310e2017-10-09 14:12:23 +0100218 const ScopedArenaSafeMap<uint32_t, HBasicBlock*>& catch_blocks) {
David Brazdil86ea7ee2016-02-16 09:26:07 +0000219 for (CatchHandlerIterator it(code_item, *try_item); it.HasNext(); it.Next()) {
220 try_boundary->AddExceptionHandler(catch_blocks.Get(it.GetHandlerAddress()));
221 }
222}
223
224bool HBasicBlockBuilder::MightHaveLiveNormalPredecessors(HBasicBlock* catch_block) {
225 if (kIsDebugBuild) {
226 DCHECK_NE(catch_block->GetDexPc(), kNoDexPc) << "Should not be called on synthetic blocks";
227 DCHECK(!graph_->GetEntryBlock()->GetSuccessors().empty())
228 << "Basic blocks must have been created and connected";
229 for (HBasicBlock* predecessor : catch_block->GetPredecessors()) {
230 DCHECK(!predecessor->IsSingleTryBoundary())
231 << "TryBoundary blocks must not have not been created yet";
232 }
233 }
234
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000235 const Instruction& first = code_item_->InstructionAt(catch_block->GetDexPc());
David Brazdil86ea7ee2016-02-16 09:26:07 +0000236 if (first.Opcode() == Instruction::MOVE_EXCEPTION) {
237 // Verifier guarantees that if a catch block begins with MOVE_EXCEPTION then
238 // it has no live normal predecessors.
239 return false;
240 } else if (catch_block->GetPredecessors().empty()) {
241 // Normal control-flow edges have already been created. Since block's list of
242 // predecessors is empty, it cannot have any live or dead normal predecessors.
243 return false;
244 }
245
246 // The catch block has normal predecessors but we do not know which are live
247 // and which will be removed during the initial DCE. Return `true` to signal
248 // that it may have live normal predecessors.
249 return true;
250}
251
252void HBasicBlockBuilder::InsertTryBoundaryBlocks() {
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000253 if (code_item_->tries_size_ == 0) {
David Brazdil86ea7ee2016-02-16 09:26:07 +0000254 return;
255 }
256
257 // Keep a map of all try blocks and their respective TryItems. We do not use
258 // the block's pointer but rather its id to ensure deterministic iteration.
Vladimir Marko69d310e2017-10-09 14:12:23 +0100259 ScopedArenaSafeMap<uint32_t, const DexFile::TryItem*> try_block_info(
260 std::less<uint32_t>(), local_allocator_->Adapter(kArenaAllocGraphBuilder));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000261
262 // Obtain TryItem information for blocks with throwing instructions, and split
263 // blocks which are both try & catch to simplify the graph.
264 for (HBasicBlock* block : graph_->GetBlocks()) {
265 if (block->GetDexPc() == kNoDexPc) {
266 continue;
267 }
268
269 // Do not bother creating exceptional edges for try blocks which have no
270 // throwing instructions. In that case we simply assume that the block is
271 // not covered by a TryItem. This prevents us from creating a throw-catch
272 // loop for synchronized blocks.
273 if (ContainsElement(throwing_blocks_, block)) {
274 // Try to find a TryItem covering the block.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000275 const int32_t try_item_idx = DexFile::FindTryItem(DexFile::GetTryItems(*code_item_, 0u),
276 code_item_->tries_size_,
Mathieu Chartier3da1d0f2017-11-06 20:02:24 -0800277 block->GetDexPc());
David Brazdil86ea7ee2016-02-16 09:26:07 +0000278 if (try_item_idx != -1) {
279 // Block throwing and in a TryItem. Store the try block information.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000280 try_block_info.Put(block->GetBlockId(), DexFile::GetTryItems(*code_item_, try_item_idx));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000281 }
282 }
283 }
284
285 // Map from a handler dex_pc to the corresponding catch block.
Vladimir Marko69d310e2017-10-09 14:12:23 +0100286 ScopedArenaSafeMap<uint32_t, HBasicBlock*> catch_blocks(
287 std::less<uint32_t>(), local_allocator_->Adapter(kArenaAllocGraphBuilder));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000288
289 // Iterate over catch blocks, create artifical landing pads if necessary to
290 // simplify the CFG, and set metadata.
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000291 const uint8_t* handlers_ptr = DexFile::GetCatchHandlerData(*code_item_, 0);
David Brazdil86ea7ee2016-02-16 09:26:07 +0000292 uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr);
293 for (uint32_t idx = 0; idx < handlers_size; ++idx) {
294 CatchHandlerIterator iterator(handlers_ptr);
295 for (; iterator.HasNext(); iterator.Next()) {
296 uint32_t address = iterator.GetHandlerAddress();
297 if (catch_blocks.find(address) != catch_blocks.end()) {
298 // Catch block already processed.
299 continue;
300 }
301
302 // Check if we should create an artifical landing pad for the catch block.
303 // We create one if the catch block is also a try block because we do not
304 // have a strategy for inserting TryBoundaries on exceptional edges.
305 // We also create one if the block might have normal predecessors so as to
306 // simplify register allocation.
307 HBasicBlock* catch_block = GetBlockAt(address);
308 bool is_try_block = (try_block_info.find(catch_block->GetBlockId()) != try_block_info.end());
309 if (is_try_block || MightHaveLiveNormalPredecessors(catch_block)) {
Vladimir Marko69d310e2017-10-09 14:12:23 +0100310 HBasicBlock* new_catch_block = new (allocator_) HBasicBlock(graph_, address);
311 new_catch_block->AddInstruction(new (allocator_) HGoto(address));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000312 new_catch_block->AddSuccessor(catch_block);
313 graph_->AddBlock(new_catch_block);
314 catch_block = new_catch_block;
315 }
316
317 catch_blocks.Put(address, catch_block);
318 catch_block->SetTryCatchInformation(
Vladimir Marko69d310e2017-10-09 14:12:23 +0100319 new (allocator_) TryCatchInformation(iterator.GetHandlerTypeIndex(), *dex_file_));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000320 }
321 handlers_ptr = iterator.EndDataPointer();
322 }
323
324 // Do a pass over the try blocks and insert entering TryBoundaries where at
325 // least one predecessor is not covered by the same TryItem as the try block.
326 // We do not split each edge separately, but rather create one boundary block
327 // that all predecessors are relinked to. This preserves loop headers (b/23895756).
Vladimir Marko7d157fc2017-05-10 16:29:23 +0100328 for (const auto& entry : try_block_info) {
329 uint32_t block_id = entry.first;
330 const DexFile::TryItem* try_item = entry.second;
331 HBasicBlock* try_block = graph_->GetBlocks()[block_id];
David Brazdil86ea7ee2016-02-16 09:26:07 +0000332 for (HBasicBlock* predecessor : try_block->GetPredecessors()) {
Vladimir Marko7d157fc2017-05-10 16:29:23 +0100333 if (GetTryItem(predecessor, try_block_info) != try_item) {
David Brazdil86ea7ee2016-02-16 09:26:07 +0000334 // Found a predecessor not covered by the same TryItem. Insert entering
335 // boundary block.
Vladimir Marko69d310e2017-10-09 14:12:23 +0100336 HTryBoundary* try_entry = new (allocator_) HTryBoundary(
337 HTryBoundary::BoundaryKind::kEntry, try_block->GetDexPc());
David Brazdil86ea7ee2016-02-16 09:26:07 +0000338 try_block->CreateImmediateDominator()->AddInstruction(try_entry);
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000339 LinkToCatchBlocks(try_entry, *code_item_, try_item, catch_blocks);
David Brazdil86ea7ee2016-02-16 09:26:07 +0000340 break;
341 }
342 }
343 }
344
345 // Do a second pass over the try blocks and insert exit TryBoundaries where
346 // the successor is not in the same TryItem.
Vladimir Marko7d157fc2017-05-10 16:29:23 +0100347 for (const auto& entry : try_block_info) {
348 uint32_t block_id = entry.first;
349 const DexFile::TryItem* try_item = entry.second;
350 HBasicBlock* try_block = graph_->GetBlocks()[block_id];
David Brazdil86ea7ee2016-02-16 09:26:07 +0000351 // NOTE: Do not use iterators because SplitEdge would invalidate them.
352 for (size_t i = 0, e = try_block->GetSuccessors().size(); i < e; ++i) {
353 HBasicBlock* successor = try_block->GetSuccessors()[i];
354
355 // If the successor is a try block, all of its predecessors must be
356 // covered by the same TryItem. Otherwise the previous pass would have
357 // created a non-throwing boundary block.
358 if (GetTryItem(successor, try_block_info) != nullptr) {
Vladimir Marko7d157fc2017-05-10 16:29:23 +0100359 DCHECK_EQ(try_item, GetTryItem(successor, try_block_info));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000360 continue;
361 }
362
363 // Insert TryBoundary and link to catch blocks.
364 HTryBoundary* try_exit =
Vladimir Marko69d310e2017-10-09 14:12:23 +0100365 new (allocator_) HTryBoundary(HTryBoundary::BoundaryKind::kExit, successor->GetDexPc());
David Brazdil86ea7ee2016-02-16 09:26:07 +0000366 graph_->SplitEdge(try_block, successor)->AddInstruction(try_exit);
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000367 LinkToCatchBlocks(try_exit, *code_item_, try_item, catch_blocks);
David Brazdil86ea7ee2016-02-16 09:26:07 +0000368 }
369 }
370}
371
372bool HBasicBlockBuilder::Build() {
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000373 DCHECK(code_item_ != nullptr);
David Brazdil86ea7ee2016-02-16 09:26:07 +0000374 DCHECK(graph_->GetBlocks().empty());
375
Vladimir Marko69d310e2017-10-09 14:12:23 +0100376 graph_->SetEntryBlock(new (allocator_) HBasicBlock(graph_, kNoDexPc));
377 graph_->SetExitBlock(new (allocator_) HBasicBlock(graph_, kNoDexPc));
David Brazdil86ea7ee2016-02-16 09:26:07 +0000378
379 // TODO(dbrazdil): Do CreateBranchTargets and ConnectBasicBlocks in one pass.
380 if (!CreateBranchTargets()) {
381 return false;
382 }
383
384 ConnectBasicBlocks();
385 InsertTryBoundaryBlocks();
386
387 return true;
388}
389
Vladimir Marko92f7f3c2017-10-31 11:38:30 +0000390void HBasicBlockBuilder::BuildIntrinsic() {
391 DCHECK(code_item_ == nullptr);
392 DCHECK(graph_->GetBlocks().empty());
393
394 // Create blocks.
395 HBasicBlock* entry_block = new (allocator_) HBasicBlock(graph_, kNoDexPc);
396 HBasicBlock* exit_block = new (allocator_) HBasicBlock(graph_, kNoDexPc);
397 HBasicBlock* body = MaybeCreateBlockAt(/* semantic_dex_pc */ kNoDexPc, /* store_dex_pc */ 0u);
398
399 // Add blocks to the graph.
400 graph_->AddBlock(entry_block);
401 graph_->AddBlock(body);
402 graph_->AddBlock(exit_block);
403 graph_->SetEntryBlock(entry_block);
404 graph_->SetExitBlock(exit_block);
405
406 // Connect blocks.
407 entry_block->AddSuccessor(body);
408 body->AddSuccessor(exit_block);
409}
410
Mathieu Chartierde4b08f2017-07-10 14:13:41 -0700411size_t HBasicBlockBuilder::GetQuickenIndex(uint32_t dex_pc) const {
412 return quicken_index_for_dex_pc_.Get(dex_pc);
413}
414
David Brazdil86ea7ee2016-02-16 09:26:07 +0000415} // namespace art