blob: 5b395c8eeb0d1795c07f42718eada94d937b8eb4 [file] [log] [blame]
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00001/*
2 * 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
17#include "code_generator.h"
18
19#include "code_generator_arm.h"
Alexandre Rames5319def2014-10-23 10:03:10 +010020#include "code_generator_arm64.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000021#include "code_generator_x86.h"
Nicolas Geoffray9cf35522014-06-09 18:40:10 +010022#include "code_generator_x86_64.h"
Yevgeny Roubane3ea8382014-08-08 16:29:38 +070023#include "compiled_method.h"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000024#include "dex/verified_method.h"
25#include "driver/dex_compilation_unit.h"
26#include "gc_map_builder.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000027#include "leb128.h"
28#include "mapping_table.h"
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +010029#include "mirror/array-inl.h"
30#include "mirror/object_array-inl.h"
31#include "mirror/object_reference.h"
Nicolas Geoffray3c049742014-09-24 18:10:46 +010032#include "ssa_liveness_analysis.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000033#include "utils/assembler.h"
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +000034#include "verifier/dex_gc_map.h"
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000035#include "vmap_table.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000036
37namespace art {
38
Nicolas Geoffray19a19cf2014-10-22 16:07:05 +010039size_t CodeGenerator::GetCacheOffset(uint32_t index) {
40 return mirror::ObjectArray<mirror::Object>::OffsetOfElement(index).SizeValue();
41}
42
Nicolas Geoffraydc23d832015-02-16 11:15:43 +000043static bool IsSingleGoto(HBasicBlock* block) {
44 HLoopInformation* loop_info = block->GetLoopInformation();
45 // TODO: Remove the null check b/19084197.
46 return (block->GetFirstInstruction() != nullptr)
47 && (block->GetFirstInstruction() == block->GetLastInstruction())
48 && block->GetLastInstruction()->IsGoto()
49 // Back edges generate the suspend check.
50 && (loop_info == nullptr || !loop_info->IsBackEdge(block));
51}
52
Nicolas Geoffray73e80c32014-07-22 17:47:56 +010053void CodeGenerator::CompileBaseline(CodeAllocator* allocator, bool is_leaf) {
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +000054 Initialize();
Nicolas Geoffray73e80c32014-07-22 17:47:56 +010055 if (!is_leaf) {
56 MarkNotLeaf();
57 }
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +000058 InitializeCodeGeneration(GetGraph()->GetNumberOfLocalVRegs()
59 + GetGraph()->GetTemporariesVRegSlots()
60 + 1 /* filler */,
61 0, /* the baseline compiler does not have live registers at slow path */
62 0, /* the baseline compiler does not have live registers at slow path */
63 GetGraph()->GetMaximumNumberOfOutVRegs()
64 + 1 /* current method */,
65 GetGraph()->GetBlocks());
66 CompileInternal(allocator, /* is_baseline */ true);
67}
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +010068
Nicolas Geoffraydc23d832015-02-16 11:15:43 +000069bool CodeGenerator::GoesToNextBlock(HBasicBlock* current, HBasicBlock* next) const {
70 DCHECK_EQ(block_order_->Get(current_block_index_), current);
71 return GetNextBlockToEmit() == FirstNonEmptyBlock(next);
72}
73
74HBasicBlock* CodeGenerator::GetNextBlockToEmit() const {
75 for (size_t i = current_block_index_ + 1; i < block_order_->Size(); ++i) {
76 HBasicBlock* block = block_order_->Get(i);
77 if (!IsSingleGoto(block)) {
78 return block;
79 }
80 }
81 return nullptr;
82}
83
84HBasicBlock* CodeGenerator::FirstNonEmptyBlock(HBasicBlock* block) const {
85 while (IsSingleGoto(block)) {
86 block = block->GetSuccessors().Get(0);
87 }
88 return block;
89}
90
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +000091void CodeGenerator::CompileInternal(CodeAllocator* allocator, bool is_baseline) {
Nicolas Geoffray8a16d972014-09-11 10:30:02 +010092 HGraphVisitor* instruction_visitor = GetInstructionVisitor();
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +000093 DCHECK_EQ(current_block_index_, 0u);
94 GenerateFrameEntry();
95 for (size_t e = block_order_->Size(); current_block_index_ < e; ++current_block_index_) {
96 HBasicBlock* block = block_order_->Get(current_block_index_);
Nicolas Geoffraydc23d832015-02-16 11:15:43 +000097 // Don't generate code for an empty block. Its predecessors will branch to its successor
98 // directly. Also, the label of that block will not be emitted, so this helps catch
99 // errors where we reference that label.
100 if (IsSingleGoto(block)) continue;
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100101 Bind(block);
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100102 for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
103 HInstruction* current = it.Current();
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000104 if (is_baseline) {
Nicolas Geoffrayc0572a42015-02-06 14:35:25 +0000105 InitLocationsBaseline(current);
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000106 }
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100107 current->Accept(instruction_visitor);
108 }
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000109 }
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000110
111 // Generate the slow paths.
112 for (size_t i = 0, e = slow_paths_.Size(); i < e; ++i) {
113 slow_paths_.Get(i)->EmitNativeCode(this);
114 }
115
116 // Finalize instructions in assember;
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000117 Finalize(allocator);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000118}
119
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100120void CodeGenerator::CompileOptimized(CodeAllocator* allocator) {
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000121 // The register allocator already called `InitializeCodeGeneration`,
122 // where the frame size has been computed.
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000123 DCHECK(block_order_ != nullptr);
Nicolas Geoffray92a73ae2014-10-16 11:12:52 +0100124 Initialize();
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000125 CompileInternal(allocator, /* is_baseline */ false);
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000126}
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100127
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000128void CodeGenerator::Finalize(CodeAllocator* allocator) {
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100129 size_t code_size = GetAssembler()->CodeSize();
130 uint8_t* buffer = allocator->Allocate(code_size);
Serban Constantinescu32f5b4d2014-11-25 20:05:46 +0000131
Nicolas Geoffray86dbb9a2014-06-04 11:12:39 +0100132 MemoryRegion code(buffer, code_size);
133 GetAssembler()->FinalizeInstructions(code);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000134}
135
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100136size_t CodeGenerator::FindFreeEntry(bool* array, size_t length) {
137 for (size_t i = 0; i < length; ++i) {
138 if (!array[i]) {
139 array[i] = true;
140 return i;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100141 }
142 }
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100143 LOG(FATAL) << "Could not find a register in baseline register allocator";
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000144 UNREACHABLE();
145 return -1;
146}
147
Nicolas Geoffray3c035032014-10-28 10:46:40 +0000148size_t CodeGenerator::FindTwoFreeConsecutiveAlignedEntries(bool* array, size_t length) {
149 for (size_t i = 0; i < length - 1; i += 2) {
Nicolas Geoffray1ba0f592014-10-27 15:14:55 +0000150 if (!array[i] && !array[i + 1]) {
151 array[i] = true;
152 array[i + 1] = true;
153 return i;
154 }
155 }
156 LOG(FATAL) << "Could not find a register in baseline register allocator";
157 UNREACHABLE();
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100158 return -1;
159}
160
Nicolas Geoffray4c204ba2015-02-03 15:12:35 +0000161void CodeGenerator::InitializeCodeGeneration(size_t number_of_spill_slots,
162 size_t maximum_number_of_live_core_registers,
163 size_t maximum_number_of_live_fp_registers,
164 size_t number_of_out_slots,
165 const GrowableArray<HBasicBlock*>& block_order) {
166 block_order_ = &block_order;
167 DCHECK(block_order_->Get(0) == GetGraph()->GetEntryBlock());
168 DCHECK(GoesToNextBlock(GetGraph()->GetEntryBlock(), block_order_->Get(1)));
Nicolas Geoffray4dee6362015-01-23 18:23:14 +0000169 ComputeSpillMask();
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100170 first_register_slot_in_slow_path_ = (number_of_out_slots + number_of_spill_slots) * kVRegSize;
171
Nicolas Geoffrayc0572a42015-02-06 14:35:25 +0000172 if (number_of_spill_slots == 0
173 && !HasAllocatedCalleeSaveRegisters()
174 && IsLeafMethod()
175 && !RequiresCurrentMethod()) {
176 DCHECK_EQ(maximum_number_of_live_core_registers, 0u);
177 DCHECK_EQ(maximum_number_of_live_fp_registers, 0u);
178 SetFrameSize(CallPushesPC() ? GetWordSize() : 0);
179 } else {
180 SetFrameSize(RoundUp(
181 number_of_spill_slots * kVRegSize
182 + number_of_out_slots * kVRegSize
183 + maximum_number_of_live_core_registers * GetWordSize()
184 + maximum_number_of_live_fp_registers * GetFloatingPointSpillSlotSize()
185 + FrameEntrySpillSize(),
186 kStackAlignment));
187 }
Nicolas Geoffrayab032bc2014-07-15 12:55:21 +0100188}
189
190Location CodeGenerator::GetTemporaryLocation(HTemporary* temp) const {
191 uint16_t number_of_locals = GetGraph()->GetNumberOfLocalVRegs();
Calin Juravlef97f9fb2014-11-11 15:38:19 +0000192 // The type of the previous instruction tells us if we need a single or double stack slot.
193 Primitive::Type type = temp->GetType();
194 int32_t temp_size = (type == Primitive::kPrimLong) || (type == Primitive::kPrimDouble) ? 2 : 1;
Nicolas Geoffrayab032bc2014-07-15 12:55:21 +0100195 // Use the temporary region (right below the dex registers).
196 int32_t slot = GetFrameSize() - FrameEntrySpillSize()
197 - kVRegSize // filler
198 - (number_of_locals * kVRegSize)
Calin Juravlef97f9fb2014-11-11 15:38:19 +0000199 - ((temp_size + temp->GetIndex()) * kVRegSize);
200 return temp_size == 2 ? Location::DoubleStackSlot(slot) : Location::StackSlot(slot);
Nicolas Geoffrayab032bc2014-07-15 12:55:21 +0100201}
202
203int32_t CodeGenerator::GetStackSlot(HLocal* local) const {
204 uint16_t reg_number = local->GetRegNumber();
205 uint16_t number_of_locals = GetGraph()->GetNumberOfLocalVRegs();
206 if (reg_number >= number_of_locals) {
207 // Local is a parameter of the method. It is stored in the caller's frame.
208 return GetFrameSize() + kVRegSize // ART method
209 + (reg_number - number_of_locals) * kVRegSize;
210 } else {
211 // Local is a temporary in this method. It is stored in this method's frame.
212 return GetFrameSize() - FrameEntrySpillSize()
213 - kVRegSize // filler.
214 - (number_of_locals * kVRegSize)
215 + (reg_number * kVRegSize);
216 }
217}
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100218
219void CodeGenerator::AllocateRegistersLocally(HInstruction* instruction) const {
220 LocationSummary* locations = instruction->GetLocations();
221 if (locations == nullptr) return;
222
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100223 for (size_t i = 0, e = GetNumberOfCoreRegisters(); i < e; ++i) {
224 blocked_core_registers_[i] = false;
225 }
226
227 for (size_t i = 0, e = GetNumberOfFloatingPointRegisters(); i < e; ++i) {
228 blocked_fpu_registers_[i] = false;
229 }
230
231 for (size_t i = 0, e = number_of_register_pairs_; i < e; ++i) {
232 blocked_register_pairs_[i] = false;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100233 }
234
235 // Mark all fixed input, temp and output registers as used.
236 for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) {
237 Location loc = locations->InAt(i);
Nicolas Geoffray5b4b8982014-12-18 17:45:56 +0000238 // The DCHECKS below check that a register is not specified twice in
239 // the summary.
240 if (loc.IsRegister()) {
241 DCHECK(!blocked_core_registers_[loc.reg()]);
242 blocked_core_registers_[loc.reg()] = true;
243 } else if (loc.IsFpuRegister()) {
244 DCHECK(!blocked_fpu_registers_[loc.reg()]);
245 blocked_fpu_registers_[loc.reg()] = true;
246 } else if (loc.IsFpuRegisterPair()) {
247 DCHECK(!blocked_fpu_registers_[loc.AsFpuRegisterPairLow<int>()]);
248 blocked_fpu_registers_[loc.AsFpuRegisterPairLow<int>()] = true;
249 DCHECK(!blocked_fpu_registers_[loc.AsFpuRegisterPairHigh<int>()]);
250 blocked_fpu_registers_[loc.AsFpuRegisterPairHigh<int>()] = true;
251 } else if (loc.IsRegisterPair()) {
252 DCHECK(!blocked_core_registers_[loc.AsRegisterPairLow<int>()]);
253 blocked_core_registers_[loc.AsRegisterPairLow<int>()] = true;
254 DCHECK(!blocked_core_registers_[loc.AsRegisterPairHigh<int>()]);
255 blocked_core_registers_[loc.AsRegisterPairHigh<int>()] = true;
256 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100257 }
258
259 for (size_t i = 0, e = locations->GetTempCount(); i < e; ++i) {
260 Location loc = locations->GetTemp(i);
Nicolas Geoffray5b4b8982014-12-18 17:45:56 +0000261 // The DCHECKS below check that a register is not specified twice in
262 // the summary.
263 if (loc.IsRegister()) {
264 DCHECK(!blocked_core_registers_[loc.reg()]);
265 blocked_core_registers_[loc.reg()] = true;
266 } else if (loc.IsFpuRegister()) {
267 DCHECK(!blocked_fpu_registers_[loc.reg()]);
268 blocked_fpu_registers_[loc.reg()] = true;
269 } else {
270 DCHECK(loc.GetPolicy() == Location::kRequiresRegister
271 || loc.GetPolicy() == Location::kRequiresFpuRegister);
272 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100273 }
274
Nicolas Geoffray98893962015-01-21 12:32:32 +0000275 static constexpr bool kBaseline = true;
276 SetupBlockedRegisters(kBaseline);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100277
278 // Allocate all unallocated input locations.
279 for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) {
280 Location loc = locations->InAt(i);
281 HInstruction* input = instruction->InputAt(i);
282 if (loc.IsUnallocated()) {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100283 if ((loc.GetPolicy() == Location::kRequiresRegister)
284 || (loc.GetPolicy() == Location::kRequiresFpuRegister)) {
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100285 loc = AllocateFreeRegister(input->GetType());
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100286 } else {
287 DCHECK_EQ(loc.GetPolicy(), Location::kAny);
288 HLoadLocal* load = input->AsLoadLocal();
289 if (load != nullptr) {
290 loc = GetStackLocation(load);
291 } else {
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100292 loc = AllocateFreeRegister(input->GetType());
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100293 }
294 }
295 locations->SetInAt(i, loc);
296 }
297 }
298
299 // Allocate all unallocated temp locations.
300 for (size_t i = 0, e = locations->GetTempCount(); i < e; ++i) {
301 Location loc = locations->GetTemp(i);
302 if (loc.IsUnallocated()) {
Roland Levillain647b9ed2014-11-27 12:06:00 +0000303 switch (loc.GetPolicy()) {
304 case Location::kRequiresRegister:
305 // Allocate a core register (large enough to fit a 32-bit integer).
306 loc = AllocateFreeRegister(Primitive::kPrimInt);
307 break;
308
309 case Location::kRequiresFpuRegister:
310 // Allocate a core register (large enough to fit a 64-bit double).
311 loc = AllocateFreeRegister(Primitive::kPrimDouble);
312 break;
313
314 default:
315 LOG(FATAL) << "Unexpected policy for temporary location "
316 << loc.GetPolicy();
317 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100318 locations->SetTempAt(i, loc);
319 }
320 }
Nicolas Geoffray5b4b8982014-12-18 17:45:56 +0000321 Location result_location = locations->Out();
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100322 if (result_location.IsUnallocated()) {
323 switch (result_location.GetPolicy()) {
324 case Location::kAny:
325 case Location::kRequiresRegister:
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100326 case Location::kRequiresFpuRegister:
Nicolas Geoffray71175b72014-10-09 22:13:55 +0100327 result_location = AllocateFreeRegister(instruction->GetType());
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +0100328 break;
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100329 case Location::kSameAsFirstInput:
330 result_location = locations->InAt(0);
331 break;
332 }
Nicolas Geoffray829280c2015-01-28 10:20:37 +0000333 locations->UpdateOut(result_location);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100334 }
335}
336
Nicolas Geoffrayc0572a42015-02-06 14:35:25 +0000337void CodeGenerator::InitLocationsBaseline(HInstruction* instruction) {
338 AllocateLocations(instruction);
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100339 if (instruction->GetLocations() == nullptr) {
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100340 if (instruction->IsTemporary()) {
341 HInstruction* previous = instruction->GetPrevious();
342 Location temp_location = GetTemporaryLocation(instruction->AsTemporary());
343 Move(previous, temp_location, instruction);
Nicolas Geoffraye5038322014-07-04 09:41:32 +0100344 }
Nicolas Geoffraya7aca372014-04-28 17:47:12 +0100345 return;
346 }
347 AllocateRegistersLocally(instruction);
348 for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) {
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000349 Location location = instruction->GetLocations()->InAt(i);
Nicolas Geoffrayf43083d2014-11-07 10:48:10 +0000350 HInstruction* input = instruction->InputAt(i);
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000351 if (location.IsValid()) {
352 // Move the input to the desired location.
Nicolas Geoffrayf43083d2014-11-07 10:48:10 +0000353 if (input->GetNext()->IsTemporary()) {
354 // If the input was stored in a temporary, use that temporary to
355 // perform the move.
356 Move(input->GetNext(), location, instruction);
357 } else {
358 Move(input, location, instruction);
359 }
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +0000360 }
361 }
362}
363
Nicolas Geoffrayc0572a42015-02-06 14:35:25 +0000364void CodeGenerator::AllocateLocations(HInstruction* instruction) {
365 instruction->Accept(GetLocationBuilder());
366 LocationSummary* locations = instruction->GetLocations();
367 if (!instruction->IsSuspendCheckEntry()) {
368 if (locations != nullptr && locations->CanCall()) {
369 MarkNotLeaf();
370 }
371 if (instruction->NeedsCurrentMethod()) {
372 SetRequiresCurrentMethod();
373 }
374 }
375}
376
Nicolas Geoffray12df9eb2015-01-09 14:53:50 +0000377CodeGenerator* CodeGenerator::Create(HGraph* graph,
Calin Juravle34166012014-12-19 17:22:29 +0000378 InstructionSet instruction_set,
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000379 const InstructionSetFeatures& isa_features,
380 const CompilerOptions& compiler_options) {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000381 switch (instruction_set) {
382 case kArm:
383 case kThumb2: {
Nicolas Geoffray12df9eb2015-01-09 14:53:50 +0000384 return new arm::CodeGeneratorARM(graph,
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000385 *isa_features.AsArmInstructionSetFeatures(),
386 compiler_options);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000387 }
Alexandre Rames5319def2014-10-23 10:03:10 +0100388 case kArm64: {
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000389 return new arm64::CodeGeneratorARM64(graph, compiler_options);
Alexandre Rames5319def2014-10-23 10:03:10 +0100390 }
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000391 case kMips:
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000392 return nullptr;
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000393 case kX86: {
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000394 return new x86::CodeGeneratorX86(graph, compiler_options);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000395 }
Dmitry Petrochenko6a58cb12014-04-02 17:27:59 +0700396 case kX86_64: {
Calin Juravlecd6dffe2015-01-08 17:35:35 +0000397 return new x86_64::CodeGeneratorX86_64(graph, compiler_options);
Dmitry Petrochenko6a58cb12014-04-02 17:27:59 +0700398 }
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000399 default:
Nicolas Geoffray787c3072014-03-17 10:20:19 +0000400 return nullptr;
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000401 }
402}
403
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000404void CodeGenerator::BuildNativeGCMap(
405 std::vector<uint8_t>* data, const DexCompilationUnit& dex_compilation_unit) const {
406 const std::vector<uint8_t>& gc_map_raw =
407 dex_compilation_unit.GetVerifiedMethod()->GetDexGcMap();
408 verifier::DexPcToReferenceMap dex_gc_map(&(gc_map_raw)[0]);
409
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000410 uint32_t max_native_offset = 0;
411 for (size_t i = 0; i < pc_infos_.Size(); i++) {
412 uint32_t native_offset = pc_infos_.Get(i).native_pc;
413 if (native_offset > max_native_offset) {
414 max_native_offset = native_offset;
415 }
416 }
417
418 GcMapBuilder builder(data, pc_infos_.Size(), max_native_offset, dex_gc_map.RegWidth());
419 for (size_t i = 0; i < pc_infos_.Size(); i++) {
420 struct PcInfo pc_info = pc_infos_.Get(i);
421 uint32_t native_offset = pc_info.native_pc;
422 uint32_t dex_pc = pc_info.dex_pc;
423 const uint8_t* references = dex_gc_map.FindBitMap(dex_pc, false);
Jean Christophe Beyler0ada95d2014-12-04 11:20:20 -0800424 CHECK(references != nullptr) << "Missing ref for dex pc 0x" << std::hex << dex_pc;
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000425 builder.AddEntry(native_offset, references);
426 }
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000427}
428
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800429void CodeGenerator::BuildMappingTable(std::vector<uint8_t>* data, DefaultSrcMap* src_map) const {
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000430 uint32_t pc2dex_data_size = 0u;
431 uint32_t pc2dex_entries = pc_infos_.Size();
432 uint32_t pc2dex_offset = 0u;
433 int32_t pc2dex_dalvik_offset = 0;
434 uint32_t dex2pc_data_size = 0u;
435 uint32_t dex2pc_entries = 0u;
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000436 uint32_t dex2pc_offset = 0u;
437 int32_t dex2pc_dalvik_offset = 0;
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000438
Yevgeny Roubane3ea8382014-08-08 16:29:38 +0700439 if (src_map != nullptr) {
440 src_map->reserve(pc2dex_entries);
441 }
442
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000443 for (size_t i = 0; i < pc2dex_entries; i++) {
444 struct PcInfo pc_info = pc_infos_.Get(i);
445 pc2dex_data_size += UnsignedLeb128Size(pc_info.native_pc - pc2dex_offset);
446 pc2dex_data_size += SignedLeb128Size(pc_info.dex_pc - pc2dex_dalvik_offset);
447 pc2dex_offset = pc_info.native_pc;
448 pc2dex_dalvik_offset = pc_info.dex_pc;
Yevgeny Roubane3ea8382014-08-08 16:29:38 +0700449 if (src_map != nullptr) {
450 src_map->push_back(SrcMapElem({pc2dex_offset, pc2dex_dalvik_offset}));
451 }
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000452 }
453
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000454 // Walk over the blocks and find which ones correspond to catch block entries.
455 for (size_t i = 0; i < graph_->GetBlocks().Size(); ++i) {
456 HBasicBlock* block = graph_->GetBlocks().Get(i);
457 if (block->IsCatchBlock()) {
458 intptr_t native_pc = GetAddressOf(block);
459 ++dex2pc_entries;
460 dex2pc_data_size += UnsignedLeb128Size(native_pc - dex2pc_offset);
461 dex2pc_data_size += SignedLeb128Size(block->GetDexPc() - dex2pc_dalvik_offset);
462 dex2pc_offset = native_pc;
463 dex2pc_dalvik_offset = block->GetDexPc();
464 }
465 }
466
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000467 uint32_t total_entries = pc2dex_entries + dex2pc_entries;
468 uint32_t hdr_data_size = UnsignedLeb128Size(total_entries) + UnsignedLeb128Size(pc2dex_entries);
469 uint32_t data_size = hdr_data_size + pc2dex_data_size + dex2pc_data_size;
470 data->resize(data_size);
471
472 uint8_t* data_ptr = &(*data)[0];
473 uint8_t* write_pos = data_ptr;
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000474
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000475 write_pos = EncodeUnsignedLeb128(write_pos, total_entries);
476 write_pos = EncodeUnsignedLeb128(write_pos, pc2dex_entries);
477 DCHECK_EQ(static_cast<size_t>(write_pos - data_ptr), hdr_data_size);
478 uint8_t* write_pos2 = write_pos + pc2dex_data_size;
479
480 pc2dex_offset = 0u;
481 pc2dex_dalvik_offset = 0u;
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000482 dex2pc_offset = 0u;
483 dex2pc_dalvik_offset = 0u;
484
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000485 for (size_t i = 0; i < pc2dex_entries; i++) {
486 struct PcInfo pc_info = pc_infos_.Get(i);
487 DCHECK(pc2dex_offset <= pc_info.native_pc);
488 write_pos = EncodeUnsignedLeb128(write_pos, pc_info.native_pc - pc2dex_offset);
489 write_pos = EncodeSignedLeb128(write_pos, pc_info.dex_pc - pc2dex_dalvik_offset);
490 pc2dex_offset = pc_info.native_pc;
491 pc2dex_dalvik_offset = pc_info.dex_pc;
492 }
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000493
494 for (size_t i = 0; i < graph_->GetBlocks().Size(); ++i) {
495 HBasicBlock* block = graph_->GetBlocks().Get(i);
496 if (block->IsCatchBlock()) {
497 intptr_t native_pc = GetAddressOf(block);
498 write_pos2 = EncodeUnsignedLeb128(write_pos2, native_pc - dex2pc_offset);
499 write_pos2 = EncodeSignedLeb128(write_pos2, block->GetDexPc() - dex2pc_dalvik_offset);
500 dex2pc_offset = native_pc;
501 dex2pc_dalvik_offset = block->GetDexPc();
502 }
503 }
504
505
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000506 DCHECK_EQ(static_cast<size_t>(write_pos - data_ptr), hdr_data_size + pc2dex_data_size);
507 DCHECK_EQ(static_cast<size_t>(write_pos2 - data_ptr), data_size);
508
509 if (kIsDebugBuild) {
510 // Verify the encoded table holds the expected data.
511 MappingTable table(data_ptr);
512 CHECK_EQ(table.TotalSize(), total_entries);
513 CHECK_EQ(table.PcToDexSize(), pc2dex_entries);
514 auto it = table.PcToDexBegin();
515 auto it2 = table.DexToPcBegin();
516 for (size_t i = 0; i < pc2dex_entries; i++) {
517 struct PcInfo pc_info = pc_infos_.Get(i);
518 CHECK_EQ(pc_info.native_pc, it.NativePcOffset());
519 CHECK_EQ(pc_info.dex_pc, it.DexPc());
520 ++it;
521 }
Nicolas Geoffrayde58ab22014-11-05 12:46:03 +0000522 for (size_t i = 0; i < graph_->GetBlocks().Size(); ++i) {
523 HBasicBlock* block = graph_->GetBlocks().Get(i);
524 if (block->IsCatchBlock()) {
525 CHECK_EQ(GetAddressOf(block), it2.NativePcOffset());
526 CHECK_EQ(block->GetDexPc(), it2.DexPc());
527 ++it2;
528 }
529 }
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000530 CHECK(it == table.PcToDexEnd());
531 CHECK(it2 == table.DexToPcEnd());
532 }
533}
534
535void CodeGenerator::BuildVMapTable(std::vector<uint8_t>* data) const {
536 Leb128EncodingVector vmap_encoder;
Nicolas Geoffray4a34a422014-04-03 10:38:37 +0100537 // We currently don't use callee-saved registers.
538 size_t size = 0 + 1 /* marker */ + 0;
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000539 vmap_encoder.Reserve(size + 1u); // All values are likely to be one byte in ULEB128 (<128).
540 vmap_encoder.PushBackUnsigned(size);
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +0000541 vmap_encoder.PushBackUnsigned(VmapTable::kAdjustedFpMarker);
542
543 *data = vmap_encoder.GetData();
544}
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000545
Nicolas Geoffray39468442014-09-02 15:17:15 +0100546void CodeGenerator::BuildStackMaps(std::vector<uint8_t>* data) {
547 uint32_t size = stack_map_stream_.ComputeNeededSize();
548 data->resize(size);
549 MemoryRegion region(data->data(), size);
550 stack_map_stream_.FillIn(region);
551}
552
553void CodeGenerator::RecordPcInfo(HInstruction* instruction, uint32_t dex_pc) {
Calin Juravled2ec87d2014-12-08 14:24:46 +0000554 if (instruction != nullptr) {
Roland Levillain624279f2014-12-04 11:54:28 +0000555 // The code generated for some type conversions may call the
556 // runtime, thus normally requiring a subsequent call to this
557 // method. However, the method verifier does not produce PC
Calin Juravled2ec87d2014-12-08 14:24:46 +0000558 // information for certain instructions, which are considered "atomic"
559 // (they cannot join a GC).
Roland Levillain624279f2014-12-04 11:54:28 +0000560 // Therefore we do not currently record PC information for such
561 // instructions. As this may change later, we added this special
562 // case so that code generators may nevertheless call
563 // CodeGenerator::RecordPcInfo without triggering an error in
564 // CodeGenerator::BuildNativeGCMap ("Missing ref for dex pc 0x")
565 // thereafter.
Calin Juravled2ec87d2014-12-08 14:24:46 +0000566 if (instruction->IsTypeConversion()) {
567 return;
568 }
569 if (instruction->IsRem()) {
570 Primitive::Type type = instruction->AsRem()->GetResultType();
571 if ((type == Primitive::kPrimFloat) || (type == Primitive::kPrimDouble)) {
572 return;
573 }
574 }
Roland Levillain624279f2014-12-04 11:54:28 +0000575 }
576
Nicolas Geoffray39468442014-09-02 15:17:15 +0100577 // Collect PC infos for the mapping table.
578 struct PcInfo pc_info;
579 pc_info.dex_pc = dex_pc;
580 pc_info.native_pc = GetAssembler()->CodeSize();
581 pc_infos_.Add(pc_info);
582
583 // Populate stack map information.
584
585 if (instruction == nullptr) {
586 // For stack overflow checks.
587 stack_map_stream_.AddStackMapEntry(dex_pc, pc_info.native_pc, 0, 0, 0, 0);
588 return;
589 }
590
591 LocationSummary* locations = instruction->GetLocations();
592 HEnvironment* environment = instruction->GetEnvironment();
593
594 size_t environment_size = instruction->EnvironmentSize();
595
Nicolas Geoffray39468442014-09-02 15:17:15 +0100596 size_t inlining_depth = 0;
Nicolas Geoffray98893962015-01-21 12:32:32 +0000597 uint32_t register_mask = locations->GetRegisterMask();
598 if (locations->OnlyCallsOnSlowPath()) {
599 // In case of slow path, we currently set the location of caller-save registers
600 // to register (instead of their stack location when pushed before the slow-path
601 // call). Therefore register_mask contains both callee-save and caller-save
602 // registers that hold objects. We must remove the caller-save from the mask, since
603 // they will be overwritten by the callee.
604 register_mask &= core_callee_save_mask_;
605 }
606 // The register mask must be a subset of callee-save registers.
607 DCHECK_EQ(register_mask & core_callee_save_mask_, register_mask);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100608 stack_map_stream_.AddStackMapEntry(
609 dex_pc, pc_info.native_pc, register_mask,
610 locations->GetStackMask(), environment_size, inlining_depth);
611
612 // Walk over the environment, and record the location of dex registers.
613 for (size_t i = 0; i < environment_size; ++i) {
614 HInstruction* current = environment->GetInstructionAt(i);
615 if (current == nullptr) {
616 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kNone, 0);
617 continue;
618 }
619
620 Location location = locations->GetEnvironmentAt(i);
621 switch (location.GetKind()) {
622 case Location::kConstant: {
623 DCHECK(current == location.GetConstant());
624 if (current->IsLongConstant()) {
625 int64_t value = current->AsLongConstant()->GetValue();
626 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, Low32Bits(value));
627 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, High32Bits(value));
628 ++i;
629 DCHECK_LT(i, environment_size);
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000630 } else if (current->IsDoubleConstant()) {
631 int64_t value = bit_cast<double, int64_t>(current->AsDoubleConstant()->GetValue());
632 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, Low32Bits(value));
633 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, High32Bits(value));
634 ++i;
635 DCHECK_LT(i, environment_size);
636 } else if (current->IsIntConstant()) {
Nicolas Geoffray39468442014-09-02 15:17:15 +0100637 int32_t value = current->AsIntConstant()->GetValue();
638 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, value);
Nicolas Geoffrayd6138ef2015-02-18 14:48:53 +0000639 } else if (current->IsNullConstant()) {
640 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, 0);
Nicolas Geoffraye53798a2014-12-01 10:31:54 +0000641 } else {
642 DCHECK(current->IsFloatConstant());
643 int32_t value = bit_cast<float, int32_t>(current->AsFloatConstant()->GetValue());
644 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kConstant, value);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100645 }
646 break;
647 }
648
649 case Location::kStackSlot: {
650 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInStack, location.GetStackIndex());
651 break;
652 }
653
654 case Location::kDoubleStackSlot: {
655 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInStack, location.GetStackIndex());
656 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInStack,
657 location.GetHighStackIndex(kVRegSize));
658 ++i;
659 DCHECK_LT(i, environment_size);
660 break;
661 }
662
663 case Location::kRegister : {
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +0100664 int id = location.reg();
Nicolas Geoffray39468442014-09-02 15:17:15 +0100665 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInRegister, id);
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100666 if (current->GetType() == Primitive::kPrimLong) {
Nicolas Geoffray39468442014-09-02 15:17:15 +0100667 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInRegister, id);
668 ++i;
669 DCHECK_LT(i, environment_size);
670 }
671 break;
672 }
673
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100674 case Location::kFpuRegister : {
675 int id = location.reg();
676 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInFpuRegister, id);
677 if (current->GetType() == Primitive::kPrimDouble) {
678 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInFpuRegister, id);
679 ++i;
680 DCHECK_LT(i, environment_size);
681 }
682 break;
683 }
684
Nicolas Geoffray840e5462015-01-07 16:01:24 +0000685 case Location::kFpuRegisterPair : {
686 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInFpuRegister, location.low());
687 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInFpuRegister, location.high());
688 ++i;
689 DCHECK_LT(i, environment_size);
690 break;
691 }
692
Nicolas Geoffray6c2dff82015-01-21 14:56:54 +0000693 case Location::kRegisterPair : {
694 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInRegister, location.low());
695 stack_map_stream_.AddDexRegisterEntry(DexRegisterMap::kInRegister, location.high());
696 ++i;
697 DCHECK_LT(i, environment_size);
698 break;
699 }
700
Nicolas Geoffray39468442014-09-02 15:17:15 +0100701 default:
702 LOG(FATAL) << "Unexpected kind " << location.GetKind();
703 }
704 }
705}
706
Calin Juravle77520bc2015-01-12 18:45:46 +0000707bool CodeGenerator::CanMoveNullCheckToUser(HNullCheck* null_check) {
708 HInstruction* first_next_not_move = null_check->GetNextDisregardingMoves();
709 return (first_next_not_move != nullptr) && first_next_not_move->CanDoImplicitNullCheck();
710}
711
712void CodeGenerator::MaybeRecordImplicitNullCheck(HInstruction* instr) {
713 // If we are from a static path don't record the pc as we can't throw NPE.
714 // NB: having the checks here makes the code much less verbose in the arch
715 // specific code generators.
716 if (instr->IsStaticFieldSet() || instr->IsStaticFieldGet()) {
717 return;
718 }
719
720 if (!compiler_options_.GetImplicitNullChecks()) {
721 return;
722 }
723
724 if (!instr->CanDoImplicitNullCheck()) {
725 return;
726 }
727
728 // Find the first previous instruction which is not a move.
729 HInstruction* first_prev_not_move = instr->GetPreviousDisregardingMoves();
730
731 // If the instruction is a null check it means that `instr` is the first user
732 // and needs to record the pc.
733 if (first_prev_not_move != nullptr && first_prev_not_move->IsNullCheck()) {
734 HNullCheck* null_check = first_prev_not_move->AsNullCheck();
735 // TODO: The parallel moves modify the environment. Their changes need to be reverted
736 // otherwise the stack maps at the throw point will not be correct.
737 RecordPcInfo(null_check, null_check->GetDexPc());
738 }
739}
740
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100741void CodeGenerator::SaveLiveRegisters(LocationSummary* locations) {
742 RegisterSet* register_set = locations->GetLiveRegisters();
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100743 size_t stack_offset = first_register_slot_in_slow_path_;
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100744 for (size_t i = 0, e = GetNumberOfCoreRegisters(); i < e; ++i) {
Nicolas Geoffray98893962015-01-21 12:32:32 +0000745 if (!IsCoreCalleeSaveRegister(i)) {
746 if (register_set->ContainsCoreRegister(i)) {
747 // If the register holds an object, update the stack mask.
748 if (locations->RegisterContainsObject(i)) {
749 locations->SetStackBit(stack_offset / kVRegSize);
750 }
751 DCHECK_LT(stack_offset, GetFrameSize() - FrameEntrySpillSize());
752 stack_offset += SaveCoreRegister(stack_offset, i);
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100753 }
754 }
755 }
756
757 for (size_t i = 0, e = GetNumberOfFloatingPointRegisters(); i < e; ++i) {
Nicolas Geoffray98893962015-01-21 12:32:32 +0000758 if (!IsFloatingPointCalleeSaveRegister(i)) {
759 if (register_set->ContainsFloatingPointRegister(i)) {
760 DCHECK_LT(stack_offset, GetFrameSize() - FrameEntrySpillSize());
761 stack_offset += SaveFloatingPointRegister(stack_offset, i);
762 }
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100763 }
764 }
765}
766
767void CodeGenerator::RestoreLiveRegisters(LocationSummary* locations) {
768 RegisterSet* register_set = locations->GetLiveRegisters();
Nicolas Geoffray102cbed2014-10-15 18:31:05 +0100769 size_t stack_offset = first_register_slot_in_slow_path_;
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100770 for (size_t i = 0, e = GetNumberOfCoreRegisters(); i < e; ++i) {
Nicolas Geoffray98893962015-01-21 12:32:32 +0000771 if (!IsCoreCalleeSaveRegister(i)) {
772 if (register_set->ContainsCoreRegister(i)) {
773 DCHECK_LT(stack_offset, GetFrameSize() - FrameEntrySpillSize());
774 stack_offset += RestoreCoreRegister(stack_offset, i);
775 }
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100776 }
777 }
778
779 for (size_t i = 0, e = GetNumberOfFloatingPointRegisters(); i < e; ++i) {
Nicolas Geoffray98893962015-01-21 12:32:32 +0000780 if (!IsFloatingPointCalleeSaveRegister(i)) {
781 if (register_set->ContainsFloatingPointRegister(i)) {
782 DCHECK_LT(stack_offset, GetFrameSize() - FrameEntrySpillSize());
783 stack_offset += RestoreFloatingPointRegister(stack_offset, i);
784 }
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +0100785 }
786 }
787}
788
Nicolas Geoffray3c049742014-09-24 18:10:46 +0100789void CodeGenerator::ClearSpillSlotsFromLoopPhisInStackMap(HSuspendCheck* suspend_check) const {
790 LocationSummary* locations = suspend_check->GetLocations();
791 HBasicBlock* block = suspend_check->GetBlock();
792 DCHECK(block->GetLoopInformation()->GetSuspendCheck() == suspend_check);
793 DCHECK(block->IsLoopHeader());
794
795 for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
796 HInstruction* current = it.Current();
797 LiveInterval* interval = current->GetLiveInterval();
798 // We only need to clear bits of loop phis containing objects and allocated in register.
799 // Loop phis allocated on stack already have the object in the stack.
800 if (current->GetType() == Primitive::kPrimNot
801 && interval->HasRegister()
802 && interval->HasSpillSlot()) {
803 locations->ClearStackBit(interval->GetSpillSlot() / kVRegSize);
804 }
805 }
806}
807
Nicolas Geoffrayf0e39372014-11-12 17:50:07 +0000808void CodeGenerator::EmitParallelMoves(Location from1, Location to1, Location from2, Location to2) {
Nicolas Geoffrayf0e39372014-11-12 17:50:07 +0000809 HParallelMove parallel_move(GetGraph()->GetArena());
Nicolas Geoffray42d1f5f2015-01-16 09:14:18 +0000810 parallel_move.AddMove(from1, to1, nullptr);
811 parallel_move.AddMove(from2, to2, nullptr);
Nicolas Geoffrayf0e39372014-11-12 17:50:07 +0000812 GetMoveResolver()->EmitNativeCode(&parallel_move);
813}
814
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000815} // namespace art