Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1 | /* |
| 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 | #ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ |
| 19 | |
Mark P Mendell | 17077d8 | 2015-12-16 19:15:59 +0000 | [diff] [blame] | 20 | #include "arch/x86/instruction_set_features_x86.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 21 | #include "base/enums.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 22 | #include "code_generator.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 23 | #include "dex/dex_file_types.h" |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 24 | #include "driver/compiler_options.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 25 | #include "nodes.h" |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 26 | #include "parallel_move_resolver.h" |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 27 | #include "utils/x86/assembler_x86.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 28 | |
Vladimir Marko | 0a51605 | 2019-10-14 13:00:44 +0000 | [diff] [blame] | 29 | namespace art { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 30 | namespace x86 { |
| 31 | |
Nicolas Geoffray | 86a8d7a | 2014-11-19 08:47:18 +0000 | [diff] [blame] | 32 | // Use a local definition to prevent copying mistakes. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 33 | static constexpr size_t kX86WordSize = static_cast<size_t>(kX86PointerSize); |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 34 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 35 | class CodeGeneratorX86; |
| 36 | |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 37 | static constexpr Register kParameterCoreRegisters[] = { ECX, EDX, EBX }; |
| 38 | static constexpr RegisterPair kParameterCorePairRegisters[] = { ECX_EDX, EDX_EBX }; |
| 39 | static constexpr size_t kParameterCoreRegistersLength = arraysize(kParameterCoreRegisters); |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 40 | static constexpr XmmRegister kParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 }; |
| 41 | static constexpr size_t kParameterFpuRegistersLength = arraysize(kParameterFpuRegisters); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 42 | |
Nicolas Geoffray | d75948a | 2015-03-27 09:53:16 +0000 | [diff] [blame] | 43 | static constexpr Register kRuntimeParameterCoreRegisters[] = { EAX, ECX, EDX, EBX }; |
| 44 | static constexpr size_t kRuntimeParameterCoreRegistersLength = |
| 45 | arraysize(kRuntimeParameterCoreRegisters); |
| 46 | static constexpr XmmRegister kRuntimeParameterFpuRegisters[] = { XMM0, XMM1, XMM2, XMM3 }; |
| 47 | static constexpr size_t kRuntimeParameterFpuRegistersLength = |
| 48 | arraysize(kRuntimeParameterFpuRegisters); |
| 49 | |
| 50 | class InvokeRuntimeCallingConvention : public CallingConvention<Register, XmmRegister> { |
| 51 | public: |
| 52 | InvokeRuntimeCallingConvention() |
| 53 | : CallingConvention(kRuntimeParameterCoreRegisters, |
| 54 | kRuntimeParameterCoreRegistersLength, |
| 55 | kRuntimeParameterFpuRegisters, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 56 | kRuntimeParameterFpuRegistersLength, |
| 57 | kX86PointerSize) {} |
Nicolas Geoffray | d75948a | 2015-03-27 09:53:16 +0000 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | DISALLOW_COPY_AND_ASSIGN(InvokeRuntimeCallingConvention); |
| 61 | }; |
| 62 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 63 | class InvokeDexCallingConvention : public CallingConvention<Register, XmmRegister> { |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 64 | public: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 65 | InvokeDexCallingConvention() : CallingConvention( |
| 66 | kParameterCoreRegisters, |
| 67 | kParameterCoreRegistersLength, |
| 68 | kParameterFpuRegisters, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 69 | kParameterFpuRegistersLength, |
| 70 | kX86PointerSize) {} |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 71 | |
| 72 | RegisterPair GetRegisterPairAt(size_t argument_index) { |
| 73 | DCHECK_LT(argument_index + 1, GetNumberOfRegisters()); |
| 74 | return kParameterCorePairRegisters[argument_index]; |
| 75 | } |
| 76 | |
| 77 | private: |
| 78 | DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConvention); |
| 79 | }; |
| 80 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 81 | class InvokeDexCallingConventionVisitorX86 : public InvokeDexCallingConventionVisitor { |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 82 | public: |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 83 | InvokeDexCallingConventionVisitorX86() {} |
| 84 | virtual ~InvokeDexCallingConventionVisitorX86() {} |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 85 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 86 | Location GetNextLocation(DataType::Type type) override; |
| 87 | Location GetReturnLocation(DataType::Type type) const override; |
| 88 | Location GetMethodLocation() const override; |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 89 | |
| 90 | private: |
| 91 | InvokeDexCallingConvention calling_convention; |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 92 | |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 93 | DISALLOW_COPY_AND_ASSIGN(InvokeDexCallingConventionVisitorX86); |
Nicolas Geoffray | a747a39 | 2014-04-17 14:56:23 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
Vladimir Marko | 86c8752 | 2020-05-11 16:55:55 +0100 | [diff] [blame] | 96 | class CriticalNativeCallingConventionVisitorX86 : public InvokeDexCallingConventionVisitor { |
| 97 | public: |
| 98 | explicit CriticalNativeCallingConventionVisitorX86(bool for_register_allocation) |
| 99 | : for_register_allocation_(for_register_allocation) {} |
| 100 | |
| 101 | virtual ~CriticalNativeCallingConventionVisitorX86() {} |
| 102 | |
| 103 | Location GetNextLocation(DataType::Type type) override; |
| 104 | Location GetReturnLocation(DataType::Type type) const override; |
| 105 | Location GetMethodLocation() const override; |
| 106 | |
| 107 | size_t GetStackOffset() const { return stack_offset_; } |
| 108 | |
| 109 | private: |
| 110 | // Register allocator does not support adjusting frame size, so we cannot provide final locations |
| 111 | // of stack arguments for register allocation. We ask the register allocator for any location and |
| 112 | // move these arguments to the right place after adjusting the SP when generating the call. |
| 113 | const bool for_register_allocation_; |
| 114 | size_t stack_offset_ = 0u; |
| 115 | |
| 116 | DISALLOW_COPY_AND_ASSIGN(CriticalNativeCallingConventionVisitorX86); |
| 117 | }; |
| 118 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 119 | class FieldAccessCallingConventionX86 : public FieldAccessCallingConvention { |
| 120 | public: |
| 121 | FieldAccessCallingConventionX86() {} |
| 122 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 123 | Location GetObjectLocation() const override { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 124 | return Location::RegisterLocation(ECX); |
| 125 | } |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 126 | Location GetFieldIndexLocation() const override { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 127 | return Location::RegisterLocation(EAX); |
| 128 | } |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 129 | Location GetReturnLocation(DataType::Type type) const override { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 130 | return DataType::Is64BitType(type) |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 131 | ? Location::RegisterPairLocation(EAX, EDX) |
| 132 | : Location::RegisterLocation(EAX); |
| 133 | } |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 134 | Location GetSetValueLocation(DataType::Type type, bool is_instance) const override { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 135 | return DataType::Is64BitType(type) |
Nicolas Geoffray | 5b3c6c0 | 2017-01-19 14:22:26 +0000 | [diff] [blame] | 136 | ? (is_instance |
| 137 | ? Location::RegisterPairLocation(EDX, EBX) |
| 138 | : Location::RegisterPairLocation(ECX, EDX)) |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 139 | : (is_instance |
| 140 | ? Location::RegisterLocation(EDX) |
| 141 | : Location::RegisterLocation(ECX)); |
| 142 | } |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 143 | Location GetFpuLocation(DataType::Type type ATTRIBUTE_UNUSED) const override { |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 144 | return Location::FpuRegisterLocation(XMM0); |
| 145 | } |
| 146 | |
| 147 | private: |
| 148 | DISALLOW_COPY_AND_ASSIGN(FieldAccessCallingConventionX86); |
| 149 | }; |
| 150 | |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 151 | class ParallelMoveResolverX86 : public ParallelMoveResolverWithSwap { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 152 | public: |
| 153 | ParallelMoveResolverX86(ArenaAllocator* allocator, CodeGeneratorX86* codegen) |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 154 | : ParallelMoveResolverWithSwap(allocator), codegen_(codegen) {} |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 155 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 156 | void EmitMove(size_t index) override; |
| 157 | void EmitSwap(size_t index) override; |
| 158 | void SpillScratch(int reg) override; |
| 159 | void RestoreScratch(int reg) override; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 160 | |
| 161 | X86Assembler* GetAssembler() const; |
| 162 | |
| 163 | private: |
| 164 | void Exchange(Register reg, int mem); |
Mark Mendell | 7c8d009 | 2015-01-26 11:21:33 -0500 | [diff] [blame] | 165 | void Exchange32(XmmRegister reg, int mem); |
Aart Bik | cfe50bb | 2017-12-12 14:54:12 -0800 | [diff] [blame] | 166 | void Exchange128(XmmRegister reg, int mem); |
| 167 | void ExchangeMemory(int mem1, int mem2, int number_of_words); |
| 168 | void MoveMemoryToMemory(int dst, int src, int number_of_words); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 169 | |
| 170 | CodeGeneratorX86* const codegen_; |
| 171 | |
| 172 | DISALLOW_COPY_AND_ASSIGN(ParallelMoveResolverX86); |
| 173 | }; |
| 174 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 175 | class LocationsBuilderX86 : public HGraphVisitor { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 176 | public: |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 177 | LocationsBuilderX86(HGraph* graph, CodeGeneratorX86* codegen) |
| 178 | : HGraphVisitor(graph), codegen_(codegen) {} |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 179 | |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 180 | #define DECLARE_VISIT_INSTRUCTION(name, super) \ |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 181 | void Visit##name(H##name* instr) override; |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 182 | |
Alexandre Rames | ef20f71 | 2015-06-09 10:29:30 +0100 | [diff] [blame] | 183 | FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION) |
| 184 | FOR_EACH_CONCRETE_INSTRUCTION_X86(DECLARE_VISIT_INSTRUCTION) |
Shalini Salomi Bodapati | dd121f6 | 2018-10-26 15:03:53 +0530 | [diff] [blame] | 185 | FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION) |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 186 | |
| 187 | #undef DECLARE_VISIT_INSTRUCTION |
| 188 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 189 | void VisitInstruction(HInstruction* instruction) override { |
Alexandre Rames | ef20f71 | 2015-06-09 10:29:30 +0100 | [diff] [blame] | 190 | LOG(FATAL) << "Unreachable instruction " << instruction->DebugName() |
| 191 | << " (id " << instruction->GetId() << ")"; |
| 192 | } |
| 193 | |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 194 | private: |
| 195 | void HandleBitwiseOperation(HBinaryOperation* instruction); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 196 | void HandleInvoke(HInvoke* invoke); |
Vladimir Marko | 5f7b58e | 2015-11-23 19:49:34 +0000 | [diff] [blame] | 197 | void HandleCondition(HCondition* condition); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 198 | void HandleShift(HBinaryOperation* instruction); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 199 | void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); |
| 200 | void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); |
Shalini Salomi Bodapati | b45a435 | 2019-07-10 16:09:41 +0530 | [diff] [blame] | 201 | bool CpuHasAvxFeatureFlag(); |
| 202 | bool CpuHasAvx2FeatureFlag(); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 203 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 204 | CodeGeneratorX86* const codegen_; |
Roland Levillain | 2d27c8e | 2015-04-28 15:48:45 +0100 | [diff] [blame] | 205 | InvokeDexCallingConventionVisitorX86 parameter_visitor_; |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 206 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 207 | DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86); |
| 208 | }; |
| 209 | |
Aart Bik | 42249c3 | 2016-01-07 15:33:50 -0800 | [diff] [blame] | 210 | class InstructionCodeGeneratorX86 : public InstructionCodeGenerator { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 211 | public: |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 212 | InstructionCodeGeneratorX86(HGraph* graph, CodeGeneratorX86* codegen); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 213 | |
Nicolas Geoffray | 360231a | 2014-10-08 21:07:48 +0100 | [diff] [blame] | 214 | #define DECLARE_VISIT_INSTRUCTION(name, super) \ |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 215 | void Visit##name(H##name* instr) override; |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 216 | |
Alexandre Rames | ef20f71 | 2015-06-09 10:29:30 +0100 | [diff] [blame] | 217 | FOR_EACH_CONCRETE_INSTRUCTION_COMMON(DECLARE_VISIT_INSTRUCTION) |
| 218 | FOR_EACH_CONCRETE_INSTRUCTION_X86(DECLARE_VISIT_INSTRUCTION) |
Shalini Salomi Bodapati | dd121f6 | 2018-10-26 15:03:53 +0530 | [diff] [blame] | 219 | FOR_EACH_CONCRETE_INSTRUCTION_X86_COMMON(DECLARE_VISIT_INSTRUCTION) |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 220 | |
| 221 | #undef DECLARE_VISIT_INSTRUCTION |
| 222 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 223 | void VisitInstruction(HInstruction* instruction) override { |
Alexandre Rames | ef20f71 | 2015-06-09 10:29:30 +0100 | [diff] [blame] | 224 | LOG(FATAL) << "Unreachable instruction " << instruction->DebugName() |
| 225 | << " (id " << instruction->GetId() << ")"; |
| 226 | } |
| 227 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 228 | X86Assembler* GetAssembler() const { return assembler_; } |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 229 | |
Vladimir Marko | f3e0ee2 | 2015-12-17 15:23:13 +0000 | [diff] [blame] | 230 | // The compare/jump sequence will generate about (1.5 * num_entries) instructions. A jump |
| 231 | // table version generates 7 instructions and num_entries literals. Compare/jump sequence will |
| 232 | // generates less code/data with a small num_entries. |
| 233 | static constexpr uint32_t kPackedSwitchJumpTableThreshold = 5; |
| 234 | |
Andra Danciu | 1ca6f32 | 2020-08-12 08:58:07 +0000 | [diff] [blame] | 235 | // Generate a GC root reference load: |
| 236 | // |
| 237 | // root <- *address |
| 238 | // |
| 239 | // while honoring read barriers based on read_barrier_option. |
| 240 | void GenerateGcRootFieldLoad(HInstruction* instruction, |
| 241 | Location root, |
| 242 | const Address& address, |
| 243 | Label* fixup_label, |
| 244 | ReadBarrierOption read_barrier_option); |
| 245 | |
Andra Danciu | cde9819 | 2020-09-13 12:32:09 +0000 | [diff] [blame] | 246 | void HandleFieldSet(HInstruction* instruction, |
| 247 | uint32_t value_index, |
| 248 | DataType::Type type, |
| 249 | Address field_addr, |
| 250 | Register base, |
| 251 | bool is_volatile, |
| 252 | bool value_can_be_null); |
| 253 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 254 | private: |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 255 | // Generate code for the given suspend check. If not null, `successor` |
| 256 | // is the block to branch to if the suspend check is not needed, and after |
| 257 | // the suspend call. |
| 258 | void GenerateSuspendCheck(HSuspendCheck* check, HBasicBlock* successor); |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 259 | void GenerateClassInitializationCheck(SlowPathCode* slow_path, Register class_reg); |
Vladimir Marko | 175e786 | 2018-03-27 09:03:13 +0000 | [diff] [blame] | 260 | void GenerateBitstringTypeCheckCompare(HTypeCheckInstruction* check, Register temp); |
Nicolas Geoffray | 9574c4b | 2014-11-12 13:19:37 +0000 | [diff] [blame] | 261 | void HandleBitwiseOperation(HBinaryOperation* instruction); |
Calin Juravle | bacfec3 | 2014-11-14 15:54:36 +0000 | [diff] [blame] | 262 | void GenerateDivRemIntegral(HBinaryOperation* instruction); |
Guillaume Sanchez | 0f88e87 | 2015-03-30 17:55:45 +0100 | [diff] [blame] | 263 | void DivRemOneOrMinusOne(HBinaryOperation* instruction); |
Guillaume Sanchez | b19930c | 2015-04-09 21:12:15 +0100 | [diff] [blame] | 264 | void DivByPowerOfTwo(HDiv* instruction); |
Shalini Salomi Bodapati | a66784b | 2018-11-06 13:05:44 +0530 | [diff] [blame] | 265 | void RemByPowerOfTwo(HRem* instruction); |
Guillaume Sanchez | 0f88e87 | 2015-03-30 17:55:45 +0100 | [diff] [blame] | 266 | void GenerateDivRemWithAnyConstant(HBinaryOperation* instruction); |
Mark Mendell | c470193 | 2015-04-10 13:18:51 -0400 | [diff] [blame] | 267 | void GenerateRemFP(HRem* rem); |
Vladimir Marko | 5f7b58e | 2015-11-23 19:49:34 +0000 | [diff] [blame] | 268 | void HandleCondition(HCondition* condition); |
Calin Juravle | 9aec02f | 2014-11-18 23:06:35 +0000 | [diff] [blame] | 269 | void HandleShift(HBinaryOperation* instruction); |
| 270 | void GenerateShlLong(const Location& loc, Register shifter); |
| 271 | void GenerateShrLong(const Location& loc, Register shifter); |
| 272 | void GenerateUShrLong(const Location& loc, Register shifter); |
Mark P Mendell | 7394569 | 2015-04-29 14:56:17 +0000 | [diff] [blame] | 273 | void GenerateShlLong(const Location& loc, int shift); |
| 274 | void GenerateShrLong(const Location& loc, int shift); |
| 275 | void GenerateUShrLong(const Location& loc, int shift); |
Aart Bik | 351df3e | 2018-03-07 11:54:57 -0800 | [diff] [blame] | 276 | void GenerateMinMaxInt(LocationSummary* locations, bool is_min, DataType::Type type); |
Aart Bik | 1f8d51b | 2018-02-15 10:42:37 -0800 | [diff] [blame] | 277 | void GenerateMinMaxFP(LocationSummary* locations, bool is_min, DataType::Type type); |
Aart Bik | 351df3e | 2018-03-07 11:54:57 -0800 | [diff] [blame] | 278 | void GenerateMinMax(HBinaryOperation* minmax, bool is_min); |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 279 | |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 280 | void HandleFieldSet(HInstruction* instruction, |
| 281 | const FieldInfo& field_info, |
| 282 | bool value_can_be_null); |
Calin Juravle | 52c4896 | 2014-12-16 17:02:57 +0000 | [diff] [blame] | 283 | void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 284 | |
| 285 | // Generate a heap reference load using one register `out`: |
| 286 | // |
| 287 | // out <- *(out + offset) |
| 288 | // |
| 289 | // while honoring heap poisoning and/or read barriers (if any). |
Roland Levillain | 95e7ffc | 2016-01-22 11:57:25 +0000 | [diff] [blame] | 290 | // |
| 291 | // Location `maybe_temp` is used when generating a read barrier and |
| 292 | // shall be a register in that case; it may be an invalid location |
| 293 | // otherwise. |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 294 | void GenerateReferenceLoadOneRegister(HInstruction* instruction, |
| 295 | Location out, |
| 296 | uint32_t offset, |
Mathieu Chartier | aa474eb | 2016-11-09 15:18:27 -0800 | [diff] [blame] | 297 | Location maybe_temp, |
Mathieu Chartier | 3af00dc | 2016-11-10 11:25:57 -0800 | [diff] [blame] | 298 | ReadBarrierOption read_barrier_option); |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 299 | // Generate a heap reference load using two different registers |
| 300 | // `out` and `obj`: |
| 301 | // |
| 302 | // out <- *(obj + offset) |
| 303 | // |
| 304 | // while honoring heap poisoning and/or read barriers (if any). |
Roland Levillain | 95e7ffc | 2016-01-22 11:57:25 +0000 | [diff] [blame] | 305 | // |
| 306 | // Location `maybe_temp` is used when generating a Baker's (fast |
| 307 | // path) read barrier and shall be a register in that case; it may |
| 308 | // be an invalid location otherwise. |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 309 | void GenerateReferenceLoadTwoRegisters(HInstruction* instruction, |
| 310 | Location out, |
| 311 | Location obj, |
Mathieu Chartier | 5c44c1b | 2016-11-04 18:13:04 -0700 | [diff] [blame] | 312 | uint32_t offset, |
Mathieu Chartier | 3af00dc | 2016-11-10 11:25:57 -0800 | [diff] [blame] | 313 | ReadBarrierOption read_barrier_option); |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 314 | |
Roland Levillain | 232ade0 | 2015-04-20 15:14:36 +0100 | [diff] [blame] | 315 | // Push value to FPU stack. `is_fp` specifies whether the value is floating point or not. |
| 316 | // `is_wide` specifies whether it is long/double or not. |
Mark Mendell | 24f2dfa | 2015-01-14 19:51:45 -0500 | [diff] [blame] | 317 | void PushOntoFPStack(Location source, uint32_t temp_offset, |
Roland Levillain | 232ade0 | 2015-04-20 15:14:36 +0100 | [diff] [blame] | 318 | uint32_t stack_adjustment, bool is_fp, bool is_wide); |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 319 | |
Mark Mendell | 152408f | 2015-12-31 12:28:50 -0500 | [diff] [blame] | 320 | template<class LabelType> |
Mingyao Yang | d43b3ac | 2015-04-01 14:03:04 -0700 | [diff] [blame] | 321 | void GenerateTestAndBranch(HInstruction* instruction, |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 322 | size_t condition_input_index, |
Mark Mendell | 152408f | 2015-12-31 12:28:50 -0500 | [diff] [blame] | 323 | LabelType* true_target, |
| 324 | LabelType* false_target); |
| 325 | template<class LabelType> |
David Brazdil | 0debae7 | 2015-11-12 18:37:00 +0000 | [diff] [blame] | 326 | void GenerateCompareTestAndBranch(HCondition* condition, |
Mark Mendell | 152408f | 2015-12-31 12:28:50 -0500 | [diff] [blame] | 327 | LabelType* true_target, |
| 328 | LabelType* false_target); |
| 329 | template<class LabelType> |
| 330 | void GenerateFPJumps(HCondition* cond, LabelType* true_label, LabelType* false_label); |
| 331 | template<class LabelType> |
| 332 | void GenerateLongComparesAndJumps(HCondition* cond, |
| 333 | LabelType* true_label, |
| 334 | LabelType* false_label); |
| 335 | |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 336 | void HandleGoto(HInstruction* got, HBasicBlock* successor); |
Vladimir Marko | f3e0ee2 | 2015-12-17 15:23:13 +0000 | [diff] [blame] | 337 | void GenPackedSwitchWithCompares(Register value_reg, |
| 338 | int32_t lower_bound, |
| 339 | uint32_t num_entries, |
| 340 | HBasicBlock* switch_block, |
| 341 | HBasicBlock* default_block); |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 342 | |
Mark P Mendell | 2f10a5f | 2016-01-25 14:47:50 +0000 | [diff] [blame] | 343 | void GenerateFPCompare(Location lhs, Location rhs, HInstruction* insn, bool is_double); |
Shalini Salomi Bodapati | b45a435 | 2019-07-10 16:09:41 +0530 | [diff] [blame] | 344 | bool CpuHasAvxFeatureFlag(); |
| 345 | bool CpuHasAvx2FeatureFlag(); |
Mark P Mendell | 2f10a5f | 2016-01-25 14:47:50 +0000 | [diff] [blame] | 346 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 347 | X86Assembler* const assembler_; |
| 348 | CodeGeneratorX86* const codegen_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 349 | |
| 350 | DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorX86); |
| 351 | }; |
| 352 | |
Mark Mendell | 805b3b5 | 2015-09-18 14:10:29 -0400 | [diff] [blame] | 353 | class JumpTableRIPFixup; |
| 354 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 355 | class CodeGeneratorX86 : public CodeGenerator { |
| 356 | public: |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 357 | CodeGeneratorX86(HGraph* graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 358 | const CompilerOptions& compiler_options, |
| 359 | OptimizingCompilerStats* stats = nullptr); |
Nicolas Geoffray | f12feb8 | 2014-07-17 18:32:41 +0100 | [diff] [blame] | 360 | virtual ~CodeGeneratorX86() {} |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 361 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 362 | void GenerateFrameEntry() override; |
| 363 | void GenerateFrameExit() override; |
| 364 | void Bind(HBasicBlock* block) override; |
| 365 | void MoveConstant(Location destination, int32_t value) override; |
| 366 | void MoveLocation(Location dst, Location src, DataType::Type dst_type) override; |
| 367 | void AddLocationAsTemp(Location location, LocationSummary* locations) override; |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 368 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 369 | size_t SaveCoreRegister(size_t stack_index, uint32_t reg_id) override; |
| 370 | size_t RestoreCoreRegister(size_t stack_index, uint32_t reg_id) override; |
| 371 | size_t SaveFloatingPointRegister(size_t stack_index, uint32_t reg_id) override; |
| 372 | size_t RestoreFloatingPointRegister(size_t stack_index, uint32_t reg_id) override; |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 373 | |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 374 | // Generate code to invoke a runtime entry point. |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 375 | void InvokeRuntime(QuickEntrypointEnum entrypoint, |
| 376 | HInstruction* instruction, |
| 377 | uint32_t dex_pc, |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 378 | SlowPathCode* slow_path = nullptr) override; |
Alexandre Rames | 8158f28 | 2015-08-07 10:26:17 +0100 | [diff] [blame] | 379 | |
Roland Levillain | dec8f63 | 2016-07-22 17:10:06 +0100 | [diff] [blame] | 380 | // Generate code to invoke a runtime entry point, but do not record |
| 381 | // PC-related information in a stack map. |
| 382 | void InvokeRuntimeWithoutRecordingPcInfo(int32_t entry_point_offset, |
| 383 | HInstruction* instruction, |
| 384 | SlowPathCode* slow_path); |
| 385 | |
Serban Constantinescu | ba45db0 | 2016-07-12 22:53:02 +0100 | [diff] [blame] | 386 | void GenerateInvokeRuntime(int32_t entry_point_offset); |
| 387 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 388 | size_t GetWordSize() const override { |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 389 | return kX86WordSize; |
| 390 | } |
| 391 | |
Artem Serov | 6a0b657 | 2019-07-26 20:38:37 +0100 | [diff] [blame] | 392 | size_t GetSlowPathFPWidth() const override { |
Aart Bik | b13c65b | 2017-03-21 20:14:07 -0700 | [diff] [blame] | 393 | return GetGraph()->HasSIMD() |
Artem Serov | c8150b5 | 2019-07-31 18:28:00 +0100 | [diff] [blame] | 394 | ? GetSIMDRegisterWidth() |
Aart Bik | b13c65b | 2017-03-21 20:14:07 -0700 | [diff] [blame] | 395 | : 2 * kX86WordSize; // 8 bytes == 2 words for each spill |
Mark Mendell | f85a9ca | 2015-01-13 09:20:58 -0500 | [diff] [blame] | 396 | } |
| 397 | |
Artem Serov | 6a0b657 | 2019-07-26 20:38:37 +0100 | [diff] [blame] | 398 | size_t GetCalleePreservedFPWidth() const override { |
| 399 | return 2 * kX86WordSize; |
| 400 | } |
| 401 | |
Artem Serov | c8150b5 | 2019-07-31 18:28:00 +0100 | [diff] [blame] | 402 | size_t GetSIMDRegisterWidth() const override { |
| 403 | return 4 * kX86WordSize; |
| 404 | } |
| 405 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 406 | HGraphVisitor* GetLocationBuilder() override { |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 407 | return &location_builder_; |
| 408 | } |
| 409 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 410 | HGraphVisitor* GetInstructionVisitor() override { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 411 | return &instruction_visitor_; |
| 412 | } |
| 413 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 414 | X86Assembler* GetAssembler() override { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 415 | return &assembler_; |
| 416 | } |
| 417 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 418 | const X86Assembler& GetAssembler() const override { |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 419 | return assembler_; |
| 420 | } |
| 421 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 422 | uintptr_t GetAddressOf(HBasicBlock* block) override { |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 423 | return GetLabelOf(block)->Position(); |
| 424 | } |
Calin Juravle | 34bacdf | 2014-10-07 20:23:36 +0100 | [diff] [blame] | 425 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 426 | void SetupBlockedRegisters() const override; |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 427 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 428 | void DumpCoreRegister(std::ostream& stream, int reg) const override; |
| 429 | void DumpFloatingPointRegister(std::ostream& stream, int reg) const override; |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 430 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 431 | ParallelMoveResolverX86* GetMoveResolver() override { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 432 | return &move_resolver_; |
| 433 | } |
| 434 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 435 | InstructionSet GetInstructionSet() const override { |
Nicolas Geoffray | 412f10c | 2014-06-19 10:00:34 +0100 | [diff] [blame] | 436 | return InstructionSet::kX86; |
| 437 | } |
| 438 | |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 439 | const X86InstructionSetFeatures& GetInstructionSetFeatures() const; |
| 440 | |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 441 | // Helper method to move a 32bits value between two locations. |
| 442 | void Move32(Location destination, Location source); |
| 443 | // Helper method to move a 64bits value between two locations. |
| 444 | void Move64(Location destination, Location source); |
Andra Danciu | d0f71f2 | 2020-09-17 09:00:15 +0000 | [diff] [blame] | 445 | // Helper method to load a value from an address to a register. |
| 446 | void LoadFromMemoryNoBarrier(DataType::Type dst_type, |
| 447 | Location dst, |
| 448 | Address src, |
Ulya Trafimovich | 322eced | 2021-06-02 15:39:36 +0100 | [diff] [blame] | 449 | HInstruction* instr = nullptr, |
Andra Danciu | d0f71f2 | 2020-09-17 09:00:15 +0000 | [diff] [blame] | 450 | XmmRegister temp = kNoXmmRegister, |
| 451 | bool is_atomic_load = false); |
Andra Danciu | 73c3180 | 2020-09-01 13:17:05 +0000 | [diff] [blame] | 452 | // Helper method to move a primitive value from a location to an address. |
| 453 | void MoveToMemory(DataType::Type src_type, |
| 454 | Location src, |
| 455 | Register dst_base, |
| 456 | Register dst_index = Register::kNoRegister, |
| 457 | ScaleFactor dst_scale = TIMES_1, |
| 458 | int32_t dst_disp = 0); |
Nicolas Geoffray | 01bc96d | 2014-04-11 17:43:50 +0100 | [diff] [blame] | 459 | |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 460 | // Check if the desired_string_load_kind is supported. If it is, return it, |
| 461 | // otherwise return a fall-back kind that should be used instead. |
| 462 | HLoadString::LoadKind GetSupportedLoadStringKind( |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 463 | HLoadString::LoadKind desired_string_load_kind) override; |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 464 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 465 | // Check if the desired_class_load_kind is supported. If it is, return it, |
| 466 | // otherwise return a fall-back kind that should be used instead. |
| 467 | HLoadClass::LoadKind GetSupportedLoadClassKind( |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 468 | HLoadClass::LoadKind desired_class_load_kind) override; |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 469 | |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 470 | // Check if the desired_dispatch_info is supported. If it is, return it, |
| 471 | // otherwise return a fall-back info that should be used instead. |
| 472 | HInvokeStaticOrDirect::DispatchInfo GetSupportedInvokeStaticOrDirectDispatch( |
| 473 | const HInvokeStaticOrDirect::DispatchInfo& desired_dispatch_info, |
Nicolas Geoffray | bdb2ecc | 2018-09-18 14:33:55 +0100 | [diff] [blame] | 474 | ArtMethod* method) override; |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 475 | |
Nicolas Geoffray | 8d34a18 | 2020-09-16 09:46:58 +0100 | [diff] [blame] | 476 | void LoadMethod(MethodLoadKind load_kind, Location temp, HInvoke* invoke); |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 477 | // Generate a call to a static or direct method. |
Vladimir Marko | e7197bf | 2017-06-02 17:00:23 +0100 | [diff] [blame] | 478 | void GenerateStaticOrDirectCall( |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 479 | HInvokeStaticOrDirect* invoke, Location temp, SlowPathCode* slow_path = nullptr) override; |
Andreas Gampe | bfb5ba9 | 2015-09-01 15:45:02 +0000 | [diff] [blame] | 480 | // Generate a call to a virtual method. |
Vladimir Marko | e7197bf | 2017-06-02 17:00:23 +0100 | [diff] [blame] | 481 | void GenerateVirtualCall( |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 482 | HInvokeVirtual* invoke, Location temp, SlowPathCode* slow_path = nullptr) override; |
Andreas Gampe | 85b62f2 | 2015-09-09 13:15:38 -0700 | [diff] [blame] | 483 | |
Vladimir Marko | 6fd1606 | 2018-06-26 11:02:04 +0100 | [diff] [blame] | 484 | void RecordBootImageIntrinsicPatch(HX86ComputeBaseMethodAddress* method_address, |
| 485 | uint32_t intrinsic_data); |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 486 | void RecordBootImageRelRoPatch(HX86ComputeBaseMethodAddress* method_address, |
| 487 | uint32_t boot_image_offset); |
Nicolas Geoffray | 8d34a18 | 2020-09-16 09:46:58 +0100 | [diff] [blame] | 488 | void RecordBootImageMethodPatch(HInvoke* invoke); |
| 489 | void RecordMethodBssEntryPatch(HInvoke* invoke); |
Vladimir Marko | 59eb30f | 2018-02-20 11:52:34 +0000 | [diff] [blame] | 490 | void RecordBootImageTypePatch(HLoadClass* load_class); |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 491 | Label* NewTypeBssEntryPatch(HLoadClass* load_class); |
Vladimir Marko | 59eb30f | 2018-02-20 11:52:34 +0000 | [diff] [blame] | 492 | void RecordBootImageStringPatch(HLoadString* load_string); |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 493 | Label* NewStringBssEntryPatch(HLoadString* load_string); |
Vladimir Marko | eb9eb00 | 2020-10-02 13:54:19 +0100 | [diff] [blame] | 494 | void RecordBootImageJniEntrypointPatch(HInvokeStaticOrDirect* invoke); |
Vladimir Marko | eebb821 | 2018-06-05 14:57:24 +0100 | [diff] [blame] | 495 | |
| 496 | void LoadBootImageAddress(Register reg, |
Vladimir Marko | 6fd1606 | 2018-06-26 11:02:04 +0100 | [diff] [blame] | 497 | uint32_t boot_image_reference, |
Vladimir Marko | eebb821 | 2018-06-05 14:57:24 +0100 | [diff] [blame] | 498 | HInvokeStaticOrDirect* invoke); |
Vladimir Marko | de91ca9 | 2020-10-27 13:41:40 +0000 | [diff] [blame] | 499 | void LoadIntrinsicDeclaringClass(Register reg, HInvokeStaticOrDirect* invoke); |
Vladimir Marko | eebb821 | 2018-06-05 14:57:24 +0100 | [diff] [blame] | 500 | |
Nicolas Geoffray | f0acfe7 | 2017-01-09 20:54:52 +0000 | [diff] [blame] | 501 | Label* NewJitRootStringPatch(const DexFile& dex_file, |
Vladimir Marko | 174b2e2 | 2017-10-12 13:34:49 +0100 | [diff] [blame] | 502 | dex::StringIndex string_index, |
Nicolas Geoffray | f0acfe7 | 2017-01-09 20:54:52 +0000 | [diff] [blame] | 503 | Handle<mirror::String> handle); |
Nicolas Geoffray | 5247c08 | 2017-01-13 14:17:29 +0000 | [diff] [blame] | 504 | Label* NewJitRootClassPatch(const DexFile& dex_file, |
Vladimir Marko | 174b2e2 | 2017-10-12 13:34:49 +0100 | [diff] [blame] | 505 | dex::TypeIndex type_index, |
Nicolas Geoffray | 5247c08 | 2017-01-13 14:17:29 +0000 | [diff] [blame] | 506 | Handle<mirror::Class> handle); |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 507 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 508 | void MoveFromReturnRegister(Location trg, DataType::Type type) override; |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 509 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 510 | // Emit linker patches. |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 511 | void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches) override; |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 512 | |
Nicolas Geoffray | 22384ae | 2016-12-12 22:33:36 +0000 | [diff] [blame] | 513 | void PatchJitRootUse(uint8_t* code, |
| 514 | const uint8_t* roots_data, |
| 515 | const PatchInfo<Label>& info, |
| 516 | uint64_t index_in_table) const; |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 517 | void EmitJitRootPatches(uint8_t* code, const uint8_t* roots_data) override; |
Nicolas Geoffray | 132d836 | 2016-11-16 09:19:42 +0000 | [diff] [blame] | 518 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 519 | // Emit a write barrier. |
Nicolas Geoffray | 07276db | 2015-05-18 14:22:09 +0100 | [diff] [blame] | 520 | void MarkGCCard(Register temp, |
| 521 | Register card, |
| 522 | Register object, |
| 523 | Register value, |
| 524 | bool value_can_be_null); |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 525 | |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 526 | void GenerateMemoryBarrier(MemBarrierKind kind); |
| 527 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 528 | Label* GetLabelOf(HBasicBlock* block) const { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 529 | return CommonGetLabelOf<Label>(block_labels_, block); |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 530 | } |
| 531 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 532 | void Initialize() override { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 533 | block_labels_ = CommonInitializeLabels<Label>(); |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 534 | } |
| 535 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 536 | bool NeedsTwoRegisters(DataType::Type type) const override { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 537 | return type == DataType::Type::kInt64; |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 540 | bool ShouldSplitLongMoves() const override { return true; } |
Nicolas Geoffray | 234d69d | 2015-03-09 10:28:50 +0000 | [diff] [blame] | 541 | |
Nicolas Geoffray | 1cf9528 | 2014-12-12 19:22:03 +0000 | [diff] [blame] | 542 | Label* GetFrameEntryLabel() { return &frame_entry_label_; } |
| 543 | |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 544 | void AddMethodAddressOffset(HX86ComputeBaseMethodAddress* method_base, int32_t offset) { |
| 545 | method_address_offset_.Put(method_base->GetId(), offset); |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 546 | } |
| 547 | |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 548 | int32_t GetMethodAddressOffset(HX86ComputeBaseMethodAddress* method_base) const { |
| 549 | return method_address_offset_.Get(method_base->GetId()); |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | int32_t ConstantAreaStart() const { |
| 553 | return constant_area_start_; |
| 554 | } |
| 555 | |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 556 | Address LiteralDoubleAddress(double v, HX86ComputeBaseMethodAddress* method_base, Register reg); |
| 557 | Address LiteralFloatAddress(float v, HX86ComputeBaseMethodAddress* method_base, Register reg); |
| 558 | Address LiteralInt32Address(int32_t v, HX86ComputeBaseMethodAddress* method_base, Register reg); |
| 559 | Address LiteralInt64Address(int64_t v, HX86ComputeBaseMethodAddress* method_base, Register reg); |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 560 | |
Aart Bik | a19616e | 2016-02-01 18:57:58 -0800 | [diff] [blame] | 561 | // Load a 32-bit value into a register in the most efficient manner. |
| 562 | void Load32BitValue(Register dest, int32_t value); |
| 563 | |
| 564 | // Compare a register with a 32-bit value in the most efficient manner. |
| 565 | void Compare32BitValue(Register dest, int32_t value); |
| 566 | |
Vladimir Marko | 56f4bdd | 2016-09-16 11:32:36 +0100 | [diff] [blame] | 567 | // Compare int values. Supports only register locations for `lhs`. |
| 568 | void GenerateIntCompare(Location lhs, Location rhs); |
jessicahandojo | 4877b79 | 2016-09-08 19:49:13 -0700 | [diff] [blame] | 569 | void GenerateIntCompare(Register lhs, Location rhs); |
Vladimir Marko | 56f4bdd | 2016-09-16 11:32:36 +0100 | [diff] [blame] | 570 | |
| 571 | // Construct address for array access. |
| 572 | static Address ArrayAddress(Register obj, |
| 573 | Location index, |
| 574 | ScaleFactor scale, |
| 575 | uint32_t data_offset); |
| 576 | |
Mark Mendell | 805b3b5 | 2015-09-18 14:10:29 -0400 | [diff] [blame] | 577 | Address LiteralCaseTable(HX86PackedSwitch* switch_instr, Register reg, Register value); |
| 578 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 579 | void Finalize(CodeAllocator* allocator) override; |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 580 | |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 581 | // Fast path implementation of ReadBarrier::Barrier for a heap |
| 582 | // reference field load when Baker's read barriers are used. |
| 583 | void GenerateFieldLoadWithBakerReadBarrier(HInstruction* instruction, |
Roland Levillain | e3f43ac | 2016-01-19 15:07:47 +0000 | [diff] [blame] | 584 | Location ref, |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 585 | Register obj, |
| 586 | uint32_t offset, |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 587 | bool needs_null_check); |
| 588 | // Fast path implementation of ReadBarrier::Barrier for a heap |
| 589 | // reference array load when Baker's read barriers are used. |
| 590 | void GenerateArrayLoadWithBakerReadBarrier(HInstruction* instruction, |
Roland Levillain | e3f43ac | 2016-01-19 15:07:47 +0000 | [diff] [blame] | 591 | Location ref, |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 592 | Register obj, |
| 593 | uint32_t data_offset, |
| 594 | Location index, |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 595 | bool needs_null_check); |
Roland Levillain | a1aa3b1 | 2016-10-26 13:03:38 +0100 | [diff] [blame] | 596 | // Factored implementation, used by GenerateFieldLoadWithBakerReadBarrier, |
| 597 | // GenerateArrayLoadWithBakerReadBarrier and some intrinsics. |
| 598 | // |
| 599 | // Load the object reference located at address `src`, held by |
| 600 | // object `obj`, into `ref`, and mark it if needed. The base of |
| 601 | // address `src` must be `obj`. |
| 602 | // |
| 603 | // If `always_update_field` is true, the value of the reference is |
| 604 | // atomically updated in the holder (`obj`). This operation |
| 605 | // requires a temporary register, which must be provided as a |
| 606 | // non-null pointer (`temp`). |
Sang, Chunlei | 0fcd2b8 | 2016-04-05 17:12:59 +0800 | [diff] [blame] | 607 | void GenerateReferenceLoadWithBakerReadBarrier(HInstruction* instruction, |
| 608 | Location ref, |
| 609 | Register obj, |
| 610 | const Address& src, |
Roland Levillain | a1aa3b1 | 2016-10-26 13:03:38 +0100 | [diff] [blame] | 611 | bool needs_null_check, |
| 612 | bool always_update_field = false, |
| 613 | Register* temp = nullptr); |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 614 | |
| 615 | // Generate a read barrier for a heap reference within `instruction` |
| 616 | // using a slow path. |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 617 | // |
| 618 | // A read barrier for an object reference read from the heap is |
| 619 | // implemented as a call to the artReadBarrierSlow runtime entry |
| 620 | // point, which is passed the values in locations `ref`, `obj`, and |
| 621 | // `offset`: |
| 622 | // |
| 623 | // mirror::Object* artReadBarrierSlow(mirror::Object* ref, |
| 624 | // mirror::Object* obj, |
| 625 | // uint32_t offset); |
| 626 | // |
| 627 | // The `out` location contains the value returned by |
| 628 | // artReadBarrierSlow. |
| 629 | // |
| 630 | // When `index` is provided (i.e. for array accesses), the offset |
| 631 | // value passed to artReadBarrierSlow is adjusted to take `index` |
| 632 | // into account. |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 633 | void GenerateReadBarrierSlow(HInstruction* instruction, |
| 634 | Location out, |
| 635 | Location ref, |
| 636 | Location obj, |
| 637 | uint32_t offset, |
| 638 | Location index = Location::NoLocation()); |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 639 | |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 640 | // If read barriers are enabled, generate a read barrier for a heap |
| 641 | // reference using a slow path. If heap poisoning is enabled, also |
| 642 | // unpoison the reference in `out`. |
| 643 | void MaybeGenerateReadBarrierSlow(HInstruction* instruction, |
| 644 | Location out, |
| 645 | Location ref, |
| 646 | Location obj, |
| 647 | uint32_t offset, |
| 648 | Location index = Location::NoLocation()); |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 649 | |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 650 | // Generate a read barrier for a GC root within `instruction` using |
| 651 | // a slow path. |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 652 | // |
| 653 | // A read barrier for an object reference GC root is implemented as |
| 654 | // a call to the artReadBarrierForRootSlow runtime entry point, |
| 655 | // which is passed the value in location `root`: |
| 656 | // |
| 657 | // mirror::Object* artReadBarrierForRootSlow(GcRoot<mirror::Object>* root); |
| 658 | // |
| 659 | // The `out` location contains the value returned by |
| 660 | // artReadBarrierForRootSlow. |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 661 | void GenerateReadBarrierForRootSlow(HInstruction* instruction, Location out, Location root); |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 662 | |
Mark P Mendell | 17077d8 | 2015-12-16 19:15:59 +0000 | [diff] [blame] | 663 | // Ensure that prior stores complete to memory before subsequent loads. |
| 664 | // The locked add implementation will avoid serializing device memory, but will |
| 665 | // touch (but not change) the top of the stack. |
| 666 | // The 'non_temporal' parameter should be used to ensure ordering of non-temporal stores. |
| 667 | void MemoryFence(bool non_temporal = false) { |
Mark Mendell | 7aa04a1 | 2016-01-27 22:39:07 -0500 | [diff] [blame] | 668 | if (!non_temporal) { |
Mark P Mendell | 17077d8 | 2015-12-16 19:15:59 +0000 | [diff] [blame] | 669 | assembler_.lock()->addl(Address(ESP, 0), Immediate(0)); |
| 670 | } else { |
| 671 | assembler_.mfence(); |
| 672 | } |
| 673 | } |
| 674 | |
Vladimir Marko | dec7817 | 2020-06-19 15:31:23 +0100 | [diff] [blame] | 675 | void IncreaseFrame(size_t adjustment) override; |
| 676 | void DecreaseFrame(size_t adjustment) override; |
| 677 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 678 | void GenerateNop() override; |
| 679 | void GenerateImplicitNullCheck(HNullCheck* instruction) override; |
| 680 | void GenerateExplicitNullCheck(HNullCheck* instruction) override; |
Mark P Mendell | 17077d8 | 2015-12-16 19:15:59 +0000 | [diff] [blame] | 681 | |
Nicolas Geoffray | e2a3aa9 | 2019-11-25 17:52:58 +0000 | [diff] [blame] | 682 | void MaybeGenerateInlineCacheCheck(HInstruction* instruction, Register klass); |
Nicolas Geoffray | a59af8a | 2019-11-27 17:42:32 +0000 | [diff] [blame] | 683 | void MaybeIncrementHotness(bool is_frame_entry); |
Nicolas Geoffray | e2a3aa9 | 2019-11-25 17:52:58 +0000 | [diff] [blame] | 684 | |
Vladimir Marko | 4ef451a | 2020-07-23 09:54:27 +0000 | [diff] [blame] | 685 | // When we don't know the proper offset for the value, we use kPlaceholder32BitOffset. |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 686 | // The correct value will be inserted when processing Assembler fixups. |
Vladimir Marko | 4ef451a | 2020-07-23 09:54:27 +0000 | [diff] [blame] | 687 | static constexpr int32_t kPlaceholder32BitOffset = 256; |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 688 | |
Nicolas Geoffray | 3c7bb98 | 2014-07-23 16:04:16 +0100 | [diff] [blame] | 689 | private: |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 690 | struct X86PcRelativePatchInfo : PatchInfo<Label> { |
| 691 | X86PcRelativePatchInfo(HX86ComputeBaseMethodAddress* address, |
Vladimir Marko | 59eb30f | 2018-02-20 11:52:34 +0000 | [diff] [blame] | 692 | const DexFile* target_dex_file, |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 693 | uint32_t target_index) |
| 694 | : PatchInfo(target_dex_file, target_index), |
| 695 | method_address(address) {} |
| 696 | HX86ComputeBaseMethodAddress* method_address; |
| 697 | }; |
Vladimir Marko | 0f7dca4 | 2015-11-02 14:36:43 +0000 | [diff] [blame] | 698 | |
Vladimir Marko | d8dbc8d | 2017-09-20 13:37:47 +0100 | [diff] [blame] | 699 | template <linker::LinkerPatch (*Factory)(size_t, const DexFile*, uint32_t, uint32_t)> |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 700 | void EmitPcRelativeLinkerPatches(const ArenaDeque<X86PcRelativePatchInfo>& infos, |
Vladimir Marko | d8dbc8d | 2017-09-20 13:37:47 +0100 | [diff] [blame] | 701 | ArenaVector<linker::LinkerPatch>* linker_patches); |
Vladimir Marko | 0f7dca4 | 2015-11-02 14:36:43 +0000 | [diff] [blame] | 702 | |
Nicolas Geoffray | 8d34a18 | 2020-09-16 09:46:58 +0100 | [diff] [blame] | 703 | Register GetInvokeExtraParameter(HInvoke* invoke, Register temp); |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 704 | Register GetInvokeStaticOrDirectExtraParameter(HInvokeStaticOrDirect* invoke, Register temp); |
| 705 | |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 706 | // Labels for each block that will be compiled. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 707 | Label* block_labels_; // Indexed by block id. |
Nicolas Geoffray | 1cf9528 | 2014-12-12 19:22:03 +0000 | [diff] [blame] | 708 | Label frame_entry_label_; |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 709 | LocationsBuilderX86 location_builder_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 710 | InstructionCodeGeneratorX86 instruction_visitor_; |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 711 | ParallelMoveResolverX86 move_resolver_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 712 | X86Assembler assembler_; |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 713 | |
Vladimir Marko | 2d06e02 | 2019-07-08 15:45:19 +0100 | [diff] [blame] | 714 | // PC-relative method patch info for kBootImageLinkTimePcRelative. |
Vladimir Marko | 6597946 | 2017-05-19 17:25:12 +0100 | [diff] [blame] | 715 | ArenaDeque<X86PcRelativePatchInfo> boot_image_method_patches_; |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 716 | // PC-relative method patch info for kBssEntry. |
| 717 | ArenaDeque<X86PcRelativePatchInfo> method_bss_entry_patches_; |
Vladimir Marko | 764d454 | 2017-05-16 10:31:41 +0100 | [diff] [blame] | 718 | // PC-relative type patch info for kBootImageLinkTimePcRelative. |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 719 | ArenaDeque<X86PcRelativePatchInfo> boot_image_type_patches_; |
Vladimir Marko | e47f60c | 2018-02-21 13:43:28 +0000 | [diff] [blame] | 720 | // PC-relative type patch info for kBssEntry. |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 721 | ArenaDeque<X86PcRelativePatchInfo> type_bss_entry_patches_; |
Vladimir Marko | 8f63f10 | 2020-09-28 12:10:28 +0100 | [diff] [blame] | 722 | // PC-relative public type patch info for kBssEntryPublic. |
| 723 | ArenaDeque<X86PcRelativePatchInfo> public_type_bss_entry_patches_; |
| 724 | // PC-relative package type patch info for kBssEntryPackage. |
| 725 | ArenaDeque<X86PcRelativePatchInfo> package_type_bss_entry_patches_; |
Vladimir Marko | e47f60c | 2018-02-21 13:43:28 +0000 | [diff] [blame] | 726 | // PC-relative String patch info for kBootImageLinkTimePcRelative. |
Vladimir Marko | 59eb30f | 2018-02-20 11:52:34 +0000 | [diff] [blame] | 727 | ArenaDeque<X86PcRelativePatchInfo> boot_image_string_patches_; |
Vladimir Marko | e47f60c | 2018-02-21 13:43:28 +0000 | [diff] [blame] | 728 | // PC-relative String patch info for kBssEntry. |
Vladimir Marko | 6cfbdbc | 2017-07-25 13:26:39 +0100 | [diff] [blame] | 729 | ArenaDeque<X86PcRelativePatchInfo> string_bss_entry_patches_; |
Vladimir Marko | eb9eb00 | 2020-10-02 13:54:19 +0100 | [diff] [blame] | 730 | // PC-relative method patch info for kBootImageLinkTimePcRelative+kCallCriticalNative. |
| 731 | ArenaDeque<X86PcRelativePatchInfo> boot_image_jni_entrypoint_patches_; |
Vladimir Marko | 2d06e02 | 2019-07-08 15:45:19 +0100 | [diff] [blame] | 732 | // PC-relative patch info for IntrinsicObjects for the boot image, |
| 733 | // and for method/type/string patches for kBootImageRelRo otherwise. |
| 734 | ArenaDeque<X86PcRelativePatchInfo> boot_image_other_patches_; |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 735 | |
Nicolas Geoffray | 132d836 | 2016-11-16 09:19:42 +0000 | [diff] [blame] | 736 | // Patches for string root accesses in JIT compiled code. |
| 737 | ArenaDeque<PatchInfo<Label>> jit_string_patches_; |
Nicolas Geoffray | 22384ae | 2016-12-12 22:33:36 +0000 | [diff] [blame] | 738 | // Patches for class root accesses in JIT compiled code. |
| 739 | ArenaDeque<PatchInfo<Label>> jit_class_patches_; |
| 740 | |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 741 | // Offset to the start of the constant area in the assembled code. |
| 742 | // Used for fixups to the constant area. |
| 743 | int32_t constant_area_start_; |
| 744 | |
Mark Mendell | 805b3b5 | 2015-09-18 14:10:29 -0400 | [diff] [blame] | 745 | // Fixups for jump tables that need to be patched after the constant table is generated. |
| 746 | ArenaVector<JumpTableRIPFixup*> fixups_to_jump_tables_; |
| 747 | |
Nicolas Geoffray | 133719e | 2017-01-22 15:44:39 +0000 | [diff] [blame] | 748 | // Maps a HX86ComputeBaseMethodAddress instruction id, to its offset in the |
| 749 | // compiled code. |
| 750 | ArenaSafeMap<uint32_t, int32_t> method_address_offset_; |
Mark Mendell | 0616ae0 | 2015-04-17 12:49:27 -0400 | [diff] [blame] | 751 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 752 | DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86); |
| 753 | }; |
| 754 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 755 | } // namespace x86 |
| 756 | } // namespace art |
| 757 | |
| 758 | #endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ |