1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_
18 #define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_
19 
20 #include "base/enums.h"
21 #include "class_root.h"
22 #include "code_generator.h"
23 #include "common_arm.h"
24 #include "dex/string_reference.h"
25 #include "dex/type_reference.h"
26 #include "driver/compiler_options.h"
27 #include "nodes.h"
28 #include "parallel_move_resolver.h"
29 #include "utils/arm/assembler_arm_vixl.h"
30 
31 // TODO(VIXL): make vixl clean wrt -Wshadow.
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wshadow"
34 #include "aarch32/constants-aarch32.h"
35 #include "aarch32/instructions-aarch32.h"
36 #include "aarch32/macro-assembler-aarch32.h"
37 #pragma GCC diagnostic pop
38 
39 namespace art {
40 
41 namespace linker {
42 class Thumb2RelativePatcherTest;
43 }  // namespace linker
44 
45 namespace arm {
46 
47 // This constant is used as an approximate margin when emission of veneer and literal pools
48 // must be blocked.
49 static constexpr int kMaxMacroInstructionSizeInBytes =
50     15 * vixl::aarch32::kMaxInstructionSizeInBytes;
51 
52 static const vixl::aarch32::Register kParameterCoreRegistersVIXL[] = {
53     vixl::aarch32::r1,
54     vixl::aarch32::r2,
55     vixl::aarch32::r3
56 };
57 static const size_t kParameterCoreRegistersLengthVIXL = arraysize(kParameterCoreRegistersVIXL);
58 static const vixl::aarch32::SRegister kParameterFpuRegistersVIXL[] = {
59     vixl::aarch32::s0,
60     vixl::aarch32::s1,
61     vixl::aarch32::s2,
62     vixl::aarch32::s3,
63     vixl::aarch32::s4,
64     vixl::aarch32::s5,
65     vixl::aarch32::s6,
66     vixl::aarch32::s7,
67     vixl::aarch32::s8,
68     vixl::aarch32::s9,
69     vixl::aarch32::s10,
70     vixl::aarch32::s11,
71     vixl::aarch32::s12,
72     vixl::aarch32::s13,
73     vixl::aarch32::s14,
74     vixl::aarch32::s15
75 };
76 static const size_t kParameterFpuRegistersLengthVIXL = arraysize(kParameterFpuRegistersVIXL);
77 
78 static const vixl::aarch32::Register kMethodRegister = vixl::aarch32::r0;
79 
80 // Callee saves core registers r5, r6, r7, r8 (except when emitting Baker
81 // read barriers, where it is used as Marking Register), r10, r11, and lr.
82 static const vixl::aarch32::RegisterList kCoreCalleeSaves = vixl::aarch32::RegisterList::Union(
83     vixl::aarch32::RegisterList(vixl::aarch32::r5,
84                                 vixl::aarch32::r6,
85                                 vixl::aarch32::r7),
86     // Do not consider r8 as a callee-save register with Baker read barriers.
87     ((kEmitCompilerReadBarrier && kUseBakerReadBarrier)
88          ? vixl::aarch32::RegisterList()
89          : vixl::aarch32::RegisterList(vixl::aarch32::r8)),
90     vixl::aarch32::RegisterList(vixl::aarch32::r10,
91                                 vixl::aarch32::r11,
92                                 vixl::aarch32::lr));
93 
94 // Callee saves FP registers s16 to s31 inclusive.
95 static const vixl::aarch32::SRegisterList kFpuCalleeSaves =
96     vixl::aarch32::SRegisterList(vixl::aarch32::s16, 16);
97 
98 static const vixl::aarch32::Register kRuntimeParameterCoreRegistersVIXL[] = {
99     vixl::aarch32::r0,
100     vixl::aarch32::r1,
101     vixl::aarch32::r2,
102     vixl::aarch32::r3
103 };
104 static const size_t kRuntimeParameterCoreRegistersLengthVIXL =
105     arraysize(kRuntimeParameterCoreRegistersVIXL);
106 static const vixl::aarch32::SRegister kRuntimeParameterFpuRegistersVIXL[] = {
107     vixl::aarch32::s0,
108     vixl::aarch32::s1,
109     vixl::aarch32::s2,
110     vixl::aarch32::s3
111 };
112 static const size_t kRuntimeParameterFpuRegistersLengthVIXL =
113     arraysize(kRuntimeParameterFpuRegistersVIXL);
114 
115 class LoadClassSlowPathARMVIXL;
116 class CodeGeneratorARMVIXL;
117 
118 using VIXLInt32Literal = vixl::aarch32::Literal<int32_t>;
119 using VIXLUInt32Literal = vixl::aarch32::Literal<uint32_t>;
120 
121 class JumpTableARMVIXL : public DeletableArenaObject<kArenaAllocSwitchTable> {
122  public:
JumpTableARMVIXL(HPackedSwitch * switch_instr)123   explicit JumpTableARMVIXL(HPackedSwitch* switch_instr)
124       : switch_instr_(switch_instr),
125         table_start_(),
126         bb_addresses_(switch_instr->GetAllocator()->Adapter(kArenaAllocCodeGenerator)) {
127     uint32_t num_entries = switch_instr_->GetNumEntries();
128     for (uint32_t i = 0; i < num_entries; i++) {
129       VIXLInt32Literal *lit = new VIXLInt32Literal(0, vixl32::RawLiteral::kManuallyPlaced);
130       bb_addresses_.emplace_back(lit);
131     }
132   }
133 
GetTableStartLabel()134   vixl::aarch32::Label* GetTableStartLabel() { return &table_start_; }
135 
136   void EmitTable(CodeGeneratorARMVIXL* codegen);
137   void FixTable(CodeGeneratorARMVIXL* codegen);
138 
139  private:
140   HPackedSwitch* const switch_instr_;
141   vixl::aarch32::Label table_start_;
142   ArenaVector<std::unique_ptr<VIXLInt32Literal>> bb_addresses_;
143 
144   DISALLOW_COPY_AND_ASSIGN(JumpTableARMVIXL);
145 };
146 
147 class InvokeRuntimeCallingConventionARMVIXL
148     : public CallingConvention<vixl::aarch32::Register, vixl::aarch32::SRegister> {
149  public:
InvokeRuntimeCallingConventionARMVIXL()150   InvokeRuntimeCallingConventionARMVIXL()
151       : CallingConvention(kRuntimeParameterCoreRegistersVIXL,
152                           kRuntimeParameterCoreRegistersLengthVIXL,
153                           kRuntimeParameterFpuRegistersVIXL,
154                           kRuntimeParameterFpuRegistersLengthVIXL,
155                           kArmPointerSize) {}
156 
157  private:
158   DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConventionARMVIXL);
159 };
160 
161 class InvokeDexCallingConventionARMVIXL
162     : public CallingConvention<vixl::aarch32::Register, vixl::aarch32::SRegister> {
163  public:
InvokeDexCallingConventionARMVIXL()164   InvokeDexCallingConventionARMVIXL()
165       : CallingConvention(kParameterCoreRegistersVIXL,
166                           kParameterCoreRegistersLengthVIXL,
167                           kParameterFpuRegistersVIXL,
168                           kParameterFpuRegistersLengthVIXL,
169                           kArmPointerSize) {}
170 
171  private:
172   DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionARMVIXL);
173 };
174 
175 class InvokeDexCallingConventionVisitorARMVIXL : public InvokeDexCallingConventionVisitor {
176  public:
InvokeDexCallingConventionVisitorARMVIXL()177   InvokeDexCallingConventionVisitorARMVIXL() {}
~InvokeDexCallingConventionVisitorARMVIXL()178   virtual ~InvokeDexCallingConventionVisitorARMVIXL() {}
179 
180   Location GetNextLocation(DataType::Type type) override;
181   Location GetReturnLocation(DataType::Type type) const override;
182   Location GetMethodLocation() const override;
183 
184  private:
185   InvokeDexCallingConventionARMVIXL calling_convention;
186   uint32_t double_index_ = 0;
187 
188   DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorARMVIXL);
189 };
190 
191 class CriticalNativeCallingConventionVisitorARMVIXL : public InvokeDexCallingConventionVisitor {
192  public:
CriticalNativeCallingConventionVisitorARMVIXL(bool for_register_allocation)193   explicit CriticalNativeCallingConventionVisitorARMVIXL(bool for_register_allocation)
194       : for_register_allocation_(for_register_allocation) {}
195 
~CriticalNativeCallingConventionVisitorARMVIXL()196   virtual ~CriticalNativeCallingConventionVisitorARMVIXL() {}
197 
198   Location GetNextLocation(DataType::Type type) override;
199   Location GetReturnLocation(DataType::Type type) const override;
200   Location GetMethodLocation() const override;
201 
GetStackOffset()202   size_t GetStackOffset() const { return stack_offset_; }
203 
204  private:
205   // Register allocator does not support adjusting frame size, so we cannot provide final locations
206   // of stack arguments for register allocation. We ask the register allocator for any location and
207   // move these arguments to the right place after adjusting the SP when generating the call.
208   const bool for_register_allocation_;
209   size_t gpr_index_ = 0u;
210   size_t stack_offset_ = 0u;
211 
212   DISALLOW_COPY_AND_ASSIGN(CriticalNativeCallingConventionVisitorARMVIXL);
213 };
214 
215 class FieldAccessCallingConventionARMVIXL : public FieldAccessCallingConvention {
216  public:
FieldAccessCallingConventionARMVIXL()217   FieldAccessCallingConventionARMVIXL() {}
218 
GetObjectLocation()219   Location GetObjectLocation() const override {
220     return helpers::LocationFrom(vixl::aarch32::r1);
221   }
GetFieldIndexLocation()222   Location GetFieldIndexLocation() const override {
223     return helpers::LocationFrom(vixl::aarch32::r0);
224   }
GetReturnLocation(DataType::Type type)225   Location GetReturnLocation(DataType::Type type) const override {
226     return DataType::Is64BitType(type)
227         ? helpers::LocationFrom(vixl::aarch32::r0, vixl::aarch32::r1)
228         : helpers::LocationFrom(vixl::aarch32::r0);
229   }
GetSetValueLocation(DataType::Type type,bool is_instance)230   Location GetSetValueLocation(DataType::Type type, bool is_instance) const override {
231     return DataType::Is64BitType(type)
232         ? helpers::LocationFrom(vixl::aarch32::r2, vixl::aarch32::r3)
233         : (is_instance
234             ? helpers::LocationFrom(vixl::aarch32::r2)
235             : helpers::LocationFrom(vixl::aarch32::r1));
236   }
GetFpuLocation(DataType::Type type)237   Location GetFpuLocation(DataType::Type type) const override {
238     return DataType::Is64BitType(type)
239         ? helpers::LocationFrom(vixl::aarch32::s0, vixl::aarch32::s1)
240         : helpers::LocationFrom(vixl::aarch32::s0);
241   }
242 
243  private:
244   DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionARMVIXL);
245 };
246 
247 class SlowPathCodeARMVIXL : public SlowPathCode {
248  public:
SlowPathCodeARMVIXL(HInstruction * instruction)249   explicit SlowPathCodeARMVIXL(HInstruction* instruction)
250       : SlowPathCode(instruction), entry_label_(), exit_label_() {}
251 
GetEntryLabel()252   vixl::aarch32::Label* GetEntryLabel() { return &entry_label_; }
GetExitLabel()253   vixl::aarch32::Label* GetExitLabel() { return &exit_label_; }
254 
255   void SaveLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) override;
256   void RestoreLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) override;
257 
258  private:
259   vixl::aarch32::Label entry_label_;
260   vixl::aarch32::Label exit_label_;
261 
262   DISALLOW_COPY_AND_ASSIGN(SlowPathCodeARMVIXL);
263 };
264 
265 class ParallelMoveResolverARMVIXL : public ParallelMoveResolverWithSwap {
266  public:
ParallelMoveResolverARMVIXL(ArenaAllocator * allocator,CodeGeneratorARMVIXL * codegen)267   ParallelMoveResolverARMVIXL(ArenaAllocator* allocator, CodeGeneratorARMVIXL* codegen)
268       : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {}
269 
270   void EmitMove(size_t index) override;
271   void EmitSwap(size_t index) override;
272   void SpillScratch(int reg) override;
273   void RestoreScratch(int reg) override;
274 
275   ArmVIXLAssembler* GetAssembler() const;
276 
277  private:
278   void Exchange(vixl32::Register reg, int mem);
279   void Exchange(int mem1, int mem2);
280 
281   CodeGeneratorARMVIXL* const codegen_;
282 
283   DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverARMVIXL);
284 };
285 
286 class LocationsBuilderARMVIXL : public HGraphVisitor {
287  public:
LocationsBuilderARMVIXL(HGraph * graph,CodeGeneratorARMVIXL * codegen)288   LocationsBuilderARMVIXL(HGraph* graph, CodeGeneratorARMVIXL* codegen)
289       : HGraphVisitor(graph), codegen_(codegen) {}
290 
291 #define DECLARE_VISIT_INSTRUCTION(name, super)     \
292   void Visit##name(H##name* instr) override;
293 
294   FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)295   FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)
296   FOR_EACH_CONCRETE_INSTRUCTION_SHARED(DECLARE_VISIT_INSTRUCTION)
297 
298 #undef DECLARE_VISIT_INSTRUCTION
299 
300   void VisitInstruction(HInstruction* instruction) override {
301     LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
302                << " (id " << instruction->GetId() << ")";
303   }
304 
305  private:
306   void HandleInvoke(HInvoke* invoke);
307   void HandleBitwiseOperation(HBinaryOperation* operation, Opcode opcode);
308   void HandleCondition(HCondition* condition);
309   void HandleIntegerRotate(LocationSummary* locations);
310   void HandleLongRotate(LocationSummary* locations);
311   void HandleShift(HBinaryOperation* operation);
312   void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info);
313   void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
314 
315   Location ArithmeticZeroOrFpuRegister(HInstruction* input);
316   Location ArmEncodableConstantOrRegister(HInstruction* constant, Opcode opcode);
317   bool CanEncodeConstantAsImmediate(HConstant* input_cst, Opcode opcode);
318 
319   CodeGeneratorARMVIXL* const codegen_;
320   InvokeDexCallingConventionVisitorARMVIXL parameter_visitor_;
321 
322   DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARMVIXL);
323 };
324 
325 class InstructionCodeGeneratorARMVIXL : public InstructionCodeGenerator {
326  public:
327   InstructionCodeGeneratorARMVIXL(HGraph* graph, CodeGeneratorARMVIXL* codegen);
328 
329 #define DECLARE_VISIT_INSTRUCTION(name, super)     \
330   void Visit##name(H##name* instr) override;
331 
332   FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION)
FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)333   FOR_EACH_CONCRETE_INSTRUCTION_ARM(DECLARE_VISIT_INSTRUCTION)
334   FOR_EACH_CONCRETE_INSTRUCTION_SHARED(DECLARE_VISIT_INSTRUCTION)
335 
336 #undef DECLARE_VISIT_INSTRUCTION
337 
338   void VisitInstruction(HInstruction* instruction) override {
339     LOG(FATAL) << "Unreachable instruction " << instruction->DebugName()
340                << " (id " << instruction->GetId() << ")";
341   }
342 
GetAssembler()343   ArmVIXLAssembler* GetAssembler() const { return assembler_; }
GetVIXLAssembler()344   ArmVIXLMacroAssembler* GetVIXLAssembler() { return GetAssembler()->GetVIXLAssembler(); }
345 
346   void GenerateAndConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
347 
348  private:
349   // Generate code for the given suspend check. If not null, `successor`
350   // is the block to branch to if the suspend check is not needed, and after
351   // the suspend call.
352   void GenerateSuspendCheck(HSuspendCheck* instruction, HBasicBlock* successor);
353   void GenerateClassInitializationCheck(LoadClassSlowPathARMVIXL* slow_path,
354                                         vixl32::Register class_reg);
355   void GenerateBitstringTypeCheckCompare(HTypeCheckInstruction* check,
356                                          vixl::aarch32::Register temp,
357                                          vixl::aarch32::FlagsUpdate flags_update);
358   void GenerateOrrConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
359   void GenerateEorConst(vixl::aarch32::Register out, vixl::aarch32::Register first, uint32_t value);
360   void GenerateAddLongConst(Location out, Location first, uint64_t value);
361   void HandleBitwiseOperation(HBinaryOperation* operation);
362   void HandleCondition(HCondition* condition);
363   void HandleIntegerRotate(HRor* ror);
364   void HandleLongRotate(HRor* ror);
365   void HandleShift(HBinaryOperation* operation);
366 
367   void GenerateWideAtomicStore(vixl::aarch32::Register addr,
368                                uint32_t offset,
369                                vixl::aarch32::Register value_lo,
370                                vixl::aarch32::Register value_hi,
371                                vixl::aarch32::Register temp1,
372                                vixl::aarch32::Register temp2,
373                                HInstruction* instruction);
374   void GenerateWideAtomicLoad(vixl::aarch32::Register addr,
375                               uint32_t offset,
376                               vixl::aarch32::Register out_lo,
377                               vixl::aarch32::Register out_hi);
378 
379   void HandleFieldSet(HInstruction* instruction,
380                       const FieldInfo& field_info,
381                       bool value_can_be_null);
382   void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info);
383 
384   void GenerateMinMaxInt(LocationSummary* locations, bool is_min);
385   void GenerateMinMaxLong(LocationSummary* locations, bool is_min);
386   void GenerateMinMaxFloat(HInstruction* minmax, bool is_min);
387   void GenerateMinMaxDouble(HInstruction* minmax, bool is_min);
388   void GenerateMinMax(HBinaryOperation* minmax, bool is_min);
389 
390   // Generate a heap reference load using one register `out`:
391   //
392   //   out <- *(out + offset)
393   //
394   // while honoring heap poisoning and/or read barriers (if any).
395   //
396   // Location `maybe_temp` is used when generating a read barrier and
397   // shall be a register in that case; it may be an invalid location
398   // otherwise.
399   void GenerateReferenceLoadOneRegister(HInstruction* instruction,
400                                         Location out,
401                                         uint32_t offset,
402                                         Location maybe_temp,
403                                         ReadBarrierOption read_barrier_option);
404   // Generate a heap reference load using two different registers
405   // `out` and `obj`:
406   //
407   //   out <- *(obj + offset)
408   //
409   // while honoring heap poisoning and/or read barriers (if any).
410   //
411   // Location `maybe_temp` is used when generating a Baker's (fast
412   // path) read barrier and shall be a register in that case; it may
413   // be an invalid location otherwise.
414   void GenerateReferenceLoadTwoRegisters(HInstruction* instruction,
415                                          Location out,
416                                          Location obj,
417                                          uint32_t offset,
418                                          Location maybe_temp,
419                                          ReadBarrierOption read_barrier_option);
420   void GenerateTestAndBranch(HInstruction* instruction,
421                              size_t condition_input_index,
422                              vixl::aarch32::Label* true_target,
423                              vixl::aarch32::Label* false_target,
424                              bool far_target = true);
425   void GenerateCompareTestAndBranch(HCondition* condition,
426                                     vixl::aarch32::Label* true_target,
427                                     vixl::aarch32::Label* false_target,
428                                     bool is_far_target = true);
429   void DivRemOneOrMinusOne(HBinaryOperation* instruction);
430   void DivRemByPowerOfTwo(HBinaryOperation* instruction);
431   void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction);
432   void GenerateDivRemConstantIntegral(HBinaryOperation* instruction);
433   void HandleGoto(HInstruction* got, HBasicBlock* successor);
434 
435   vixl::aarch32::MemOperand VecAddress(
436       HVecMemoryOperation* instruction,
437       // This function may acquire a scratch register.
438       vixl::aarch32::UseScratchRegisterScope* temps_scope,
439       /*out*/ vixl32::Register* scratch);
440   vixl::aarch32::AlignedMemOperand VecAddressUnaligned(
441       HVecMemoryOperation* instruction,
442       // This function may acquire a scratch register.
443       vixl::aarch32::UseScratchRegisterScope* temps_scope,
444       /*out*/ vixl32::Register* scratch);
445 
446   ArmVIXLAssembler* const assembler_;
447   CodeGeneratorARMVIXL* const codegen_;
448 
449   DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorARMVIXL);
450 };
451 
452 class CodeGeneratorARMVIXL : public CodeGenerator {
453  public:
454   CodeGeneratorARMVIXL(HGraph* graph,
455                        const CompilerOptions& compiler_options,
456                        OptimizingCompilerStats* stats = nullptr);
~CodeGeneratorARMVIXL()457   virtual ~CodeGeneratorARMVIXL() {}
458 
459   void GenerateFrameEntry() override;
460   void GenerateFrameExit() override;
461   void Bind(HBasicBlock* block) override;
462   void MoveConstant(Location destination, int32_t value) override;
463   void MoveLocation(Location dst, Location src, DataType::Type dst_type) override;
464   void AddLocationAsTemp(Location location, LocationSummary* locations) override;
465 
466   size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) override;
467   size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) override;
468   size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
469   size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) override;
470 
GetWordSize()471   size_t GetWordSize() const override {
472     return static_cast<size_t>(kArmPointerSize);
473   }
474 
GetCalleePreservedFPWidth()475   size_t GetCalleePreservedFPWidth() const override {
476     return vixl::aarch32::kSRegSizeInBytes;
477   }
478 
GetSIMDRegisterWidth()479   size_t GetSIMDRegisterWidth() const override {
480     // ARM 32-bit backend doesn't support Q registers in vectorizer, only D
481     // registers (due to register allocator restrictions: overlapping s/d/q
482     // registers).
483     return vixl::aarch32::kDRegSizeInBytes;
484   }
485 
GetLocationBuilder()486   HGraphVisitor* GetLocationBuilder() override { return &location_builder_; }
487 
GetInstructionVisitor()488   HGraphVisitor* GetInstructionVisitor() override { return &instruction_visitor_; }
489 
GetAssembler()490   ArmVIXLAssembler* GetAssembler() override { return &assembler_; }
491 
GetAssembler()492   const ArmVIXLAssembler& GetAssembler() const override { return assembler_; }
493 
GetVIXLAssembler()494   ArmVIXLMacroAssembler* GetVIXLAssembler() { return GetAssembler()->GetVIXLAssembler(); }
495 
GetAddressOf(HBasicBlock * block)496   uintptr_t GetAddressOf(HBasicBlock* block) override {
497     vixl::aarch32::Label* block_entry_label = GetLabelOf(block);
498     DCHECK(block_entry_label->IsBound());
499     return block_entry_label->GetLocation();
500   }
501 
502   void FixJumpTables();
503   void SetupBlockedRegisters() const override;
504 
505   void DumpCoreRegister(std::ostream& stream, int reg) const override;
506   void DumpFloatingPointRegister(std::ostream& stream, int reg) const override;
507 
GetMoveResolver()508   ParallelMoveResolver* GetMoveResolver() override { return &move_resolver_; }
GetInstructionSet()509   InstructionSet GetInstructionSet() const override { return InstructionSet::kThumb2; }
510 
511   const ArmInstructionSetFeatures& GetInstructionSetFeatures() const;
512 
513   // Helper method to move a 32-bit value between two locations.
514   void Move32(Location destination, Location source);
515 
516   void LoadFromShiftedRegOffset(DataType::Type type,
517                                 Location out_loc,
518                                 vixl::aarch32::Register base,
519                                 vixl::aarch32::Register reg_index,
520                                 vixl::aarch32::Condition cond = vixl::aarch32::al);
521   void StoreToShiftedRegOffset(DataType::Type type,
522                                Location out_loc,
523                                vixl::aarch32::Register base,
524                                vixl::aarch32::Register reg_index,
525                                vixl::aarch32::Condition cond = vixl::aarch32::al);
526 
527   // Generate code to invoke a runtime entry point.
528   void InvokeRuntime(QuickEntrypointEnum entrypoint,
529                      HInstruction* instruction,
530                      uint32_t dex_pc,
531                      SlowPathCode* slow_path = nullptr) override;
532 
533   // Generate code to invoke a runtime entry point, but do not record
534   // PC-related information in a stack map.
535   void InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset,
536                                            HInstruction* instruction,
537                                            SlowPathCode* slow_path);
538 
539   // Emit a write barrier.
540   void MarkGCCard(vixl::aarch32::Register temp,
541                   vixl::aarch32::Register card,
542                   vixl::aarch32::Register object,
543                   vixl::aarch32::Register value,
544                   bool value_can_be_null);
545 
546   void GenerateMemoryBarrier(MemBarrierKind kind);
547 
GetLabelOf(HBasicBlock * block)548   vixl::aarch32::Label* GetLabelOf(HBasicBlock* block) {
549     block = FirstNonEmptyBlock(block);
550     return &(block_labels_[block->GetBlockId()]);
551   }
552 
553   vixl32::Label* GetFinalLabel(HInstruction* instruction, vixl32::Label* final_label);
554 
Initialize()555   void Initialize() override {
556     block_labels_.resize(GetGraph()->GetBlocks().size());
557   }
558 
559   void Finalize(CodeAllocator* allocator) override;
560 
NeedsTwoRegisters(DataType::Type type)561   bool NeedsTwoRegisters(DataType::Type type) const override {
562     return type == DataType::Type::kFloat64 || type == DataType::Type::kInt64;
563   }
564 
565   void ComputeSpillMask() override;
566 
GetFrameEntryLabel()567   vixl::aarch32::Label* GetFrameEntryLabel() { return &frame_entry_label_; }
568 
569   // Check if the desired_string_load_kind is supported. If it is, return it,
570   // otherwise return a fall-back kind that should be used instead.
571   HLoadString::LoadKind GetSupportedLoadStringKind(
572       HLoadString::LoadKind desired_string_load_kind) override;
573 
574   // Check if the desired_class_load_kind is supported. If it is, return it,
575   // otherwise return a fall-back kind that should be used instead.
576   HLoadClass::LoadKind GetSupportedLoadClassKind(
577       HLoadClass::LoadKind desired_class_load_kind) override;
578 
579   // Check if the desired_dispatch_info is supported. If it is, return it,
580   // otherwise return a fall-back info that should be used instead.
581   HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch(
582       const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info,
583       ArtMethod* method) override;
584 
585   void LoadMethod(MethodLoadKind load_kind, Location temp, HInvoke* invoke);
586   void GenerateStaticOrDirectCall(
587       HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
588   void GenerateVirtualCall(
589       HInvokeVirtual* invoke, Location temp, SlowPathCode* slow_path = nullptr) override;
590 
591   void MoveFromReturnRegister(Location trg, DataType::Type type) override;
592 
593   // The PcRelativePatchInfo is used for PC-relative addressing of methods/strings/types,
594   // whether through .data.bimg.rel.ro, .bss, or directly in the boot image.
595   //
596   // The PC-relative address is loaded with three instructions,
597   // MOVW+MOVT to load the offset to base_reg and then ADD base_reg, PC. The offset
598   // is calculated from the ADD's effective PC, i.e. PC+4 on Thumb2. Though we
599   // currently emit these 3 instructions together, instruction scheduling could
600   // split this sequence apart, so we keep separate labels for each of them.
601   struct PcRelativePatchInfo {
PcRelativePatchInfoPcRelativePatchInfo602     PcRelativePatchInfo(const DexFile* dex_file, uint32_t off_or_idx)
603         : target_dex_file(dex_file), offset_or_index(off_or_idx) { }
604     PcRelativePatchInfo(PcRelativePatchInfo&& other) = default;
605 
606     // Target dex file or null for .data.bmig.rel.ro patches.
607     const DexFile* target_dex_file;
608     // Either the boot image offset (to write to .data.bmig.rel.ro) or string/type/method index.
609     uint32_t offset_or_index;
610     vixl::aarch32::Label movw_label;
611     vixl::aarch32::Label movt_label;
612     vixl::aarch32::Label add_pc_label;
613   };
614 
615   PcRelativePatchInfo* NewBootImageIntrinsicPatch(uint32_t intrinsic_data);
616   PcRelativePatchInfo* NewBootImageRelRoPatch(uint32_t boot_image_offset);
617   PcRelativePatchInfo* NewBootImageMethodPatch(MethodReference target_method);
618   PcRelativePatchInfo* NewMethodBssEntryPatch(MethodReference target_method);
619   PcRelativePatchInfo* NewBootImageTypePatch(const DexFile& dex_file, dex::TypeIndex type_index);
620   PcRelativePatchInfo* NewTypeBssEntryPatch(HLoadClass* load_class);
621   PcRelativePatchInfo* NewBootImageStringPatch(const DexFile& dex_file,
622                                                dex::StringIndex string_index);
623   PcRelativePatchInfo* NewStringBssEntryPatch(const DexFile& dex_file,
624                                               dex::StringIndex string_index);
625 
626   // Emit the BL instruction for entrypoint thunk call and record the associated patch for AOT.
627   void EmitEntrypointThunkCall(ThreadOffset32 entrypoint_offset);
628 
629   // Emit the BNE instruction for baker read barrier and record
630   // the associated patch for AOT or slow path for JIT.
631   void EmitBakerReadBarrierBne(uint32_t custom_data);
632 
633   VIXLUInt32Literal* DeduplicateBootImageAddressLiteral(uint32_t address);
634   VIXLUInt32Literal* DeduplicateJitStringLiteral(const DexFile& dex_file,
635                                                  dex::StringIndex string_index,
636                                                  Handle<mirror::String> handle);
637   VIXLUInt32Literal* DeduplicateJitClassLiteral(const DexFile& dex_file,
638                                                 dex::TypeIndex type_index,
639                                                 Handle<mirror::Class> handle);
640 
641   void LoadBootImageAddress(vixl::aarch32::Register reg, uint32_t boot_image_reference);
642   void LoadTypeForBootImageIntrinsic(vixl::aarch32::Register reg, TypeReference type_reference);
643   void LoadIntrinsicDeclaringClass(vixl::aarch32::Register reg, HInvoke* invoke);
644   void LoadClassRootForIntrinsic(vixl::aarch32::Register reg, ClassRoot class_root);
645 
646   void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches) override;
647   bool NeedsThunkCode(const linker::LinkerPatch& patch) const override;
648   void EmitThunkCode(const linker::LinkerPatch& patch,
649                      /*out*/ ArenaVector<uint8_t>* code,
650                      /*out*/ std::string* debug_name) override;
651 
652   void EmitJitRootPatches(uint8_t* code, const uint8_t* roots_data) override;
653 
654   // Generate a GC root reference load:
655   //
656   //   root <- *(obj + offset)
657   //
658   // while honoring read barriers based on read_barrier_option.
659   void GenerateGcRootFieldLoad(HInstruction* instruction,
660                                Location root,
661                                vixl::aarch32::Register obj,
662                                uint32_t offset,
663                                ReadBarrierOption read_barrier_option);
664   // Generate MOV for an intrinsic CAS to mark the old value with Baker read barrier.
665   void GenerateIntrinsicCasMoveWithBakerReadBarrier(vixl::aarch32::Register marked_old_value,
666                                                     vixl::aarch32::Register old_value);
667   // Fast path implementation of ReadBarrier::Barrier for a heap
668   // reference field load when Baker's read barriers are used.
669   // Overload suitable for Unsafe.getObject/-Volatile() intrinsic.
670   void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction,
671                                              Location ref,
672                                              vixl::aarch32::Register obj,
673                                              const vixl::aarch32::MemOperand& src,
674                                              bool needs_null_check);
675   // Fast path implementation of ReadBarrier::Barrier for a heap
676   // reference field load when Baker's read barriers are used.
677   void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction,
678                                              Location ref,
679                                              vixl::aarch32::Register obj,
680                                              uint32_t offset,
681                                              Location maybe_temp,
682                                              bool needs_null_check);
683   // Fast path implementation of ReadBarrier::Barrier for a heap
684   // reference array load when Baker's read barriers are used.
685   void GenerateArrayLoadWithBakerReadBarrier(Location ref,
686                                              vixl::aarch32::Register obj,
687                                              uint32_t data_offset,
688                                              Location index,
689                                              Location temp,
690                                              bool needs_null_check);
691 
692   // Emit code checking the status of the Marking Register, and
693   // aborting the program if MR does not match the value stored in the
694   // art::Thread object. Code is only emitted in debug mode and if
695   // CompilerOptions::EmitRunTimeChecksInDebugMode returns true.
696   //
697   // Argument `code` is used to identify the different occurrences of
698   // MaybeGenerateMarkingRegisterCheck in the code generator, and is
699   // used together with kMarkingRegisterCheckBreakCodeBaseCode to
700   // create the value passed to the BKPT instruction. Note that unlike
701   // in the ARM64 code generator, where `__LINE__` is passed as `code`
702   // argument to
703   // CodeGeneratorARM64::MaybeGenerateMarkingRegisterCheck, we cannot
704   // realistically do that here, as Encoding T1 for the BKPT
705   // instruction only accepts 8-bit immediate values.
706   //
707   // If `temp_loc` is a valid location, it is expected to be a
708   // register and will be used as a temporary to generate code;
709   // otherwise, a temporary will be fetched from the core register
710   // scratch pool.
711   virtual void MaybeGenerateMarkingRegisterCheck(int code,
712                                                  Location temp_loc = Location::NoLocation());
713 
714   // Create slow path for a read barrier for a heap reference within `instruction`.
715   //
716   // This is a helper function for GenerateReadBarrierSlow() that has the same
717   // arguments. The creation and adding of the slow path is exposed for intrinsics
718   // that cannot use GenerateReadBarrierSlow() from their own slow paths.
719   SlowPathCodeARMVIXL* AddReadBarrierSlowPath(HInstruction* instruction,
720                                               Location out,
721                                               Location ref,
722                                               Location obj,
723                                               uint32_t offset,
724                                               Location index);
725 
726   // Generate a read barrier for a heap reference within `instruction`
727   // using a slow path.
728   //
729   // A read barrier for an object reference read from the heap is
730   // implemented as a call to the artReadBarrierSlow runtime entry
731   // point, which is passed the values in locations `ref`, `obj`, and
732   // `offset`:
733   //
734   //   mirror::Object* artReadBarrierSlow(mirror::Object* ref,
735   //                                      mirror::Object* obj,
736   //                                      uint32_t offset);
737   //
738   // The `out` location contains the value returned by
739   // artReadBarrierSlow.
740   //
741   // When `index` is provided (i.e. for array accesses), the offset
742   // value passed to artReadBarrierSlow is adjusted to take `index`
743   // into account.
744   void GenerateReadBarrierSlow(HInstruction* instruction,
745                                Location out,
746                                Location ref,
747                                Location obj,
748                                uint32_t offset,
749                                Location index = Location::NoLocation());
750 
751   // If read barriers are enabled, generate a read barrier for a heap
752   // reference using a slow path. If heap poisoning is enabled, also
753   // unpoison the reference in `out`.
754   void MaybeGenerateReadBarrierSlow(HInstruction* instruction,
755                                     Location out,
756                                     Location ref,
757                                     Location obj,
758                                     uint32_t offset,
759                                     Location index = Location::NoLocation());
760 
761   // Generate a read barrier for a GC root within `instruction` using
762   // a slow path.
763   //
764   // A read barrier for an object reference GC root is implemented as
765   // a call to the artReadBarrierForRootSlow runtime entry point,
766   // which is passed the value in location `root`:
767   //
768   //   mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root);
769   //
770   // The `out` location contains the value returned by
771   // artReadBarrierForRootSlow.
772   void GenerateReadBarrierForRootSlow(HInstruction* instruction, Location out, Location root);
773 
774   void IncreaseFrame(size_t adjustment) override;
775   void DecreaseFrame(size_t adjustment) override;
776 
777   void GenerateNop() override;
778 
779   void GenerateImplicitNullCheck(HNullCheck* instruction) override;
780   void GenerateExplicitNullCheck(HNullCheck* instruction) override;
781 
CreateJumpTable(HPackedSwitch * switch_instr)782   JumpTableARMVIXL* CreateJumpTable(HPackedSwitch* switch_instr) {
783     jump_tables_.emplace_back(new (GetGraph()->GetAllocator()) JumpTableARMVIXL(switch_instr));
784     return jump_tables_.back().get();
785   }
786   void EmitJumpTables();
787 
788   void EmitMovwMovtPlaceholder(CodeGeneratorARMVIXL::PcRelativePatchInfo* labels,
789                                vixl::aarch32::Register out);
790 
791   // `temp` is an extra temporary register that is used for some conditions;
792   // callers may not specify it, in which case the method will use a scratch
793   // register instead.
794   void GenerateConditionWithZero(IfCondition condition,
795                                  vixl::aarch32::Register out,
796                                  vixl::aarch32::Register in,
797                                  vixl::aarch32::Register temp = vixl32::Register());
798 
MaybeRecordImplicitNullCheck(HInstruction * instr)799   void MaybeRecordImplicitNullCheck(HInstruction* instr) final {
800     // The function must be only be called within special scopes
801     // (EmissionCheckScope, ExactAssemblyScope) which prevent generation of
802     // veneer/literal pools by VIXL assembler.
803     CHECK_EQ(GetVIXLAssembler()->ArePoolsBlocked(), true)
804         << "The function must only be called within EmissionCheckScope or ExactAssemblyScope";
805     CodeGenerator::MaybeRecordImplicitNullCheck(instr);
806   }
807 
808   void MaybeGenerateInlineCacheCheck(HInstruction* instruction, vixl32::Register klass);
809   void MaybeIncrementHotness(bool is_frame_entry);
810 
811  private:
812   // Encoding of thunk type and data for link-time generated thunks for Baker read barriers.
813 
814   enum class BakerReadBarrierKind : uint8_t {
815     kField,         // Field get or array get with constant offset (i.e. constant index).
816     kArray,         // Array get with index in register.
817     kGcRoot,        // GC root load.
818     kIntrinsicCas,  // Unsafe/VarHandle CAS intrinsic.
819     kLast = kIntrinsicCas
820   };
821 
822   enum class BakerReadBarrierWidth : uint8_t {
823     kWide,          // 32-bit LDR (and 32-bit NEG if heap poisoning is enabled).
824     kNarrow,        // 16-bit LDR (and 16-bit NEG if heap poisoning is enabled).
825     kLast = kNarrow
826   };
827 
828   static constexpr uint32_t kBakerReadBarrierInvalidEncodedReg = /* pc is invalid */ 15u;
829 
830   static constexpr size_t kBitsForBakerReadBarrierKind =
831       MinimumBitsToStore(static_cast<size_t>(BakerReadBarrierKind::kLast));
832   static constexpr size_t kBakerReadBarrierBitsForRegister =
833       MinimumBitsToStore(kBakerReadBarrierInvalidEncodedReg);
834   using BakerReadBarrierKindField =
835       BitField<BakerReadBarrierKind, 0, kBitsForBakerReadBarrierKind>;
836   using BakerReadBarrierFirstRegField =
837       BitField<uint32_t, kBitsForBakerReadBarrierKind, kBakerReadBarrierBitsForRegister>;
838   using BakerReadBarrierSecondRegField =
839       BitField<uint32_t,
840                kBitsForBakerReadBarrierKind + kBakerReadBarrierBitsForRegister,
841                kBakerReadBarrierBitsForRegister>;
842   static constexpr size_t kBitsForBakerReadBarrierWidth =
843       MinimumBitsToStore(static_cast<size_t>(BakerReadBarrierWidth::kLast));
844   using BakerReadBarrierWidthField =
845       BitField<BakerReadBarrierWidth,
846                kBitsForBakerReadBarrierKind + 2 * kBakerReadBarrierBitsForRegister,
847                kBitsForBakerReadBarrierWidth>;
848 
CheckValidReg(uint32_t reg)849   static void CheckValidReg(uint32_t reg) {
850     DCHECK(reg < vixl::aarch32::ip.GetCode() && reg != mr.GetCode()) << reg;
851   }
852 
EncodeBakerReadBarrierFieldData(uint32_t base_reg,uint32_t holder_reg,bool narrow)853   static uint32_t EncodeBakerReadBarrierFieldData(uint32_t base_reg,
854                                                   uint32_t holder_reg,
855                                                   bool narrow) {
856     CheckValidReg(base_reg);
857     CheckValidReg(holder_reg);
858     DCHECK(!narrow || base_reg < 8u) << base_reg;
859     BakerReadBarrierWidth width =
860         narrow ? BakerReadBarrierWidth::kNarrow : BakerReadBarrierWidth::kWide;
861     return BakerReadBarrierKindField::Encode(BakerReadBarrierKind::kField) |
862            BakerReadBarrierFirstRegField::Encode(base_reg) |
863            BakerReadBarrierSecondRegField::Encode(holder_reg) |
864            BakerReadBarrierWidthField::Encode(width);
865   }
866 
EncodeBakerReadBarrierArrayData(uint32_t base_reg)867   static uint32_t EncodeBakerReadBarrierArrayData(uint32_t base_reg) {
868     CheckValidReg(base_reg);
869     return BakerReadBarrierKindField::Encode(BakerReadBarrierKind::kArray) |
870            BakerReadBarrierFirstRegField::Encode(base_reg) |
871            BakerReadBarrierSecondRegField::Encode(kBakerReadBarrierInvalidEncodedReg) |
872            BakerReadBarrierWidthField::Encode(BakerReadBarrierWidth::kWide);
873   }
874 
EncodeBakerReadBarrierGcRootData(uint32_t root_reg,bool narrow)875   static uint32_t EncodeBakerReadBarrierGcRootData(uint32_t root_reg, bool narrow) {
876     CheckValidReg(root_reg);
877     DCHECK(!narrow || root_reg < 8u) << root_reg;
878     BakerReadBarrierWidth width =
879         narrow ? BakerReadBarrierWidth::kNarrow : BakerReadBarrierWidth::kWide;
880     return BakerReadBarrierKindField::Encode(BakerReadBarrierKind::kGcRoot) |
881            BakerReadBarrierFirstRegField::Encode(root_reg) |
882            BakerReadBarrierSecondRegField::Encode(kBakerReadBarrierInvalidEncodedReg) |
883            BakerReadBarrierWidthField::Encode(width);
884   }
885 
EncodeBakerReadBarrierIntrinsicCasData(uint32_t root_reg)886   static uint32_t EncodeBakerReadBarrierIntrinsicCasData(uint32_t root_reg) {
887     CheckValidReg(root_reg);
888     return BakerReadBarrierKindField::Encode(BakerReadBarrierKind::kIntrinsicCas) |
889            BakerReadBarrierFirstRegField::Encode(root_reg) |
890            BakerReadBarrierSecondRegField::Encode(kBakerReadBarrierInvalidEncodedReg) |
891            BakerReadBarrierWidthField::Encode(BakerReadBarrierWidth::kWide);
892   }
893 
894   void CompileBakerReadBarrierThunk(ArmVIXLAssembler& assembler,
895                                     uint32_t encoded_data,
896                                     /*out*/ std::string* debug_name);
897 
898   using Uint32ToLiteralMap = ArenaSafeMap<uint32_t, VIXLUInt32Literal*>;
899   using StringToLiteralMap = ArenaSafeMap<StringReference,
900                                           VIXLUInt32Literal*,
901                                           StringReferenceValueComparator>;
902   using TypeToLiteralMap = ArenaSafeMap<TypeReference,
903                                         VIXLUInt32Literal*,
904                                         TypeReferenceValueComparator>;
905 
906   struct BakerReadBarrierPatchInfo {
BakerReadBarrierPatchInfoBakerReadBarrierPatchInfo907     explicit BakerReadBarrierPatchInfo(uint32_t data) : label(), custom_data(data) { }
908 
909     vixl::aarch32::Label label;
910     uint32_t custom_data;
911   };
912 
913   VIXLUInt32Literal* DeduplicateUint32Literal(uint32_t value, Uint32ToLiteralMap* map);
914   PcRelativePatchInfo* NewPcRelativePatch(const DexFile* dex_file,
915                                           uint32_t offset_or_index,
916                                           ArenaDeque<PcRelativePatchInfo>* patches);
917   template <linker::LinkerPatch (*Factory)(size_t, const DexFile*, uint32_t, uint32_t)>
918   static void EmitPcRelativeLinkerPatches(const ArenaDeque<PcRelativePatchInfo>& infos,
919                                           ArenaVector<linker::LinkerPatch>* linker_patches);
920 
921   // Labels for each block that will be compiled.
922   // We use a deque so that the `vixl::aarch32::Label` objects do not move in memory.
923   ArenaDeque<vixl::aarch32::Label> block_labels_;  // Indexed by block id.
924   vixl::aarch32::Label frame_entry_label_;
925 
926   ArenaVector<std::unique_ptr<JumpTableARMVIXL>> jump_tables_;
927   LocationsBuilderARMVIXL location_builder_;
928   InstructionCodeGeneratorARMVIXL instruction_visitor_;
929   ParallelMoveResolverARMVIXL move_resolver_;
930 
931   ArmVIXLAssembler assembler_;
932 
933   // PC-relative method patch info for kBootImageLinkTimePcRelative.
934   ArenaDeque<PcRelativePatchInfo> boot_image_method_patches_;
935   // PC-relative method patch info for kBssEntry.
936   ArenaDeque<PcRelativePatchInfo> method_bss_entry_patches_;
937   // PC-relative type patch info for kBootImageLinkTimePcRelative.
938   ArenaDeque<PcRelativePatchInfo> boot_image_type_patches_;
939   // PC-relative type patch info for kBssEntry.
940   ArenaDeque<PcRelativePatchInfo> type_bss_entry_patches_;
941   // PC-relative public type patch info for kBssEntryPublic.
942   ArenaDeque<PcRelativePatchInfo> public_type_bss_entry_patches_;
943   // PC-relative package type patch info for kBssEntryPackage.
944   ArenaDeque<PcRelativePatchInfo> package_type_bss_entry_patches_;
945   // PC-relative String patch info for kBootImageLinkTimePcRelative.
946   ArenaDeque<PcRelativePatchInfo> boot_image_string_patches_;
947   // PC-relative String patch info for kBssEntry.
948   ArenaDeque<PcRelativePatchInfo> string_bss_entry_patches_;
949   // PC-relative patch info for IntrinsicObjects for the boot image,
950   // and for method/type/string patches for kBootImageRelRo otherwise.
951   ArenaDeque<PcRelativePatchInfo> boot_image_other_patches_;
952   // Patch info for calls to entrypoint dispatch thunks. Used for slow paths.
953   ArenaDeque<PatchInfo<vixl::aarch32::Label>> call_entrypoint_patches_;
954   // Baker read barrier patch info.
955   ArenaDeque<BakerReadBarrierPatchInfo> baker_read_barrier_patches_;
956 
957   // Deduplication map for 32-bit literals, used for JIT for boot image addresses.
958   Uint32ToLiteralMap uint32_literals_;
959   // Patches for string literals in JIT compiled code.
960   StringToLiteralMap jit_string_patches_;
961   // Patches for class literals in JIT compiled code.
962   TypeToLiteralMap jit_class_patches_;
963 
964   // Baker read barrier slow paths, mapping custom data (uint32_t) to label.
965   // Wrap the label to work around vixl::aarch32::Label being non-copyable
966   // and non-moveable and as such unusable in ArenaSafeMap<>.
967   struct LabelWrapper {
LabelWrapperLabelWrapper968     LabelWrapper(const LabelWrapper& src)
969         : label() {
970       DCHECK(!src.label.IsReferenced() && !src.label.IsBound());
971     }
972     LabelWrapper() = default;
973     vixl::aarch32::Label label;
974   };
975   ArenaSafeMap<uint32_t, LabelWrapper> jit_baker_read_barrier_slow_paths_;
976 
977   friend class linker::Thumb2RelativePatcherTest;
978   DISALLOW_COPY_AND_ASSIGN(CodeGeneratorARMVIXL);
979 };
980 
981 }  // namespace arm
982 }  // namespace art
983 
984 #endif  // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_VIXL_H_
985