David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 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_INSTRUCTION_BUILDER_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_INSTRUCTION_BUILDER_H_ |
| 19 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 20 | #include "base/scoped_arena_allocator.h" |
| 21 | #include "base/scoped_arena_containers.h" |
| 22 | #include "data_type.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 23 | #include "dex/code_item_accessors.h" |
| 24 | #include "dex/dex_file.h" |
| 25 | #include "dex/dex_file_types.h" |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 26 | #include "handle.h" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 27 | #include "nodes.h" |
Mathieu Chartier | de4b08f | 2017-07-10 14:13:41 -0700 | [diff] [blame] | 28 | #include "quicken_info.h" |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 32 | class ArenaBitVector; |
| 33 | class ArtField; |
| 34 | class ArtMethod; |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 35 | class CodeGenerator; |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 36 | class CompilerDriver; |
| 37 | class DexCompilationUnit; |
| 38 | class HBasicBlockBuilder; |
Andreas Gampe | 26de38b | 2016-07-27 17:53:11 -0700 | [diff] [blame] | 39 | class Instruction; |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 40 | class OptimizingCompilerStats; |
| 41 | class SsaBuilder; |
| 42 | class VariableSizedHandleScope; |
| 43 | |
| 44 | namespace mirror { |
| 45 | class Class; |
| 46 | } // namespace mirror |
Andreas Gampe | 26de38b | 2016-07-27 17:53:11 -0700 | [diff] [blame] | 47 | |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 48 | class HInstructionBuilder : public ValueObject { |
| 49 | public: |
| 50 | HInstructionBuilder(HGraph* graph, |
| 51 | HBasicBlockBuilder* block_builder, |
| 52 | SsaBuilder* ssa_builder, |
| 53 | const DexFile* dex_file, |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 54 | const CodeItemDebugInfoAccessor& accessor, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 55 | DataType::Type return_type, |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 56 | const DexCompilationUnit* dex_compilation_unit, |
| 57 | const DexCompilationUnit* outer_compilation_unit, |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 58 | CompilerDriver* compiler_driver, |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 59 | CodeGenerator* code_generator, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 60 | const uint8_t* interpreter_metadata, |
| 61 | OptimizingCompilerStats* compiler_stats, |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 62 | VariableSizedHandleScope* handles, |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 63 | ScopedArenaAllocator* local_allocator); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 64 | |
| 65 | bool Build(); |
Vladimir Marko | 92f7f3c | 2017-10-31 11:38:30 +0000 | [diff] [blame] | 66 | void BuildIntrinsic(ArtMethod* method); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 67 | |
| 68 | private: |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 69 | void InitializeBlockLocals(); |
| 70 | void PropagateLocalsToCatchBlocks(); |
| 71 | void SetLoopHeaderPhiInputs(); |
| 72 | |
Mathieu Chartier | de4b08f | 2017-07-10 14:13:41 -0700 | [diff] [blame] | 73 | bool ProcessDexInstruction(const Instruction& instruction, uint32_t dex_pc, size_t quicken_index); |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 74 | ArenaBitVector* FindNativeDebugInfoLocations(); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 75 | |
| 76 | bool CanDecodeQuickenedInfo() const; |
Mathieu Chartier | de4b08f | 2017-07-10 14:13:41 -0700 | [diff] [blame] | 77 | uint16_t LookupQuickenedInfo(uint32_t quicken_index); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 78 | |
| 79 | HBasicBlock* FindBlockStartingAt(uint32_t dex_pc) const; |
| 80 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 81 | ScopedArenaVector<HInstruction*>* GetLocalsFor(HBasicBlock* block); |
Mingyao Yang | 01b47b0 | 2017-02-03 12:09:57 -0800 | [diff] [blame] | 82 | // Out of line version of GetLocalsFor(), which has a fast path that is |
| 83 | // beneficial to get inlined by callers. |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 84 | ScopedArenaVector<HInstruction*>* GetLocalsForWithAllocation( |
| 85 | HBasicBlock* block, ScopedArenaVector<HInstruction*>* locals, const size_t vregs); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 86 | HInstruction* ValueOfLocalAt(HBasicBlock* block, size_t local); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 87 | HInstruction* LoadLocal(uint32_t register_index, DataType::Type type) const; |
David Brazdil | c120bbe | 2016-04-22 16:57:00 +0100 | [diff] [blame] | 88 | HInstruction* LoadNullCheckedLocal(uint32_t register_index, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 89 | void UpdateLocal(uint32_t register_index, HInstruction* instruction); |
| 90 | |
| 91 | void AppendInstruction(HInstruction* instruction); |
| 92 | void InsertInstructionAtTop(HInstruction* instruction); |
| 93 | void InitializeInstruction(HInstruction* instruction); |
| 94 | |
| 95 | void InitializeParameters(); |
| 96 | |
| 97 | // Returns whether the current method needs access check for the type. |
| 98 | // Output parameter finalizable is set to whether the type is finalizable. |
Vladimir Marko | 8d6768d | 2017-03-14 10:13:21 +0000 | [diff] [blame] | 99 | bool NeedsAccessCheck(dex::TypeIndex type_index, /*out*/bool* finalizable) const |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 100 | REQUIRES_SHARED(Locks::mutator_lock_); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 101 | |
| 102 | template<typename T> |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 103 | void Unop_12x(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 104 | |
| 105 | template<typename T> |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 106 | void Binop_23x(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 107 | |
| 108 | template<typename T> |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 109 | void Binop_23x_shift(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 110 | |
| 111 | void Binop_23x_cmp(const Instruction& instruction, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 112 | DataType::Type type, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 113 | ComparisonBias bias, |
| 114 | uint32_t dex_pc); |
| 115 | |
| 116 | template<typename T> |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 117 | void Binop_12x(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 118 | |
| 119 | template<typename T> |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 120 | void Binop_12x_shift(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 121 | |
| 122 | template<typename T> |
| 123 | void Binop_22b(const Instruction& instruction, bool reverse, uint32_t dex_pc); |
| 124 | |
| 125 | template<typename T> |
| 126 | void Binop_22s(const Instruction& instruction, bool reverse, uint32_t dex_pc); |
| 127 | |
| 128 | template<typename T> void If_21t(const Instruction& instruction, uint32_t dex_pc); |
| 129 | template<typename T> void If_22t(const Instruction& instruction, uint32_t dex_pc); |
| 130 | |
| 131 | void Conversion_12x(const Instruction& instruction, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 132 | DataType::Type input_type, |
| 133 | DataType::Type result_type, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 134 | uint32_t dex_pc); |
| 135 | |
| 136 | void BuildCheckedDivRem(uint16_t out_reg, |
| 137 | uint16_t first_reg, |
| 138 | int64_t second_reg_or_constant, |
| 139 | uint32_t dex_pc, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 140 | DataType::Type type, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 141 | bool second_is_lit, |
| 142 | bool is_div); |
| 143 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 144 | void BuildReturn(const Instruction& instruction, DataType::Type type, uint32_t dex_pc); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 145 | |
| 146 | // Builds an instance field access node and returns whether the instruction is supported. |
Mathieu Chartier | de4b08f | 2017-07-10 14:13:41 -0700 | [diff] [blame] | 147 | bool BuildInstanceFieldAccess(const Instruction& instruction, |
| 148 | uint32_t dex_pc, |
| 149 | bool is_put, |
| 150 | size_t quicken_index); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 151 | |
| 152 | void BuildUnresolvedStaticFieldAccess(const Instruction& instruction, |
| 153 | uint32_t dex_pc, |
| 154 | bool is_put, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 155 | DataType::Type field_type); |
Nicolas Geoffray | dbb9aef | 2017-11-23 10:44:11 +0000 | [diff] [blame] | 156 | // Builds a static field access node. |
| 157 | void BuildStaticFieldAccess(const Instruction& instruction, uint32_t dex_pc, bool is_put); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 158 | |
| 159 | void BuildArrayAccess(const Instruction& instruction, |
| 160 | uint32_t dex_pc, |
| 161 | bool is_get, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 162 | DataType::Type anticipated_type); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 163 | |
| 164 | // Builds an invocation node and returns whether the instruction is supported. |
| 165 | bool BuildInvoke(const Instruction& instruction, |
| 166 | uint32_t dex_pc, |
| 167 | uint32_t method_idx, |
| 168 | uint32_t number_of_vreg_arguments, |
| 169 | bool is_range, |
| 170 | uint32_t* args, |
| 171 | uint32_t register_index); |
| 172 | |
Orion Hodson | ac14139 | 2017-01-13 11:53:47 +0000 | [diff] [blame] | 173 | // Builds an invocation node for invoke-polymorphic and returns whether the |
| 174 | // instruction is supported. |
| 175 | bool BuildInvokePolymorphic(const Instruction& instruction, |
| 176 | uint32_t dex_pc, |
| 177 | uint32_t method_idx, |
| 178 | uint32_t proto_idx, |
| 179 | uint32_t number_of_vreg_arguments, |
| 180 | bool is_range, |
| 181 | uint32_t* args, |
| 182 | uint32_t register_index); |
| 183 | |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 184 | // Builds a new array node and the instructions that fill it. |
Igor Murashkin | 79d8fa7 | 2017-04-18 09:37:23 -0700 | [diff] [blame] | 185 | HNewArray* BuildFilledNewArray(uint32_t dex_pc, |
| 186 | dex::TypeIndex type_index, |
| 187 | uint32_t number_of_vreg_arguments, |
| 188 | bool is_range, |
| 189 | uint32_t* args, |
| 190 | uint32_t register_index); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 191 | |
| 192 | void BuildFillArrayData(const Instruction& instruction, uint32_t dex_pc); |
| 193 | |
| 194 | // Fills the given object with data as specified in the fill-array-data |
| 195 | // instruction. Currently only used for non-reference and non-floating point |
| 196 | // arrays. |
| 197 | template <typename T> |
| 198 | void BuildFillArrayData(HInstruction* object, |
| 199 | const T* data, |
| 200 | uint32_t element_count, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 201 | DataType::Type anticipated_type, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 202 | uint32_t dex_pc); |
| 203 | |
| 204 | // Fills the given object with data as specified in the fill-array-data |
| 205 | // instruction. The data must be for long and double arrays. |
| 206 | void BuildFillWideArrayData(HInstruction* object, |
| 207 | const int64_t* data, |
| 208 | uint32_t element_count, |
| 209 | uint32_t dex_pc); |
| 210 | |
| 211 | // Builds a `HInstanceOf`, or a `HCheckCast` instruction. |
| 212 | void BuildTypeCheck(const Instruction& instruction, |
| 213 | uint8_t destination, |
| 214 | uint8_t reference, |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 215 | dex::TypeIndex type_index, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 216 | uint32_t dex_pc); |
| 217 | |
| 218 | // Builds an instruction sequence for a switch statement. |
| 219 | void BuildSwitch(const Instruction& instruction, uint32_t dex_pc); |
| 220 | |
Vladimir Marko | 28e012a | 2017-12-07 11:22:59 +0000 | [diff] [blame] | 221 | // Builds a `HLoadString` loading the given `string_index`. |
| 222 | void BuildLoadString(dex::StringIndex string_index, uint32_t dex_pc); |
| 223 | |
| 224 | // Builds a `HLoadClass` loading the given `type_index`. |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 225 | HLoadClass* BuildLoadClass(dex::TypeIndex type_index, uint32_t dex_pc); |
| 226 | |
Nicolas Geoffray | 5247c08 | 2017-01-13 14:17:29 +0000 | [diff] [blame] | 227 | HLoadClass* BuildLoadClass(dex::TypeIndex type_index, |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 228 | const DexFile& dex_file, |
| 229 | Handle<mirror::Class> klass, |
Nicolas Geoffray | 5247c08 | 2017-01-13 14:17:29 +0000 | [diff] [blame] | 230 | uint32_t dex_pc, |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 231 | bool needs_access_check) |
| 232 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | 5247c08 | 2017-01-13 14:17:29 +0000 | [diff] [blame] | 233 | |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 234 | // Returns the outer-most compiling method's class. |
Vladimir Marko | 28e012a | 2017-12-07 11:22:59 +0000 | [diff] [blame] | 235 | ObjPtr<mirror::Class> GetOutermostCompilingClass() const; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 236 | |
| 237 | // Returns the class whose method is being compiled. |
Vladimir Marko | 28e012a | 2017-12-07 11:22:59 +0000 | [diff] [blame] | 238 | ObjPtr<mirror::Class> GetCompilingClass() const; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 239 | |
| 240 | // Returns whether `type_index` points to the outer-most compiling method's class. |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 241 | bool IsOutermostCompilingClass(dex::TypeIndex type_index) const; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 242 | |
| 243 | void PotentiallySimplifyFakeString(uint16_t original_dex_register, |
| 244 | uint32_t dex_pc, |
| 245 | HInvoke* invoke); |
| 246 | |
| 247 | bool SetupInvokeArguments(HInvoke* invoke, |
| 248 | uint32_t number_of_vreg_arguments, |
| 249 | uint32_t* args, |
| 250 | uint32_t register_index, |
| 251 | bool is_range, |
| 252 | const char* descriptor, |
| 253 | size_t start_index, |
| 254 | size_t* argument_index); |
| 255 | |
| 256 | bool HandleInvoke(HInvoke* invoke, |
| 257 | uint32_t number_of_vreg_arguments, |
| 258 | uint32_t* args, |
| 259 | uint32_t register_index, |
| 260 | bool is_range, |
| 261 | const char* descriptor, |
Aart Bik | 296fbb4 | 2016-06-07 13:49:12 -0700 | [diff] [blame] | 262 | HClinitCheck* clinit_check, |
| 263 | bool is_unresolved); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 264 | |
| 265 | bool HandleStringInit(HInvoke* invoke, |
| 266 | uint32_t number_of_vreg_arguments, |
| 267 | uint32_t* args, |
| 268 | uint32_t register_index, |
| 269 | bool is_range, |
| 270 | const char* descriptor); |
| 271 | void HandleStringInitResult(HInvokeStaticOrDirect* invoke); |
| 272 | |
| 273 | HClinitCheck* ProcessClinitCheckForInvoke( |
| 274 | uint32_t dex_pc, |
| 275 | ArtMethod* method, |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 276 | HInvokeStaticOrDirect::ClinitCheckRequirement* clinit_check_requirement) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 277 | REQUIRES_SHARED(Locks::mutator_lock_); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 278 | |
| 279 | // Build a HNewInstance instruction. |
Igor Murashkin | 79d8fa7 | 2017-04-18 09:37:23 -0700 | [diff] [blame] | 280 | HNewInstance* BuildNewInstance(dex::TypeIndex type_index, uint32_t dex_pc); |
| 281 | |
| 282 | // Build a HConstructorFence for HNewInstance and HNewArray instructions. This ensures the |
| 283 | // happens-before ordering for default-initialization of the object referred to by new_instance. |
| 284 | void BuildConstructorFenceForAllocation(HInstruction* allocation); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 285 | |
| 286 | // Return whether the compiler can assume `cls` is initialized. |
| 287 | bool IsInitialized(Handle<mirror::Class> cls) const |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 288 | REQUIRES_SHARED(Locks::mutator_lock_); |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 289 | |
| 290 | // Try to resolve a method using the class linker. Return null if a method could |
| 291 | // not be resolved. |
| 292 | ArtMethod* ResolveMethod(uint16_t method_idx, InvokeType invoke_type); |
| 293 | |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 294 | // Try to resolve a field using the class linker. Return null if it could not |
| 295 | // be found. |
| 296 | ArtField* ResolveField(uint16_t field_idx, bool is_static, bool is_put); |
| 297 | |
Vladimir Marko | 8d6768d | 2017-03-14 10:13:21 +0000 | [diff] [blame] | 298 | ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_index, |
| 299 | const DexCompilationUnit& compilation_unit) const |
| 300 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 301 | |
| 302 | ObjPtr<mirror::Class> LookupReferrerClass() const REQUIRES_SHARED(Locks::mutator_lock_); |
| 303 | |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 304 | ArenaAllocator* const allocator_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 305 | HGraph* const graph_; |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 306 | VariableSizedHandleScope* const handles_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 307 | |
| 308 | // The dex file where the method being compiled is, and the bytecode data. |
| 309 | const DexFile* const dex_file_; |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 310 | const CodeItemDebugInfoAccessor code_item_accessor_; // null for intrinsic graph. |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 311 | |
| 312 | // The return type of the method being compiled. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 313 | const DataType::Type return_type_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 314 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 315 | HBasicBlockBuilder* const block_builder_; |
| 316 | SsaBuilder* const ssa_builder_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 317 | |
| 318 | CompilerDriver* const compiler_driver_; |
| 319 | |
Nicolas Geoffray | 83c8e27 | 2017-01-31 14:36:37 +0000 | [diff] [blame] | 320 | CodeGenerator* const code_generator_; |
| 321 | |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 322 | // The compilation unit of the current method being compiled. Note that |
| 323 | // it can be an inlined method. |
Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 324 | const DexCompilationUnit* const dex_compilation_unit_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 325 | |
| 326 | // The compilation unit of the outermost method being compiled. That is the |
| 327 | // method being compiled (and not inlined), and potentially inlining other |
| 328 | // methods. |
| 329 | const DexCompilationUnit* const outer_compilation_unit_; |
| 330 | |
Mathieu Chartier | de4b08f | 2017-07-10 14:13:41 -0700 | [diff] [blame] | 331 | // Original values kept after instruction quickening. |
| 332 | QuickenInfoTable quicken_info_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 333 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 334 | OptimizingCompilerStats* const compilation_stats_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 335 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 336 | ScopedArenaAllocator* const local_allocator_; |
| 337 | ScopedArenaVector<ScopedArenaVector<HInstruction*>> locals_for_; |
| 338 | HBasicBlock* current_block_; |
| 339 | ScopedArenaVector<HInstruction*>* current_locals_; |
| 340 | HInstruction* latest_result_; |
| 341 | // Current "this" parameter. |
| 342 | // Valid only after InitializeParameters() finishes. |
| 343 | // * Null for static methods. |
| 344 | // * Non-null for instance methods. |
| 345 | HParameterValue* current_this_parameter_; |
| 346 | |
| 347 | ScopedArenaVector<HBasicBlock*> loop_headers_; |
David Brazdil | dee58d6 | 2016-04-07 09:54:26 +0000 | [diff] [blame] | 348 | |
| 349 | static constexpr int kDefaultNumberOfLoops = 2; |
| 350 | |
| 351 | DISALLOW_COPY_AND_ASSIGN(HInstructionBuilder); |
| 352 | }; |
| 353 | |
| 354 | } // namespace art |
| 355 | |
| 356 | #endif // ART_COMPILER_OPTIMIZING_INSTRUCTION_BUILDER_H_ |