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 | #include "code_generator.h" |
| 18 | |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 19 | #ifdef ART_ENABLE_CODEGEN_arm |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 20 | #include "code_generator_arm.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 21 | #endif |
| 22 | |
| 23 | #ifdef ART_ENABLE_CODEGEN_arm64 |
Alexandre Rames | 5319def | 2014-10-23 10:03:10 +0100 | [diff] [blame] | 24 | #include "code_generator_arm64.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 25 | #endif |
| 26 | |
| 27 | #ifdef ART_ENABLE_CODEGEN_x86 |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 28 | #include "code_generator_x86.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 29 | #endif |
| 30 | |
| 31 | #ifdef ART_ENABLE_CODEGEN_x86_64 |
Nicolas Geoffray | 9cf3552 | 2014-06-09 18:40:10 +0100 | [diff] [blame] | 32 | #include "code_generator_x86_64.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
Goran Jakovljevic | f652cec | 2015-08-25 16:11:42 +0200 | [diff] [blame] | 35 | #ifdef ART_ENABLE_CODEGEN_mips |
| 36 | #include "code_generator_mips.h" |
| 37 | #endif |
| 38 | |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 39 | #ifdef ART_ENABLE_CODEGEN_mips64 |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 40 | #include "code_generator_mips64.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 41 | #endif |
| 42 | |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 43 | #include "compiled_method.h" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 44 | #include "dex/verified_method.h" |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 45 | #include "driver/compiler_driver.h" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 46 | #include "gc_map_builder.h" |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 47 | #include "graph_visualizer.h" |
Nicolas Geoffray | 5bd05a5 | 2015-10-13 09:48:30 +0100 | [diff] [blame] | 48 | #include "intrinsics.h" |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 49 | #include "leb128.h" |
| 50 | #include "mapping_table.h" |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 51 | #include "mirror/array-inl.h" |
| 52 | #include "mirror/object_array-inl.h" |
| 53 | #include "mirror/object_reference.h" |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 54 | #include "parallel_move_resolver.h" |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 55 | #include "ssa_liveness_analysis.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 56 | #include "utils/assembler.h" |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 57 | #include "verifier/dex_gc_map.h" |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 58 | #include "vmap_table.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 59 | |
| 60 | namespace art { |
| 61 | |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 62 | // Return whether a location is consistent with a type. |
| 63 | static bool CheckType(Primitive::Type type, Location location) { |
| 64 | if (location.IsFpuRegister() |
| 65 | || (location.IsUnallocated() && (location.GetPolicy() == Location::kRequiresFpuRegister))) { |
| 66 | return (type == Primitive::kPrimFloat) || (type == Primitive::kPrimDouble); |
| 67 | } else if (location.IsRegister() || |
| 68 | (location.IsUnallocated() && (location.GetPolicy() == Location::kRequiresRegister))) { |
| 69 | return Primitive::IsIntegralType(type) || (type == Primitive::kPrimNot); |
| 70 | } else if (location.IsRegisterPair()) { |
| 71 | return type == Primitive::kPrimLong; |
| 72 | } else if (location.IsFpuRegisterPair()) { |
| 73 | return type == Primitive::kPrimDouble; |
| 74 | } else if (location.IsStackSlot()) { |
| 75 | return (Primitive::IsIntegralType(type) && type != Primitive::kPrimLong) |
| 76 | || (type == Primitive::kPrimFloat) |
| 77 | || (type == Primitive::kPrimNot); |
| 78 | } else if (location.IsDoubleStackSlot()) { |
| 79 | return (type == Primitive::kPrimLong) || (type == Primitive::kPrimDouble); |
| 80 | } else if (location.IsConstant()) { |
| 81 | if (location.GetConstant()->IsIntConstant()) { |
| 82 | return Primitive::IsIntegralType(type) && (type != Primitive::kPrimLong); |
| 83 | } else if (location.GetConstant()->IsNullConstant()) { |
| 84 | return type == Primitive::kPrimNot; |
| 85 | } else if (location.GetConstant()->IsLongConstant()) { |
| 86 | return type == Primitive::kPrimLong; |
| 87 | } else if (location.GetConstant()->IsFloatConstant()) { |
| 88 | return type == Primitive::kPrimFloat; |
| 89 | } else { |
| 90 | return location.GetConstant()->IsDoubleConstant() |
| 91 | && (type == Primitive::kPrimDouble); |
| 92 | } |
| 93 | } else { |
| 94 | return location.IsInvalid() || (location.GetPolicy() == Location::kAny); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Check that a location summary is consistent with an instruction. |
| 99 | static bool CheckTypeConsistency(HInstruction* instruction) { |
| 100 | LocationSummary* locations = instruction->GetLocations(); |
| 101 | if (locations == nullptr) { |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | if (locations->Out().IsUnallocated() |
| 106 | && (locations->Out().GetPolicy() == Location::kSameAsFirstInput)) { |
| 107 | DCHECK(CheckType(instruction->GetType(), locations->InAt(0))) |
| 108 | << instruction->GetType() |
| 109 | << " " << locations->InAt(0); |
| 110 | } else { |
| 111 | DCHECK(CheckType(instruction->GetType(), locations->Out())) |
| 112 | << instruction->GetType() |
| 113 | << " " << locations->Out(); |
| 114 | } |
| 115 | |
| 116 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
| 117 | DCHECK(CheckType(instruction->InputAt(i)->GetType(), locations->InAt(i))) |
| 118 | << instruction->InputAt(i)->GetType() |
| 119 | << " " << locations->InAt(i); |
| 120 | } |
| 121 | |
| 122 | HEnvironment* environment = instruction->GetEnvironment(); |
| 123 | for (size_t i = 0; i < instruction->EnvironmentSize(); ++i) { |
| 124 | if (environment->GetInstructionAt(i) != nullptr) { |
| 125 | Primitive::Type type = environment->GetInstructionAt(i)->GetType(); |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 126 | DCHECK(CheckType(type, environment->GetLocationAt(i))) |
| 127 | << type << " " << environment->GetLocationAt(i); |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 128 | } else { |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 129 | DCHECK(environment->GetLocationAt(i).IsInvalid()) |
| 130 | << environment->GetLocationAt(i); |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | return true; |
| 134 | } |
| 135 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 136 | size_t CodeGenerator::GetCacheOffset(uint32_t index) { |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 137 | return sizeof(GcRoot<mirror::Object>) * index; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 140 | size_t CodeGenerator::GetCachePointerOffset(uint32_t index) { |
| 141 | auto pointer_size = InstructionSetPointerSize(GetInstructionSet()); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 142 | return pointer_size * index; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Nicolas Geoffray | 73e80c3 | 2014-07-22 17:47:56 +0100 | [diff] [blame] | 145 | void CodeGenerator::CompileBaseline(CodeAllocator* allocator, bool is_leaf) { |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 146 | Initialize(); |
Nicolas Geoffray | 73e80c3 | 2014-07-22 17:47:56 +0100 | [diff] [blame] | 147 | if (!is_leaf) { |
| 148 | MarkNotLeaf(); |
| 149 | } |
Mathieu Chartier | e3b034a | 2015-05-31 14:29:23 -0700 | [diff] [blame] | 150 | const bool is_64_bit = Is64BitInstructionSet(GetInstructionSet()); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 151 | InitializeCodeGeneration(GetGraph()->GetNumberOfLocalVRegs() |
| 152 | + GetGraph()->GetTemporariesVRegSlots() |
| 153 | + 1 /* filler */, |
| 154 | 0, /* the baseline compiler does not have live registers at slow path */ |
| 155 | 0, /* the baseline compiler does not have live registers at slow path */ |
| 156 | GetGraph()->GetMaximumNumberOfOutVRegs() |
Mathieu Chartier | e3b034a | 2015-05-31 14:29:23 -0700 | [diff] [blame] | 157 | + (is_64_bit ? 2 : 1) /* current method */, |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 158 | GetGraph()->GetBlocks()); |
| 159 | CompileInternal(allocator, /* is_baseline */ true); |
| 160 | } |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 161 | |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 162 | bool CodeGenerator::GoesToNextBlock(HBasicBlock* current, HBasicBlock* next) const { |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 163 | DCHECK_EQ((*block_order_)[current_block_index_], current); |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 164 | return GetNextBlockToEmit() == FirstNonEmptyBlock(next); |
| 165 | } |
| 166 | |
| 167 | HBasicBlock* CodeGenerator::GetNextBlockToEmit() const { |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 168 | for (size_t i = current_block_index_ + 1; i < block_order_->size(); ++i) { |
| 169 | HBasicBlock* block = (*block_order_)[i]; |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 170 | if (!block->IsSingleJump()) { |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 171 | return block; |
| 172 | } |
| 173 | } |
| 174 | return nullptr; |
| 175 | } |
| 176 | |
| 177 | HBasicBlock* CodeGenerator::FirstNonEmptyBlock(HBasicBlock* block) const { |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 178 | while (block->IsSingleJump()) { |
Vladimir Marko | ec7802a | 2015-10-01 20:57:57 +0100 | [diff] [blame] | 179 | block = block->GetSuccessors()[0]; |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 180 | } |
| 181 | return block; |
| 182 | } |
| 183 | |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 184 | class DisassemblyScope { |
| 185 | public: |
| 186 | DisassemblyScope(HInstruction* instruction, const CodeGenerator& codegen) |
| 187 | : codegen_(codegen), instruction_(instruction), start_offset_(static_cast<size_t>(-1)) { |
| 188 | if (codegen_.GetDisassemblyInformation() != nullptr) { |
| 189 | start_offset_ = codegen_.GetAssembler().CodeSize(); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | ~DisassemblyScope() { |
| 194 | // We avoid building this data when we know it will not be used. |
| 195 | if (codegen_.GetDisassemblyInformation() != nullptr) { |
| 196 | codegen_.GetDisassemblyInformation()->AddInstructionInterval( |
| 197 | instruction_, start_offset_, codegen_.GetAssembler().CodeSize()); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | private: |
| 202 | const CodeGenerator& codegen_; |
| 203 | HInstruction* instruction_; |
| 204 | size_t start_offset_; |
| 205 | }; |
| 206 | |
| 207 | |
| 208 | void CodeGenerator::GenerateSlowPaths() { |
| 209 | size_t code_start = 0; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 210 | for (SlowPathCode* slow_path : slow_paths_) { |
Vladimir Marko | 0f7dca4 | 2015-11-02 14:36:43 +0000 | [diff] [blame^] | 211 | current_slow_path_ = slow_path; |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 212 | if (disasm_info_ != nullptr) { |
| 213 | code_start = GetAssembler()->CodeSize(); |
| 214 | } |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 215 | slow_path->EmitNativeCode(this); |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 216 | if (disasm_info_ != nullptr) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 217 | disasm_info_->AddSlowPathInterval(slow_path, code_start, GetAssembler()->CodeSize()); |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 218 | } |
| 219 | } |
Vladimir Marko | 0f7dca4 | 2015-11-02 14:36:43 +0000 | [diff] [blame^] | 220 | current_slow_path_ = nullptr; |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 223 | void CodeGenerator::CompileInternal(CodeAllocator* allocator, bool is_baseline) { |
Roland Levillain | 3e3d733 | 2015-04-28 11:00:54 +0100 | [diff] [blame] | 224 | is_baseline_ = is_baseline; |
Nicolas Geoffray | 8a16d97 | 2014-09-11 10:30:02 +0100 | [diff] [blame] | 225 | HGraphVisitor* instruction_visitor = GetInstructionVisitor(); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 226 | DCHECK_EQ(current_block_index_, 0u); |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 227 | |
| 228 | size_t frame_start = GetAssembler()->CodeSize(); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 229 | GenerateFrameEntry(); |
David Srbecky | c6b4dd8 | 2015-04-07 20:32:43 +0100 | [diff] [blame] | 230 | DCHECK_EQ(GetAssembler()->cfi().GetCurrentCFAOffset(), static_cast<int>(frame_size_)); |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 231 | if (disasm_info_ != nullptr) { |
| 232 | disasm_info_->SetFrameEntryInterval(frame_start, GetAssembler()->CodeSize()); |
| 233 | } |
| 234 | |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 235 | for (size_t e = block_order_->size(); current_block_index_ < e; ++current_block_index_) { |
| 236 | HBasicBlock* block = (*block_order_)[current_block_index_]; |
Nicolas Geoffray | dc23d83 | 2015-02-16 11:15:43 +0000 | [diff] [blame] | 237 | // Don't generate code for an empty block. Its predecessors will branch to its successor |
| 238 | // directly. Also, the label of that block will not be emitted, so this helps catch |
| 239 | // errors where we reference that label. |
David Brazdil | fc6a86a | 2015-06-26 10:33:45 +0000 | [diff] [blame] | 240 | if (block->IsSingleJump()) continue; |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 241 | Bind(block); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 242 | for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { |
| 243 | HInstruction* current = it.Current(); |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 244 | DisassemblyScope disassembly_scope(current, *this); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 245 | if (is_baseline) { |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 246 | InitLocationsBaseline(current); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 247 | } |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 248 | DCHECK(CheckTypeConsistency(current)); |
Yevgeny Rouban | 2a7c1ef | 2015-07-22 18:36:24 +0600 | [diff] [blame] | 249 | uintptr_t native_pc_begin = GetAssembler()->CodeSize(); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 250 | current->Accept(instruction_visitor); |
Yevgeny Rouban | 2a7c1ef | 2015-07-22 18:36:24 +0600 | [diff] [blame] | 251 | uintptr_t native_pc_end = GetAssembler()->CodeSize(); |
| 252 | RecordNativeDebugInfo(current->GetDexPc(), native_pc_begin, native_pc_end); |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 253 | } |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 254 | } |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 255 | |
Alexandre Rames | eb7b739 | 2015-06-19 14:47:01 +0100 | [diff] [blame] | 256 | GenerateSlowPaths(); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 257 | |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 258 | // Emit catch stack maps at the end of the stack map stream as expected by the |
| 259 | // runtime exception handler. |
| 260 | if (!is_baseline && graph_->HasTryCatch()) { |
| 261 | RecordCatchBlockInfo(); |
| 262 | } |
| 263 | |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 264 | // Finalize instructions in assember; |
Serban Constantinescu | 32f5b4d | 2014-11-25 20:05:46 +0000 | [diff] [blame] | 265 | Finalize(allocator); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 268 | void CodeGenerator::CompileOptimized(CodeAllocator* allocator) { |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 269 | // The register allocator already called `InitializeCodeGeneration`, |
| 270 | // where the frame size has been computed. |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 271 | DCHECK(block_order_ != nullptr); |
Nicolas Geoffray | 92a73ae | 2014-10-16 11:12:52 +0100 | [diff] [blame] | 272 | Initialize(); |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 273 | CompileInternal(allocator, /* is_baseline */ false); |
Serban Constantinescu | 32f5b4d | 2014-11-25 20:05:46 +0000 | [diff] [blame] | 274 | } |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 275 | |
Serban Constantinescu | 32f5b4d | 2014-11-25 20:05:46 +0000 | [diff] [blame] | 276 | void CodeGenerator::Finalize(CodeAllocator* allocator) { |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 277 | size_t code_size = GetAssembler()->CodeSize(); |
| 278 | uint8_t* buffer = allocator->Allocate(code_size); |
Serban Constantinescu | 32f5b4d | 2014-11-25 20:05:46 +0000 | [diff] [blame] | 279 | |
Nicolas Geoffray | 86dbb9a | 2014-06-04 11:12:39 +0100 | [diff] [blame] | 280 | MemoryRegion code(buffer, code_size); |
| 281 | GetAssembler()->FinalizeInstructions(code); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 282 | } |
| 283 | |
Vladimir Marko | 5815501 | 2015-08-19 12:49:41 +0000 | [diff] [blame] | 284 | void CodeGenerator::EmitLinkerPatches(ArenaVector<LinkerPatch>* linker_patches ATTRIBUTE_UNUSED) { |
| 285 | // No linker patches by default. |
| 286 | } |
| 287 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 288 | size_t CodeGenerator::FindFreeEntry(bool* array, size_t length) { |
| 289 | for (size_t i = 0; i < length; ++i) { |
| 290 | if (!array[i]) { |
| 291 | array[i] = true; |
| 292 | return i; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 293 | } |
| 294 | } |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 295 | LOG(FATAL) << "Could not find a register in baseline register allocator"; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 296 | UNREACHABLE(); |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Nicolas Geoffray | 3c03503 | 2014-10-28 10:46:40 +0000 | [diff] [blame] | 299 | size_t CodeGenerator::FindTwoFreeConsecutiveAlignedEntries(bool* array, size_t length) { |
| 300 | for (size_t i = 0; i < length - 1; i += 2) { |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 301 | if (!array[i] && !array[i + 1]) { |
| 302 | array[i] = true; |
| 303 | array[i + 1] = true; |
| 304 | return i; |
| 305 | } |
| 306 | } |
| 307 | LOG(FATAL) << "Could not find a register in baseline register allocator"; |
| 308 | UNREACHABLE(); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 311 | void CodeGenerator::InitializeCodeGeneration(size_t number_of_spill_slots, |
| 312 | size_t maximum_number_of_live_core_registers, |
| 313 | size_t maximum_number_of_live_fp_registers, |
| 314 | size_t number_of_out_slots, |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 315 | const ArenaVector<HBasicBlock*>& block_order) { |
Nicolas Geoffray | 4c204ba | 2015-02-03 15:12:35 +0000 | [diff] [blame] | 316 | block_order_ = &block_order; |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 317 | DCHECK(!block_order.empty()); |
| 318 | DCHECK(block_order[0] == GetGraph()->GetEntryBlock()); |
Nicolas Geoffray | 4dee636 | 2015-01-23 18:23:14 +0000 | [diff] [blame] | 319 | ComputeSpillMask(); |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 320 | first_register_slot_in_slow_path_ = (number_of_out_slots + number_of_spill_slots) * kVRegSize; |
| 321 | |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 322 | if (number_of_spill_slots == 0 |
| 323 | && !HasAllocatedCalleeSaveRegisters() |
| 324 | && IsLeafMethod() |
| 325 | && !RequiresCurrentMethod()) { |
| 326 | DCHECK_EQ(maximum_number_of_live_core_registers, 0u); |
| 327 | DCHECK_EQ(maximum_number_of_live_fp_registers, 0u); |
| 328 | SetFrameSize(CallPushesPC() ? GetWordSize() : 0); |
| 329 | } else { |
| 330 | SetFrameSize(RoundUp( |
| 331 | number_of_spill_slots * kVRegSize |
| 332 | + number_of_out_slots * kVRegSize |
| 333 | + maximum_number_of_live_core_registers * GetWordSize() |
| 334 | + maximum_number_of_live_fp_registers * GetFloatingPointSpillSlotSize() |
| 335 | + FrameEntrySpillSize(), |
| 336 | kStackAlignment)); |
| 337 | } |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | Location CodeGenerator::GetTemporaryLocation(HTemporary* temp) const { |
| 341 | uint16_t number_of_locals = GetGraph()->GetNumberOfLocalVRegs(); |
Calin Juravle | f97f9fb | 2014-11-11 15:38:19 +0000 | [diff] [blame] | 342 | // The type of the previous instruction tells us if we need a single or double stack slot. |
| 343 | Primitive::Type type = temp->GetType(); |
| 344 | int32_t temp_size = (type == Primitive::kPrimLong) || (type == Primitive::kPrimDouble) ? 2 : 1; |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 345 | // Use the temporary region (right below the dex registers). |
| 346 | int32_t slot = GetFrameSize() - FrameEntrySpillSize() |
| 347 | - kVRegSize // filler |
| 348 | - (number_of_locals * kVRegSize) |
Calin Juravle | f97f9fb | 2014-11-11 15:38:19 +0000 | [diff] [blame] | 349 | - ((temp_size + temp->GetIndex()) * kVRegSize); |
| 350 | return temp_size == 2 ? Location::DoubleStackSlot(slot) : Location::StackSlot(slot); |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | int32_t CodeGenerator::GetStackSlot(HLocal* local) const { |
| 354 | uint16_t reg_number = local->GetRegNumber(); |
| 355 | uint16_t number_of_locals = GetGraph()->GetNumberOfLocalVRegs(); |
| 356 | if (reg_number >= number_of_locals) { |
| 357 | // Local is a parameter of the method. It is stored in the caller's frame. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 358 | // TODO: Share this logic with StackVisitor::GetVRegOffsetFromQuickCode. |
| 359 | return GetFrameSize() + InstructionSetPointerSize(GetInstructionSet()) // ART method |
Nicolas Geoffray | ab032bc | 2014-07-15 12:55:21 +0100 | [diff] [blame] | 360 | + (reg_number - number_of_locals) * kVRegSize; |
| 361 | } else { |
| 362 | // Local is a temporary in this method. It is stored in this method's frame. |
| 363 | return GetFrameSize() - FrameEntrySpillSize() |
| 364 | - kVRegSize // filler. |
| 365 | - (number_of_locals * kVRegSize) |
| 366 | + (reg_number * kVRegSize); |
| 367 | } |
| 368 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 369 | |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 370 | void CodeGenerator::CreateCommonInvokeLocationSummary( |
Nicolas Geoffray | 4e40c26 | 2015-06-03 12:02:38 +0100 | [diff] [blame] | 371 | HInvoke* invoke, InvokeDexCallingConventionVisitor* visitor) { |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 372 | ArenaAllocator* allocator = invoke->GetBlock()->GetGraph()->GetArena(); |
| 373 | LocationSummary* locations = new (allocator) LocationSummary(invoke, LocationSummary::kCall); |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 374 | |
| 375 | for (size_t i = 0; i < invoke->GetNumberOfArguments(); i++) { |
| 376 | HInstruction* input = invoke->InputAt(i); |
| 377 | locations->SetInAt(i, visitor->GetNextLocation(input->GetType())); |
| 378 | } |
| 379 | |
| 380 | locations->SetOut(visitor->GetReturnLocation(invoke->GetType())); |
Nicolas Geoffray | 94015b9 | 2015-06-04 18:21:04 +0100 | [diff] [blame] | 381 | |
| 382 | if (invoke->IsInvokeStaticOrDirect()) { |
| 383 | HInvokeStaticOrDirect* call = invoke->AsInvokeStaticOrDirect(); |
Vladimir Marko | dc151b2 | 2015-10-15 18:02:30 +0100 | [diff] [blame] | 384 | switch (call->GetMethodLoadKind()) { |
| 385 | case HInvokeStaticOrDirect::MethodLoadKind::kRecursive: |
| 386 | locations->SetInAt(call->GetCurrentMethodInputIndex(), visitor->GetMethodLocation()); |
| 387 | break; |
| 388 | case HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod: |
| 389 | locations->AddTemp(visitor->GetMethodLocation()); |
| 390 | locations->SetInAt(call->GetCurrentMethodInputIndex(), Location::RequiresRegister()); |
| 391 | break; |
| 392 | default: |
| 393 | locations->AddTemp(visitor->GetMethodLocation()); |
| 394 | break; |
Nicolas Geoffray | 94015b9 | 2015-06-04 18:21:04 +0100 | [diff] [blame] | 395 | } |
| 396 | } else { |
| 397 | locations->AddTemp(visitor->GetMethodLocation()); |
| 398 | } |
Nicolas Geoffray | fd88f16 | 2015-06-03 11:23:52 +0100 | [diff] [blame] | 399 | } |
| 400 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 401 | void CodeGenerator::GenerateInvokeUnresolvedRuntimeCall(HInvokeUnresolved* invoke) { |
| 402 | MoveConstant(invoke->GetLocations()->GetTemp(0), invoke->GetDexMethodIndex()); |
| 403 | |
| 404 | // Initialize to anything to silent compiler warnings. |
| 405 | QuickEntrypointEnum entrypoint = kQuickInvokeStaticTrampolineWithAccessCheck; |
| 406 | switch (invoke->GetOriginalInvokeType()) { |
| 407 | case kStatic: |
| 408 | entrypoint = kQuickInvokeStaticTrampolineWithAccessCheck; |
| 409 | break; |
| 410 | case kDirect: |
| 411 | entrypoint = kQuickInvokeDirectTrampolineWithAccessCheck; |
| 412 | break; |
| 413 | case kVirtual: |
| 414 | entrypoint = kQuickInvokeVirtualTrampolineWithAccessCheck; |
| 415 | break; |
| 416 | case kSuper: |
| 417 | entrypoint = kQuickInvokeSuperTrampolineWithAccessCheck; |
| 418 | break; |
| 419 | case kInterface: |
| 420 | entrypoint = kQuickInvokeInterfaceTrampolineWithAccessCheck; |
| 421 | break; |
| 422 | } |
| 423 | InvokeRuntime(entrypoint, invoke, invoke->GetDexPc(), nullptr); |
| 424 | } |
| 425 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 426 | void CodeGenerator::CreateUnresolvedFieldLocationSummary( |
| 427 | HInstruction* field_access, |
| 428 | Primitive::Type field_type, |
| 429 | const FieldAccessCallingConvention& calling_convention) { |
| 430 | bool is_instance = field_access->IsUnresolvedInstanceFieldGet() |
| 431 | || field_access->IsUnresolvedInstanceFieldSet(); |
| 432 | bool is_get = field_access->IsUnresolvedInstanceFieldGet() |
| 433 | || field_access->IsUnresolvedStaticFieldGet(); |
| 434 | |
| 435 | ArenaAllocator* allocator = field_access->GetBlock()->GetGraph()->GetArena(); |
| 436 | LocationSummary* locations = |
| 437 | new (allocator) LocationSummary(field_access, LocationSummary::kCall); |
| 438 | |
| 439 | locations->AddTemp(calling_convention.GetFieldIndexLocation()); |
| 440 | |
| 441 | if (is_instance) { |
| 442 | // Add the `this` object for instance field accesses. |
| 443 | locations->SetInAt(0, calling_convention.GetObjectLocation()); |
| 444 | } |
| 445 | |
| 446 | // Note that pSetXXStatic/pGetXXStatic always takes/returns an int or int64 |
| 447 | // regardless of the the type. Because of that we forced to special case |
| 448 | // the access to floating point values. |
| 449 | if (is_get) { |
| 450 | if (Primitive::IsFloatingPointType(field_type)) { |
| 451 | // The return value will be stored in regular registers while register |
| 452 | // allocator expects it in a floating point register. |
| 453 | // Note We don't need to request additional temps because the return |
| 454 | // register(s) are already blocked due the call and they may overlap with |
| 455 | // the input or field index. |
| 456 | // The transfer between the two will be done at codegen level. |
| 457 | locations->SetOut(calling_convention.GetFpuLocation(field_type)); |
| 458 | } else { |
| 459 | locations->SetOut(calling_convention.GetReturnLocation(field_type)); |
| 460 | } |
| 461 | } else { |
| 462 | size_t set_index = is_instance ? 1 : 0; |
| 463 | if (Primitive::IsFloatingPointType(field_type)) { |
| 464 | // The set value comes from a float location while the calling convention |
| 465 | // expects it in a regular register location. Allocate a temp for it and |
| 466 | // make the transfer at codegen. |
| 467 | AddLocationAsTemp(calling_convention.GetSetValueLocation(field_type, is_instance), locations); |
| 468 | locations->SetInAt(set_index, calling_convention.GetFpuLocation(field_type)); |
| 469 | } else { |
| 470 | locations->SetInAt(set_index, |
| 471 | calling_convention.GetSetValueLocation(field_type, is_instance)); |
| 472 | } |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | void CodeGenerator::GenerateUnresolvedFieldAccess( |
| 477 | HInstruction* field_access, |
| 478 | Primitive::Type field_type, |
| 479 | uint32_t field_index, |
| 480 | uint32_t dex_pc, |
| 481 | const FieldAccessCallingConvention& calling_convention) { |
| 482 | LocationSummary* locations = field_access->GetLocations(); |
| 483 | |
| 484 | MoveConstant(locations->GetTemp(0), field_index); |
| 485 | |
| 486 | bool is_instance = field_access->IsUnresolvedInstanceFieldGet() |
| 487 | || field_access->IsUnresolvedInstanceFieldSet(); |
| 488 | bool is_get = field_access->IsUnresolvedInstanceFieldGet() |
| 489 | || field_access->IsUnresolvedStaticFieldGet(); |
| 490 | |
| 491 | if (!is_get && Primitive::IsFloatingPointType(field_type)) { |
| 492 | // Copy the float value to be set into the calling convention register. |
| 493 | // Note that using directly the temp location is problematic as we don't |
| 494 | // support temp register pairs. To avoid boilerplate conversion code, use |
| 495 | // the location from the calling convention. |
| 496 | MoveLocation(calling_convention.GetSetValueLocation(field_type, is_instance), |
| 497 | locations->InAt(is_instance ? 1 : 0), |
| 498 | (Primitive::Is64BitType(field_type) ? Primitive::kPrimLong : Primitive::kPrimInt)); |
| 499 | } |
| 500 | |
| 501 | QuickEntrypointEnum entrypoint = kQuickSet8Static; // Initialize to anything to avoid warnings. |
| 502 | switch (field_type) { |
| 503 | case Primitive::kPrimBoolean: |
| 504 | entrypoint = is_instance |
| 505 | ? (is_get ? kQuickGetBooleanInstance : kQuickSet8Instance) |
| 506 | : (is_get ? kQuickGetBooleanStatic : kQuickSet8Static); |
| 507 | break; |
| 508 | case Primitive::kPrimByte: |
| 509 | entrypoint = is_instance |
| 510 | ? (is_get ? kQuickGetByteInstance : kQuickSet8Instance) |
| 511 | : (is_get ? kQuickGetByteStatic : kQuickSet8Static); |
| 512 | break; |
| 513 | case Primitive::kPrimShort: |
| 514 | entrypoint = is_instance |
| 515 | ? (is_get ? kQuickGetShortInstance : kQuickSet16Instance) |
| 516 | : (is_get ? kQuickGetShortStatic : kQuickSet16Static); |
| 517 | break; |
| 518 | case Primitive::kPrimChar: |
| 519 | entrypoint = is_instance |
| 520 | ? (is_get ? kQuickGetCharInstance : kQuickSet16Instance) |
| 521 | : (is_get ? kQuickGetCharStatic : kQuickSet16Static); |
| 522 | break; |
| 523 | case Primitive::kPrimInt: |
| 524 | case Primitive::kPrimFloat: |
| 525 | entrypoint = is_instance |
| 526 | ? (is_get ? kQuickGet32Instance : kQuickSet32Instance) |
| 527 | : (is_get ? kQuickGet32Static : kQuickSet32Static); |
| 528 | break; |
| 529 | case Primitive::kPrimNot: |
| 530 | entrypoint = is_instance |
| 531 | ? (is_get ? kQuickGetObjInstance : kQuickSetObjInstance) |
| 532 | : (is_get ? kQuickGetObjStatic : kQuickSetObjStatic); |
| 533 | break; |
| 534 | case Primitive::kPrimLong: |
| 535 | case Primitive::kPrimDouble: |
| 536 | entrypoint = is_instance |
| 537 | ? (is_get ? kQuickGet64Instance : kQuickSet64Instance) |
| 538 | : (is_get ? kQuickGet64Static : kQuickSet64Static); |
| 539 | break; |
| 540 | default: |
| 541 | LOG(FATAL) << "Invalid type " << field_type; |
| 542 | } |
| 543 | InvokeRuntime(entrypoint, field_access, dex_pc, nullptr); |
| 544 | |
| 545 | if (is_get && Primitive::IsFloatingPointType(field_type)) { |
| 546 | MoveLocation(locations->Out(), calling_convention.GetReturnLocation(field_type), field_type); |
| 547 | } |
| 548 | } |
| 549 | |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 550 | void CodeGenerator::CreateLoadClassLocationSummary(HLoadClass* cls, |
| 551 | Location runtime_type_index_location, |
| 552 | Location runtime_return_location) { |
| 553 | ArenaAllocator* allocator = cls->GetBlock()->GetGraph()->GetArena(); |
| 554 | LocationSummary::CallKind call_kind = cls->NeedsAccessCheck() |
| 555 | ? LocationSummary::kCall |
| 556 | : (cls->CanCallRuntime() |
| 557 | ? LocationSummary::kCallOnSlowPath |
| 558 | : LocationSummary::kNoCall); |
| 559 | LocationSummary* locations = new (allocator) LocationSummary(cls, call_kind); |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 560 | if (cls->NeedsAccessCheck()) { |
Calin Juravle | 580b609 | 2015-10-06 17:35:58 +0100 | [diff] [blame] | 561 | locations->SetInAt(0, Location::NoLocation()); |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 562 | locations->AddTemp(runtime_type_index_location); |
| 563 | locations->SetOut(runtime_return_location); |
| 564 | } else { |
Calin Juravle | 580b609 | 2015-10-06 17:35:58 +0100 | [diff] [blame] | 565 | locations->SetInAt(0, Location::RequiresRegister()); |
Calin Juravle | 98893e1 | 2015-10-02 21:05:03 +0100 | [diff] [blame] | 566 | locations->SetOut(Location::RequiresRegister()); |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | |
Mark Mendell | 5f87418 | 2015-03-04 15:42:45 -0500 | [diff] [blame] | 571 | void CodeGenerator::BlockIfInRegister(Location location, bool is_out) const { |
| 572 | // The DCHECKS below check that a register is not specified twice in |
| 573 | // the summary. The out location can overlap with an input, so we need |
| 574 | // to special case it. |
| 575 | if (location.IsRegister()) { |
| 576 | DCHECK(is_out || !blocked_core_registers_[location.reg()]); |
| 577 | blocked_core_registers_[location.reg()] = true; |
| 578 | } else if (location.IsFpuRegister()) { |
| 579 | DCHECK(is_out || !blocked_fpu_registers_[location.reg()]); |
| 580 | blocked_fpu_registers_[location.reg()] = true; |
| 581 | } else if (location.IsFpuRegisterPair()) { |
| 582 | DCHECK(is_out || !blocked_fpu_registers_[location.AsFpuRegisterPairLow<int>()]); |
| 583 | blocked_fpu_registers_[location.AsFpuRegisterPairLow<int>()] = true; |
| 584 | DCHECK(is_out || !blocked_fpu_registers_[location.AsFpuRegisterPairHigh<int>()]); |
| 585 | blocked_fpu_registers_[location.AsFpuRegisterPairHigh<int>()] = true; |
| 586 | } else if (location.IsRegisterPair()) { |
| 587 | DCHECK(is_out || !blocked_core_registers_[location.AsRegisterPairLow<int>()]); |
| 588 | blocked_core_registers_[location.AsRegisterPairLow<int>()] = true; |
| 589 | DCHECK(is_out || !blocked_core_registers_[location.AsRegisterPairHigh<int>()]); |
| 590 | blocked_core_registers_[location.AsRegisterPairHigh<int>()] = true; |
| 591 | } |
| 592 | } |
| 593 | |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 594 | void CodeGenerator::AllocateRegistersLocally(HInstruction* instruction) const { |
| 595 | LocationSummary* locations = instruction->GetLocations(); |
| 596 | if (locations == nullptr) return; |
| 597 | |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 598 | for (size_t i = 0, e = GetNumberOfCoreRegisters(); i < e; ++i) { |
| 599 | blocked_core_registers_[i] = false; |
| 600 | } |
| 601 | |
| 602 | for (size_t i = 0, e = GetNumberOfFloatingPointRegisters(); i < e; ++i) { |
| 603 | blocked_fpu_registers_[i] = false; |
| 604 | } |
| 605 | |
| 606 | for (size_t i = 0, e = number_of_register_pairs_; i < e; ++i) { |
| 607 | blocked_register_pairs_[i] = false; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | // Mark all fixed input, temp and output registers as used. |
| 611 | for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) { |
Mark Mendell | 5f87418 | 2015-03-04 15:42:45 -0500 | [diff] [blame] | 612 | BlockIfInRegister(locations->InAt(i)); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | for (size_t i = 0, e = locations->GetTempCount(); i < e; ++i) { |
| 616 | Location loc = locations->GetTemp(i); |
Mark Mendell | 5f87418 | 2015-03-04 15:42:45 -0500 | [diff] [blame] | 617 | BlockIfInRegister(loc); |
| 618 | } |
| 619 | Location result_location = locations->Out(); |
| 620 | if (locations->OutputCanOverlapWithInputs()) { |
| 621 | BlockIfInRegister(result_location, /* is_out */ true); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 622 | } |
| 623 | |
Mark Mendell | 5f87418 | 2015-03-04 15:42:45 -0500 | [diff] [blame] | 624 | SetupBlockedRegisters(/* is_baseline */ true); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 625 | |
| 626 | // Allocate all unallocated input locations. |
| 627 | for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) { |
| 628 | Location loc = locations->InAt(i); |
| 629 | HInstruction* input = instruction->InputAt(i); |
| 630 | if (loc.IsUnallocated()) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 631 | if ((loc.GetPolicy() == Location::kRequiresRegister) |
| 632 | || (loc.GetPolicy() == Location::kRequiresFpuRegister)) { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 633 | loc = AllocateFreeRegister(input->GetType()); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 634 | } else { |
| 635 | DCHECK_EQ(loc.GetPolicy(), Location::kAny); |
| 636 | HLoadLocal* load = input->AsLoadLocal(); |
| 637 | if (load != nullptr) { |
| 638 | loc = GetStackLocation(load); |
| 639 | } else { |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 640 | loc = AllocateFreeRegister(input->GetType()); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 641 | } |
| 642 | } |
| 643 | locations->SetInAt(i, loc); |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | // Allocate all unallocated temp locations. |
| 648 | for (size_t i = 0, e = locations->GetTempCount(); i < e; ++i) { |
| 649 | Location loc = locations->GetTemp(i); |
| 650 | if (loc.IsUnallocated()) { |
Roland Levillain | 647b9ed | 2014-11-27 12:06:00 +0000 | [diff] [blame] | 651 | switch (loc.GetPolicy()) { |
| 652 | case Location::kRequiresRegister: |
| 653 | // Allocate a core register (large enough to fit a 32-bit integer). |
| 654 | loc = AllocateFreeRegister(Primitive::kPrimInt); |
| 655 | break; |
| 656 | |
| 657 | case Location::kRequiresFpuRegister: |
| 658 | // Allocate a core register (large enough to fit a 64-bit double). |
| 659 | loc = AllocateFreeRegister(Primitive::kPrimDouble); |
| 660 | break; |
| 661 | |
| 662 | default: |
| 663 | LOG(FATAL) << "Unexpected policy for temporary location " |
| 664 | << loc.GetPolicy(); |
| 665 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 666 | locations->SetTempAt(i, loc); |
| 667 | } |
| 668 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 669 | if (result_location.IsUnallocated()) { |
| 670 | switch (result_location.GetPolicy()) { |
| 671 | case Location::kAny: |
| 672 | case Location::kRequiresRegister: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 673 | case Location::kRequiresFpuRegister: |
Nicolas Geoffray | 71175b7 | 2014-10-09 22:13:55 +0100 | [diff] [blame] | 674 | result_location = AllocateFreeRegister(instruction->GetType()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 675 | break; |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 676 | case Location::kSameAsFirstInput: |
| 677 | result_location = locations->InAt(0); |
| 678 | break; |
| 679 | } |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 680 | locations->UpdateOut(result_location); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 681 | } |
| 682 | } |
| 683 | |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 684 | void CodeGenerator::InitLocationsBaseline(HInstruction* instruction) { |
| 685 | AllocateLocations(instruction); |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 686 | if (instruction->GetLocations() == nullptr) { |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 687 | if (instruction->IsTemporary()) { |
| 688 | HInstruction* previous = instruction->GetPrevious(); |
| 689 | Location temp_location = GetTemporaryLocation(instruction->AsTemporary()); |
| 690 | Move(previous, temp_location, instruction); |
Nicolas Geoffray | e503832 | 2014-07-04 09:41:32 +0100 | [diff] [blame] | 691 | } |
Nicolas Geoffray | a7aca37 | 2014-04-28 17:47:12 +0100 | [diff] [blame] | 692 | return; |
| 693 | } |
| 694 | AllocateRegistersLocally(instruction); |
| 695 | for (size_t i = 0, e = instruction->InputCount(); i < e; ++i) { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 696 | Location location = instruction->GetLocations()->InAt(i); |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 697 | HInstruction* input = instruction->InputAt(i); |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 698 | if (location.IsValid()) { |
| 699 | // Move the input to the desired location. |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 700 | if (input->GetNext()->IsTemporary()) { |
| 701 | // If the input was stored in a temporary, use that temporary to |
| 702 | // perform the move. |
| 703 | Move(input->GetNext(), location, instruction); |
| 704 | } else { |
| 705 | Move(input, location, instruction); |
| 706 | } |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | } |
| 710 | |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 711 | void CodeGenerator::AllocateLocations(HInstruction* instruction) { |
| 712 | instruction->Accept(GetLocationBuilder()); |
Alexandre Rames | 88c13cd | 2015-04-14 17:35:39 +0100 | [diff] [blame] | 713 | DCHECK(CheckTypeConsistency(instruction)); |
Nicolas Geoffray | c0572a4 | 2015-02-06 14:35:25 +0000 | [diff] [blame] | 714 | LocationSummary* locations = instruction->GetLocations(); |
| 715 | if (!instruction->IsSuspendCheckEntry()) { |
| 716 | if (locations != nullptr && locations->CanCall()) { |
| 717 | MarkNotLeaf(); |
| 718 | } |
| 719 | if (instruction->NeedsCurrentMethod()) { |
| 720 | SetRequiresCurrentMethod(); |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 725 | void CodeGenerator::MaybeRecordStat(MethodCompilationStat compilation_stat, size_t count) const { |
| 726 | if (stats_ != nullptr) { |
| 727 | stats_->RecordStat(compilation_stat, count); |
| 728 | } |
| 729 | } |
| 730 | |
Nicolas Geoffray | 12df9eb | 2015-01-09 14:53:50 +0000 | [diff] [blame] | 731 | CodeGenerator* CodeGenerator::Create(HGraph* graph, |
Calin Juravle | 3416601 | 2014-12-19 17:22:29 +0000 | [diff] [blame] | 732 | InstructionSet instruction_set, |
Calin Juravle | cd6dffe | 2015-01-08 17:35:35 +0000 | [diff] [blame] | 733 | const InstructionSetFeatures& isa_features, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 734 | const CompilerOptions& compiler_options, |
| 735 | OptimizingCompilerStats* stats) { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 736 | switch (instruction_set) { |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 737 | #ifdef ART_ENABLE_CODEGEN_arm |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 738 | case kArm: |
| 739 | case kThumb2: { |
Nicolas Geoffray | 12df9eb | 2015-01-09 14:53:50 +0000 | [diff] [blame] | 740 | return new arm::CodeGeneratorARM(graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 741 | *isa_features.AsArmInstructionSetFeatures(), |
| 742 | compiler_options, |
| 743 | stats); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 744 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 745 | #endif |
| 746 | #ifdef ART_ENABLE_CODEGEN_arm64 |
Alexandre Rames | 5319def | 2014-10-23 10:03:10 +0100 | [diff] [blame] | 747 | case kArm64: { |
Serban Constantinescu | 579885a | 2015-02-22 20:51:33 +0000 | [diff] [blame] | 748 | return new arm64::CodeGeneratorARM64(graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 749 | *isa_features.AsArm64InstructionSetFeatures(), |
| 750 | compiler_options, |
| 751 | stats); |
Alexandre Rames | 5319def | 2014-10-23 10:03:10 +0100 | [diff] [blame] | 752 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 753 | #endif |
| 754 | #ifdef ART_ENABLE_CODEGEN_mips |
Goran Jakovljevic | f652cec | 2015-08-25 16:11:42 +0200 | [diff] [blame] | 755 | case kMips: { |
| 756 | return new mips::CodeGeneratorMIPS(graph, |
| 757 | *isa_features.AsMipsInstructionSetFeatures(), |
| 758 | compiler_options, |
| 759 | stats); |
| 760 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 761 | #endif |
| 762 | #ifdef ART_ENABLE_CODEGEN_mips64 |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 763 | case kMips64: { |
| 764 | return new mips64::CodeGeneratorMIPS64(graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 765 | *isa_features.AsMips64InstructionSetFeatures(), |
| 766 | compiler_options, |
| 767 | stats); |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 768 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 769 | #endif |
| 770 | #ifdef ART_ENABLE_CODEGEN_x86 |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 771 | case kX86: { |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 772 | return new x86::CodeGeneratorX86(graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 773 | *isa_features.AsX86InstructionSetFeatures(), |
| 774 | compiler_options, |
| 775 | stats); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 776 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 777 | #endif |
| 778 | #ifdef ART_ENABLE_CODEGEN_x86_64 |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 779 | case kX86_64: { |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 780 | return new x86_64::CodeGeneratorX86_64(graph, |
Serban Constantinescu | ecc4366 | 2015-08-13 13:33:12 +0100 | [diff] [blame] | 781 | *isa_features.AsX86_64InstructionSetFeatures(), |
| 782 | compiler_options, |
| 783 | stats); |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 784 | } |
Alex Light | 50fa993 | 2015-08-10 15:30:07 -0700 | [diff] [blame] | 785 | #endif |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 786 | default: |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 787 | return nullptr; |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 788 | } |
| 789 | } |
| 790 | |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 791 | void CodeGenerator::BuildNativeGCMap( |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 792 | ArenaVector<uint8_t>* data, const CompilerDriver& compiler_driver) const { |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 793 | const std::vector<uint8_t>& gc_map_raw = |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 794 | compiler_driver.GetVerifiedMethod(&GetGraph()->GetDexFile(), GetGraph()->GetMethodIdx()) |
| 795 | ->GetDexGcMap(); |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 796 | verifier::DexPcToReferenceMap dex_gc_map(&(gc_map_raw)[0]); |
| 797 | |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 798 | uint32_t max_native_offset = stack_map_stream_.ComputeMaxNativePcOffset(); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 799 | |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 800 | size_t num_stack_maps = stack_map_stream_.GetNumberOfStackMaps(); |
| 801 | GcMapBuilder builder(data, num_stack_maps, max_native_offset, dex_gc_map.RegWidth()); |
| 802 | for (size_t i = 0; i != num_stack_maps; ++i) { |
| 803 | const StackMapStream::StackMapEntry& stack_map_entry = stack_map_stream_.GetStackMap(i); |
| 804 | uint32_t native_offset = stack_map_entry.native_pc_offset; |
| 805 | uint32_t dex_pc = stack_map_entry.dex_pc; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 806 | const uint8_t* references = dex_gc_map.FindBitMap(dex_pc, false); |
Jean Christophe Beyler | 0ada95d | 2014-12-04 11:20:20 -0800 | [diff] [blame] | 807 | CHECK(references != nullptr) << "Missing ref for dex pc 0x" << std::hex << dex_pc; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 808 | builder.AddEntry(native_offset, references); |
| 809 | } |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 810 | } |
| 811 | |
Vladimir Marko | f9f6441 | 2015-09-02 14:05:49 +0100 | [diff] [blame] | 812 | void CodeGenerator::BuildMappingTable(ArenaVector<uint8_t>* data) const { |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 813 | uint32_t pc2dex_data_size = 0u; |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 814 | uint32_t pc2dex_entries = stack_map_stream_.GetNumberOfStackMaps(); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 815 | uint32_t pc2dex_offset = 0u; |
| 816 | int32_t pc2dex_dalvik_offset = 0; |
| 817 | uint32_t dex2pc_data_size = 0u; |
| 818 | uint32_t dex2pc_entries = 0u; |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 819 | uint32_t dex2pc_offset = 0u; |
| 820 | int32_t dex2pc_dalvik_offset = 0; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 821 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 822 | for (size_t i = 0; i < pc2dex_entries; i++) { |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 823 | const StackMapStream::StackMapEntry& stack_map_entry = stack_map_stream_.GetStackMap(i); |
| 824 | pc2dex_data_size += UnsignedLeb128Size(stack_map_entry.native_pc_offset - pc2dex_offset); |
| 825 | pc2dex_data_size += SignedLeb128Size(stack_map_entry.dex_pc - pc2dex_dalvik_offset); |
| 826 | pc2dex_offset = stack_map_entry.native_pc_offset; |
| 827 | pc2dex_dalvik_offset = stack_map_entry.dex_pc; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 830 | // Walk over the blocks and find which ones correspond to catch block entries. |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 831 | for (HBasicBlock* block : graph_->GetBlocks()) { |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 832 | if (block->IsCatchBlock()) { |
| 833 | intptr_t native_pc = GetAddressOf(block); |
| 834 | ++dex2pc_entries; |
| 835 | dex2pc_data_size += UnsignedLeb128Size(native_pc - dex2pc_offset); |
| 836 | dex2pc_data_size += SignedLeb128Size(block->GetDexPc() - dex2pc_dalvik_offset); |
| 837 | dex2pc_offset = native_pc; |
| 838 | dex2pc_dalvik_offset = block->GetDexPc(); |
| 839 | } |
| 840 | } |
| 841 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 842 | uint32_t total_entries = pc2dex_entries + dex2pc_entries; |
| 843 | uint32_t hdr_data_size = UnsignedLeb128Size(total_entries) + UnsignedLeb128Size(pc2dex_entries); |
| 844 | uint32_t data_size = hdr_data_size + pc2dex_data_size + dex2pc_data_size; |
| 845 | data->resize(data_size); |
| 846 | |
| 847 | uint8_t* data_ptr = &(*data)[0]; |
| 848 | uint8_t* write_pos = data_ptr; |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 849 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 850 | write_pos = EncodeUnsignedLeb128(write_pos, total_entries); |
| 851 | write_pos = EncodeUnsignedLeb128(write_pos, pc2dex_entries); |
| 852 | DCHECK_EQ(static_cast<size_t>(write_pos - data_ptr), hdr_data_size); |
| 853 | uint8_t* write_pos2 = write_pos + pc2dex_data_size; |
| 854 | |
| 855 | pc2dex_offset = 0u; |
| 856 | pc2dex_dalvik_offset = 0u; |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 857 | dex2pc_offset = 0u; |
| 858 | dex2pc_dalvik_offset = 0u; |
| 859 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 860 | for (size_t i = 0; i < pc2dex_entries; i++) { |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 861 | const StackMapStream::StackMapEntry& stack_map_entry = stack_map_stream_.GetStackMap(i); |
| 862 | DCHECK(pc2dex_offset <= stack_map_entry.native_pc_offset); |
| 863 | write_pos = EncodeUnsignedLeb128(write_pos, stack_map_entry.native_pc_offset - pc2dex_offset); |
| 864 | write_pos = EncodeSignedLeb128(write_pos, stack_map_entry.dex_pc - pc2dex_dalvik_offset); |
| 865 | pc2dex_offset = stack_map_entry.native_pc_offset; |
| 866 | pc2dex_dalvik_offset = stack_map_entry.dex_pc; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 867 | } |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 868 | |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 869 | for (HBasicBlock* block : graph_->GetBlocks()) { |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 870 | if (block->IsCatchBlock()) { |
| 871 | intptr_t native_pc = GetAddressOf(block); |
| 872 | write_pos2 = EncodeUnsignedLeb128(write_pos2, native_pc - dex2pc_offset); |
| 873 | write_pos2 = EncodeSignedLeb128(write_pos2, block->GetDexPc() - dex2pc_dalvik_offset); |
| 874 | dex2pc_offset = native_pc; |
| 875 | dex2pc_dalvik_offset = block->GetDexPc(); |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 880 | DCHECK_EQ(static_cast<size_t>(write_pos - data_ptr), hdr_data_size + pc2dex_data_size); |
| 881 | DCHECK_EQ(static_cast<size_t>(write_pos2 - data_ptr), data_size); |
| 882 | |
| 883 | if (kIsDebugBuild) { |
| 884 | // Verify the encoded table holds the expected data. |
| 885 | MappingTable table(data_ptr); |
| 886 | CHECK_EQ(table.TotalSize(), total_entries); |
| 887 | CHECK_EQ(table.PcToDexSize(), pc2dex_entries); |
| 888 | auto it = table.PcToDexBegin(); |
| 889 | auto it2 = table.DexToPcBegin(); |
| 890 | for (size_t i = 0; i < pc2dex_entries; i++) { |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 891 | const StackMapStream::StackMapEntry& stack_map_entry = stack_map_stream_.GetStackMap(i); |
| 892 | CHECK_EQ(stack_map_entry.native_pc_offset, it.NativePcOffset()); |
| 893 | CHECK_EQ(stack_map_entry.dex_pc, it.DexPc()); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 894 | ++it; |
| 895 | } |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 896 | for (HBasicBlock* block : graph_->GetBlocks()) { |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 897 | if (block->IsCatchBlock()) { |
| 898 | CHECK_EQ(GetAddressOf(block), it2.NativePcOffset()); |
| 899 | CHECK_EQ(block->GetDexPc(), it2.DexPc()); |
| 900 | ++it2; |
| 901 | } |
| 902 | } |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 903 | CHECK(it == table.PcToDexEnd()); |
| 904 | CHECK(it2 == table.DexToPcEnd()); |
| 905 | } |
| 906 | } |
| 907 | |
Vladimir Marko | f9f6441 | 2015-09-02 14:05:49 +0100 | [diff] [blame] | 908 | void CodeGenerator::BuildVMapTable(ArenaVector<uint8_t>* data) const { |
Vladimir Marko | ec7802a | 2015-10-01 20:57:57 +0100 | [diff] [blame] | 909 | Leb128Encoder<ArenaVector<uint8_t>> vmap_encoder(data); |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 910 | // We currently don't use callee-saved registers. |
| 911 | size_t size = 0 + 1 /* marker */ + 0; |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 912 | vmap_encoder.Reserve(size + 1u); // All values are likely to be one byte in ULEB128 (<128). |
| 913 | vmap_encoder.PushBackUnsigned(size); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 914 | vmap_encoder.PushBackUnsigned(VmapTable::kAdjustedFpMarker); |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 915 | } |
Nicolas Geoffray | 92cf83e | 2014-03-18 17:59:20 +0000 | [diff] [blame] | 916 | |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 917 | size_t CodeGenerator::ComputeStackMapsSize() { |
| 918 | return stack_map_stream_.PrepareForFillIn(); |
| 919 | } |
| 920 | |
| 921 | void CodeGenerator::BuildStackMaps(MemoryRegion region) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 922 | stack_map_stream_.FillIn(region); |
| 923 | } |
| 924 | |
Yevgeny Rouban | 2a7c1ef | 2015-07-22 18:36:24 +0600 | [diff] [blame] | 925 | void CodeGenerator::RecordNativeDebugInfo(uint32_t dex_pc, |
| 926 | uintptr_t native_pc_begin, |
| 927 | uintptr_t native_pc_end) { |
Nicolas Geoffray | d28b969 | 2015-11-04 14:36:55 +0000 | [diff] [blame] | 928 | if (compiler_options_.GetGenerateDebugInfo() && |
| 929 | dex_pc != kNoDexPc && |
| 930 | native_pc_begin != native_pc_end) { |
| 931 | src_map_.push_back(SrcMapElem({static_cast<uint32_t>(native_pc_begin), |
| 932 | static_cast<int32_t>(dex_pc)})); |
Yevgeny Rouban | 2a7c1ef | 2015-07-22 18:36:24 +0600 | [diff] [blame] | 933 | } |
| 934 | } |
| 935 | |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 936 | void CodeGenerator::RecordPcInfo(HInstruction* instruction, |
| 937 | uint32_t dex_pc, |
| 938 | SlowPathCode* slow_path) { |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 939 | if (instruction != nullptr) { |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 940 | // The code generated for some type conversions and comparisons |
| 941 | // may call the runtime, thus normally requiring a subsequent |
| 942 | // call to this method. However, the method verifier does not |
| 943 | // produce PC information for certain instructions, which are |
| 944 | // considered "atomic" (they cannot join a GC). |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 945 | // Therefore we do not currently record PC information for such |
| 946 | // instructions. As this may change later, we added this special |
| 947 | // case so that code generators may nevertheless call |
| 948 | // CodeGenerator::RecordPcInfo without triggering an error in |
| 949 | // CodeGenerator::BuildNativeGCMap ("Missing ref for dex pc 0x") |
| 950 | // thereafter. |
Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 951 | if (instruction->IsTypeConversion() || instruction->IsCompare()) { |
Calin Juravle | d2ec87d | 2014-12-08 14:24:46 +0000 | [diff] [blame] | 952 | return; |
| 953 | } |
| 954 | if (instruction->IsRem()) { |
| 955 | Primitive::Type type = instruction->AsRem()->GetResultType(); |
| 956 | if ((type == Primitive::kPrimFloat) || (type == Primitive::kPrimDouble)) { |
| 957 | return; |
| 958 | } |
| 959 | } |
Roland Levillain | 624279f | 2014-12-04 11:54:28 +0000 | [diff] [blame] | 960 | } |
| 961 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 962 | uint32_t outer_dex_pc = dex_pc; |
| 963 | uint32_t outer_environment_size = 0; |
| 964 | uint32_t inlining_depth = 0; |
| 965 | if (instruction != nullptr) { |
| 966 | for (HEnvironment* environment = instruction->GetEnvironment(); |
| 967 | environment != nullptr; |
| 968 | environment = environment->GetParent()) { |
| 969 | outer_dex_pc = environment->GetDexPc(); |
| 970 | outer_environment_size = environment->Size(); |
| 971 | if (environment != instruction->GetEnvironment()) { |
| 972 | inlining_depth++; |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 977 | // Collect PC infos for the mapping table. |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 978 | uint32_t native_pc = GetAssembler()->CodeSize(); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 979 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 980 | if (instruction == nullptr) { |
| 981 | // For stack overflow checks. |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 982 | stack_map_stream_.BeginStackMapEntry(outer_dex_pc, native_pc, 0, 0, 0, 0); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 983 | stack_map_stream_.EndStackMapEntry(); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 984 | return; |
| 985 | } |
| 986 | LocationSummary* locations = instruction->GetLocations(); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 987 | |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 988 | uint32_t register_mask = locations->GetRegisterMask(); |
| 989 | if (locations->OnlyCallsOnSlowPath()) { |
| 990 | // In case of slow path, we currently set the location of caller-save registers |
| 991 | // to register (instead of their stack location when pushed before the slow-path |
| 992 | // call). Therefore register_mask contains both callee-save and caller-save |
| 993 | // registers that hold objects. We must remove the caller-save from the mask, since |
| 994 | // they will be overwritten by the callee. |
| 995 | register_mask &= core_callee_save_mask_; |
| 996 | } |
| 997 | // The register mask must be a subset of callee-save registers. |
| 998 | DCHECK_EQ(register_mask & core_callee_save_mask_, register_mask); |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 999 | stack_map_stream_.BeginStackMapEntry(outer_dex_pc, |
| 1000 | native_pc, |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 1001 | register_mask, |
| 1002 | locations->GetStackMask(), |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1003 | outer_environment_size, |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 1004 | inlining_depth); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1005 | |
| 1006 | EmitEnvironment(instruction->GetEnvironment(), slow_path); |
| 1007 | stack_map_stream_.EndStackMapEntry(); |
| 1008 | } |
| 1009 | |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1010 | void CodeGenerator::RecordCatchBlockInfo() { |
| 1011 | ArenaAllocator* arena = graph_->GetArena(); |
| 1012 | |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 1013 | for (HBasicBlock* block : *block_order_) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1014 | if (!block->IsCatchBlock()) { |
| 1015 | continue; |
| 1016 | } |
| 1017 | |
| 1018 | uint32_t dex_pc = block->GetDexPc(); |
| 1019 | uint32_t num_vregs = graph_->GetNumberOfVRegs(); |
| 1020 | uint32_t inlining_depth = 0; // Inlining of catch blocks is not supported at the moment. |
| 1021 | uint32_t native_pc = GetAddressOf(block); |
| 1022 | uint32_t register_mask = 0; // Not used. |
| 1023 | |
| 1024 | // The stack mask is not used, so we leave it empty. |
| 1025 | ArenaBitVector* stack_mask = new (arena) ArenaBitVector(arena, 0, /* expandable */ true); |
| 1026 | |
| 1027 | stack_map_stream_.BeginStackMapEntry(dex_pc, |
| 1028 | native_pc, |
| 1029 | register_mask, |
| 1030 | stack_mask, |
| 1031 | num_vregs, |
| 1032 | inlining_depth); |
| 1033 | |
| 1034 | HInstruction* current_phi = block->GetFirstPhi(); |
| 1035 | for (size_t vreg = 0; vreg < num_vregs; ++vreg) { |
| 1036 | while (current_phi != nullptr && current_phi->AsPhi()->GetRegNumber() < vreg) { |
| 1037 | HInstruction* next_phi = current_phi->GetNext(); |
| 1038 | DCHECK(next_phi == nullptr || |
| 1039 | current_phi->AsPhi()->GetRegNumber() <= next_phi->AsPhi()->GetRegNumber()) |
| 1040 | << "Phis need to be sorted by vreg number to keep this a linear-time loop."; |
| 1041 | current_phi = next_phi; |
| 1042 | } |
| 1043 | |
| 1044 | if (current_phi == nullptr || current_phi->AsPhi()->GetRegNumber() != vreg) { |
| 1045 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0); |
| 1046 | } else { |
| 1047 | Location location = current_phi->GetLiveInterval()->ToLocation(); |
| 1048 | switch (location.GetKind()) { |
| 1049 | case Location::kStackSlot: { |
| 1050 | stack_map_stream_.AddDexRegisterEntry( |
| 1051 | DexRegisterLocation::Kind::kInStack, location.GetStackIndex()); |
| 1052 | break; |
| 1053 | } |
| 1054 | case Location::kDoubleStackSlot: { |
| 1055 | stack_map_stream_.AddDexRegisterEntry( |
| 1056 | DexRegisterLocation::Kind::kInStack, location.GetStackIndex()); |
| 1057 | stack_map_stream_.AddDexRegisterEntry( |
| 1058 | DexRegisterLocation::Kind::kInStack, location.GetHighStackIndex(kVRegSize)); |
| 1059 | ++vreg; |
| 1060 | DCHECK_LT(vreg, num_vregs); |
| 1061 | break; |
| 1062 | } |
| 1063 | default: { |
| 1064 | // All catch phis must be allocated to a stack slot. |
| 1065 | LOG(FATAL) << "Unexpected kind " << location.GetKind(); |
| 1066 | UNREACHABLE(); |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | } |
| 1071 | |
| 1072 | stack_map_stream_.EndStackMapEntry(); |
| 1073 | } |
| 1074 | } |
| 1075 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1076 | void CodeGenerator::EmitEnvironment(HEnvironment* environment, SlowPathCode* slow_path) { |
| 1077 | if (environment == nullptr) return; |
| 1078 | |
| 1079 | if (environment->GetParent() != nullptr) { |
| 1080 | // We emit the parent environment first. |
| 1081 | EmitEnvironment(environment->GetParent(), slow_path); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 1082 | stack_map_stream_.BeginInlineInfoEntry(environment->GetMethodIdx(), |
| 1083 | environment->GetDexPc(), |
| 1084 | environment->GetInvokeType(), |
| 1085 | environment->Size()); |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 1086 | } |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1087 | |
| 1088 | // Walk over the environment, and record the location of dex registers. |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1089 | for (size_t i = 0, environment_size = environment->Size(); i < environment_size; ++i) { |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1090 | HInstruction* current = environment->GetInstructionAt(i); |
| 1091 | if (current == nullptr) { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1092 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1093 | continue; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1094 | } |
| 1095 | |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 1096 | Location location = environment->GetLocationAt(i); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1097 | switch (location.GetKind()) { |
| 1098 | case Location::kConstant: { |
| 1099 | DCHECK_EQ(current, location.GetConstant()); |
| 1100 | if (current->IsLongConstant()) { |
| 1101 | int64_t value = current->AsLongConstant()->GetValue(); |
| 1102 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1103 | DexRegisterLocation::Kind::kConstant, Low32Bits(value)); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1104 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1105 | DexRegisterLocation::Kind::kConstant, High32Bits(value)); |
| 1106 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1107 | DCHECK_LT(i, environment_size); |
| 1108 | } else if (current->IsDoubleConstant()) { |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1109 | int64_t value = bit_cast<int64_t, double>(current->AsDoubleConstant()->GetValue()); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1110 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1111 | DexRegisterLocation::Kind::kConstant, Low32Bits(value)); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1112 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1113 | DexRegisterLocation::Kind::kConstant, High32Bits(value)); |
| 1114 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1115 | DCHECK_LT(i, environment_size); |
| 1116 | } else if (current->IsIntConstant()) { |
| 1117 | int32_t value = current->AsIntConstant()->GetValue(); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1118 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kConstant, value); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1119 | } else if (current->IsNullConstant()) { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1120 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kConstant, 0); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1121 | } else { |
| 1122 | DCHECK(current->IsFloatConstant()) << current->DebugName(); |
Roland Levillain | da4d79b | 2015-03-24 14:36:11 +0000 | [diff] [blame] | 1123 | int32_t value = bit_cast<int32_t, float>(current->AsFloatConstant()->GetValue()); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1124 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kConstant, value); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1125 | } |
| 1126 | break; |
| 1127 | } |
| 1128 | |
| 1129 | case Location::kStackSlot: { |
| 1130 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1131 | DexRegisterLocation::Kind::kInStack, location.GetStackIndex()); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1132 | break; |
| 1133 | } |
| 1134 | |
| 1135 | case Location::kDoubleStackSlot: { |
| 1136 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1137 | DexRegisterLocation::Kind::kInStack, location.GetStackIndex()); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1138 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1139 | DexRegisterLocation::Kind::kInStack, location.GetHighStackIndex(kVRegSize)); |
| 1140 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1141 | DCHECK_LT(i, environment_size); |
| 1142 | break; |
| 1143 | } |
| 1144 | |
| 1145 | case Location::kRegister : { |
| 1146 | int id = location.reg(); |
| 1147 | if (slow_path != nullptr && slow_path->IsCoreRegisterSaved(id)) { |
| 1148 | uint32_t offset = slow_path->GetStackOffsetOfCoreRegister(id); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1149 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1150 | if (current->GetType() == Primitive::kPrimLong) { |
| 1151 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1152 | DexRegisterLocation::Kind::kInStack, offset + kVRegSize); |
| 1153 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1154 | DCHECK_LT(i, environment_size); |
| 1155 | } |
| 1156 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1157 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInRegister, id); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1158 | if (current->GetType() == Primitive::kPrimLong) { |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 1159 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInRegisterHigh, id); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1160 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1161 | DCHECK_LT(i, environment_size); |
| 1162 | } |
| 1163 | } |
| 1164 | break; |
| 1165 | } |
| 1166 | |
| 1167 | case Location::kFpuRegister : { |
| 1168 | int id = location.reg(); |
| 1169 | if (slow_path != nullptr && slow_path->IsFpuRegisterSaved(id)) { |
| 1170 | uint32_t offset = slow_path->GetStackOffsetOfFpuRegister(id); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1171 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1172 | if (current->GetType() == Primitive::kPrimDouble) { |
| 1173 | stack_map_stream_.AddDexRegisterEntry( |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1174 | DexRegisterLocation::Kind::kInStack, offset + kVRegSize); |
| 1175 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1176 | DCHECK_LT(i, environment_size); |
| 1177 | } |
| 1178 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1179 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInFpuRegister, id); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1180 | if (current->GetType() == Primitive::kPrimDouble) { |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 1181 | stack_map_stream_.AddDexRegisterEntry( |
| 1182 | DexRegisterLocation::Kind::kInFpuRegisterHigh, id); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1183 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1184 | DCHECK_LT(i, environment_size); |
| 1185 | } |
| 1186 | } |
| 1187 | break; |
| 1188 | } |
| 1189 | |
| 1190 | case Location::kFpuRegisterPair : { |
| 1191 | int low = location.low(); |
| 1192 | int high = location.high(); |
| 1193 | if (slow_path != nullptr && slow_path->IsFpuRegisterSaved(low)) { |
| 1194 | uint32_t offset = slow_path->GetStackOffsetOfFpuRegister(low); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1195 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1196 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1197 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInFpuRegister, low); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1198 | } |
| 1199 | if (slow_path != nullptr && slow_path->IsFpuRegisterSaved(high)) { |
| 1200 | uint32_t offset = slow_path->GetStackOffsetOfFpuRegister(high); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1201 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
| 1202 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1203 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1204 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInFpuRegister, high); |
| 1205 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1206 | } |
| 1207 | DCHECK_LT(i, environment_size); |
| 1208 | break; |
| 1209 | } |
| 1210 | |
| 1211 | case Location::kRegisterPair : { |
| 1212 | int low = location.low(); |
| 1213 | int high = location.high(); |
| 1214 | if (slow_path != nullptr && slow_path->IsCoreRegisterSaved(low)) { |
| 1215 | uint32_t offset = slow_path->GetStackOffsetOfCoreRegister(low); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1216 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1217 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1218 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInRegister, low); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1219 | } |
| 1220 | if (slow_path != nullptr && slow_path->IsCoreRegisterSaved(high)) { |
| 1221 | uint32_t offset = slow_path->GetStackOffsetOfCoreRegister(high); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1222 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInStack, offset); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1223 | } else { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1224 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kInRegister, high); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1225 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1226 | ++i; |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1227 | DCHECK_LT(i, environment_size); |
| 1228 | break; |
| 1229 | } |
| 1230 | |
| 1231 | case Location::kInvalid: { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1232 | stack_map_stream_.AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1233 | break; |
| 1234 | } |
| 1235 | |
| 1236 | default: |
| 1237 | LOG(FATAL) << "Unexpected kind " << location.GetKind(); |
| 1238 | } |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1239 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1240 | |
| 1241 | if (environment->GetParent() != nullptr) { |
| 1242 | stack_map_stream_.EndInlineInfoEntry(); |
| 1243 | } |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1244 | } |
| 1245 | |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1246 | bool CodeGenerator::IsImplicitNullCheckAllowed(HNullCheck* null_check) const { |
| 1247 | return compiler_options_.GetImplicitNullChecks() && |
| 1248 | // Null checks which might throw into a catch block need to save live |
| 1249 | // registers and therefore cannot be done implicitly. |
| 1250 | !null_check->CanThrowIntoCatchBlock(); |
| 1251 | } |
| 1252 | |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 1253 | bool CodeGenerator::CanMoveNullCheckToUser(HNullCheck* null_check) { |
| 1254 | HInstruction* first_next_not_move = null_check->GetNextDisregardingMoves(); |
Calin Juravle | 641547a | 2015-04-21 22:08:51 +0100 | [diff] [blame] | 1255 | |
| 1256 | return (first_next_not_move != nullptr) |
| 1257 | && first_next_not_move->CanDoImplicitNullCheckOn(null_check->InputAt(0)); |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | void CodeGenerator::MaybeRecordImplicitNullCheck(HInstruction* instr) { |
| 1261 | // If we are from a static path don't record the pc as we can't throw NPE. |
| 1262 | // NB: having the checks here makes the code much less verbose in the arch |
| 1263 | // specific code generators. |
| 1264 | if (instr->IsStaticFieldSet() || instr->IsStaticFieldGet()) { |
| 1265 | return; |
| 1266 | } |
| 1267 | |
Calin Juravle | 641547a | 2015-04-21 22:08:51 +0100 | [diff] [blame] | 1268 | if (!instr->CanDoImplicitNullCheckOn(instr->InputAt(0))) { |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 1269 | return; |
| 1270 | } |
| 1271 | |
| 1272 | // Find the first previous instruction which is not a move. |
| 1273 | HInstruction* first_prev_not_move = instr->GetPreviousDisregardingMoves(); |
| 1274 | |
| 1275 | // If the instruction is a null check it means that `instr` is the first user |
| 1276 | // and needs to record the pc. |
| 1277 | if (first_prev_not_move != nullptr && first_prev_not_move->IsNullCheck()) { |
| 1278 | HNullCheck* null_check = first_prev_not_move->AsNullCheck(); |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1279 | if (IsImplicitNullCheckAllowed(null_check)) { |
| 1280 | // TODO: The parallel moves modify the environment. Their changes need to be |
| 1281 | // reverted otherwise the stack maps at the throw point will not be correct. |
| 1282 | RecordPcInfo(null_check, null_check->GetDexPc()); |
| 1283 | } |
Calin Juravle | 77520bc | 2015-01-12 18:45:46 +0000 | [diff] [blame] | 1284 | } |
| 1285 | } |
| 1286 | |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 1287 | void CodeGenerator::ClearSpillSlotsFromLoopPhisInStackMap(HSuspendCheck* suspend_check) const { |
| 1288 | LocationSummary* locations = suspend_check->GetLocations(); |
| 1289 | HBasicBlock* block = suspend_check->GetBlock(); |
| 1290 | DCHECK(block->GetLoopInformation()->GetSuspendCheck() == suspend_check); |
| 1291 | DCHECK(block->IsLoopHeader()); |
| 1292 | |
| 1293 | for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { |
| 1294 | HInstruction* current = it.Current(); |
| 1295 | LiveInterval* interval = current->GetLiveInterval(); |
| 1296 | // We only need to clear bits of loop phis containing objects and allocated in register. |
| 1297 | // Loop phis allocated on stack already have the object in the stack. |
| 1298 | if (current->GetType() == Primitive::kPrimNot |
| 1299 | && interval->HasRegister() |
| 1300 | && interval->HasSpillSlot()) { |
| 1301 | locations->ClearStackBit(interval->GetSpillSlot() / kVRegSize); |
| 1302 | } |
| 1303 | } |
| 1304 | } |
| 1305 | |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 1306 | void CodeGenerator::EmitParallelMoves(Location from1, |
| 1307 | Location to1, |
| 1308 | Primitive::Type type1, |
| 1309 | Location from2, |
| 1310 | Location to2, |
| 1311 | Primitive::Type type2) { |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 1312 | HParallelMove parallel_move(GetGraph()->GetArena()); |
Nicolas Geoffray | 9021825 | 2015-04-15 11:56:51 +0100 | [diff] [blame] | 1313 | parallel_move.AddMove(from1, to1, type1, nullptr); |
| 1314 | parallel_move.AddMove(from2, to2, type2, nullptr); |
Nicolas Geoffray | f0e3937 | 2014-11-12 17:50:07 +0000 | [diff] [blame] | 1315 | GetMoveResolver()->EmitNativeCode(¶llel_move); |
| 1316 | } |
| 1317 | |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1318 | void CodeGenerator::ValidateInvokeRuntime(HInstruction* instruction, SlowPathCode* slow_path) { |
| 1319 | // Ensure that the call kind indication given to the register allocator is |
| 1320 | // coherent with the runtime call generated, and that the GC side effect is |
| 1321 | // set when required. |
| 1322 | if (slow_path == nullptr) { |
Roland Levillain | df3f822 | 2015-08-13 12:31:44 +0100 | [diff] [blame] | 1323 | DCHECK(instruction->GetLocations()->WillCall()) << instruction->DebugName(); |
| 1324 | DCHECK(instruction->GetSideEffects().Includes(SideEffects::CanTriggerGC())) |
| 1325 | << instruction->DebugName() << instruction->GetSideEffects().ToString(); |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1326 | } else { |
Roland Levillain | df3f822 | 2015-08-13 12:31:44 +0100 | [diff] [blame] | 1327 | DCHECK(instruction->GetLocations()->OnlyCallsOnSlowPath() || slow_path->IsFatal()) |
| 1328 | << instruction->DebugName() << slow_path->GetDescription(); |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1329 | DCHECK(instruction->GetSideEffects().Includes(SideEffects::CanTriggerGC()) || |
| 1330 | // Control flow would not come back into the code if a fatal slow |
| 1331 | // path is taken, so we do not care if it triggers GC. |
| 1332 | slow_path->IsFatal() || |
| 1333 | // HDeoptimize is a special case: we know we are not coming back from |
| 1334 | // it into the code. |
Roland Levillain | df3f822 | 2015-08-13 12:31:44 +0100 | [diff] [blame] | 1335 | instruction->IsDeoptimize()) |
| 1336 | << instruction->DebugName() << instruction->GetSideEffects().ToString() |
| 1337 | << slow_path->GetDescription(); |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | // Check the coherency of leaf information. |
| 1341 | DCHECK(instruction->IsSuspendCheck() |
| 1342 | || ((slow_path != nullptr) && slow_path->IsFatal()) |
| 1343 | || instruction->GetLocations()->CanCall() |
Roland Levillain | df3f822 | 2015-08-13 12:31:44 +0100 | [diff] [blame] | 1344 | || !IsLeafMethod()) |
| 1345 | << instruction->DebugName() << ((slow_path != nullptr) ? slow_path->GetDescription() : ""); |
Alexandre Rames | 78e3ef6 | 2015-08-12 13:43:29 +0100 | [diff] [blame] | 1346 | } |
| 1347 | |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 1348 | void SlowPathCode::SaveLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) { |
| 1349 | RegisterSet* register_set = locations->GetLiveRegisters(); |
| 1350 | size_t stack_offset = codegen->GetFirstRegisterSlotInSlowPath(); |
| 1351 | for (size_t i = 0, e = codegen->GetNumberOfCoreRegisters(); i < e; ++i) { |
| 1352 | if (!codegen->IsCoreCalleeSaveRegister(i)) { |
| 1353 | if (register_set->ContainsCoreRegister(i)) { |
| 1354 | // If the register holds an object, update the stack mask. |
| 1355 | if (locations->RegisterContainsObject(i)) { |
| 1356 | locations->SetStackBit(stack_offset / kVRegSize); |
| 1357 | } |
| 1358 | DCHECK_LT(stack_offset, codegen->GetFrameSize() - codegen->FrameEntrySpillSize()); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1359 | DCHECK_LT(i, kMaximumNumberOfExpectedRegisters); |
| 1360 | saved_core_stack_offsets_[i] = stack_offset; |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 1361 | stack_offset += codegen->SaveCoreRegister(stack_offset, i); |
| 1362 | } |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | for (size_t i = 0, e = codegen->GetNumberOfFloatingPointRegisters(); i < e; ++i) { |
| 1367 | if (!codegen->IsFloatingPointCalleeSaveRegister(i)) { |
| 1368 | if (register_set->ContainsFloatingPointRegister(i)) { |
| 1369 | DCHECK_LT(stack_offset, codegen->GetFrameSize() - codegen->FrameEntrySpillSize()); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 1370 | DCHECK_LT(i, kMaximumNumberOfExpectedRegisters); |
| 1371 | saved_fpu_stack_offsets_[i] = stack_offset; |
Nicolas Geoffray | a8ac913 | 2015-03-13 16:36:36 +0000 | [diff] [blame] | 1372 | stack_offset += codegen->SaveFloatingPointRegister(stack_offset, i); |
| 1373 | } |
| 1374 | } |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | void SlowPathCode::RestoreLiveRegisters(CodeGenerator* codegen, LocationSummary* locations) { |
| 1379 | RegisterSet* register_set = locations->GetLiveRegisters(); |
| 1380 | size_t stack_offset = codegen->GetFirstRegisterSlotInSlowPath(); |
| 1381 | for (size_t i = 0, e = codegen->GetNumberOfCoreRegisters(); i < e; ++i) { |
| 1382 | if (!codegen->IsCoreCalleeSaveRegister(i)) { |
| 1383 | if (register_set->ContainsCoreRegister(i)) { |
| 1384 | DCHECK_LT(stack_offset, codegen->GetFrameSize() - codegen->FrameEntrySpillSize()); |
| 1385 | stack_offset += codegen->RestoreCoreRegister(stack_offset, i); |
| 1386 | } |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | for (size_t i = 0, e = codegen->GetNumberOfFloatingPointRegisters(); i < e; ++i) { |
| 1391 | if (!codegen->IsFloatingPointCalleeSaveRegister(i)) { |
| 1392 | if (register_set->ContainsFloatingPointRegister(i)) { |
| 1393 | DCHECK_LT(stack_offset, codegen->GetFrameSize() - codegen->FrameEntrySpillSize()); |
| 1394 | stack_offset += codegen->RestoreFloatingPointRegister(stack_offset, i); |
| 1395 | } |
| 1396 | } |
| 1397 | } |
| 1398 | } |
| 1399 | |
Nicolas Geoffray | 5bd05a5 | 2015-10-13 09:48:30 +0100 | [diff] [blame] | 1400 | void CodeGenerator::CreateSystemArrayCopyLocationSummary(HInvoke* invoke) { |
| 1401 | // Check to see if we have known failures that will cause us to have to bail out |
| 1402 | // to the runtime, and just generate the runtime call directly. |
| 1403 | HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant(); |
| 1404 | HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant(); |
| 1405 | |
| 1406 | // The positions must be non-negative. |
| 1407 | if ((src_pos != nullptr && src_pos->GetValue() < 0) || |
| 1408 | (dest_pos != nullptr && dest_pos->GetValue() < 0)) { |
| 1409 | // We will have to fail anyways. |
| 1410 | return; |
| 1411 | } |
| 1412 | |
| 1413 | // The length must be >= 0. |
| 1414 | HIntConstant* length = invoke->InputAt(4)->AsIntConstant(); |
| 1415 | if (length != nullptr) { |
| 1416 | int32_t len = length->GetValue(); |
| 1417 | if (len < 0) { |
| 1418 | // Just call as normal. |
| 1419 | return; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | SystemArrayCopyOptimizations optimizations(invoke); |
| 1424 | |
| 1425 | if (optimizations.GetDestinationIsSource()) { |
| 1426 | if (src_pos != nullptr && dest_pos != nullptr && src_pos->GetValue() < dest_pos->GetValue()) { |
| 1427 | // We only support backward copying if source and destination are the same. |
| 1428 | return; |
| 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | if (optimizations.GetDestinationIsPrimitiveArray() || optimizations.GetSourceIsPrimitiveArray()) { |
| 1433 | // We currently don't intrinsify primitive copying. |
| 1434 | return; |
| 1435 | } |
| 1436 | |
| 1437 | ArenaAllocator* allocator = invoke->GetBlock()->GetGraph()->GetArena(); |
| 1438 | LocationSummary* locations = new (allocator) LocationSummary(invoke, |
| 1439 | LocationSummary::kCallOnSlowPath, |
| 1440 | kIntrinsified); |
| 1441 | // arraycopy(Object src, int src_pos, Object dest, int dest_pos, int length). |
| 1442 | locations->SetInAt(0, Location::RequiresRegister()); |
| 1443 | locations->SetInAt(1, Location::RegisterOrConstant(invoke->InputAt(1))); |
| 1444 | locations->SetInAt(2, Location::RequiresRegister()); |
| 1445 | locations->SetInAt(3, Location::RegisterOrConstant(invoke->InputAt(3))); |
| 1446 | locations->SetInAt(4, Location::RegisterOrConstant(invoke->InputAt(4))); |
| 1447 | |
| 1448 | locations->AddTemp(Location::RequiresRegister()); |
| 1449 | locations->AddTemp(Location::RequiresRegister()); |
| 1450 | locations->AddTemp(Location::RequiresRegister()); |
| 1451 | } |
| 1452 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1453 | } // namespace art |