blob: fc7333fa25a728604ac4861fd2c675bbe680075e [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 Geoffrayf583e592014-04-07 13:20:42 +010067void HGraphBuilder::InitializeLocals(uint16_t count) {
68 graph_->SetNumberOfVRegs(count);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000069 locals_.SetSize(count);
70 for (int i = 0; i < count; i++) {
71 HLocal* local = new (arena_) HLocal(i);
72 entry_block_->AddInstruction(local);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000073 locals_.Put(i, local);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +000074 }
75}
76
Nicolas Geoffray52e832b2014-11-06 15:15:31 +000077void HGraphBuilder::InitializeParameters(uint16_t number_of_parameters) {
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010078 // dex_compilation_unit_ is null only when unit testing.
79 if (dex_compilation_unit_ == nullptr) {
Nicolas Geoffray52e832b2014-11-06 15:15:31 +000080 return;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010081 }
82
83 graph_->SetNumberOfInVRegs(number_of_parameters);
84 const char* shorty = dex_compilation_unit_->GetShorty();
85 int locals_index = locals_.Size() - number_of_parameters;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010086 int parameter_index = 0;
87
88 if (!dex_compilation_unit_->IsStatic()) {
89 // Add the implicit 'this' argument, not expressed in the signature.
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +010090 HParameterValue* parameter =
91 new (arena_) HParameterValue(parameter_index++, Primitive::kPrimNot);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +010092 entry_block_->AddInstruction(parameter);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010093 HLocal* local = GetLocalAt(locals_index++);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +010094 entry_block_->AddInstruction(new (arena_) HStoreLocal(local, parameter));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +010095 number_of_parameters--;
96 }
97
98 uint32_t pos = 1;
99 for (int i = 0; i < number_of_parameters; i++) {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100100 HParameterValue* parameter =
101 new (arena_) HParameterValue(parameter_index++, Primitive::GetType(shorty[pos++]));
102 entry_block_->AddInstruction(parameter);
103 HLocal* local = GetLocalAt(locals_index++);
104 // Store the parameter value in the local that the dex code will use
105 // to reference that parameter.
106 entry_block_->AddInstruction(new (arena_) HStoreLocal(local, parameter));
107 bool is_wide = (parameter->GetType() == Primitive::kPrimLong)
108 || (parameter->GetType() == Primitive::kPrimDouble);
109 if (is_wide) {
110 i++;
111 locals_index++;
112 parameter_index++;
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100113 }
114 }
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100115}
116
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100117template<typename T>
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100118void HGraphBuilder::If_22t(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000119 int32_t target_offset = instruction.GetTargetOffset();
120 PotentiallyAddSuspendCheck(target_offset, dex_offset);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100121 HInstruction* first = LoadLocal(instruction.VRegA(), Primitive::kPrimInt);
122 HInstruction* second = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
Dave Allison20dfc792014-06-16 20:44:29 -0700123 T* comparison = new (arena_) T(first, second);
124 current_block_->AddInstruction(comparison);
125 HInstruction* ifinst = new (arena_) HIf(comparison);
126 current_block_->AddInstruction(ifinst);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000127 HBasicBlock* target = FindBlockStartingAt(dex_offset + target_offset);
Dave Allison20dfc792014-06-16 20:44:29 -0700128 DCHECK(target != nullptr);
129 current_block_->AddSuccessor(target);
130 target = FindBlockStartingAt(dex_offset + instruction.SizeInCodeUnits());
131 DCHECK(target != nullptr);
132 current_block_->AddSuccessor(target);
133 current_block_ = nullptr;
134}
135
136template<typename T>
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100137void HGraphBuilder::If_21t(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000138 int32_t target_offset = instruction.GetTargetOffset();
139 PotentiallyAddSuspendCheck(target_offset, dex_offset);
Dave Allison20dfc792014-06-16 20:44:29 -0700140 HInstruction* value = LoadLocal(instruction.VRegA(), Primitive::kPrimInt);
141 T* comparison = new (arena_) T(value, GetIntConstant(0));
142 current_block_->AddInstruction(comparison);
143 HInstruction* ifinst = new (arena_) HIf(comparison);
144 current_block_->AddInstruction(ifinst);
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000145 HBasicBlock* target = FindBlockStartingAt(dex_offset + target_offset);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100146 DCHECK(target != nullptr);
147 current_block_->AddSuccessor(target);
148 target = FindBlockStartingAt(dex_offset + instruction.SizeInCodeUnits());
149 DCHECK(target != nullptr);
150 current_block_->AddSuccessor(target);
151 current_block_ = nullptr;
152}
153
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000154HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000155 const uint16_t* code_ptr = code_item.insns_;
156 const uint16_t* code_end = code_item.insns_ + code_item.insns_size_in_code_units_;
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100157 code_start_ = code_ptr;
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000158
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000159 // Setup the graph with the entry block and exit block.
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000160 graph_ = new (arena_) HGraph(arena_);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100161 entry_block_ = new (arena_) HBasicBlock(graph_, 0);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000162 graph_->AddBlock(entry_block_);
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100163 exit_block_ = new (arena_) HBasicBlock(graph_, kNoDexPc);
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000164 graph_->SetEntryBlock(entry_block_);
165 graph_->SetExitBlock(exit_block_);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000166
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000167 InitializeLocals(code_item.registers_size_);
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100168 graph_->UpdateMaximumNumberOfOutVRegs(code_item.outs_size_);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000169
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000170 // To avoid splitting blocks, we compute ahead of time the instructions that
171 // start a new block, and create these blocks.
172 ComputeBranchTargets(code_ptr, code_end);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000173
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000174 // Also create blocks for catch handlers.
175 if (code_item.tries_size_ != 0) {
176 const uint8_t* handlers_ptr = DexFile::GetCatchHandlerData(code_item, 0);
177 uint32_t handlers_size = DecodeUnsignedLeb128(&handlers_ptr);
178 for (uint32_t idx = 0; idx < handlers_size; ++idx) {
179 CatchHandlerIterator iterator(handlers_ptr);
180 for (; iterator.HasNext(); iterator.Next()) {
181 uint32_t address = iterator.GetHandlerAddress();
182 HBasicBlock* block = FindBlockStartingAt(address);
183 if (block == nullptr) {
184 block = new (arena_) HBasicBlock(graph_, address);
185 branch_targets_.Put(address, block);
186 }
187 block->SetIsCatchBlock();
188 }
189 handlers_ptr = iterator.EndDataPointer();
190 }
191 }
192
Nicolas Geoffray52e832b2014-11-06 15:15:31 +0000193 InitializeParameters(code_item.ins_size_);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100194
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000195 size_t dex_offset = 0;
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000196 while (code_ptr < code_end) {
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000197 // Update the current block if dex_offset starts a new block.
198 MaybeUpdateCurrentBlock(dex_offset);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000199 const Instruction& instruction = *Instruction::At(code_ptr);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000200 if (!AnalyzeDexInstruction(instruction, dex_offset)) return nullptr;
201 dex_offset += instruction.SizeInCodeUnits();
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000202 code_ptr += instruction.SizeInCodeUnits();
203 }
204
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000205 // Add the exit block at the end to give it the highest id.
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000206 graph_->AddBlock(exit_block_);
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000207 exit_block_->AddInstruction(new (arena_) HExit());
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000208 // Add the suspend check to the entry block.
209 entry_block_->AddInstruction(new (arena_) HSuspendCheck(0));
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000210 entry_block_->AddInstruction(new (arena_) HGoto());
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000211 return graph_;
212}
213
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000214void HGraphBuilder::MaybeUpdateCurrentBlock(size_t index) {
215 HBasicBlock* block = FindBlockStartingAt(index);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000216 if (block == nullptr) {
217 return;
218 }
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000219
220 if (current_block_ != nullptr) {
221 // Branching instructions clear current_block, so we know
222 // the last instruction of the current block is not a branching
223 // instruction. We add an unconditional goto to the found block.
224 current_block_->AddInstruction(new (arena_) HGoto());
225 current_block_->AddSuccessor(block);
226 }
227 graph_->AddBlock(block);
228 current_block_ = block;
229}
230
231void HGraphBuilder::ComputeBranchTargets(const uint16_t* code_ptr, const uint16_t* code_end) {
232 // TODO: Support switch instructions.
233 branch_targets_.SetSize(code_end - code_ptr);
234
235 // Create the first block for the dex instructions, single successor of the entry block.
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100236 HBasicBlock* block = new (arena_) HBasicBlock(graph_, 0);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000237 branch_targets_.Put(0, block);
238 entry_block_->AddSuccessor(block);
239
240 // Iterate over all instructions and find branching instructions. Create blocks for
241 // the locations these instructions branch to.
242 size_t dex_offset = 0;
243 while (code_ptr < code_end) {
244 const Instruction& instruction = *Instruction::At(code_ptr);
245 if (instruction.IsBranch()) {
246 int32_t target = instruction.GetTargetOffset() + dex_offset;
247 // Create a block for the target instruction.
248 if (FindBlockStartingAt(target) == nullptr) {
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100249 block = new (arena_) HBasicBlock(graph_, target);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000250 branch_targets_.Put(target, block);
251 }
252 dex_offset += instruction.SizeInCodeUnits();
253 code_ptr += instruction.SizeInCodeUnits();
254 if ((code_ptr < code_end) && (FindBlockStartingAt(dex_offset) == nullptr)) {
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100255 block = new (arena_) HBasicBlock(graph_, dex_offset);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000256 branch_targets_.Put(dex_offset, block);
257 }
258 } else {
259 code_ptr += instruction.SizeInCodeUnits();
260 dex_offset += instruction.SizeInCodeUnits();
261 }
262 }
263}
264
265HBasicBlock* HGraphBuilder::FindBlockStartingAt(int32_t index) const {
266 DCHECK_GE(index, 0);
267 return branch_targets_.Get(index);
268}
269
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100270template<typename T>
Roland Levillain88cb1752014-10-20 16:36:47 +0100271void HGraphBuilder::Unop_12x(const Instruction& instruction, Primitive::Type type) {
272 HInstruction* first = LoadLocal(instruction.VRegB(), type);
273 current_block_->AddInstruction(new (arena_) T(type, first));
274 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
275}
276
Roland Levillaindff1f282014-11-05 14:15:05 +0000277void HGraphBuilder::Conversion_12x(const Instruction& instruction,
278 Primitive::Type input_type,
279 Primitive::Type result_type) {
280 HInstruction* first = LoadLocal(instruction.VRegB(), input_type);
281 current_block_->AddInstruction(new (arena_) HTypeConversion(result_type, first));
282 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
283}
284
Roland Levillain88cb1752014-10-20 16:36:47 +0100285template<typename T>
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100286void HGraphBuilder::Binop_23x(const Instruction& instruction, Primitive::Type type) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100287 HInstruction* first = LoadLocal(instruction.VRegB(), type);
288 HInstruction* second = LoadLocal(instruction.VRegC(), type);
289 current_block_->AddInstruction(new (arena_) T(type, first, second));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100290 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
291}
292
293template<typename T>
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100294void HGraphBuilder::Binop_12x(const Instruction& instruction, Primitive::Type type) {
295 HInstruction* first = LoadLocal(instruction.VRegA(), type);
296 HInstruction* second = LoadLocal(instruction.VRegB(), type);
297 current_block_->AddInstruction(new (arena_) T(type, first, second));
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100298 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
299}
300
301template<typename T>
302void HGraphBuilder::Binop_22s(const Instruction& instruction, bool reverse) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100303 HInstruction* first = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
304 HInstruction* second = GetIntConstant(instruction.VRegC_22s());
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100305 if (reverse) {
306 std::swap(first, second);
307 }
308 current_block_->AddInstruction(new (arena_) T(Primitive::kPrimInt, first, second));
309 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
310}
311
312template<typename T>
313void HGraphBuilder::Binop_22b(const Instruction& instruction, bool reverse) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100314 HInstruction* first = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
315 HInstruction* second = GetIntConstant(instruction.VRegC_22b());
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100316 if (reverse) {
317 std::swap(first, second);
318 }
319 current_block_->AddInstruction(new (arena_) T(Primitive::kPrimInt, first, second));
320 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
321}
322
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100323void HGraphBuilder::BuildReturn(const Instruction& instruction, Primitive::Type type) {
324 if (type == Primitive::kPrimVoid) {
325 current_block_->AddInstruction(new (arena_) HReturnVoid());
326 } else {
327 HInstruction* value = LoadLocal(instruction.VRegA(), type);
328 current_block_->AddInstruction(new (arena_) HReturn(value));
329 }
330 current_block_->AddSuccessor(exit_block_);
331 current_block_ = nullptr;
332}
333
334bool HGraphBuilder::BuildInvoke(const Instruction& instruction,
335 uint32_t dex_offset,
336 uint32_t method_idx,
337 uint32_t number_of_vreg_arguments,
338 bool is_range,
339 uint32_t* args,
340 uint32_t register_index) {
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100341 Instruction::Code opcode = instruction.Opcode();
342 InvokeType invoke_type;
343 switch (opcode) {
344 case Instruction::INVOKE_STATIC:
345 case Instruction::INVOKE_STATIC_RANGE:
346 invoke_type = kStatic;
347 break;
348 case Instruction::INVOKE_DIRECT:
349 case Instruction::INVOKE_DIRECT_RANGE:
350 invoke_type = kDirect;
351 break;
352 case Instruction::INVOKE_VIRTUAL:
353 case Instruction::INVOKE_VIRTUAL_RANGE:
354 invoke_type = kVirtual;
355 break;
356 case Instruction::INVOKE_INTERFACE:
357 case Instruction::INVOKE_INTERFACE_RANGE:
358 invoke_type = kInterface;
359 break;
360 case Instruction::INVOKE_SUPER_RANGE:
361 case Instruction::INVOKE_SUPER:
362 invoke_type = kSuper;
363 break;
364 default:
365 LOG(FATAL) << "Unexpected invoke op: " << opcode;
366 return false;
367 }
368
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100369 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx);
370 const DexFile::ProtoId& proto_id = dex_file_->GetProtoId(method_id.proto_idx_);
371 const char* descriptor = dex_file_->StringDataByIdx(proto_id.shorty_idx_);
372 Primitive::Type return_type = Primitive::GetType(descriptor[0]);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100373 bool is_instance_call = invoke_type != kStatic;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100374 const size_t number_of_arguments = strlen(descriptor) - (is_instance_call ? 0 : 1);
375
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100376 HInvoke* invoke = nullptr;
377 if (invoke_type == kVirtual) {
378 MethodReference target_method(dex_file_, method_idx);
379 uintptr_t direct_code;
380 uintptr_t direct_method;
381 int vtable_index;
382 // TODO: Add devirtualization support.
383 compiler_driver_->ComputeInvokeInfo(dex_compilation_unit_, dex_offset, true, true,
384 &invoke_type, &target_method, &vtable_index,
385 &direct_code, &direct_method);
386 if (vtable_index == -1) {
387 return false;
388 }
389 invoke = new (arena_) HInvokeVirtual(
390 arena_, number_of_arguments, return_type, dex_offset, vtable_index);
391 } else {
392 // Treat invoke-direct like static calls for now.
393 invoke = new (arena_) HInvokeStatic(
394 arena_, number_of_arguments, return_type, dex_offset, method_idx);
395 }
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100396
397 size_t start_index = 0;
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100398 Temporaries temps(graph_, is_instance_call ? 1 : 0);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100399 if (is_instance_call) {
400 HInstruction* arg = LoadLocal(is_range ? register_index : args[0], Primitive::kPrimNot);
Nicolas Geoffrayf12feb82014-07-17 18:32:41 +0100401 HNullCheck* null_check = new (arena_) HNullCheck(arg, dex_offset);
402 current_block_->AddInstruction(null_check);
403 temps.Add(null_check);
404 invoke->SetArgumentAt(0, null_check);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100405 start_index = 1;
406 }
407
408 uint32_t descriptor_index = 1;
409 uint32_t argument_index = start_index;
410 for (size_t i = start_index; i < number_of_vreg_arguments; i++, argument_index++) {
411 Primitive::Type type = Primitive::GetType(descriptor[descriptor_index++]);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100412 bool is_wide = (type == Primitive::kPrimLong) || (type == Primitive::kPrimDouble);
413 if (!is_range && is_wide && args[i] + 1 != args[i + 1]) {
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100414 LOG(WARNING) << "Non sequential register pair in " << dex_compilation_unit_->GetSymbol()
415 << " at " << dex_offset;
416 // We do not implement non sequential register pair.
417 return false;
418 }
419 HInstruction* arg = LoadLocal(is_range ? register_index + i : args[i], type);
420 invoke->SetArgumentAt(argument_index, arg);
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100421 if (is_wide) {
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100422 i++;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100423 }
424 }
425
426 DCHECK_EQ(argument_index, number_of_arguments);
427 current_block_->AddInstruction(invoke);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100428 latest_result_ = invoke;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100429 return true;
430}
431
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100432bool HGraphBuilder::BuildInstanceFieldAccess(const Instruction& instruction,
433 uint32_t dex_offset,
434 bool is_put) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100435 uint32_t source_or_dest_reg = instruction.VRegA_22c();
436 uint32_t obj_reg = instruction.VRegB_22c();
437 uint16_t field_index = instruction.VRegC_22c();
438
439 ScopedObjectAccess soa(Thread::Current());
440 StackHandleScope<1> hs(soa.Self());
441 Handle<mirror::ArtField> resolved_field(hs.NewHandle(
442 compiler_driver_->ComputeInstanceFieldInfo(field_index, dex_compilation_unit_, is_put, soa)));
443
444 if (resolved_field.Get() == nullptr) {
445 return false;
446 }
447 if (resolved_field->IsVolatile()) {
448 return false;
449 }
450
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100451 Primitive::Type field_type = resolved_field->GetTypeAsPrimitiveType();
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100452
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100453 HInstruction* object = LoadLocal(obj_reg, Primitive::kPrimNot);
454 current_block_->AddInstruction(new (arena_) HNullCheck(object, dex_offset));
455 if (is_put) {
456 Temporaries temps(graph_, 1);
457 HInstruction* null_check = current_block_->GetLastInstruction();
458 // We need one temporary for the null check.
459 temps.Add(null_check);
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100460 HInstruction* value = LoadLocal(source_or_dest_reg, field_type);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100461 current_block_->AddInstruction(new (arena_) HInstanceFieldSet(
462 null_check,
463 value,
Nicolas Geoffray39468442014-09-02 15:17:15 +0100464 field_type,
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100465 resolved_field->GetOffset()));
466 } else {
467 current_block_->AddInstruction(new (arena_) HInstanceFieldGet(
468 current_block_->GetLastInstruction(),
Nicolas Geoffrayabed4d02014-07-14 15:24:11 +0100469 field_type,
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100470 resolved_field->GetOffset()));
471
472 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
473 }
474 return true;
475}
476
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100477
478
479bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction,
480 uint32_t dex_offset,
481 bool is_put) {
482 uint32_t source_or_dest_reg = instruction.VRegA_21c();
483 uint16_t field_index = instruction.VRegB_21c();
484
485 uint32_t storage_index;
486 bool is_referrers_class;
487 bool is_initialized;
488 bool is_volatile;
489 MemberOffset field_offset(0u);
490 Primitive::Type field_type;
491
492 bool fast_path = compiler_driver_->ComputeStaticFieldInfo(field_index,
493 dex_compilation_unit_,
494 is_put,
495 &field_offset,
496 &storage_index,
497 &is_referrers_class,
498 &is_volatile,
499 &is_initialized,
500 &field_type);
501 if (!fast_path) {
502 return false;
503 }
504
505 if (is_volatile) {
506 return false;
507 }
508
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100509 HLoadClass* constant = new (arena_) HLoadClass(
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000510 storage_index, is_referrers_class, dex_offset);
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100511 current_block_->AddInstruction(constant);
512
513 HInstruction* cls = constant;
Nicolas Geoffray424f6762014-11-03 14:51:25 +0000514 if (!is_initialized) {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +0100515 cls = new (arena_) HClinitCheck(constant, dex_offset);
516 current_block_->AddInstruction(cls);
517 }
518
519 if (is_put) {
520 // We need to keep the class alive before loading the value.
521 Temporaries temps(graph_, 1);
522 temps.Add(cls);
523 HInstruction* value = LoadLocal(source_or_dest_reg, field_type);
524 DCHECK_EQ(value->GetType(), field_type);
525 current_block_->AddInstruction(
526 new (arena_) HStaticFieldSet(cls, value, field_type, field_offset));
527 } else {
528 current_block_->AddInstruction(new (arena_) HStaticFieldGet(cls, field_type, field_offset));
529 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
530 }
531 return true;
532}
533
Calin Juravle865fc882014-11-06 17:09:03 +0000534void HGraphBuilder::BuildCheckedDiv(uint16_t out_reg,
535 uint16_t first_reg,
Calin Juravle0f00db72014-11-06 18:19:23 +0000536 int32_t second_reg,
Calin Juravled0d48522014-11-04 16:40:20 +0000537 uint32_t dex_offset,
538 Primitive::Type type,
539 bool second_is_lit) {
540 DCHECK(type == Primitive::kPrimInt);
541
Calin Juravle865fc882014-11-06 17:09:03 +0000542 HInstruction* first = LoadLocal(first_reg, type);
543 HInstruction* second = second_is_lit ? GetIntConstant(second_reg) : LoadLocal(second_reg, type);
Calin Juravled0d48522014-11-04 16:40:20 +0000544 if (!second->IsIntConstant() || (second->AsIntConstant()->GetValue() == 0)) {
545 second = new (arena_) HDivZeroCheck(second, dex_offset);
546 Temporaries temps(graph_, 1);
547 current_block_->AddInstruction(second);
548 temps.Add(current_block_->GetLastInstruction());
549 }
550
551 current_block_->AddInstruction(new (arena_) HDiv(type, first, second));
Calin Juravle865fc882014-11-06 17:09:03 +0000552 UpdateLocal(out_reg, current_block_->GetLastInstruction());
Calin Juravled0d48522014-11-04 16:40:20 +0000553}
554
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100555void HGraphBuilder::BuildArrayAccess(const Instruction& instruction,
556 uint32_t dex_offset,
557 bool is_put,
558 Primitive::Type anticipated_type) {
559 uint8_t source_or_dest_reg = instruction.VRegA_23x();
560 uint8_t array_reg = instruction.VRegB_23x();
561 uint8_t index_reg = instruction.VRegC_23x();
562
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100563 // We need one temporary for the null check, one for the index, and one for the length.
564 Temporaries temps(graph_, 3);
565
566 HInstruction* object = LoadLocal(array_reg, Primitive::kPrimNot);
567 object = new (arena_) HNullCheck(object, dex_offset);
568 current_block_->AddInstruction(object);
569 temps.Add(object);
570
571 HInstruction* length = new (arena_) HArrayLength(object);
572 current_block_->AddInstruction(length);
573 temps.Add(length);
574 HInstruction* index = LoadLocal(index_reg, Primitive::kPrimInt);
575 index = new (arena_) HBoundsCheck(index, length, dex_offset);
576 current_block_->AddInstruction(index);
577 temps.Add(index);
578 if (is_put) {
579 HInstruction* value = LoadLocal(source_or_dest_reg, anticipated_type);
580 // TODO: Insert a type check node if the type is Object.
Nicolas Geoffray39468442014-09-02 15:17:15 +0100581 current_block_->AddInstruction(new (arena_) HArraySet(
582 object, index, value, anticipated_type, dex_offset));
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +0100583 } else {
584 current_block_->AddInstruction(new (arena_) HArrayGet(object, index, anticipated_type));
585 UpdateLocal(source_or_dest_reg, current_block_->GetLastInstruction());
586 }
587}
588
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100589void HGraphBuilder::BuildFilledNewArray(uint32_t dex_offset,
590 uint32_t type_index,
591 uint32_t number_of_vreg_arguments,
592 bool is_range,
593 uint32_t* args,
594 uint32_t register_index) {
595 HInstruction* length = GetIntConstant(number_of_vreg_arguments);
596 HInstruction* object = new (arena_) HNewArray(length, dex_offset, type_index);
597 current_block_->AddInstruction(object);
598
599 const char* descriptor = dex_file_->StringByTypeIdx(type_index);
600 DCHECK_EQ(descriptor[0], '[') << descriptor;
601 char primitive = descriptor[1];
602 DCHECK(primitive == 'I'
603 || primitive == 'L'
604 || primitive == '[') << descriptor;
605 bool is_reference_array = (primitive == 'L') || (primitive == '[');
606 Primitive::Type type = is_reference_array ? Primitive::kPrimNot : Primitive::kPrimInt;
607
608 Temporaries temps(graph_, 1);
609 temps.Add(object);
610 for (size_t i = 0; i < number_of_vreg_arguments; ++i) {
611 HInstruction* value = LoadLocal(is_range ? register_index + i : args[i], type);
612 HInstruction* index = GetIntConstant(i);
613 current_block_->AddInstruction(
614 new (arena_) HArraySet(object, index, value, type, dex_offset));
615 }
616 latest_result_ = object;
617}
618
619template <typename T>
620void HGraphBuilder::BuildFillArrayData(HInstruction* object,
621 const T* data,
622 uint32_t element_count,
623 Primitive::Type anticipated_type,
624 uint32_t dex_offset) {
625 for (uint32_t i = 0; i < element_count; ++i) {
626 HInstruction* index = GetIntConstant(i);
627 HInstruction* value = GetIntConstant(data[i]);
628 current_block_->AddInstruction(new (arena_) HArraySet(
629 object, index, value, anticipated_type, dex_offset));
630 }
631}
632
Calin Juravled0d48522014-11-04 16:40:20 +0000633void HGraphBuilder::BuildFillArrayData(const Instruction& instruction, uint32_t dex_offset) {
634 Temporaries temps(graph_, 1);
635 HInstruction* array = LoadLocal(instruction.VRegA_31t(), Primitive::kPrimNot);
636 HNullCheck* null_check = new (arena_) HNullCheck(array, dex_offset);
637 current_block_->AddInstruction(null_check);
638 temps.Add(null_check);
639
640 HInstruction* length = new (arena_) HArrayLength(null_check);
641 current_block_->AddInstruction(length);
642
643 int32_t payload_offset = instruction.VRegB_31t() + dex_offset;
644 const Instruction::ArrayDataPayload* payload =
645 reinterpret_cast<const Instruction::ArrayDataPayload*>(code_start_ + payload_offset);
646 const uint8_t* data = payload->data;
647 uint32_t element_count = payload->element_count;
648
649 // Implementation of this DEX instruction seems to be that the bounds check is
650 // done before doing any stores.
651 HInstruction* last_index = GetIntConstant(payload->element_count - 1);
652 current_block_->AddInstruction(new (arena_) HBoundsCheck(last_index, length, dex_offset));
653
654 switch (payload->element_width) {
655 case 1:
656 BuildFillArrayData(null_check,
657 reinterpret_cast<const int8_t*>(data),
658 element_count,
659 Primitive::kPrimByte,
660 dex_offset);
661 break;
662 case 2:
663 BuildFillArrayData(null_check,
664 reinterpret_cast<const int16_t*>(data),
665 element_count,
666 Primitive::kPrimShort,
667 dex_offset);
668 break;
669 case 4:
670 BuildFillArrayData(null_check,
671 reinterpret_cast<const int32_t*>(data),
672 element_count,
673 Primitive::kPrimInt,
674 dex_offset);
675 break;
676 case 8:
677 BuildFillWideArrayData(null_check,
678 reinterpret_cast<const int64_t*>(data),
679 element_count,
680 dex_offset);
681 break;
682 default:
683 LOG(FATAL) << "Unknown element width for " << payload->element_width;
684 }
685}
686
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100687void HGraphBuilder::BuildFillWideArrayData(HInstruction* object,
Nicolas Geoffray8d6ae522014-10-23 18:32:13 +0100688 const int64_t* data,
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +0100689 uint32_t element_count,
690 uint32_t dex_offset) {
691 for (uint32_t i = 0; i < element_count; ++i) {
692 HInstruction* index = GetIntConstant(i);
693 HInstruction* value = GetLongConstant(data[i]);
694 current_block_->AddInstruction(new (arena_) HArraySet(
695 object, index, value, Primitive::kPrimLong, dex_offset));
696 }
697}
698
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000699void HGraphBuilder::PotentiallyAddSuspendCheck(int32_t target_offset, uint32_t dex_offset) {
700 if (target_offset <= 0) {
701 // Unconditionnally add a suspend check to backward branches. We can remove
702 // them after we recognize loops in the graph.
703 current_block_->AddInstruction(new (arena_) HSuspendCheck(dex_offset));
704 }
705}
706
707bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32_t dex_offset) {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000708 if (current_block_ == nullptr) {
709 return true; // Dead code
710 }
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000711
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000712 switch (instruction.Opcode()) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000713 case Instruction::CONST_4: {
714 int32_t register_index = instruction.VRegA();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100715 HIntConstant* constant = GetIntConstant(instruction.VRegB_11n());
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +0000716 UpdateLocal(register_index, constant);
717 break;
718 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000719
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100720 case Instruction::CONST_16: {
721 int32_t register_index = instruction.VRegA();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100722 HIntConstant* constant = GetIntConstant(instruction.VRegB_21s());
723 UpdateLocal(register_index, constant);
724 break;
725 }
726
Dave Allison20dfc792014-06-16 20:44:29 -0700727 case Instruction::CONST: {
728 int32_t register_index = instruction.VRegA();
729 HIntConstant* constant = GetIntConstant(instruction.VRegB_31i());
730 UpdateLocal(register_index, constant);
731 break;
732 }
733
734 case Instruction::CONST_HIGH16: {
735 int32_t register_index = instruction.VRegA();
736 HIntConstant* constant = GetIntConstant(instruction.VRegB_21h() << 16);
737 UpdateLocal(register_index, constant);
738 break;
739 }
740
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100741 case Instruction::CONST_WIDE_16: {
742 int32_t register_index = instruction.VRegA();
Dave Allison20dfc792014-06-16 20:44:29 -0700743 // Get 16 bits of constant value, sign extended to 64 bits.
744 int64_t value = instruction.VRegB_21s();
745 value <<= 48;
746 value >>= 48;
747 HLongConstant* constant = GetLongConstant(value);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100748 UpdateLocal(register_index, constant);
749 break;
750 }
751
752 case Instruction::CONST_WIDE_32: {
753 int32_t register_index = instruction.VRegA();
Dave Allison20dfc792014-06-16 20:44:29 -0700754 // Get 32 bits of constant value, sign extended to 64 bits.
755 int64_t value = instruction.VRegB_31i();
756 value <<= 32;
757 value >>= 32;
758 HLongConstant* constant = GetLongConstant(value);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100759 UpdateLocal(register_index, constant);
760 break;
761 }
762
763 case Instruction::CONST_WIDE: {
764 int32_t register_index = instruction.VRegA();
765 HLongConstant* constant = GetLongConstant(instruction.VRegB_51l());
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100766 UpdateLocal(register_index, constant);
767 break;
768 }
769
Dave Allison20dfc792014-06-16 20:44:29 -0700770 case Instruction::CONST_WIDE_HIGH16: {
771 int32_t register_index = instruction.VRegA();
772 int64_t value = static_cast<int64_t>(instruction.VRegB_21h()) << 48;
773 HLongConstant* constant = GetLongConstant(value);
774 UpdateLocal(register_index, constant);
775 break;
776 }
777
778 // TODO: these instructions are also used to move floating point values, so what is
779 // the type (int or float)?
780 case Instruction::MOVE:
781 case Instruction::MOVE_FROM16:
782 case Instruction::MOVE_16: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100783 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimInt);
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100784 UpdateLocal(instruction.VRegA(), value);
785 break;
786 }
787
Dave Allison20dfc792014-06-16 20:44:29 -0700788 // TODO: these instructions are also used to move floating point values, so what is
789 // the type (long or double)?
790 case Instruction::MOVE_WIDE:
791 case Instruction::MOVE_WIDE_FROM16:
792 case Instruction::MOVE_WIDE_16: {
793 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimLong);
794 UpdateLocal(instruction.VRegA(), value);
795 break;
796 }
797
798 case Instruction::MOVE_OBJECT:
799 case Instruction::MOVE_OBJECT_16:
800 case Instruction::MOVE_OBJECT_FROM16: {
801 HInstruction* value = LoadLocal(instruction.VRegB(), Primitive::kPrimNot);
802 UpdateLocal(instruction.VRegA(), value);
803 break;
804 }
805
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000806 case Instruction::RETURN_VOID: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100807 BuildReturn(instruction, Primitive::kPrimVoid);
Nicolas Geoffray818f2102014-02-18 16:43:35 +0000808 break;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000809 }
810
Dave Allison20dfc792014-06-16 20:44:29 -0700811#define IF_XX(comparison, cond) \
812 case Instruction::IF_##cond: If_22t<comparison>(instruction, dex_offset); break; \
813 case Instruction::IF_##cond##Z: If_21t<comparison>(instruction, dex_offset); break
Nicolas Geoffrayb55f8352014-04-07 15:26:35 +0100814
Dave Allison20dfc792014-06-16 20:44:29 -0700815 IF_XX(HEqual, EQ);
816 IF_XX(HNotEqual, NE);
817 IF_XX(HLessThan, LT);
818 IF_XX(HLessThanOrEqual, LE);
819 IF_XX(HGreaterThan, GT);
820 IF_XX(HGreaterThanOrEqual, GE);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000821
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000822 case Instruction::GOTO:
823 case Instruction::GOTO_16:
824 case Instruction::GOTO_32: {
Nicolas Geoffrayfbc695f2014-09-15 15:33:30 +0000825 int32_t offset = instruction.GetTargetOffset();
826 PotentiallyAddSuspendCheck(offset, dex_offset);
827 HBasicBlock* target = FindBlockStartingAt(offset + dex_offset);
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +0000828 DCHECK(target != nullptr);
829 current_block_->AddInstruction(new (arena_) HGoto());
830 current_block_->AddSuccessor(target);
831 current_block_ = nullptr;
832 break;
833 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000834
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100835 case Instruction::RETURN: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100836 DCHECK_NE(return_type_, Primitive::kPrimNot);
837 DCHECK_NE(return_type_, Primitive::kPrimLong);
838 DCHECK_NE(return_type_, Primitive::kPrimDouble);
839 BuildReturn(instruction, return_type_);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100840 break;
841 }
842
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100843 case Instruction::RETURN_OBJECT: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100844 DCHECK(return_type_ == Primitive::kPrimNot);
845 BuildReturn(instruction, return_type_);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100846 break;
847 }
848
849 case Instruction::RETURN_WIDE: {
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100850 DCHECK(return_type_ == Primitive::kPrimDouble || return_type_ == Primitive::kPrimLong);
851 BuildReturn(instruction, return_type_);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000852 break;
853 }
854
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +0100855 case Instruction::INVOKE_STATIC:
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100856 case Instruction::INVOKE_DIRECT:
857 case Instruction::INVOKE_VIRTUAL: {
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000858 uint32_t method_idx = instruction.VRegB_35c();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100859 uint32_t number_of_vreg_arguments = instruction.VRegA_35c();
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100860 uint32_t args[5];
Ian Rogers29a26482014-05-02 15:27:29 -0700861 instruction.GetVarArgs(args);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100862 if (!BuildInvoke(instruction, dex_offset, method_idx, number_of_vreg_arguments, false, args, -1)) {
863 return false;
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100864 }
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100865 break;
866 }
867
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +0100868 case Instruction::INVOKE_STATIC_RANGE:
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100869 case Instruction::INVOKE_DIRECT_RANGE:
870 case Instruction::INVOKE_VIRTUAL_RANGE: {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100871 uint32_t method_idx = instruction.VRegB_3rc();
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100872 uint32_t number_of_vreg_arguments = instruction.VRegA_3rc();
873 uint32_t register_index = instruction.VRegC();
874 if (!BuildInvoke(instruction, dex_offset, method_idx,
875 number_of_vreg_arguments, true, nullptr, register_index)) {
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100876 return false;
877 }
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000878 break;
879 }
880
Roland Levillain88cb1752014-10-20 16:36:47 +0100881 case Instruction::NEG_INT: {
882 Unop_12x<HNeg>(instruction, Primitive::kPrimInt);
883 break;
884 }
885
Roland Levillain2e07b4f2014-10-23 18:12:09 +0100886 case Instruction::NEG_LONG: {
887 Unop_12x<HNeg>(instruction, Primitive::kPrimLong);
888 break;
889 }
890
Roland Levillain3dbcb382014-10-28 17:30:07 +0000891 case Instruction::NEG_FLOAT: {
892 Unop_12x<HNeg>(instruction, Primitive::kPrimFloat);
893 break;
894 }
895
896 case Instruction::NEG_DOUBLE: {
897 Unop_12x<HNeg>(instruction, Primitive::kPrimDouble);
898 break;
899 }
900
Roland Levillain1cc5f2512014-10-22 18:06:21 +0100901 case Instruction::NOT_INT: {
902 Unop_12x<HNot>(instruction, Primitive::kPrimInt);
903 break;
904 }
905
Roland Levillain70566432014-10-24 16:20:17 +0100906 case Instruction::NOT_LONG: {
907 Unop_12x<HNot>(instruction, Primitive::kPrimLong);
908 break;
909 }
910
Roland Levillaindff1f282014-11-05 14:15:05 +0000911 case Instruction::INT_TO_LONG: {
912 Conversion_12x(instruction, Primitive::kPrimInt, Primitive::kPrimLong);
913 break;
914 }
915
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000916 case Instruction::ADD_INT: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100917 Binop_23x<HAdd>(instruction, Primitive::kPrimInt);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100918 break;
919 }
920
921 case Instruction::ADD_LONG: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100922 Binop_23x<HAdd>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100923 break;
924 }
925
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100926 case Instruction::ADD_DOUBLE: {
927 Binop_23x<HAdd>(instruction, Primitive::kPrimDouble);
928 break;
929 }
930
931 case Instruction::ADD_FLOAT: {
932 Binop_23x<HAdd>(instruction, Primitive::kPrimFloat);
933 break;
934 }
935
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100936 case Instruction::SUB_INT: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100937 Binop_23x<HSub>(instruction, Primitive::kPrimInt);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100938 break;
939 }
940
941 case Instruction::SUB_LONG: {
Nicolas Geoffray412f10c2014-06-19 10:00:34 +0100942 Binop_23x<HSub>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000943 break;
944 }
945
Calin Juravle096cc022014-10-23 17:01:13 +0100946 case Instruction::SUB_FLOAT: {
947 Binop_23x<HSub>(instruction, Primitive::kPrimFloat);
948 break;
949 }
950
951 case Instruction::SUB_DOUBLE: {
952 Binop_23x<HSub>(instruction, Primitive::kPrimDouble);
953 break;
954 }
955
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +0000956 case Instruction::ADD_INT_2ADDR: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100957 Binop_12x<HAdd>(instruction, Primitive::kPrimInt);
958 break;
959 }
960
Calin Juravle34bacdf2014-10-07 20:23:36 +0100961 case Instruction::MUL_INT: {
962 Binop_23x<HMul>(instruction, Primitive::kPrimInt);
963 break;
964 }
965
966 case Instruction::MUL_LONG: {
967 Binop_23x<HMul>(instruction, Primitive::kPrimLong);
968 break;
969 }
970
Calin Juravleb5bfa962014-10-21 18:02:24 +0100971 case Instruction::MUL_FLOAT: {
972 Binop_23x<HMul>(instruction, Primitive::kPrimFloat);
973 break;
974 }
975
976 case Instruction::MUL_DOUBLE: {
977 Binop_23x<HMul>(instruction, Primitive::kPrimDouble);
978 break;
979 }
980
Calin Juravled0d48522014-11-04 16:40:20 +0000981 case Instruction::DIV_INT: {
Calin Juravle865fc882014-11-06 17:09:03 +0000982 BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(),
983 dex_offset, Primitive::kPrimInt, false);
Calin Juravled0d48522014-11-04 16:40:20 +0000984 break;
985 }
986
Calin Juravle7c4954d2014-10-28 16:57:40 +0000987 case Instruction::DIV_FLOAT: {
988 Binop_23x<HDiv>(instruction, Primitive::kPrimFloat);
989 break;
990 }
991
992 case Instruction::DIV_DOUBLE: {
993 Binop_23x<HDiv>(instruction, Primitive::kPrimDouble);
994 break;
995 }
996
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +0100997 case Instruction::ADD_LONG_2ADDR: {
998 Binop_12x<HAdd>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayf583e592014-04-07 13:20:42 +0100999 break;
1000 }
1001
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001002 case Instruction::ADD_DOUBLE_2ADDR: {
1003 Binop_12x<HAdd>(instruction, Primitive::kPrimDouble);
1004 break;
1005 }
1006
1007 case Instruction::ADD_FLOAT_2ADDR: {
1008 Binop_12x<HAdd>(instruction, Primitive::kPrimFloat);
1009 break;
1010 }
1011
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001012 case Instruction::SUB_INT_2ADDR: {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001013 Binop_12x<HSub>(instruction, Primitive::kPrimInt);
1014 break;
1015 }
1016
1017 case Instruction::SUB_LONG_2ADDR: {
1018 Binop_12x<HSub>(instruction, Primitive::kPrimLong);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001019 break;
1020 }
1021
Calin Juravle096cc022014-10-23 17:01:13 +01001022 case Instruction::SUB_FLOAT_2ADDR: {
1023 Binop_12x<HSub>(instruction, Primitive::kPrimFloat);
1024 break;
1025 }
1026
1027 case Instruction::SUB_DOUBLE_2ADDR: {
1028 Binop_12x<HSub>(instruction, Primitive::kPrimDouble);
1029 break;
1030 }
1031
Calin Juravle34bacdf2014-10-07 20:23:36 +01001032 case Instruction::MUL_INT_2ADDR: {
1033 Binop_12x<HMul>(instruction, Primitive::kPrimInt);
1034 break;
1035 }
1036
1037 case Instruction::MUL_LONG_2ADDR: {
1038 Binop_12x<HMul>(instruction, Primitive::kPrimLong);
1039 break;
1040 }
1041
Calin Juravleb5bfa962014-10-21 18:02:24 +01001042 case Instruction::MUL_FLOAT_2ADDR: {
1043 Binop_12x<HMul>(instruction, Primitive::kPrimFloat);
1044 break;
1045 }
1046
1047 case Instruction::MUL_DOUBLE_2ADDR: {
1048 Binop_12x<HMul>(instruction, Primitive::kPrimDouble);
1049 break;
1050 }
1051
Calin Juravle865fc882014-11-06 17:09:03 +00001052 case Instruction::DIV_INT_2ADDR: {
1053 BuildCheckedDiv(instruction.VRegA(), instruction.VRegA(), instruction.VRegB(),
1054 dex_offset, Primitive::kPrimInt, false);
1055 break;
1056 }
1057
Calin Juravle7c4954d2014-10-28 16:57:40 +00001058 case Instruction::DIV_FLOAT_2ADDR: {
1059 Binop_12x<HDiv>(instruction, Primitive::kPrimFloat);
1060 break;
1061 }
1062
1063 case Instruction::DIV_DOUBLE_2ADDR: {
1064 Binop_12x<HDiv>(instruction, Primitive::kPrimDouble);
1065 break;
1066 }
1067
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001068 case Instruction::ADD_INT_LIT16: {
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001069 Binop_22s<HAdd>(instruction, false);
1070 break;
1071 }
1072
1073 case Instruction::RSUB_INT: {
1074 Binop_22s<HSub>(instruction, true);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001075 break;
1076 }
1077
Calin Juravle34bacdf2014-10-07 20:23:36 +01001078 case Instruction::MUL_INT_LIT16: {
1079 Binop_22s<HMul>(instruction, false);
1080 break;
1081 }
1082
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001083 case Instruction::ADD_INT_LIT8: {
Nicolas Geoffrayf583e592014-04-07 13:20:42 +01001084 Binop_22b<HAdd>(instruction, false);
1085 break;
1086 }
1087
1088 case Instruction::RSUB_INT_LIT8: {
1089 Binop_22b<HSub>(instruction, true);
Nicolas Geoffrayd8ee7372014-03-28 15:43:40 +00001090 break;
1091 }
1092
Calin Juravle34bacdf2014-10-07 20:23:36 +01001093 case Instruction::MUL_INT_LIT8: {
1094 Binop_22b<HMul>(instruction, false);
1095 break;
1096 }
1097
Calin Juravled0d48522014-11-04 16:40:20 +00001098 case Instruction::DIV_INT_LIT16:
1099 case Instruction::DIV_INT_LIT8: {
Calin Juravle865fc882014-11-06 17:09:03 +00001100 BuildCheckedDiv(instruction.VRegA(), instruction.VRegB(), instruction.VRegC(),
1101 dex_offset, Primitive::kPrimInt, true);
Calin Juravled0d48522014-11-04 16:40:20 +00001102 break;
1103 }
1104
Nicolas Geoffray2e7038a2014-04-03 18:49:58 +01001105 case Instruction::NEW_INSTANCE: {
1106 current_block_->AddInstruction(
1107 new (arena_) HNewInstance(dex_offset, instruction.VRegB_21c()));
1108 UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
1109 break;
1110 }
1111
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001112 case Instruction::NEW_ARRAY: {
1113 HInstruction* length = LoadLocal(instruction.VRegB_22c(), Primitive::kPrimInt);
1114 current_block_->AddInstruction(
1115 new (arena_) HNewArray(length, dex_offset, instruction.VRegC_22c()));
1116 UpdateLocal(instruction.VRegA_22c(), current_block_->GetLastInstruction());
1117 break;
1118 }
1119
1120 case Instruction::FILLED_NEW_ARRAY: {
1121 uint32_t number_of_vreg_arguments = instruction.VRegA_35c();
1122 uint32_t type_index = instruction.VRegB_35c();
1123 uint32_t args[5];
1124 instruction.GetVarArgs(args);
1125 BuildFilledNewArray(dex_offset, type_index, number_of_vreg_arguments, false, args, 0);
1126 break;
1127 }
1128
1129 case Instruction::FILLED_NEW_ARRAY_RANGE: {
1130 uint32_t number_of_vreg_arguments = instruction.VRegA_3rc();
1131 uint32_t type_index = instruction.VRegB_3rc();
1132 uint32_t register_index = instruction.VRegC_3rc();
1133 BuildFilledNewArray(
1134 dex_offset, type_index, number_of_vreg_arguments, true, nullptr, register_index);
1135 break;
1136 }
1137
1138 case Instruction::FILL_ARRAY_DATA: {
Calin Juravled0d48522014-11-04 16:40:20 +00001139 BuildFillArrayData(instruction, dex_offset);
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001140 break;
1141 }
1142
Nicolas Geoffrayddb311f2014-05-16 09:28:54 +01001143 case Instruction::MOVE_RESULT:
Dave Allison20dfc792014-06-16 20:44:29 -07001144 case Instruction::MOVE_RESULT_WIDE:
1145 case Instruction::MOVE_RESULT_OBJECT:
Nicolas Geoffraya3d05a42014-10-20 17:41:32 +01001146 UpdateLocal(instruction.VRegA(), latest_result_);
1147 latest_result_ = nullptr;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001148 break;
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001149
Nicolas Geoffray412f10c2014-06-19 10:00:34 +01001150 case Instruction::CMP_LONG: {
1151 Binop_23x<HCompare>(instruction, Primitive::kPrimLong);
1152 break;
1153 }
1154
Nicolas Geoffraybe9a92a2014-02-25 14:22:56 +00001155 case Instruction::NOP:
1156 break;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001157
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001158 case Instruction::IGET:
1159 case Instruction::IGET_WIDE:
1160 case Instruction::IGET_OBJECT:
1161 case Instruction::IGET_BOOLEAN:
1162 case Instruction::IGET_BYTE:
1163 case Instruction::IGET_CHAR:
1164 case Instruction::IGET_SHORT: {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001165 if (!BuildInstanceFieldAccess(instruction, dex_offset, false)) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001166 return false;
1167 }
1168 break;
1169 }
1170
1171 case Instruction::IPUT:
1172 case Instruction::IPUT_WIDE:
1173 case Instruction::IPUT_OBJECT:
1174 case Instruction::IPUT_BOOLEAN:
1175 case Instruction::IPUT_BYTE:
1176 case Instruction::IPUT_CHAR:
1177 case Instruction::IPUT_SHORT: {
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +01001178 if (!BuildInstanceFieldAccess(instruction, dex_offset, true)) {
1179 return false;
1180 }
1181 break;
1182 }
1183
1184 case Instruction::SGET:
1185 case Instruction::SGET_WIDE:
1186 case Instruction::SGET_OBJECT:
1187 case Instruction::SGET_BOOLEAN:
1188 case Instruction::SGET_BYTE:
1189 case Instruction::SGET_CHAR:
1190 case Instruction::SGET_SHORT: {
1191 if (!BuildStaticFieldAccess(instruction, dex_offset, false)) {
1192 return false;
1193 }
1194 break;
1195 }
1196
1197 case Instruction::SPUT:
1198 case Instruction::SPUT_WIDE:
1199 case Instruction::SPUT_OBJECT:
1200 case Instruction::SPUT_BOOLEAN:
1201 case Instruction::SPUT_BYTE:
1202 case Instruction::SPUT_CHAR:
1203 case Instruction::SPUT_SHORT: {
1204 if (!BuildStaticFieldAccess(instruction, dex_offset, true)) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +01001205 return false;
1206 }
1207 break;
1208 }
1209
Nicolas Geoffray3c7bb982014-07-23 16:04:16 +01001210#define ARRAY_XX(kind, anticipated_type) \
1211 case Instruction::AGET##kind: { \
1212 BuildArrayAccess(instruction, dex_offset, false, anticipated_type); \
1213 break; \
1214 } \
1215 case Instruction::APUT##kind: { \
1216 BuildArrayAccess(instruction, dex_offset, true, anticipated_type); \
1217 break; \
1218 }
1219
1220 ARRAY_XX(, Primitive::kPrimInt);
1221 ARRAY_XX(_WIDE, Primitive::kPrimLong);
1222 ARRAY_XX(_OBJECT, Primitive::kPrimNot);
1223 ARRAY_XX(_BOOLEAN, Primitive::kPrimBoolean);
1224 ARRAY_XX(_BYTE, Primitive::kPrimByte);
1225 ARRAY_XX(_CHAR, Primitive::kPrimChar);
1226 ARRAY_XX(_SHORT, Primitive::kPrimShort);
1227
Nicolas Geoffray39468442014-09-02 15:17:15 +01001228 case Instruction::ARRAY_LENGTH: {
1229 HInstruction* object = LoadLocal(instruction.VRegB_12x(), Primitive::kPrimNot);
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +00001230 // No need for a temporary for the null check, it is the only input of the following
1231 // instruction.
1232 object = new (arena_) HNullCheck(object, dex_offset);
1233 current_block_->AddInstruction(object);
Nicolas Geoffray39468442014-09-02 15:17:15 +01001234 current_block_->AddInstruction(new (arena_) HArrayLength(object));
1235 UpdateLocal(instruction.VRegA_12x(), current_block_->GetLastInstruction());
1236 break;
1237 }
1238
Nicolas Geoffrayb5f62b32014-10-30 10:58:41 +00001239 case Instruction::CONST_STRING: {
1240 current_block_->AddInstruction(new (arena_) HLoadString(instruction.VRegB_21c(), dex_offset));
1241 UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
1242 break;
1243 }
1244
1245 case Instruction::CONST_STRING_JUMBO: {
1246 current_block_->AddInstruction(new (arena_) HLoadString(instruction.VRegB_31c(), dex_offset));
1247 UpdateLocal(instruction.VRegA_31c(), current_block_->GetLastInstruction());
1248 break;
1249 }
1250
Nicolas Geoffray424f6762014-11-03 14:51:25 +00001251 case Instruction::CONST_CLASS: {
1252 uint16_t type_index = instruction.VRegB_21c();
1253 bool type_known_final;
1254 bool type_known_abstract;
1255 bool is_referrers_class;
1256 bool can_access = compiler_driver_->CanAccessTypeWithoutChecks(
1257 dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index,
1258 &type_known_final, &type_known_abstract, &is_referrers_class);
1259 if (!can_access) {
1260 return false;
1261 }
1262 current_block_->AddInstruction(
1263 new (arena_) HLoadClass(instruction.VRegB_21c(), is_referrers_class, dex_offset));
1264 UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction());
1265 break;
1266 }
1267
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +00001268 case Instruction::MOVE_EXCEPTION: {
1269 current_block_->AddInstruction(new (arena_) HLoadException());
1270 UpdateLocal(instruction.VRegA_11x(), current_block_->GetLastInstruction());
1271 break;
1272 }
1273
1274 case Instruction::THROW: {
1275 HInstruction* exception = LoadLocal(instruction.VRegA_11x(), Primitive::kPrimNot);
1276 current_block_->AddInstruction(new (arena_) HThrow(exception, dex_offset));
1277 // A throw instruction must branch to the exit block.
1278 current_block_->AddSuccessor(exit_block_);
1279 // We finished building this block. Set the current block to null to avoid
1280 // adding dead instructions to it.
1281 current_block_ = nullptr;
1282 break;
1283 }
1284
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001285 default:
1286 return false;
1287 }
1288 return true;
1289}
1290
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001291HIntConstant* HGraphBuilder::GetIntConstant0() {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001292 if (constant0_ != nullptr) {
1293 return constant0_;
1294 }
1295 constant0_ = new(arena_) HIntConstant(0);
1296 entry_block_->AddInstruction(constant0_);
1297 return constant0_;
1298}
1299
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001300HIntConstant* HGraphBuilder::GetIntConstant1() {
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +00001301 if (constant1_ != nullptr) {
1302 return constant1_;
1303 }
1304 constant1_ = new(arena_) HIntConstant(1);
1305 entry_block_->AddInstruction(constant1_);
1306 return constant1_;
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001307}
1308
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001309HIntConstant* HGraphBuilder::GetIntConstant(int32_t constant) {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001310 switch (constant) {
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001311 case 0: return GetIntConstant0();
1312 case 1: return GetIntConstant1();
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001313 default: {
1314 HIntConstant* instruction = new (arena_) HIntConstant(constant);
1315 entry_block_->AddInstruction(instruction);
1316 return instruction;
1317 }
1318 }
1319}
1320
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001321HLongConstant* HGraphBuilder::GetLongConstant(int64_t constant) {
1322 HLongConstant* instruction = new (arena_) HLongConstant(constant);
1323 entry_block_->AddInstruction(instruction);
1324 return instruction;
1325}
1326
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001327HLocal* HGraphBuilder::GetLocalAt(int register_index) const {
1328 return locals_.Get(register_index);
1329}
1330
1331void HGraphBuilder::UpdateLocal(int register_index, HInstruction* instruction) const {
1332 HLocal* local = GetLocalAt(register_index);
1333 current_block_->AddInstruction(new (arena_) HStoreLocal(local, instruction));
1334}
1335
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001336HInstruction* HGraphBuilder::LoadLocal(int register_index, Primitive::Type type) const {
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001337 HLocal* local = GetLocalAt(register_index);
Nicolas Geoffray01bc96d2014-04-11 17:43:50 +01001338 current_block_->AddInstruction(new (arena_) HLoadLocal(local, type));
Nicolas Geoffray787c3072014-03-17 10:20:19 +00001339 return current_block_->GetLastInstruction();
Nicolas Geoffray3ff386a2014-03-04 14:46:47 +00001340}
1341
Nicolas Geoffray818f2102014-02-18 16:43:35 +00001342} // namespace art