Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | */ |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 16 | |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_COMPILED_METHOD_H_ |
| 18 | #define ART_COMPILER_COMPILED_METHOD_H_ |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 20 | #include <memory> |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 21 | #include <string> |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 24 | #include "arch/instruction_set.h" |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 25 | #include "method_reference.h" |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 26 | #include "utils.h" |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 27 | #include "utils/array_ref.h" |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 28 | #include "utils/swap_space.h" |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 29 | |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 30 | namespace llvm { |
| 31 | class Function; |
Ian Rogers | a182704 | 2013-04-18 16:36:43 -0700 | [diff] [blame] | 32 | } // namespace llvm |
Shih-wei Liao | d1fec81 | 2012-02-13 09:51:10 -0800 | [diff] [blame] | 33 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 34 | namespace art { |
| 35 | |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 36 | class CompilerDriver; |
| 37 | |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 38 | class CompiledCode { |
| 39 | public: |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 40 | // For Quick to supply an code blob |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 41 | CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set, |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 42 | const ArrayRef<const uint8_t>& quick_code); |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 43 | |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 44 | InstructionSet GetInstructionSet() const { |
| 45 | return instruction_set_; |
| 46 | } |
| 47 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 48 | const SwapVector<uint8_t>* GetQuickCode() const { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 49 | return quick_code_; |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 50 | } |
| 51 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 52 | void SetCode(const ArrayRef<const uint8_t>* quick_code); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 53 | |
| 54 | bool operator==(const CompiledCode& rhs) const; |
| 55 | |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 56 | // To align an offset from a page-aligned value to make it suitable |
| 57 | // for code storage. For example on ARM, to ensure that PC relative |
| 58 | // valu computations work out as expected. |
| 59 | uint32_t AlignCode(uint32_t offset) const; |
| 60 | static uint32_t AlignCode(uint32_t offset, InstructionSet instruction_set); |
| 61 | |
| 62 | // returns the difference between the code address and a usable PC. |
| 63 | // mainly to cope with kThumb2 where the lower bit must be set. |
| 64 | size_t CodeDelta() const; |
Dave Allison | 50abf0a | 2014-06-23 13:19:59 -0700 | [diff] [blame] | 65 | static size_t CodeDelta(InstructionSet instruction_set); |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 66 | |
| 67 | // Returns a pointer suitable for invoking the code at the argument |
| 68 | // code_pointer address. Mainly to cope with kThumb2 where the |
| 69 | // lower bit must be set to indicate Thumb mode. |
| 70 | static const void* CodePointer(const void* code_pointer, |
| 71 | InstructionSet instruction_set); |
| 72 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 73 | const std::vector<uint32_t>& GetOatdataOffsetsToCompliledCodeOffset() const; |
| 74 | void AddOatdataOffsetToCompliledCodeOffset(uint32_t offset); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 75 | |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 76 | private: |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 77 | CompilerDriver* const compiler_driver_; |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 78 | |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 79 | const InstructionSet instruction_set_; |
Brian Carlstrom | 8227cc1 | 2013-03-06 14:26:48 -0800 | [diff] [blame] | 80 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 81 | // Used to store the PIC code for Quick. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 82 | SwapVector<uint8_t>* quick_code_; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 83 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 84 | // There are offsets from the oatdata symbol to where the offset to |
| 85 | // the compiled method will be found. These are computed by the |
| 86 | // OatWriter and then used by the ElfWriter to add relocations so |
| 87 | // that MCLinker can update the values to the location in the linked .so. |
| 88 | std::vector<uint32_t> oatdata_offsets_to_compiled_code_offset_; |
Logan Chien | 598c513 | 2012-04-28 22:00:44 +0800 | [diff] [blame] | 89 | }; |
| 90 | |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 91 | class SrcMapElem { |
| 92 | public: |
| 93 | uint32_t from_; |
| 94 | int32_t to_; |
| 95 | |
Yevgeny Rouban | 33ac819 | 2014-08-19 18:39:57 +0700 | [diff] [blame] | 96 | explicit operator int64_t() const { |
| 97 | return (static_cast<int64_t>(to_) << 32) | from_; |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 98 | } |
| 99 | |
Yevgeny Rouban | 33ac819 | 2014-08-19 18:39:57 +0700 | [diff] [blame] | 100 | bool operator<(const SrcMapElem& sme) const { |
| 101 | return int64_t(*this) < int64_t(sme); |
| 102 | } |
| 103 | |
| 104 | bool operator==(const SrcMapElem& sme) const { |
| 105 | return int64_t(*this) == int64_t(sme); |
| 106 | } |
| 107 | |
| 108 | explicit operator uint8_t() const { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 109 | return static_cast<uint8_t>(from_ + to_); |
| 110 | } |
| 111 | }; |
| 112 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 113 | template <class Allocator> |
| 114 | class SrcMap FINAL : public std::vector<SrcMapElem, Allocator> { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 115 | public: |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 116 | using std::vector<SrcMapElem, Allocator>::begin; |
| 117 | using typename std::vector<SrcMapElem, Allocator>::const_iterator; |
| 118 | using std::vector<SrcMapElem, Allocator>::empty; |
| 119 | using std::vector<SrcMapElem, Allocator>::end; |
| 120 | using std::vector<SrcMapElem, Allocator>::resize; |
| 121 | using std::vector<SrcMapElem, Allocator>::shrink_to_fit; |
| 122 | using std::vector<SrcMapElem, Allocator>::size; |
| 123 | |
| 124 | explicit SrcMap() {} |
| 125 | |
| 126 | template <class InputIt> |
| 127 | SrcMap(InputIt first, InputIt last, const Allocator& alloc) |
| 128 | : std::vector<SrcMapElem, Allocator>(first, last, alloc) {} |
| 129 | |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 130 | void SortByFrom() { |
Yevgeny Rouban | 33ac819 | 2014-08-19 18:39:57 +0700 | [diff] [blame] | 131 | std::sort(begin(), end(), [] (const SrcMapElem& lhs, const SrcMapElem& rhs) -> bool { |
| 132 | return lhs.from_ < rhs.from_; |
| 133 | }); |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | const_iterator FindByTo(int32_t to) const { |
Yevgeny Rouban | 33ac819 | 2014-08-19 18:39:57 +0700 | [diff] [blame] | 137 | return std::lower_bound(begin(), end(), SrcMapElem({0, to})); |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | SrcMap& Arrange() { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 141 | if (!empty()) { |
Yevgeny Rouban | 33ac819 | 2014-08-19 18:39:57 +0700 | [diff] [blame] | 142 | std::sort(begin(), end()); |
| 143 | resize(std::unique(begin(), end()) - begin()); |
| 144 | shrink_to_fit(); |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 145 | } |
| 146 | return *this; |
| 147 | } |
| 148 | |
| 149 | void DeltaFormat(const SrcMapElem& start, uint32_t highest_pc) { |
| 150 | // Convert from abs values to deltas. |
| 151 | if (!empty()) { |
| 152 | SortByFrom(); |
| 153 | |
| 154 | // TODO: one PC can be mapped to several Java src lines. |
| 155 | // do we want such a one-to-many correspondence? |
| 156 | |
| 157 | // get rid of the highest values |
| 158 | size_t i = size() - 1; |
| 159 | for (; i > 0 ; i--) { |
Yevgeny Rouban | 1127b12 | 2014-09-16 11:29:26 +0700 | [diff] [blame] | 160 | if ((*this)[i].from_ < highest_pc) { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 161 | break; |
| 162 | } |
| 163 | } |
| 164 | this->resize(i + 1); |
| 165 | |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 166 | for (i = size(); --i >= 1; ) { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 167 | (*this)[i].from_ -= (*this)[i-1].from_; |
| 168 | (*this)[i].to_ -= (*this)[i-1].to_; |
| 169 | } |
| 170 | DCHECK((*this)[0].from_ >= start.from_); |
| 171 | (*this)[0].from_ -= start.from_; |
| 172 | (*this)[0].to_ -= start.to_; |
| 173 | } |
| 174 | } |
| 175 | }; |
| 176 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 177 | using DefaultSrcMap = SrcMap<std::allocator<SrcMapElem>>; |
| 178 | using SwapSrcMap = SrcMap<SwapAllocator<SrcMapElem>>; |
| 179 | |
| 180 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 181 | enum LinkerPatchType { |
| 182 | kLinkerPatchMethod, |
| 183 | kLinkerPatchCall, |
| 184 | kLinkerPatchCallRelative, // NOTE: Actual patching is instruction_set-dependent. |
| 185 | kLinkerPatchType, |
| 186 | }; |
| 187 | |
| 188 | class LinkerPatch { |
| 189 | public: |
| 190 | static LinkerPatch MethodPatch(size_t literal_offset, |
| 191 | const DexFile* target_dex_file, |
| 192 | uint32_t target_method_idx) { |
| 193 | return LinkerPatch(literal_offset, kLinkerPatchMethod, |
| 194 | target_method_idx, target_dex_file); |
| 195 | } |
| 196 | |
| 197 | static LinkerPatch CodePatch(size_t literal_offset, |
| 198 | const DexFile* target_dex_file, |
| 199 | uint32_t target_method_idx) { |
| 200 | return LinkerPatch(literal_offset, kLinkerPatchCall, |
| 201 | target_method_idx, target_dex_file); |
| 202 | } |
| 203 | |
| 204 | static LinkerPatch RelativeCodePatch(size_t literal_offset, |
| 205 | const DexFile* target_dex_file, |
| 206 | uint32_t target_method_idx) { |
| 207 | return LinkerPatch(literal_offset, kLinkerPatchCallRelative, |
| 208 | target_method_idx, target_dex_file); |
| 209 | } |
| 210 | |
| 211 | static LinkerPatch TypePatch(size_t literal_offset, |
| 212 | const DexFile* target_dex_file, |
| 213 | uint32_t target_type_idx) { |
| 214 | return LinkerPatch(literal_offset, kLinkerPatchType, target_type_idx, target_dex_file); |
| 215 | } |
| 216 | |
| 217 | LinkerPatch(const LinkerPatch& other) = default; |
| 218 | LinkerPatch& operator=(const LinkerPatch& other) = default; |
| 219 | |
| 220 | size_t LiteralOffset() const { |
| 221 | return literal_offset_; |
| 222 | } |
| 223 | |
| 224 | LinkerPatchType Type() const { |
| 225 | return patch_type_; |
| 226 | } |
| 227 | |
| 228 | MethodReference TargetMethod() const { |
| 229 | DCHECK(patch_type_ == kLinkerPatchMethod || |
| 230 | patch_type_ == kLinkerPatchCall || patch_type_ == kLinkerPatchCallRelative); |
| 231 | return MethodReference(target_dex_file_, target_idx_); |
| 232 | } |
| 233 | |
| 234 | const DexFile* TargetTypeDexFile() const { |
| 235 | DCHECK(patch_type_ == kLinkerPatchType); |
| 236 | return target_dex_file_; |
| 237 | } |
| 238 | |
| 239 | uint32_t TargetTypeIndex() const { |
| 240 | DCHECK(patch_type_ == kLinkerPatchType); |
| 241 | return target_idx_; |
| 242 | } |
| 243 | |
| 244 | private: |
| 245 | LinkerPatch(size_t literal_offset, LinkerPatchType patch_type, |
| 246 | uint32_t target_idx, const DexFile* target_dex_file) |
| 247 | : literal_offset_(literal_offset), |
| 248 | patch_type_(patch_type), |
| 249 | target_idx_(target_idx), |
| 250 | target_dex_file_(target_dex_file) { |
| 251 | } |
| 252 | |
| 253 | size_t literal_offset_; |
| 254 | LinkerPatchType patch_type_; |
| 255 | uint32_t target_idx_; // Method index (Call/Method patches) or type index (Type patches). |
| 256 | const DexFile* target_dex_file_; |
| 257 | |
| 258 | friend bool operator==(const LinkerPatch& lhs, const LinkerPatch& rhs); |
| 259 | friend bool operator<(const LinkerPatch& lhs, const LinkerPatch& rhs); |
| 260 | }; |
| 261 | |
| 262 | inline bool operator==(const LinkerPatch& lhs, const LinkerPatch& rhs) { |
| 263 | return lhs.literal_offset_ == rhs.literal_offset_ && |
| 264 | lhs.patch_type_ == rhs.patch_type_ && |
| 265 | lhs.target_idx_ == rhs.target_idx_ && |
| 266 | lhs.target_dex_file_ == rhs.target_dex_file_; |
| 267 | } |
| 268 | |
| 269 | inline bool operator<(const LinkerPatch& lhs, const LinkerPatch& rhs) { |
| 270 | return (lhs.literal_offset_ != rhs.literal_offset_) ? lhs.literal_offset_ < rhs.literal_offset_ |
| 271 | : (lhs.patch_type_ != rhs.patch_type_) ? lhs.patch_type_ < rhs.patch_type_ |
| 272 | : (lhs.target_idx_ != rhs.target_idx_) ? lhs.target_idx_ < rhs.target_idx_ |
| 273 | : lhs.target_dex_file_ < rhs.target_dex_file_; |
| 274 | } |
| 275 | |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 276 | class CompiledMethod FINAL : public CompiledCode { |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 277 | public: |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 278 | // Constructs a CompiledMethod. |
| 279 | // Note: Consider using the static allocation methods below that will allocate the CompiledMethod |
| 280 | // in the swap space. |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 281 | CompiledMethod(CompilerDriver* driver, |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 282 | InstructionSet instruction_set, |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 283 | const ArrayRef<const uint8_t>& quick_code, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 284 | const size_t frame_size_in_bytes, |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 285 | const uint32_t core_spill_mask, |
| 286 | const uint32_t fp_spill_mask, |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 287 | DefaultSrcMap* src_mapping_table, |
| 288 | const ArrayRef<const uint8_t>& mapping_table, |
| 289 | const ArrayRef<const uint8_t>& vmap_table, |
| 290 | const ArrayRef<const uint8_t>& native_gc_map, |
| 291 | const ArrayRef<const uint8_t>& cfi_info, |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 292 | const ArrayRef<LinkerPatch>& patches = ArrayRef<LinkerPatch>()); |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 293 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 294 | ~CompiledMethod() {} |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 295 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 296 | static CompiledMethod* SwapAllocCompiledMethod( |
| 297 | CompilerDriver* driver, |
| 298 | InstructionSet instruction_set, |
| 299 | const ArrayRef<const uint8_t>& quick_code, |
| 300 | const size_t frame_size_in_bytes, |
| 301 | const uint32_t core_spill_mask, |
| 302 | const uint32_t fp_spill_mask, |
| 303 | DefaultSrcMap* src_mapping_table, |
| 304 | const ArrayRef<const uint8_t>& mapping_table, |
| 305 | const ArrayRef<const uint8_t>& vmap_table, |
| 306 | const ArrayRef<const uint8_t>& native_gc_map, |
| 307 | const ArrayRef<const uint8_t>& cfi_info, |
| 308 | const ArrayRef<LinkerPatch>& patches = ArrayRef<LinkerPatch>()); |
| 309 | |
| 310 | static CompiledMethod* SwapAllocCompiledMethodStackMap( |
| 311 | CompilerDriver* driver, |
| 312 | InstructionSet instruction_set, |
| 313 | const ArrayRef<const uint8_t>& quick_code, |
| 314 | const size_t frame_size_in_bytes, |
| 315 | const uint32_t core_spill_mask, |
| 316 | const uint32_t fp_spill_mask, |
| 317 | const ArrayRef<const uint8_t>& stack_map); |
| 318 | |
| 319 | static CompiledMethod* SwapAllocCompiledMethodCFI(CompilerDriver* driver, |
| 320 | InstructionSet instruction_set, |
| 321 | const ArrayRef<const uint8_t>& quick_code, |
| 322 | const size_t frame_size_in_bytes, |
| 323 | const uint32_t core_spill_mask, |
| 324 | const uint32_t fp_spill_mask, |
| 325 | const ArrayRef<const uint8_t>& cfi_info); |
| 326 | |
| 327 | static void ReleaseSwapAllocatedCompiledMethod(CompilerDriver* driver, CompiledMethod* m); |
| 328 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 329 | size_t GetFrameSizeInBytes() const { |
| 330 | return frame_size_in_bytes_; |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 331 | } |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 332 | |
| 333 | uint32_t GetCoreSpillMask() const { |
| 334 | return core_spill_mask_; |
| 335 | } |
| 336 | |
| 337 | uint32_t GetFpSpillMask() const { |
| 338 | return fp_spill_mask_; |
| 339 | } |
| 340 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 341 | const SwapSrcMap& GetSrcMappingTable() const { |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 342 | DCHECK(src_mapping_table_ != nullptr); |
| 343 | return *src_mapping_table_; |
| 344 | } |
| 345 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 346 | SwapVector<uint8_t> const* GetMappingTable() const { |
Nicolas Geoffray | 376b2bb | 2014-12-09 14:26:32 +0000 | [diff] [blame] | 347 | return mapping_table_; |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 350 | const SwapVector<uint8_t>& GetVmapTable() const { |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 351 | DCHECK(vmap_table_ != nullptr); |
| 352 | return *vmap_table_; |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 355 | SwapVector<uint8_t> const* GetGcMap() const { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 356 | return gc_map_; |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 357 | } |
Logan Chien | 110bcba | 2012-04-16 19:11:28 +0800 | [diff] [blame] | 358 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 359 | const SwapVector<uint8_t>* GetCFIInfo() const { |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 360 | return cfi_info_; |
| 361 | } |
| 362 | |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 363 | const SwapVector<LinkerPatch>& GetPatches() const { |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 364 | return patches_; |
| 365 | } |
| 366 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 367 | private: |
Ian Rogers | a182704 | 2013-04-18 16:36:43 -0700 | [diff] [blame] | 368 | // For quick code, the size of the activation used by the code. |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 369 | const size_t frame_size_in_bytes_; |
Ian Rogers | a182704 | 2013-04-18 16:36:43 -0700 | [diff] [blame] | 370 | // For quick code, a bit mask describing spilled GPR callee-save registers. |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 371 | const uint32_t core_spill_mask_; |
Ian Rogers | a182704 | 2013-04-18 16:36:43 -0700 | [diff] [blame] | 372 | // For quick code, a bit mask describing spilled FPR callee-save registers. |
Ian Rogers | 169c9a7 | 2011-11-13 20:13:17 -0800 | [diff] [blame] | 373 | const uint32_t fp_spill_mask_; |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 374 | // For quick code, a set of pairs (PC, Line) mapping from native PC offset to Java line |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 375 | SwapSrcMap* src_mapping_table_; |
Ian Rogers | 96faf5b | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 376 | // For quick code, a uleb128 encoded map from native PC offset to dex PC aswell as dex PC to |
| 377 | // native PC offset. Size prefixed. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 378 | SwapVector<uint8_t>* mapping_table_; |
Ian Rogers | 96faf5b | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 379 | // For quick code, a uleb128 encoded map from GPR/FPR register to dex register. Size prefixed. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 380 | SwapVector<uint8_t>* vmap_table_; |
Ian Rogers | a182704 | 2013-04-18 16:36:43 -0700 | [diff] [blame] | 381 | // For quick code, a map keyed by native PC indices to bitmaps describing what dalvik registers |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 382 | // are live. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 383 | SwapVector<uint8_t>* gc_map_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 384 | // For quick code, a FDE entry for the debug_frame section. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 385 | SwapVector<uint8_t>* cfi_info_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 386 | // For quick code, linker patches needed by the method. |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 387 | SwapVector<LinkerPatch> patches_; |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 388 | }; |
| 389 | |
Brian Carlstrom | 3320cf4 | 2011-10-04 14:58:28 -0700 | [diff] [blame] | 390 | } // namespace art |
| 391 | |
Mathieu Chartier | 193bad9 | 2013-08-29 18:46:00 -0700 | [diff] [blame] | 392 | #endif // ART_COMPILER_COMPILED_METHOD_H_ |