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