blob: a31ea29ae124ac784f8c9c06131bc16cf3983ab8 [file] [log] [blame]
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001/*
Nicolas Geoffray818f2102014-02-18 16:43:35 +00002 * Copyright (C) 2014 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
Nicolas Geoffraye5038322014-07-04 09:41:32 +010017#include "builder.h"
18
19#include "class_linker.h"
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000020#include "dex_file.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000021#include "dex_file-inl.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000022#include "dex_instruction.h"
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000023#include "dex_instruction-inl.h"
Nicolas Geoffraye5038322014-07-04 09:41:32 +010024#include "driver/compiler_driver-inl.h"
25#include "mirror/art_field.h"
26#include "mirror/art_field-inl.h"
27#include "mirror/class_loader.h"
28#include "mirror/dex_cache.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000029#include "nodes.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000030#include "primitive.h"
Nicolas Geoffraye5038322014-07-04 09:41:32 +010031#include "scoped_thread_state_change.h"
32#include "thread.h"
Nicolas Geoffray818f2102014-02-18 16:43:35 +000033
34namespace art {
35
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +010036/**
37 * Helper class to add HTemporary instructions. This class is used when
38 * converting a DEX instruction to multiple HInstruction, and where those
39 * instructions do not die at the following instruction, but instead spans
40 * multiple instructions.
41 */
42class Temporaries : public ValueObject {
43 public:
44 Temporaries(HGraph* graph, size_t count) : graph_(graph), count_(count), index_(0) {
45 graph_->UpdateNumberOfTemporaries(count_);
46 }
47
48 void Add(HInstruction* instruction) {
49 // We currently only support vreg size temps.
50 DCHECK(instruction->GetType() != Primitive::kPrimLong
51 && instruction->GetType() != Primitive::kPrimDouble);
52 HInstruction* temp = new (graph_->GetArena()) HTemporary(index_++);
53 instruction->GetBlock()->AddInstruction(temp);
54 DCHECK(temp->GetPrevious() == instruction);
55 }
56
57 private:
58 HGraph* const graph_;
59
60 // The total number of temporaries that will be used.
61 const size_t count_;
62
63 // Current index in the temporary stack, updated by `Add`.
64 size_t index_;
65};
66
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +010067static bool IsTypeSupported(Primitive::Type type) {
68 return type != Primitive::kPrimFloat && type != Primitive::kPrimDouble;
69}
70
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010071void HGraphBuilder::InitializeLocals(uint16_t count) {
72 graph_->SetNumberOfVRegs(count);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000073 locals_.SetSize(count);
74 for (int i = 0; i < count; i++) {
75 HLocal* local = new (arena_) HLocal(i);
76 entry_block_->AddInstruction(local);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000077 locals_.Put(i, local);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000078 }
79}
80
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010081bool HGraphBuilder::InitializeParameters(uint16_t number_of_parameters) {
82 // dex_compilation_unit_ is null only when unit testing.
83 if (dex_compilation_unit_ == nullptr) {
84 return true;
85 }
86
87 graph_->SetNumberOfInVRegs(number_of_parameters);
88 const char* shorty = dex_compilation_unit_->GetShorty();
89 int locals_index = locals_.Size() - number_of_parameters;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010090 int parameter_index = 0;
91
92 if (!dex_compilation_unit_->IsStatic()) {
93 // Add the implicit 'this' argument, not expressed in the signature.
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010094 HParameterValue* parameter =
95 new (arena_) HParameterValue(parameter_index++, Primitive::kPrimNot);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +010096 entry_block_->AddInstruction(parameter);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010097 HLocal* local = GetLocalAt(locals_index++);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +010098 entry_block_->AddInstruction(new (arena_) HStoreLocal(local, parameter));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010099 number_of_parameters--;
100 }
101
102 uint32_t pos = 1;
103 for (int i = 0; i < number_of_parameters; i++) {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100104 HParameterValue* parameter =
105 new (arena_) HParameterValue(parameter_index++, Primitive::GetType(shorty[pos++]));
106 entry_block_->AddInstruction(parameter);
107 HLocal* local = GetLocalAt(locals_index++);
108 // Store the parameter value in the local that the dex code will use
109 // to reference that parameter.
110 entry_block_->AddInstruction(new (arena_) HStoreLocal(local, parameter));
111 bool is_wide = (parameter->GetType() == Primitive::kPrimLong)
112 || (parameter->GetType() == Primitive::kPrimDouble);
113 if (is_wide) {
114 i++;
115 locals_index++;
116 parameter_index++;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100117 }
118 }
119 return true;
120}
121
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100122template<typename T>
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100123void HGraphBuilder::If_22t(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000124 int32_t target_offset = instruction.GetTargetOffset();
125 PotentiallyAddSuspendCheck(target_offset, dex_offset);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100126 HInstruction* first = LoadLocal(instruction.VRegA(), Primitive::kPrimInt);
127 HInstruction* second = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
Dave Allison20dfc792014-06-16 20:44:29 -0700128 T* comparison = new (arena_) T(first, second);
129 current_block_->AddInstruction(comparison);
130 HInstruction* ifinst = new (arena_) HIf(comparison);
131 current_block_->AddInstruction(ifinst);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000132 HBasicBlock* target = FindBlockStartingAt(dex_offset + target_offset);
Dave Allison20dfc792014-06-16 20:44:29 -0700133 DCHECK(target != nullptr);
134 current_block_->AddSuccessor(target);
135 target = FindBlockStartingAt(dex_offset + instruction.SizeInCodeUnits());
136 DCHECK(target != nullptr);
137 current_block_->AddSuccessor(target);
138 current_block_ = nullptr;
139}
140
141template<typename T>
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100142void HGraphBuilder::If_21t(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000143 int32_t target_offset = instruction.GetTargetOffset();
144 PotentiallyAddSuspendCheck(target_offset, dex_offset);
Dave Allison20dfc792014-06-16 20:44:29 -0700145 HInstruction* value = LoadLocal(instruction.VRegA(), Primitive::kPrimInt);
146 T* comparison = new (arena_) T(value, GetIntConstant(0));
147 current_block_->AddInstruction(comparison);
148 HInstruction* ifinst = new (arena_) HIf(comparison);
149 current_block_->AddInstruction(ifinst);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000150 HBasicBlock* target = FindBlockStartingAt(dex_offset + target_offset);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100151 DCHECK(target != nullptr);
152 current_block_->AddSuccessor(target);
153 target = FindBlockStartingAt(dex_offset + instruction.SizeInCodeUnits());
154 DCHECK(target != nullptr);
155 current_block_->AddSuccessor(target);
156 current_block_ = nullptr;
157}
158
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000159HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000160 const uint16_t* code_ptr = code_item.insns_;
161 const uint16_t* code_end = code_item.insns_ + code_item.insns_size_in_code_units_;
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100162 code_start_ = code_ptr;
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000163
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000164 // Setup the graph with the entry block and exit block.
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000165 graph_ = new (arena_) HGraph(arena_);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100166 entry_block_ = new (arena_) HBasicBlock(graph_, 0);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000167 graph_->AddBlock(entry_block_);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100168 exit_block_ = new (arena_) HBasicBlock(graph_, kNoDexPc);
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000169 graph_->SetEntryBlock(entry_block_);
170 graph_->SetExitBlock(exit_block_);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000171
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000172 InitializeLocals(code_item.registers_size_);
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100173 graph_->UpdateMaximumNumberOfOutVRegs(code_item.outs_size_);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000174
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000175 // To avoid splitting blocks, we compute ahead of time the instructions that
176 // start a new block, and create these blocks.
177 ComputeBranchTargets(code_ptr, code_end);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000178
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000179 // Also create blocks for catch handlers.
180 if (code_item.tries_size_ != 0) {
181 const uint8_t* handlers_ptr = DexFile::GetCatchHandlerData(code_item, 0);
182 uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr);
183 for (uint32_t idx = 0; idx < handlers_size; ++idx) {
184 CatchHandlerIterator iterator(handlers_ptr);
185 for (; iterator.HasNext(); iterator.Next()) {
186 uint32_t address = iterator.GetHandlerAddress();
187 HBasicBlock* block = FindBlockStartingAt(address);
188 if (block == nullptr) {
189 block = new (arena_) HBasicBlock(graph_, address);
190 branch_targets_.Put(address, block);
191 }
192 block->SetIsCatchBlock();
193 }
194 handlers_ptr = iterator.EndDataPointer();
195 }
196 }
197
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100198 if (!InitializeParameters(code_item.ins_size_)) {
199 return nullptr;
200 }
201
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000202 size_t dex_offset = 0;
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000203 while (code_ptr < code_end) {
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000204 // Update the current block if dex_offset starts a new block.
205 MaybeUpdateCurrentBlock(dex_offset);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000206 const Instruction& instruction = *Instruction::At(code_ptr);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000207 if (!AnalyzeDexInstruction(instruction, dex_offset)) return nullptr;
208 dex_offset += instruction.SizeInCodeUnits();
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000209 code_ptr += instruction.SizeInCodeUnits();
210 }
211
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000212 // Add the exit block at the end to give it the highest id.
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000213 graph_->AddBlock(exit_block_);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000214 exit_block_->AddInstruction(new (arena_) HExit());
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000215 // Add the suspend check to the entry block.
216 entry_block_->AddInstruction(new (arena_) HSuspendCheck(0));
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000217 entry_block_->AddInstruction(new (arena_) HGoto());
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000218 return graph_;
219}
220
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000221void HGraphBuilder::MaybeUpdateCurrentBlock(size_t index) {
222 HBasicBlock* block = FindBlockStartingAt(index);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000223 if (block == nullptr) {
224 return;
225 }
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000226
227 if (current_block_ != nullptr) {
228 // Branching instructions clear current_block, so we know
229 // the last instruction of the current block is not a branching
230 // instruction. We add an unconditional goto to the found block.
231 current_block_->AddInstruction(new (arena_) HGoto());
232 current_block_->AddSuccessor(block);
233 }
234 graph_->AddBlock(block);
235 current_block_ = block;
236}
237
238void HGraphBuilder::ComputeBranchTargets(const uint16_t* code_ptr, const uint16_t* code_end) {
239 // TODO: Support switch instructions.
240 branch_targets_.SetSize(code_end - code_ptr);
241
242 // Create the first block for the dex instructions, single successor of the entry block.
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100243 HBasicBlock* block = new (arena_) HBasicBlock(graph_, 0);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000244 branch_targets_.Put(0, block);
245 entry_block_->AddSuccessor(block);
246
247 // Iterate over all instructions and find branching instructions. Create blocks for
248 // the locations these instructions branch to.
249 size_t dex_offset = 0;
250 while (code_ptr < code_end) {
251 const Instruction& instruction = *Instruction::At(code_ptr);
252 if (instruction.IsBranch()) {
253 int32_t target = instruction.GetTargetOffset() + dex_offset;
254 // Create a block for the target instruction.
255 if (FindBlockStartingAt(target) == nullptr) {
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100256 block = new (arena_) HBasicBlock(graph_, target);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000257 branch_targets_.Put(target, block);
258 }
259 dex_offset += instruction.SizeInCodeUnits();
260 code_ptr += instruction.SizeInCodeUnits();
261 if ((code_ptr < code_end) && (FindBlockStartingAt(dex_offset) == nullptr)) {
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100262 block = new (arena_) HBasicBlock(graph_, dex_offset);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000263 branch_targets_.Put(dex_offset, block);
264 }
265 } else {
266 code_ptr += instruction.SizeInCodeUnits();
267 dex_offset += instruction.SizeInCodeUnits();
268 }
269 }
270}
271
272HBasicBlock* HGraphBuilder::FindBlockStartingAt(int32_t index) const {
273 DCHECK_GE(index, 0);
274 return branch_targets_.Get(index);
275}
276
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100277template<typename T>
Roland Levillain88cb1752014-10-20 16:36:47 +0100278void HGraphBuilder::Unop_12x(const Instruction& instruction, Primitive::Type type) {
279 HInstruction* first = LoadLocal(instruction.VRegB(), type);
280 current_block_->AddInstruction(new (arena_) T(type, first));
281 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
282}
283
Roland Levillaindff1f282014-11-05 14:15:05 +0000284void HGraphBuilder::Conversion_12x(const Instruction& instruction,
285 Primitive::Type input_type,
286 Primitive::Type result_type) {
287 HInstruction* first = LoadLocal(instruction.VRegB(), input_type);
288 current_block_->AddInstruction(new (arena_) HTypeConversion(result_type, first));
289 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
290}
291
Roland Levillain88cb1752014-10-20 16:36:47 +0100292template<typename T>
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100293void HGraphBuilder::Binop_23x(const Instruction& instruction, Primitive::Type type) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100294 HInstruction* first = LoadLocal(instruction.VRegB(), type);
295 HInstruction* second = LoadLocal(instruction.VRegC(), type);
296 current_block_->AddInstruction(new (arena_) T(type, first, second));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100297 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
298}
299
300template<typename T>
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100301void HGraphBuilder::Binop_12x(const Instruction& instruction, Primitive::Type type) {
302 HInstruction* first = LoadLocal(instruction.VRegA(), type);
303 HInstruction* second = LoadLocal(instruction.VRegB(), type);
304 current_block_->AddInstruction(new (arena_) T(type, first, second));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100305 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
306}
307
308template<typename T>
309void HGraphBuilder::Binop_22s(const Instruction& instruction, bool reverse) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100310 HInstruction* first = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
311 HInstruction* second = GetIntConstant(instruction.VRegC_22s());
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100312 if (reverse) {
313 std::swap(first, second);
314 }
315 current_block_->AddInstruction(new (arena_) T(Primitive::kPrimInt, first, second));
316 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
317}
318
319template<typename T>
320void HGraphBuilder::Binop_22b(const Instruction& instruction, bool reverse) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100321 HInstruction* first = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
322 HInstruction* second = GetIntConstant(instruction.VRegC_22b());
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100323 if (reverse) {
324 std::swap(first, second);
325 }
326 current_block_->AddInstruction(new (arena_) T(Primitive::kPrimInt, first, second));
327 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
328}
329
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100330void HGraphBuilder::BuildReturn(const Instruction& instruction, Primitive::Type type) {
331 if (type == Primitive::kPrimVoid) {
332 current_block_->AddInstruction(new (arena_) HReturnVoid());
333 } else {
334 HInstruction* value = LoadLocal(instruction.VRegA(), type);
335 current_block_->AddInstruction(new (arena_) HReturn(value));
336 }
337 current_block_->AddSuccessor(exit_block_);
338 current_block_ = nullptr;
339}
340
341bool HGraphBuilder::BuildInvoke(const Instruction& instruction,
342 uint32_t dex_offset,
343 uint32_t method_idx,
344 uint32_t number_of_vreg_arguments,
345 bool is_range,
346 uint32_t* args,
347 uint32_t register_index) {
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100348 Instruction::Code opcode = instruction.Opcode();
349 InvokeType invoke_type;
350 switch (opcode) {
351 case Instruction::INVOKE_STATIC:
352 case Instruction::INVOKE_STATIC_RANGE:
353 invoke_type = kStatic;
354 break;
355 case Instruction::INVOKE_DIRECT:
356 case Instruction::INVOKE_DIRECT_RANGE:
357 invoke_type = kDirect;
358 break;
359 case Instruction::INVOKE_VIRTUAL:
360 case Instruction::INVOKE_VIRTUAL_RANGE:
361 invoke_type = kVirtual;
362 break;
363 case Instruction::INVOKE_INTERFACE:
364 case Instruction::INVOKE_INTERFACE_RANGE:
365 invoke_type = kInterface;
366 break;
367 case Instruction::INVOKE_SUPER_RANGE:
368 case Instruction::INVOKE_SUPER:
369 invoke_type = kSuper;
370 break;
371 default:
372 LOG(FATAL) << "Unexpected invoke op: " << opcode;
373 return false;
374 }
375
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100376 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
377 const DexFile::ProtoId& proto_id = dex_file_->GetProtoId(method_id.proto_idx_);
378 const char* descriptor = dex_file_->StringDataByIdx(proto_id.shorty_idx_);
379 Primitive::Type return_type = Primitive::GetType(descriptor[0]);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100380 bool is_instance_call = invoke_type != kStatic;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100381 const size_t number_of_arguments = strlen(descriptor) - (is_instance_call ? 0 : 1);
382
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100383 HInvoke* invoke = nullptr;
384 if (invoke_type == kVirtual) {
385 MethodReference target_method(dex_file_, method_idx);
386 uintptr_t direct_code;
387 uintptr_t direct_method;
388 int vtable_index;
389 // TODO: Add devirtualization support.
390 compiler_driver_->ComputeInvokeInfo(dex_compilation_unit_, dex_offset, true, true,
391 &invoke_type, &target_method, &vtable_index,
392 &direct_code, &direct_method);
393 if (vtable_index == -1) {
394 return false;
395 }
396 invoke = new (arena_) HInvokeVirtual(
397 arena_, number_of_arguments, return_type, dex_offset, vtable_index);
398 } else {
399 // Treat invoke-direct like static calls for now.
400 invoke = new (arena_) HInvokeStatic(
401 arena_, number_of_arguments, return_type, dex_offset, method_idx);
402 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100403
404 size_t start_index = 0;
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100405 Temporaries temps(graph_, is_instance_call ? 1 : 0);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100406 if (is_instance_call) {
407 HInstruction* arg = LoadLocal(is_range ? register_index : args[0], Primitive::kPrimNot);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100408 HNullCheck* null_check = new (arena_) HNullCheck(arg, dex_offset);
409 current_block_->AddInstruction(null_check);
410 temps.Add(null_check);
411 invoke->SetArgumentAt(0, null_check);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100412 start_index = 1;
413 }
414
415 uint32_t descriptor_index = 1;
416 uint32_t argument_index = start_index;
417 for (size_t i = start_index; i < number_of_vreg_arguments; i++, argument_index++) {
418 Primitive::Type type = Primitive::GetType(descriptor[descriptor_index++]);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100419 bool is_wide = (type == Primitive::kPrimLong) || (type == Primitive::kPrimDouble);
420 if (!is_range && is_wide && args[i] + 1 != args[i + 1]) {
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100421 LOG(WARNING) << "Non sequential register pair in " << dex_compilation_unit_->GetSymbol()
422 << " at " << dex_offset;
423 // We do not implement non sequential register pair.
424 return false;
425 }
426 HInstruction* arg = LoadLocal(is_range ? register_index + i : args[i], type);
427 invoke->SetArgumentAt(argument_index, arg);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100428 if (is_wide) {
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100429 i++;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100430 }
431 }
432
433 DCHECK_EQ(argument_index, number_of_arguments);
434 current_block_->AddInstruction(invoke);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100435 latest_result_ = invoke;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100436 return true;
437}
438
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100439bool HGraphBuilder::BuildInstanceFieldAccess(const Instruction& instruction,
440 uint32_t dex_offset,
441 bool is_put) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100442 uint32_t source_or_dest_reg = instruction.VRegA_22c();
443 uint32_t obj_reg = instruction.VRegB_22c();
444 uint16_t field_index = instruction.VRegC_22c();
445
446 ScopedObjectAccess soa(Thread::Current());
447 StackHandleScope<1> hs(soa.Self());
448 Handle<mirror::ArtField> resolved_field(hs.NewHandle(
449 compiler_driver_->ComputeInstanceFieldInfo(field_index, dex_compilation_unit_, is_put, soa)));
450
451 if (resolved_field.Get() == nullptr) {
452 return false;
453 }
454 if (resolved_field->IsVolatile()) {
455 return false;
456 }
457
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100458 Primitive::Type field_type = resolved_field->GetTypeAsPrimitiveType();
459 if (!IsTypeSupported(field_type)) {
460 return false;
461 }
462
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100463 HInstruction* object = LoadLocal(obj_reg, Primitive::kPrimNot);
464 current_block_->AddInstruction(new (arena_) HNullCheck(object, dex_offset));
465 if (is_put) {
466 Temporaries temps(graph_, 1);
467 HInstruction* null_check = current_block_->GetLastInstruction();
468 // We need one temporary for the null check.
469 temps.Add(null_check);
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100470 HInstruction* value = LoadLocal(source_or_dest_reg, field_type);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100471 current_block_->AddInstruction(new (arena_) HInstanceFieldSet(
472 null_check,
473 value,
Nicolas Geoffray39468442014-09-02 15:17:15 +0100474 field_type,
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100475 resolved_field->GetOffset()));
476 } else {
477 current_block_->AddInstruction(new (arena_) HInstanceFieldGet(
478 current_block_->GetLastInstruction(),
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100479 field_type,
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100480 resolved_field->GetOffset()));
481
482 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
483 }
484 return true;
485}
486
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100487
488
489bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction,
490 uint32_t dex_offset,
491 bool is_put) {
492 uint32_t source_or_dest_reg = instruction.VRegA_21c();
493 uint16_t field_index = instruction.VRegB_21c();
494
495 uint32_t storage_index;
496 bool is_referrers_class;
497 bool is_initialized;
498 bool is_volatile;
499 MemberOffset field_offset(0u);
500 Primitive::Type field_type;
501
502 bool fast_path = compiler_driver_->ComputeStaticFieldInfo(field_index,
503 dex_compilation_unit_,
504 is_put,
505 &field_offset,
506 &storage_index,
507 &is_referrers_class,
508 &is_volatile,
509 &is_initialized,
510 &field_type);
511 if (!fast_path) {
512 return false;
513 }
514
515 if (is_volatile) {
516 return false;
517 }
518
519 if (!IsTypeSupported(field_type)) {
520 return false;
521 }
522
523 HLoadClass* constant = new (arena_) HLoadClass(
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000524 storage_index, is_referrers_class, dex_offset);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100525 current_block_->AddInstruction(constant);
526
527 HInstruction* cls = constant;
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000528 if (!is_initialized) {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100529 cls = new (arena_) HClinitCheck(constant, dex_offset);
530 current_block_->AddInstruction(cls);
531 }
532
533 if (is_put) {
534 // We need to keep the class alive before loading the value.
535 Temporaries temps(graph_, 1);
536 temps.Add(cls);
537 HInstruction* value = LoadLocal(source_or_dest_reg, field_type);
538 DCHECK_EQ(value->GetType(), field_type);
539 current_block_->AddInstruction(
540 new (arena_) HStaticFieldSet(cls, value, field_type, field_offset));
541 } else {
542 current_block_->AddInstruction(new (arena_) HStaticFieldGet(cls, field_type, field_offset));
543 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
544 }
545 return true;
546}
547
Calin Juravle865fc882014-11-06 17:09:03 +0000548void HGraphBuilder::BuildCheckedDiv(uint16_t out_reg,
549 uint16_t first_reg,
550 uint16_t second_reg,
Calin Juravled0d48522014-11-04 16:40:20 +0000551 uint32_t dex_offset,
552 Primitive::Type type,
553 bool second_is_lit) {
554 DCHECK(type == Primitive::kPrimInt);
555
Calin Juravle865fc882014-11-06 17:09:03 +0000556 HInstruction* first = LoadLocal(first_reg, type);
557 HInstruction* second = second_is_lit ? GetIntConstant(second_reg) : LoadLocal(second_reg, type);
Calin Juravled0d48522014-11-04 16:40:20 +0000558 if (!second->IsIntConstant() || (second->AsIntConstant()->GetValue() == 0)) {
559 second = new (arena_) HDivZeroCheck(second, dex_offset);
560 Temporaries temps(graph_, 1);
561 current_block_->AddInstruction(second);
562 temps.Add(current_block_->GetLastInstruction());
563 }
564
565 current_block_->AddInstruction(new (arena_) HDiv(type, first, second));
Calin Juravle865fc882014-11-06 17:09:03 +0000566 UpdateLocal(out_reg, current_block_->GetLastInstruction());
Calin Juravled0d48522014-11-04 16:40:20 +0000567}
568
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100569void HGraphBuilder::BuildArrayAccess(const Instruction& instruction,
570 uint32_t dex_offset,
571 bool is_put,
572 Primitive::Type anticipated_type) {
573 uint8_t source_or_dest_reg = instruction.VRegA_23x();
574 uint8_t array_reg = instruction.VRegB_23x();
575 uint8_t index_reg = instruction.VRegC_23x();
576
577 DCHECK(IsTypeSupported(anticipated_type));
578
579 // We need one temporary for the null check, one for the index, and one for the length.
580 Temporaries temps(graph_, 3);
581
582 HInstruction* object = LoadLocal(array_reg, Primitive::kPrimNot);
583 object = new (arena_) HNullCheck(object, dex_offset);
584 current_block_->AddInstruction(object);
585 temps.Add(object);
586
587 HInstruction* length = new (arena_) HArrayLength(object);
588 current_block_->AddInstruction(length);
589 temps.Add(length);
590 HInstruction* index = LoadLocal(index_reg, Primitive::kPrimInt);
591 index = new (arena_) HBoundsCheck(index, length, dex_offset);
592 current_block_->AddInstruction(index);
593 temps.Add(index);
594 if (is_put) {
595 HInstruction* value = LoadLocal(source_or_dest_reg, anticipated_type);
596 // TODO: Insert a type check node if the type is Object.
Nicolas Geoffray39468442014-09-02 15:17:15 +0100597 current_block_->AddInstruction(new (arena_) HArraySet(
598 object, index, value, anticipated_type, dex_offset));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100599 } else {
600 current_block_->AddInstruction(new (arena_) HArrayGet(object, index, anticipated_type));
601 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
602 }
603}
604
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100605void HGraphBuilder::BuildFilledNewArray(uint32_t dex_offset,
606 uint32_t type_index,
607 uint32_t number_of_vreg_arguments,
608 bool is_range,
609 uint32_t* args,
610 uint32_t register_index) {
611 HInstruction* length = GetIntConstant(number_of_vreg_arguments);
612 HInstruction* object = new (arena_) HNewArray(length, dex_offset, type_index);
613 current_block_->AddInstruction(object);
614
615 const char* descriptor = dex_file_->StringByTypeIdx(type_index);
616 DCHECK_EQ(descriptor[0], '[') << descriptor;
617 char primitive = descriptor[1];
618 DCHECK(primitive == 'I'
619 || primitive == 'L'
620 || primitive == '[') << descriptor;
621 bool is_reference_array = (primitive == 'L') || (primitive == '[');
622 Primitive::Type type = is_reference_array ? Primitive::kPrimNot : Primitive::kPrimInt;
623
624 Temporaries temps(graph_, 1);
625 temps.Add(object);
626 for (size_t i = 0; i < number_of_vreg_arguments; ++i) {
627 HInstruction* value = LoadLocal(is_range ? register_index + i : args[i], type);
628 HInstruction* index = GetIntConstant(i);
629 current_block_->AddInstruction(
630 new (arena_) HArraySet(object, index, value, type, dex_offset));
631 }
632 latest_result_ = object;
633}
634
635template <typename T>
636void HGraphBuilder::BuildFillArrayData(HInstruction* object,
637 const T* data,
638 uint32_t element_count,
639 Primitive::Type anticipated_type,
640 uint32_t dex_offset) {
641 for (uint32_t i = 0; i < element_count; ++i) {
642 HInstruction* index = GetIntConstant(i);
643 HInstruction* value = GetIntConstant(data[i]);
644 current_block_->AddInstruction(new (arena_) HArraySet(
645 object, index, value, anticipated_type, dex_offset));
646 }
647}
648
Calin Juravled0d48522014-11-04 16:40:20 +0000649void HGraphBuilder::BuildFillArrayData(const Instruction& instruction, uint32_t dex_offset) {
650 Temporaries temps(graph_, 1);
651 HInstruction* array = LoadLocal(instruction.VRegA_31t(), Primitive::kPrimNot);
652 HNullCheck* null_check = new (arena_) HNullCheck(array, dex_offset);
653 current_block_->AddInstruction(null_check);
654 temps.Add(null_check);
655
656 HInstruction* length = new (arena_) HArrayLength(null_check);
657 current_block_->AddInstruction(length);
658
659 int32_t payload_offset = instruction.VRegB_31t() + dex_offset;
660 const Instruction::ArrayDataPayload* payload =
661 reinterpret_cast<const Instruction::ArrayDataPayload*>(code_start_ + payload_offset);
662 const uint8_t* data = payload->data;
663 uint32_t element_count = payload->element_count;
664
665 // Implementation of this DEX instruction seems to be that the bounds check is
666 // done before doing any stores.
667 HInstruction* last_index = GetIntConstant(payload->element_count - 1);
668 current_block_->AddInstruction(new (arena_) HBoundsCheck(last_index, length, dex_offset));
669
670 switch (payload->element_width) {
671 case 1:
672 BuildFillArrayData(null_check,
673 reinterpret_cast<const int8_t*>(data),
674 element_count,
675 Primitive::kPrimByte,
676 dex_offset);
677 break;
678 case 2:
679 BuildFillArrayData(null_check,
680 reinterpret_cast<const int16_t*>(data),
681 element_count,
682 Primitive::kPrimShort,
683 dex_offset);
684 break;
685 case 4:
686 BuildFillArrayData(null_check,
687 reinterpret_cast<const int32_t*>(data),
688 element_count,
689 Primitive::kPrimInt,
690 dex_offset);
691 break;
692 case 8:
693 BuildFillWideArrayData(null_check,
694 reinterpret_cast<const int64_t*>(data),
695 element_count,
696 dex_offset);
697 break;
698 default:
699 LOG(FATAL) << "Unknown element width for " << payload->element_width;
700 }
701}
702
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100703void HGraphBuilder::BuildFillWideArrayData(HInstruction* object,
Nicolas Geoffray8d6ae522014-10-23 18:32:13 +0100704 const int64_t* data,
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100705 uint32_t element_count,
706 uint32_t dex_offset) {
707 for (uint32_t i = 0; i < element_count; ++i) {
708 HInstruction* index = GetIntConstant(i);
709 HInstruction* value = GetLongConstant(data[i]);
710 current_block_->AddInstruction(new (arena_) HArraySet(
711 object, index, value, Primitive::kPrimLong, dex_offset));
712 }
713}
714
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000715void HGraphBuilder::PotentiallyAddSuspendCheck(int32_t target_offset, uint32_t dex_offset) {
716 if (target_offset <= 0) {
717 // Unconditionnally add a suspend check to backward branches. We can remove
718 // them after we recognize loops in the graph.
719 current_block_->AddInstruction(new (arena_) HSuspendCheck(dex_offset));
720 }
721}
722
723bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000724 if (current_block_ == nullptr) {
725 return true; // Dead code
726 }
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000727
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000728 switch (instruction.Opcode()) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000729 case Instruction::CONST_4: {
730 int32_t register_index = instruction.VRegA();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100731 HIntConstant* constant = GetIntConstant(instruction.VRegB_11n());
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000732 UpdateLocal(register_index, constant);
733 break;
734 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000735
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100736 case Instruction::CONST_16: {
737 int32_t register_index = instruction.VRegA();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100738 HIntConstant* constant = GetIntConstant(instruction.VRegB_21s());
739 UpdateLocal(register_index, constant);
740 break;
741 }
742
Dave Allison20dfc792014-06-16 20:44:29 -0700743 case Instruction::CONST: {
744 int32_t register_index = instruction.VRegA();
745 HIntConstant* constant = GetIntConstant(instruction.VRegB_31i());
746 UpdateLocal(register_index, constant);
747 break;
748 }
749
750 case Instruction::CONST_HIGH16: {
751 int32_t register_index = instruction.VRegA();
752 HIntConstant* constant = GetIntConstant(instruction.VRegB_21h() << 16);
753 UpdateLocal(register_index, constant);
754 break;
755 }
756
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100757 case Instruction::CONST_WIDE_16: {
758 int32_t register_index = instruction.VRegA();
Dave Allison20dfc792014-06-16 20:44:29 -0700759 // Get 16 bits of constant value, sign extended to 64 bits.
760 int64_t value = instruction.VRegB_21s();
761 value <<= 48;
762 value >>= 48;
763 HLongConstant* constant = GetLongConstant(value);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100764 UpdateLocal(register_index, constant);
765 break;
766 }
767
768 case Instruction::CONST_WIDE_32: {
769 int32_t register_index = instruction.VRegA();
Dave Allison20dfc792014-06-16 20:44:29 -0700770 // Get 32 bits of constant value, sign extended to 64 bits.
771 int64_t value = instruction.VRegB_31i();
772 value <<= 32;
773 value >>= 32;
774 HLongConstant* constant = GetLongConstant(value);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100775 UpdateLocal(register_index, constant);
776 break;
777 }
778
779 case Instruction::CONST_WIDE: {
780 int32_t register_index = instruction.VRegA();
781 HLongConstant* constant = GetLongConstant(instruction.VRegB_51l());
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100782 UpdateLocal(register_index, constant);
783 break;
784 }
785
Dave Allison20dfc792014-06-16 20:44:29 -0700786 case Instruction::CONST_WIDE_HIGH16: {
787 int32_t register_index = instruction.VRegA();
788 int64_t value = static_cast<int64_t>(instruction.VRegB_21h()) << 48;
789 HLongConstant* constant = GetLongConstant(value);
790 UpdateLocal(register_index, constant);
791 break;
792 }
793
794 // TODO: these instructions are also used to move floating point values, so what is
795 // the type (int or float)?
796 case Instruction::MOVE:
797 case Instruction::MOVE_FROM16:
798 case Instruction::MOVE_16: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100799 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100800 UpdateLocal(instruction.VRegA(), value);
801 break;
802 }
803
Dave Allison20dfc792014-06-16 20:44:29 -0700804 // TODO: these instructions are also used to move floating point values, so what is
805 // the type (long or double)?
806 case Instruction::MOVE_WIDE:
807 case Instruction::MOVE_WIDE_FROM16:
808 case Instruction::MOVE_WIDE_16: {
809 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimLong);
810 UpdateLocal(instruction.VRegA(), value);
811 break;
812 }
813
814 case Instruction::MOVE_OBJECT:
815 case Instruction::MOVE_OBJECT_16:
816 case Instruction::MOVE_OBJECT_FROM16: {
817 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimNot);
818 UpdateLocal(instruction.VRegA(), value);
819 break;
820 }
821
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000822 case Instruction::RETURN_VOID: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100823 BuildReturn(instruction, Primitive::kPrimVoid);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000824 break;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000825 }
826
Dave Allison20dfc792014-06-16 20:44:29 -0700827#define IF_XX(comparison, cond) \
828 case Instruction::IF_##cond: If_22t<comparison>(instruction, dex_offset); break; \
829 case Instruction::IF_##cond##Z: If_21t<comparison>(instruction, dex_offset); break
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100830
Dave Allison20dfc792014-06-16 20:44:29 -0700831 IF_XX(HEqual, EQ);
832 IF_XX(HNotEqual, NE);
833 IF_XX(HLessThan, LT);
834 IF_XX(HLessThanOrEqual, LE);
835 IF_XX(HGreaterThan, GT);
836 IF_XX(HGreaterThanOrEqual, GE);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000837
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000838 case Instruction::GOTO:
839 case Instruction::GOTO_16:
840 case Instruction::GOTO_32: {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000841 int32_t offset = instruction.GetTargetOffset();
842 PotentiallyAddSuspendCheck(offset, dex_offset);
843 HBasicBlock* target = FindBlockStartingAt(offset + dex_offset);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000844 DCHECK(target != nullptr);
845 current_block_->AddInstruction(new (arena_) HGoto());
846 current_block_->AddSuccessor(target);
847 current_block_ = nullptr;
848 break;
849 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000850
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100851 case Instruction::RETURN: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100852 DCHECK_NE(return_type_, Primitive::kPrimNot);
853 DCHECK_NE(return_type_, Primitive::kPrimLong);
854 DCHECK_NE(return_type_, Primitive::kPrimDouble);
855 BuildReturn(instruction, return_type_);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100856 break;
857 }
858
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100859 case Instruction::RETURN_OBJECT: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100860 DCHECK(return_type_ == Primitive::kPrimNot);
861 BuildReturn(instruction, return_type_);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100862 break;
863 }
864
865 case Instruction::RETURN_WIDE: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100866 DCHECK(return_type_ == Primitive::kPrimDouble || return_type_ == Primitive::kPrimLong);
867 BuildReturn(instruction, return_type_);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000868 break;
869 }
870
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +0100871 case Instruction::INVOKE_STATIC:
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100872 case Instruction::INVOKE_DIRECT:
873 case Instruction::INVOKE_VIRTUAL: {
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000874 uint32_t method_idx = instruction.VRegB_35c();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100875 uint32_t number_of_vreg_arguments = instruction.VRegA_35c();
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100876 uint32_t args[5];
Ian Rogers29a26482014-05-02 15:27:29 -0700877 instruction.GetVarArgs(args);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100878 if (!BuildInvoke(instruction, dex_offset, method_idx, number_of_vreg_arguments, false, args, -1)) {
879 return false;
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100880 }
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100881 break;
882 }
883
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +0100884 case Instruction::INVOKE_STATIC_RANGE:
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100885 case Instruction::INVOKE_DIRECT_RANGE:
886 case Instruction::INVOKE_VIRTUAL_RANGE: {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100887 uint32_t method_idx = instruction.VRegB_3rc();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100888 uint32_t number_of_vreg_arguments = instruction.VRegA_3rc();
889 uint32_t register_index = instruction.VRegC();
890 if (!BuildInvoke(instruction, dex_offset, method_idx,
891 number_of_vreg_arguments, true, nullptr, register_index)) {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100892 return false;
893 }
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000894 break;
895 }
896
Roland Levillain88cb1752014-10-20 16:36:47 +0100897 case Instruction::NEG_INT: {
898 Unop_12x<HNeg>(instruction, Primitive::kPrimInt);
899 break;
900 }
901
Roland Levillain2e07b4f2014-10-23 18:12:09 +0100902 case Instruction::NEG_LONG: {
903 Unop_12x<HNeg>(instruction, Primitive::kPrimLong);
904 break;
905 }
906
Roland Levillain3dbcb382014-10-28 17:30:07 +0000907 case Instruction::NEG_FLOAT: {
908 Unop_12x<HNeg>(instruction, Primitive::kPrimFloat);
909 break;
910 }
911
912 case Instruction::NEG_DOUBLE: {
913 Unop_12x<HNeg>(instruction, Primitive::kPrimDouble);
914 break;
915 }
916
Roland Levillain1cc5f2512014-10-22 18:06:21 +0100917 case Instruction::NOT_INT: {
918 Unop_12x<HNot>(instruction, Primitive::kPrimInt);
919 break;
920 }
921
Roland Levillain70566432014-10-24 16:20:17 +0100922 case Instruction::NOT_LONG: {
923 Unop_12x<HNot>(instruction, Primitive::kPrimLong);
924 break;
925 }
926
Roland Levillaindff1f282014-11-05 14:15:05 +0000927 case Instruction::INT_TO_LONG: {
928 Conversion_12x(instruction, Primitive::kPrimInt, Primitive::kPrimLong);
929 break;
930 }
931
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000932 case Instruction::ADD_INT: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100933 Binop_23x<HAdd>(instruction, Primitive::kPrimInt);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100934 break;
935 }
936
937 case Instruction::ADD_LONG: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100938 Binop_23x<HAdd>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100939 break;
940 }
941
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100942 case Instruction::ADD_DOUBLE: {
943 Binop_23x<HAdd>(instruction, Primitive::kPrimDouble);
944 break;
945 }
946
947 case Instruction::ADD_FLOAT: {
948 Binop_23x<HAdd>(instruction, Primitive::kPrimFloat);
949 break;
950 }
951
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100952 case Instruction::SUB_INT: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100953 Binop_23x<HSub>(instruction, Primitive::kPrimInt);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100954 break;
955 }
956
957 case Instruction::SUB_LONG: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100958 Binop_23x<HSub>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000959 break;
960 }
961
Calin Juravle096cc022014-10-23 17:01:13 +0100962 case Instruction::SUB_FLOAT: {
963 Binop_23x<HSub>(instruction, Primitive::kPrimFloat);
964 break;
965 }
966
967 case Instruction::SUB_DOUBLE: {
968 Binop_23x<HSub>(instruction, Primitive::kPrimDouble);
969 break;
970 }
971
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000972 case Instruction::ADD_INT_2ADDR: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100973 Binop_12x<HAdd>(instruction, Primitive::kPrimInt);
974 break;
975 }
976
Calin Juravle34bacdf2014-10-07 20:23:36 +0100977 case Instruction::MUL_INT: {
978 Binop_23x<HMul>(instruction, Primitive::kPrimInt);
979 break;
980 }
981
982 case Instruction::MUL_LONG: {
983 Binop_23x<HMul>(instruction, Primitive::kPrimLong);
984 break;
985 }
986
Calin Juravleb5bfa962014-10-21 18:02:24 +0100987 case Instruction::MUL_FLOAT: {
988 Binop_23x<HMul>(instruction, Primitive::kPrimFloat);
989 break;
990 }
991
992 case Instruction::MUL_DOUBLE: {
993 Binop_23x<HMul>(instruction, Primitive::kPrimDouble);
994 break;
995 }
996
Calin Juravled0d48522014-11-04 16:40:20 +0000997 case Instruction::DIV_INT: {
Calin Juravle865fc882014-11-06 17:09:03 +0000998 BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(),
999 dex_offset, Primitive::kPrimInt, false);
Calin Juravled0d48522014-11-04 16:40:20 +00001000 break;
1001 }
1002
Calin Juravle7c4954d2014-10-28 16:57:40 +00001003 case Instruction::DIV_FLOAT: {
1004 Binop_23x<HDiv>(instruction, Primitive::kPrimFloat);
1005 break;
1006 }
1007
1008 case Instruction::DIV_DOUBLE: {
1009 Binop_23x<HDiv>(instruction, Primitive::kPrimDouble);
1010 break;
1011 }
1012
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001013 case Instruction::ADD_LONG_2ADDR: {
1014 Binop_12x<HAdd>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001015 break;
1016 }
1017
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001018 case Instruction::ADD_DOUBLE_2ADDR: {
1019 Binop_12x<HAdd>(instruction, Primitive::kPrimDouble);
1020 break;
1021 }
1022
1023 case Instruction::ADD_FLOAT_2ADDR: {
1024 Binop_12x<HAdd>(instruction, Primitive::kPrimFloat);
1025 break;
1026 }
1027
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001028 case Instruction::SUB_INT_2ADDR: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001029 Binop_12x<HSub>(instruction, Primitive::kPrimInt);
1030 break;
1031 }
1032
1033 case Instruction::SUB_LONG_2ADDR: {
1034 Binop_12x<HSub>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001035 break;
1036 }
1037
Calin Juravle096cc022014-10-23 17:01:13 +01001038 case Instruction::SUB_FLOAT_2ADDR: {
1039 Binop_12x<HSub>(instruction, Primitive::kPrimFloat);
1040 break;
1041 }
1042
1043 case Instruction::SUB_DOUBLE_2ADDR: {
1044 Binop_12x<HSub>(instruction, Primitive::kPrimDouble);
1045 break;
1046 }
1047
Calin Juravle34bacdf2014-10-07 20:23:36 +01001048 case Instruction::MUL_INT_2ADDR: {
1049 Binop_12x<HMul>(instruction, Primitive::kPrimInt);
1050 break;
1051 }
1052
1053 case Instruction::MUL_LONG_2ADDR: {
1054 Binop_12x<HMul>(instruction, Primitive::kPrimLong);
1055 break;
1056 }
1057
Calin Juravleb5bfa962014-10-21 18:02:24 +01001058 case Instruction::MUL_FLOAT_2ADDR: {
1059 Binop_12x<HMul>(instruction, Primitive::kPrimFloat);
1060 break;
1061 }
1062
1063 case Instruction::MUL_DOUBLE_2ADDR: {
1064 Binop_12x<HMul>(instruction, Primitive::kPrimDouble);
1065 break;
1066 }
1067
Calin Juravle865fc882014-11-06 17:09:03 +00001068 case Instruction::DIV_INT_2ADDR: {
1069 BuildCheckedDiv(instruction.VRegA(), instruction.VRegA(), instruction.VRegB(),
1070 dex_offset, Primitive::kPrimInt, false);
1071 break;
1072 }
1073
Calin Juravle7c4954d2014-10-28 16:57:40 +00001074 case Instruction::DIV_FLOAT_2ADDR: {
1075 Binop_12x<HDiv>(instruction, Primitive::kPrimFloat);
1076 break;
1077 }
1078
1079 case Instruction::DIV_DOUBLE_2ADDR: {
1080 Binop_12x<HDiv>(instruction, Primitive::kPrimDouble);
1081 break;
1082 }
1083
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001084 case Instruction::ADD_INT_LIT16: {
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001085 Binop_22s<HAdd>(instruction, false);
1086 break;
1087 }
1088
1089 case Instruction::RSUB_INT: {
1090 Binop_22s<HSub>(instruction, true);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001091 break;
1092 }
1093
Calin Juravle34bacdf2014-10-07 20:23:36 +01001094 case Instruction::MUL_INT_LIT16: {
1095 Binop_22s<HMul>(instruction, false);
1096 break;
1097 }
1098
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001099 case Instruction::ADD_INT_LIT8: {
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001100 Binop_22b<HAdd>(instruction, false);
1101 break;
1102 }
1103
1104 case Instruction::RSUB_INT_LIT8: {
1105 Binop_22b<HSub>(instruction, true);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001106 break;
1107 }
1108
Calin Juravle34bacdf2014-10-07 20:23:36 +01001109 case Instruction::MUL_INT_LIT8: {
1110 Binop_22b<HMul>(instruction, false);
1111 break;
1112 }
1113
Calin Juravled0d48522014-11-04 16:40:20 +00001114 case Instruction::DIV_INT_LIT16:
1115 case Instruction::DIV_INT_LIT8: {
Calin Juravle865fc882014-11-06 17:09:03 +00001116 BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(),
1117 dex_offset, Primitive::kPrimInt, true);
Calin Juravled0d48522014-11-04 16:40:20 +00001118 break;
1119 }
1120
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001121 case Instruction::NEW_INSTANCE: {
1122 current_block_->AddInstruction(
1123 new (arena_) HNewInstance(dex_offset, instruction.VRegB_21c()));
1124 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
1125 break;
1126 }
1127
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001128 case Instruction::NEW_ARRAY: {
1129 HInstruction* length = LoadLocal(instruction.VRegB_22c(), Primitive::kPrimInt);
1130 current_block_->AddInstruction(
1131 new (arena_) HNewArray(length, dex_offset, instruction.VRegC_22c()));
1132 UpdateLocal(instruction.VRegA_22c(), current_block_->GetLastInstruction());
1133 break;
1134 }
1135
1136 case Instruction::FILLED_NEW_ARRAY: {
1137 uint32_t number_of_vreg_arguments = instruction.VRegA_35c();
1138 uint32_t type_index = instruction.VRegB_35c();
1139 uint32_t args[5];
1140 instruction.GetVarArgs(args);
1141 BuildFilledNewArray(dex_offset, type_index, number_of_vreg_arguments, false, args, 0);
1142 break;
1143 }
1144
1145 case Instruction::FILLED_NEW_ARRAY_RANGE: {
1146 uint32_t number_of_vreg_arguments = instruction.VRegA_3rc();
1147 uint32_t type_index = instruction.VRegB_3rc();
1148 uint32_t register_index = instruction.VRegC_3rc();
1149 BuildFilledNewArray(
1150 dex_offset, type_index, number_of_vreg_arguments, true, nullptr, register_index);
1151 break;
1152 }
1153
1154 case Instruction::FILL_ARRAY_DATA: {
Calin Juravled0d48522014-11-04 16:40:20 +00001155 BuildFillArrayData(instruction, dex_offset);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001156 break;
1157 }
1158
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +01001159 case Instruction::MOVE_RESULT:
Dave Allison20dfc792014-06-16 20:44:29 -07001160 case Instruction::MOVE_RESULT_WIDE:
1161 case Instruction::MOVE_RESULT_OBJECT:
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001162 UpdateLocal(instruction.VRegA(), latest_result_);
1163 latest_result_ = nullptr;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001164 break;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001165
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001166 case Instruction::CMP_LONG: {
1167 Binop_23x<HCompare>(instruction, Primitive::kPrimLong);
1168 break;
1169 }
1170
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +00001171 case Instruction::NOP:
1172 break;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001173
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001174 case Instruction::IGET:
1175 case Instruction::IGET_WIDE:
1176 case Instruction::IGET_OBJECT:
1177 case Instruction::IGET_BOOLEAN:
1178 case Instruction::IGET_BYTE:
1179 case Instruction::IGET_CHAR:
1180 case Instruction::IGET_SHORT: {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001181 if (!BuildInstanceFieldAccess(instruction, dex_offset, false)) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001182 return false;
1183 }
1184 break;
1185 }
1186
1187 case Instruction::IPUT:
1188 case Instruction::IPUT_WIDE:
1189 case Instruction::IPUT_OBJECT:
1190 case Instruction::IPUT_BOOLEAN:
1191 case Instruction::IPUT_BYTE:
1192 case Instruction::IPUT_CHAR:
1193 case Instruction::IPUT_SHORT: {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001194 if (!BuildInstanceFieldAccess(instruction, dex_offset, true)) {
1195 return false;
1196 }
1197 break;
1198 }
1199
1200 case Instruction::SGET:
1201 case Instruction::SGET_WIDE:
1202 case Instruction::SGET_OBJECT:
1203 case Instruction::SGET_BOOLEAN:
1204 case Instruction::SGET_BYTE:
1205 case Instruction::SGET_CHAR:
1206 case Instruction::SGET_SHORT: {
1207 if (!BuildStaticFieldAccess(instruction, dex_offset, false)) {
1208 return false;
1209 }
1210 break;
1211 }
1212
1213 case Instruction::SPUT:
1214 case Instruction::SPUT_WIDE:
1215 case Instruction::SPUT_OBJECT:
1216 case Instruction::SPUT_BOOLEAN:
1217 case Instruction::SPUT_BYTE:
1218 case Instruction::SPUT_CHAR:
1219 case Instruction::SPUT_SHORT: {
1220 if (!BuildStaticFieldAccess(instruction, dex_offset, true)) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001221 return false;
1222 }
1223 break;
1224 }
1225
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001226#define ARRAY_XX(kind, anticipated_type) \
1227 case Instruction::AGET##kind: { \
1228 BuildArrayAccess(instruction, dex_offset, false, anticipated_type); \
1229 break; \
1230 } \
1231 case Instruction::APUT##kind: { \
1232 BuildArrayAccess(instruction, dex_offset, true, anticipated_type); \
1233 break; \
1234 }
1235
1236 ARRAY_XX(, Primitive::kPrimInt);
1237 ARRAY_XX(_WIDE, Primitive::kPrimLong);
1238 ARRAY_XX(_OBJECT, Primitive::kPrimNot);
1239 ARRAY_XX(_BOOLEAN, Primitive::kPrimBoolean);
1240 ARRAY_XX(_BYTE, Primitive::kPrimByte);
1241 ARRAY_XX(_CHAR, Primitive::kPrimChar);
1242 ARRAY_XX(_SHORT, Primitive::kPrimShort);
1243
Nicolas Geoffray39468442014-09-02 15:17:15 +01001244 case Instruction::ARRAY_LENGTH: {
1245 HInstruction* object = LoadLocal(instruction.VRegB_12x(), Primitive::kPrimNot);
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +00001246 // No need for a temporary for the null check, it is the only input of the following
1247 // instruction.
1248 object = new (arena_) HNullCheck(object, dex_offset);
1249 current_block_->AddInstruction(object);
Nicolas Geoffray39468442014-09-02 15:17:15 +01001250 current_block_->AddInstruction(new (arena_) HArrayLength(object));
1251 UpdateLocal(instruction.VRegA_12x(), current_block_->GetLastInstruction());
1252 break;
1253 }
1254
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +00001255 case Instruction::CONST_STRING: {
1256 current_block_->AddInstruction(new (arena_) HLoadString(instruction.VRegB_21c(), dex_offset));
1257 UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
1258 break;
1259 }
1260
1261 case Instruction::CONST_STRING_JUMBO: {
1262 current_block_->AddInstruction(new (arena_) HLoadString(instruction.VRegB_31c(), dex_offset));
1263 UpdateLocal(instruction.VRegA_31c(), current_block_->GetLastInstruction());
1264 break;
1265 }
1266
Nicolas Geoffray424f6762014-11-03 14:51:25 +00001267 case Instruction::CONST_CLASS: {
1268 uint16_t type_index = instruction.VRegB_21c();
1269 bool type_known_final;
1270 bool type_known_abstract;
1271 bool is_referrers_class;
1272 bool can_access = compiler_driver_->CanAccessTypeWithoutChecks(
1273 dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index,
1274 &type_known_final, &type_known_abstract, &is_referrers_class);
1275 if (!can_access) {
1276 return false;
1277 }
1278 current_block_->AddInstruction(
1279 new (arena_) HLoadClass(instruction.VRegB_21c(), is_referrers_class, dex_offset));
1280 UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
1281 break;
1282 }
1283
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +00001284 case Instruction::MOVE_EXCEPTION: {
1285 current_block_->AddInstruction(new (arena_) HLoadException());
1286 UpdateLocal(instruction.VRegA_11x(), current_block_->GetLastInstruction());
1287 break;
1288 }
1289
1290 case Instruction::THROW: {
1291 HInstruction* exception = LoadLocal(instruction.VRegA_11x(), Primitive::kPrimNot);
1292 current_block_->AddInstruction(new (arena_) HThrow(exception, dex_offset));
1293 // A throw instruction must branch to the exit block.
1294 current_block_->AddSuccessor(exit_block_);
1295 // We finished building this block. Set the current block to null to avoid
1296 // adding dead instructions to it.
1297 current_block_ = nullptr;
1298 break;
1299 }
1300
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001301 default:
1302 return false;
1303 }
1304 return true;
1305}
1306
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001307HIntConstant* HGraphBuilder::GetIntConstant0() {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001308 if (constant0_ != nullptr) {
1309 return constant0_;
1310 }
1311 constant0_ = new(arena_) HIntConstant(0);
1312 entry_block_->AddInstruction(constant0_);
1313 return constant0_;
1314}
1315
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001316HIntConstant* HGraphBuilder::GetIntConstant1() {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001317 if (constant1_ != nullptr) {
1318 return constant1_;
1319 }
1320 constant1_ = new(arena_) HIntConstant(1);
1321 entry_block_->AddInstruction(constant1_);
1322 return constant1_;
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001323}
1324
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001325HIntConstant* HGraphBuilder::GetIntConstant(int32_t constant) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001326 switch (constant) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001327 case 0: return GetIntConstant0();
1328 case 1: return GetIntConstant1();
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001329 default: {
1330 HIntConstant* instruction = new (arena_) HIntConstant(constant);
1331 entry_block_->AddInstruction(instruction);
1332 return instruction;
1333 }
1334 }
1335}
1336
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001337HLongConstant* HGraphBuilder::GetLongConstant(int64_t constant) {
1338 HLongConstant* instruction = new (arena_) HLongConstant(constant);
1339 entry_block_->AddInstruction(instruction);
1340 return instruction;
1341}
1342
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001343HLocal* HGraphBuilder::GetLocalAt(int register_index) const {
1344 return locals_.Get(register_index);
1345}
1346
1347void HGraphBuilder::UpdateLocal(int register_index, HInstruction* instruction) const {
1348 HLocal* local = GetLocalAt(register_index);
1349 current_block_->AddInstruction(new (arena_) HStoreLocal(local, instruction));
1350}
1351
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001352HInstruction* HGraphBuilder::LoadLocal(int register_index, Primitive::Type type) const {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001353 HLocal* local = GetLocalAt(register_index);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001354 current_block_->AddInstruction(new (arena_) HLoadLocal(local, type));
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001355 return current_block_->GetLastInstruction();
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001356}
1357
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001358} // namespace art