Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [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 | */ |
| 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_OAT_WRITER_H_ |
| 18 | #define ART_COMPILER_OAT_WRITER_H_ |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 21 | #include <cstddef> |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 22 | #include <memory> |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 23 | |
Vladimir Marko | b163bb7 | 2015-03-31 21:49:49 +0100 | [diff] [blame] | 24 | #include "linker/relative_patcher.h" // For linker::RelativePatcherTargetProvider. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 25 | #include "mem_map.h" |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 26 | #include "method_reference.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 27 | #include "oat.h" |
| 28 | #include "mirror/class.h" |
| 29 | #include "safe_map.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 30 | |
| 31 | namespace art { |
| 32 | |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 33 | class BitVector; |
Andreas Gampe | 7927380 | 2014-08-05 20:21:05 -0700 | [diff] [blame] | 34 | class CompiledMethod; |
Vladimir Marko | 20f8559 | 2015-03-19 10:07:02 +0000 | [diff] [blame] | 35 | class CompilerDriver; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 36 | class ImageWriter; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 37 | class OutputStream; |
Vladimir Marko | 20f8559 | 2015-03-19 10:07:02 +0000 | [diff] [blame] | 38 | class TimingLogger; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 39 | |
| 40 | // OatHeader variable length with count of D OatDexFiles |
| 41 | // |
| 42 | // OatDexFile[0] one variable sized OatDexFile with offsets to Dex and OatClasses |
| 43 | // OatDexFile[1] |
| 44 | // ... |
| 45 | // OatDexFile[D] |
| 46 | // |
| 47 | // Dex[0] one variable sized DexFile for each OatDexFile. |
| 48 | // Dex[1] these are literal copies of the input .dex files. |
| 49 | // ... |
| 50 | // Dex[D] |
| 51 | // |
| 52 | // OatClass[0] one variable sized OatClass for each of C DexFile::ClassDefs |
| 53 | // OatClass[1] contains OatClass entries with class status, offsets to code, etc. |
| 54 | // ... |
| 55 | // OatClass[C] |
| 56 | // |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 57 | // GcMap one variable sized blob with GC map. |
| 58 | // GcMap GC maps are deduplicated. |
| 59 | // ... |
| 60 | // GcMap |
| 61 | // |
| 62 | // VmapTable one variable sized VmapTable blob (quick compiler only). |
| 63 | // VmapTable VmapTables are deduplicated. |
| 64 | // ... |
| 65 | // VmapTable |
| 66 | // |
| 67 | // MappingTable one variable sized blob with MappingTable (quick compiler only). |
| 68 | // MappingTable MappingTables are deduplicated. |
| 69 | // ... |
| 70 | // MappingTable |
| 71 | // |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 72 | // padding if necessary so that the following code will be page aligned |
| 73 | // |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 74 | // OatMethodHeader fixed size header for a CompiledMethod including the size of the MethodCode. |
| 75 | // MethodCode one variable sized blob with the code of a CompiledMethod. |
| 76 | // OatMethodHeader (OatMethodHeader, MethodCode) pairs are deduplicated. |
| 77 | // MethodCode |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 78 | // ... |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 79 | // OatMethodHeader |
| 80 | // MethodCode |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 81 | // |
| 82 | class OatWriter { |
| 83 | public: |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 84 | OatWriter(const std::vector<const DexFile*>& dex_files, |
| 85 | uint32_t image_file_location_oat_checksum, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 86 | uintptr_t image_file_location_oat_begin, |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 87 | int32_t image_patch_delta, |
Ian Rogers | ca368cb | 2013-11-15 15:52:08 -0800 | [diff] [blame] | 88 | const CompilerDriver* compiler, |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 89 | ImageWriter* image_writer, |
Andreas Gampe | 22f8e5c | 2014-07-09 11:38:21 -0700 | [diff] [blame] | 90 | TimingLogger* timings, |
| 91 | SafeMap<std::string, std::string>* key_value_store); |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 92 | |
| 93 | const OatHeader& GetOatHeader() const { |
| 94 | return *oat_header_; |
| 95 | } |
| 96 | |
| 97 | size_t GetSize() const { |
| 98 | return size_; |
| 99 | } |
| 100 | |
Vladimir Marko | 5c42c29 | 2015-02-25 12:02:49 +0000 | [diff] [blame] | 101 | size_t GetBssSize() const { |
| 102 | return bss_size_; |
| 103 | } |
| 104 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 105 | const std::vector<uintptr_t>& GetAbsolutePatchLocations() const { |
| 106 | return absolute_patch_locations_; |
| 107 | } |
| 108 | |
| 109 | void SetOatDataOffset(size_t oat_data_offset) { |
| 110 | oat_data_offset_ = oat_data_offset; |
| 111 | } |
| 112 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 113 | bool Write(OutputStream* out); |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 114 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 115 | ~OatWriter(); |
| 116 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 117 | struct DebugInfo { |
David Srbecky | 6f71589 | 2015-03-30 14:21:42 +0100 | [diff] [blame] | 118 | DebugInfo(const std::string& method_name, bool deduped, |
| 119 | const char* class_descriptor, const char* src_file_name, |
| 120 | uint32_t low_pc, uint32_t high_pc, |
| 121 | const uint8_t* dbgstream, CompiledMethod* compiled_method) |
| 122 | : method_name_(method_name), deduped_(deduped), |
| 123 | class_descriptor_(class_descriptor), src_file_name_(src_file_name), |
| 124 | low_pc_(low_pc), high_pc_(high_pc), |
| 125 | dbgstream_(dbgstream), compiled_method_(compiled_method) { |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 126 | } |
Andreas Gampe | 7927380 | 2014-08-05 20:21:05 -0700 | [diff] [blame] | 127 | std::string method_name_; // Note: this name is a pretty-printed name. |
David Srbecky | 6f71589 | 2015-03-30 14:21:42 +0100 | [diff] [blame] | 128 | bool deduped_; |
| 129 | const char* class_descriptor_; |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 130 | const char* src_file_name_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 131 | uint32_t low_pc_; |
| 132 | uint32_t high_pc_; |
Yevgeny Rouban | e3ea838 | 2014-08-08 16:29:38 +0700 | [diff] [blame] | 133 | const uint8_t* dbgstream_; |
Andreas Gampe | 7927380 | 2014-08-05 20:21:05 -0700 | [diff] [blame] | 134 | CompiledMethod* compiled_method_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | const std::vector<DebugInfo>& GetCFIMethodInfo() const { |
| 138 | return method_info_; |
| 139 | } |
| 140 | |
Vladimir Marko | b163bb7 | 2015-03-31 21:49:49 +0100 | [diff] [blame] | 141 | const CompilerDriver* GetCompilerDriver() { |
| 142 | return compiler_driver_; |
| 143 | } |
| 144 | |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 145 | private: |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 146 | // The DataAccess classes are helper classes that provide access to members related to |
| 147 | // a given map, i.e. GC map, mapping table or vmap table. By abstracting these away |
| 148 | // we can share a lot of code for processing the maps with template classes below. |
| 149 | struct GcMapDataAccess; |
| 150 | struct MappingTableDataAccess; |
| 151 | struct VmapTableDataAccess; |
| 152 | |
| 153 | // The function VisitDexMethods() below iterates through all the methods in all |
| 154 | // the compiled dex files in order of their definitions. The method visitor |
| 155 | // classes provide individual bits of processing for each of the passes we need to |
| 156 | // first collect the data we want to write to the oat file and then, in later passes, |
| 157 | // to actually write it. |
| 158 | class DexMethodVisitor; |
| 159 | class OatDexMethodVisitor; |
| 160 | class InitOatClassesMethodVisitor; |
| 161 | class InitCodeMethodVisitor; |
| 162 | template <typename DataAccess> |
| 163 | class InitMapMethodVisitor; |
| 164 | class InitImageMethodVisitor; |
| 165 | class WriteCodeMethodVisitor; |
| 166 | template <typename DataAccess> |
| 167 | class WriteMapMethodVisitor; |
| 168 | |
| 169 | // Visit all the methods in all the compiled dex files in their definition order |
| 170 | // with a given DexMethodVisitor. |
| 171 | bool VisitDexMethods(DexMethodVisitor* visitor); |
| 172 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 173 | size_t InitOatHeader(); |
| 174 | size_t InitOatDexFiles(size_t offset); |
| 175 | size_t InitDexFiles(size_t offset); |
| 176 | size_t InitOatClasses(size_t offset); |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 177 | size_t InitOatMaps(size_t offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 178 | size_t InitOatCode(size_t offset) |
| 179 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 180 | size_t InitOatCodeDexFiles(size_t offset) |
| 181 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 182 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 183 | bool WriteTables(OutputStream* out, const size_t file_offset); |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 184 | size_t WriteMaps(OutputStream* out, const size_t file_offset, size_t relative_offset); |
| 185 | size_t WriteCode(OutputStream* out, const size_t file_offset, size_t relative_offset); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 186 | size_t WriteCodeDexFiles(OutputStream* out, const size_t file_offset, size_t relative_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 187 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 188 | bool WriteCodeAlignment(OutputStream* out, uint32_t aligned_code_delta); |
| 189 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 190 | class OatDexFile { |
| 191 | public: |
| 192 | explicit OatDexFile(size_t offset, const DexFile& dex_file); |
| 193 | size_t SizeOf() const; |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 194 | void UpdateChecksum(OatHeader* oat_header) const; |
| 195 | bool Write(OatWriter* oat_writer, OutputStream* out, const size_t file_offset) const; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 196 | |
| 197 | // Offset of start of OatDexFile from beginning of OatHeader. It is |
| 198 | // used to validate file position when writing. |
| 199 | size_t offset_; |
| 200 | |
| 201 | // data to write |
| 202 | uint32_t dex_file_location_size_; |
| 203 | const uint8_t* dex_file_location_data_; |
| 204 | uint32_t dex_file_location_checksum_; |
| 205 | uint32_t dex_file_offset_; |
| 206 | std::vector<uint32_t> methods_offsets_; |
| 207 | |
| 208 | private: |
| 209 | DISALLOW_COPY_AND_ASSIGN(OatDexFile); |
| 210 | }; |
| 211 | |
| 212 | class OatClass { |
| 213 | public: |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 214 | explicit OatClass(size_t offset, |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 215 | const std::vector<CompiledMethod*>& compiled_methods, |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 216 | uint32_t num_non_null_compiled_methods, |
| 217 | mirror::Class::Status status); |
| 218 | ~OatClass(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 219 | size_t GetOatMethodOffsetsOffsetFromOatHeader(size_t class_def_method_index_) const; |
| 220 | size_t GetOatMethodOffsetsOffsetFromOatClass(size_t class_def_method_index_) const; |
| 221 | size_t SizeOf() const; |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 222 | void UpdateChecksum(OatHeader* oat_header) const; |
| 223 | bool Write(OatWriter* oat_writer, OutputStream* out, const size_t file_offset) const; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 224 | |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 225 | CompiledMethod* GetCompiledMethod(size_t class_def_method_index) const { |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 226 | DCHECK_LT(class_def_method_index, compiled_methods_.size()); |
| 227 | return compiled_methods_[class_def_method_index]; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 230 | // Offset of start of OatClass from beginning of OatHeader. It is |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 231 | // used to validate file position when writing. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 232 | size_t offset_; |
| 233 | |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 234 | // CompiledMethods for each class_def_method_index, or NULL if no method is available. |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 235 | std::vector<CompiledMethod*> compiled_methods_; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 236 | |
| 237 | // Offset from OatClass::offset_ to the OatMethodOffsets for the |
| 238 | // class_def_method_index. If 0, it means the corresponding |
| 239 | // CompiledMethod entry in OatClass::compiled_methods_ should be |
| 240 | // NULL and that the OatClass::type_ should be kOatClassBitmap. |
| 241 | std::vector<uint32_t> oat_method_offsets_offsets_from_oat_class_; |
| 242 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 243 | // data to write |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 244 | |
Andreas Gampe | 785d2f2 | 2014-11-03 22:57:30 -0800 | [diff] [blame] | 245 | static_assert(mirror::Class::Status::kStatusMax < (2 ^ 16), "class status won't fit in 16bits"); |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 246 | int16_t status_; |
| 247 | |
Andreas Gampe | 785d2f2 | 2014-11-03 22:57:30 -0800 | [diff] [blame] | 248 | static_assert(OatClassType::kOatClassMax < (2 ^ 16), "oat_class type won't fit in 16bits"); |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 249 | uint16_t type_; |
| 250 | |
| 251 | uint32_t method_bitmap_size_; |
| 252 | |
| 253 | // bit vector indexed by ClassDef method index. When |
| 254 | // OatClassType::type_ is kOatClassBitmap, a set bit indicates the |
| 255 | // method has an OatMethodOffsets in methods_offsets_, otherwise |
| 256 | // the entry was ommited to save space. If OatClassType::type_ is |
| 257 | // not is kOatClassBitmap, the bitmap will be NULL. |
| 258 | BitVector* method_bitmap_; |
| 259 | |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 260 | // OatMethodOffsets and OatMethodHeaders for each CompiledMethod |
| 261 | // present in the OatClass. Note that some may be missing if |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 262 | // OatClass::compiled_methods_ contains NULL values (and |
| 263 | // oat_method_offsets_offsets_from_oat_class_ should contain 0 |
| 264 | // values in this case). |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 265 | std::vector<OatMethodOffsets> method_offsets_; |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 266 | std::vector<OatQuickMethodHeader> method_headers_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 267 | |
| 268 | private: |
| 269 | DISALLOW_COPY_AND_ASSIGN(OatClass); |
| 270 | }; |
| 271 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 272 | std::vector<DebugInfo> method_info_; |
| 273 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 274 | const CompilerDriver* const compiler_driver_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 275 | ImageWriter* const image_writer_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 276 | |
| 277 | // note OatFile does not take ownership of the DexFiles |
| 278 | const std::vector<const DexFile*>* dex_files_; |
| 279 | |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 280 | // Size required for Oat data structures. |
| 281 | size_t size_; |
| 282 | |
Vladimir Marko | 5c42c29 | 2015-02-25 12:02:49 +0000 | [diff] [blame] | 283 | // The size of the required .bss section holding the DexCache data. |
| 284 | size_t bss_size_; |
| 285 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 286 | // Offset of the oat data from the start of the mmapped region of the elf file. |
| 287 | size_t oat_data_offset_; |
| 288 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 289 | // dependencies on the image. |
| 290 | uint32_t image_file_location_oat_checksum_; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 291 | uintptr_t image_file_location_oat_begin_; |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 292 | int32_t image_patch_delta_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 293 | |
| 294 | // data to write |
Andreas Gampe | 22f8e5c | 2014-07-09 11:38:21 -0700 | [diff] [blame] | 295 | SafeMap<std::string, std::string>* key_value_store_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 296 | OatHeader* oat_header_; |
| 297 | std::vector<OatDexFile*> oat_dex_files_; |
| 298 | std::vector<OatClass*> oat_classes_; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 299 | std::unique_ptr<const std::vector<uint8_t>> interpreter_to_interpreter_bridge_; |
| 300 | std::unique_ptr<const std::vector<uint8_t>> interpreter_to_compiled_code_bridge_; |
| 301 | std::unique_ptr<const std::vector<uint8_t>> jni_dlsym_lookup_; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 302 | std::unique_ptr<const std::vector<uint8_t>> quick_generic_jni_trampoline_; |
| 303 | std::unique_ptr<const std::vector<uint8_t>> quick_imt_conflict_trampoline_; |
| 304 | std::unique_ptr<const std::vector<uint8_t>> quick_resolution_trampoline_; |
| 305 | std::unique_ptr<const std::vector<uint8_t>> quick_to_interpreter_bridge_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 306 | |
| 307 | // output stats |
| 308 | uint32_t size_dex_file_alignment_; |
| 309 | uint32_t size_executable_offset_alignment_; |
| 310 | uint32_t size_oat_header_; |
Andreas Gampe | 22f8e5c | 2014-07-09 11:38:21 -0700 | [diff] [blame] | 311 | uint32_t size_oat_header_key_value_store_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 312 | uint32_t size_dex_file_; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 313 | uint32_t size_interpreter_to_interpreter_bridge_; |
| 314 | uint32_t size_interpreter_to_compiled_code_bridge_; |
| 315 | uint32_t size_jni_dlsym_lookup_; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 316 | uint32_t size_quick_generic_jni_trampoline_; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 317 | uint32_t size_quick_imt_conflict_trampoline_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 318 | uint32_t size_quick_resolution_trampoline_; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 319 | uint32_t size_quick_to_interpreter_bridge_; |
| 320 | uint32_t size_trampoline_alignment_; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 321 | uint32_t size_method_header_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 322 | uint32_t size_code_; |
| 323 | uint32_t size_code_alignment_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 324 | uint32_t size_relative_call_thunks_; |
Vladimir Marko | c74658b | 2015-03-31 10:26:41 +0100 | [diff] [blame] | 325 | uint32_t size_misc_thunks_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 326 | uint32_t size_mapping_table_; |
| 327 | uint32_t size_vmap_table_; |
| 328 | uint32_t size_gc_map_; |
| 329 | uint32_t size_oat_dex_file_location_size_; |
| 330 | uint32_t size_oat_dex_file_location_data_; |
| 331 | uint32_t size_oat_dex_file_location_checksum_; |
| 332 | uint32_t size_oat_dex_file_offset_; |
| 333 | uint32_t size_oat_dex_file_methods_offsets_; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 334 | uint32_t size_oat_class_type_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 335 | uint32_t size_oat_class_status_; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 336 | uint32_t size_oat_class_method_bitmaps_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 337 | uint32_t size_oat_class_method_offsets_; |
| 338 | |
Vladimir Marko | b163bb7 | 2015-03-31 21:49:49 +0100 | [diff] [blame] | 339 | std::unique_ptr<linker::RelativePatcher> relative_patcher_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 340 | |
| 341 | // The locations of absolute patches relative to the start of the executable section. |
| 342 | std::vector<uintptr_t> absolute_patch_locations_; |
| 343 | |
Vladimir Marko | b163bb7 | 2015-03-31 21:49:49 +0100 | [diff] [blame] | 344 | // Map method reference to assigned offset. |
| 345 | // Wrap the map in a class implementing linker::RelativePatcherTargetProvider. |
| 346 | class MethodOffsetMap FINAL : public linker::RelativePatcherTargetProvider { |
| 347 | public: |
| 348 | std::pair<bool, uint32_t> FindMethodOffset(MethodReference ref) OVERRIDE; |
| 349 | SafeMap<MethodReference, uint32_t, MethodReferenceComparator> map; |
| 350 | }; |
| 351 | MethodOffsetMap method_offset_map_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 352 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 353 | DISALLOW_COPY_AND_ASSIGN(OatWriter); |
| 354 | }; |
| 355 | |
| 356 | } // namespace art |
| 357 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 358 | #endif // ART_COMPILER_OAT_WRITER_H_ |