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 | |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 17 | #ifndef ART_DEX2OAT_LINKER_OAT_WRITER_H_ |
| 18 | #define ART_DEX2OAT_LINKER_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> |
Igor Murashkin | 545412b | 2017-08-17 15:26:54 -0700 | [diff] [blame] | 23 | #include <vector> |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 24 | |
David Brazdil | d9c9037 | 2016-09-14 16:53:55 +0100 | [diff] [blame] | 25 | #include "base/array_ref.h" |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 26 | #include "base/dchecked_vector.h" |
David Sehr | c431b9d | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 27 | #include "base/os.h" |
David Sehr | 79e2607 | 2018-04-06 17:58:50 -0700 | [diff] [blame] | 28 | #include "base/mem_map.h" |
David Sehr | 67bf42e | 2018-02-26 16:43:04 -0800 | [diff] [blame] | 29 | #include "base/safe_map.h" |
David Srbecky | 32210b9 | 2017-12-04 14:39:21 +0000 | [diff] [blame] | 30 | #include "debug/debug_info.h" |
David Sehr | 312f3b2 | 2018-03-19 08:39:26 -0700 | [diff] [blame] | 31 | #include "dex/compact_dex_level.h" |
| 32 | #include "dex/method_reference.h" |
| 33 | #include "dex/string_reference.h" |
| 34 | #include "dex/type_reference.h" |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 35 | #include "linker/relative_patcher.h" // For RelativePatcherTargetProvider. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 36 | #include "mirror/class.h" |
Artem Udovichenko | d9786b0 | 2015-10-14 16:36:55 +0300 | [diff] [blame] | 37 | #include "oat.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 38 | |
| 39 | namespace art { |
| 40 | |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 41 | class BitVector; |
Andreas Gampe | 7927380 | 2014-08-05 20:21:05 -0700 | [diff] [blame] | 42 | class CompiledMethod; |
Vladimir Marko | 20f8559 | 2015-03-19 10:07:02 +0000 | [diff] [blame] | 43 | class CompilerDriver; |
Vladimir Marko | dc4bcce | 2018-06-21 16:15:42 +0100 | [diff] [blame] | 44 | class CompilerOptions; |
Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 45 | class DexContainer; |
Jeff Hao | 608f2ce | 2016-10-19 11:17:11 -0700 | [diff] [blame] | 46 | class ProfileCompilationInfo; |
Vladimir Marko | 20f8559 | 2015-03-19 10:07:02 +0000 | [diff] [blame] | 47 | class TimingLogger; |
Artem Udovichenko | d9786b0 | 2015-10-14 16:36:55 +0300 | [diff] [blame] | 48 | class TypeLookupTable; |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 49 | class VdexFile; |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 50 | class ZipEntry; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 51 | |
David Srbecky | c5bfa97 | 2016-02-05 15:49:10 +0000 | [diff] [blame] | 52 | namespace debug { |
Vladimir Marko | 10c1356 | 2015-11-25 14:33:36 +0000 | [diff] [blame] | 53 | struct MethodDebugInfo; |
David Srbecky | c5bfa97 | 2016-02-05 15:49:10 +0000 | [diff] [blame] | 54 | } // namespace debug |
Vladimir Marko | 10c1356 | 2015-11-25 14:33:36 +0000 | [diff] [blame] | 55 | |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 56 | namespace verifier { |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 57 | class VerifierDeps; |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 58 | } // namespace verifier |
| 59 | |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 60 | namespace linker { |
| 61 | |
| 62 | class ImageWriter; |
| 63 | class MultiOatRelativePatcher; |
| 64 | class OutputStream; |
| 65 | |
Andreas Gampe | 1554417 | 2018-06-25 15:09:06 -0700 | [diff] [blame] | 66 | enum class CopyOption { |
| 67 | kNever, |
| 68 | kAlways, |
| 69 | kOnlyIfCompressed |
| 70 | }; |
| 71 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 72 | // OatHeader variable length with count of D OatDexFiles |
| 73 | // |
Artem Udovichenko | d9786b0 | 2015-10-14 16:36:55 +0300 | [diff] [blame] | 74 | // TypeLookupTable[0] one descriptor to class def index hash table for each OatDexFile. |
| 75 | // TypeLookupTable[1] |
| 76 | // ... |
| 77 | // TypeLookupTable[D] |
| 78 | // |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 79 | // ClassOffsets[0] one table of OatClass offsets for each class def for each OatDexFile. |
| 80 | // ClassOffsets[1] |
| 81 | // ... |
| 82 | // ClassOffsets[D] |
| 83 | // |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 84 | // OatClass[0] one variable sized OatClass for each of C DexFile::ClassDefs |
| 85 | // OatClass[1] contains OatClass entries with class status, offsets to code, etc. |
| 86 | // ... |
| 87 | // OatClass[C] |
| 88 | // |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 89 | // MethodBssMapping one variable sized MethodBssMapping for each dex file, optional. |
| 90 | // MethodBssMapping |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 91 | // ... |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 92 | // MethodBssMapping |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 93 | // |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 94 | // VmapTable one variable sized VmapTable blob (CodeInfo or QuickeningInfo). |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 95 | // VmapTable VmapTables are deduplicated. |
| 96 | // ... |
| 97 | // VmapTable |
| 98 | // |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 99 | // MethodInfo one variable sized blob with MethodInfo. |
| 100 | // MethodInfo MethodInfos are deduplicated. |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 101 | // ... |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 102 | // MethodInfo |
| 103 | // |
| 104 | // OatDexFile[0] one variable sized OatDexFile with offsets to Dex and OatClasses |
| 105 | // OatDexFile[1] |
| 106 | // ... |
| 107 | // OatDexFile[D] |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 108 | // |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 109 | // padding if necessary so that the following code will be page aligned |
| 110 | // |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 111 | // OatMethodHeader fixed size header for a CompiledMethod including the size of the MethodCode. |
| 112 | // MethodCode one variable sized blob with the code of a CompiledMethod. |
| 113 | // OatMethodHeader (OatMethodHeader, MethodCode) pairs are deduplicated. |
| 114 | // MethodCode |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 115 | // ... |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 116 | // OatMethodHeader |
| 117 | // MethodCode |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 118 | // |
| 119 | class OatWriter { |
| 120 | public: |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 121 | enum class CreateTypeLookupTable { |
| 122 | kCreate, |
| 123 | kDontCreate, |
| 124 | kDefault = kCreate |
| 125 | }; |
| 126 | |
Mathieu Chartier | 603ccab | 2017-10-20 14:34:28 -0700 | [diff] [blame] | 127 | OatWriter(bool compiling_boot_image, |
| 128 | TimingLogger* timings, |
| 129 | ProfileCompilationInfo* info, |
| 130 | CompactDexLevel compact_dex_level); |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 131 | |
| 132 | // To produce a valid oat file, the user must first add sources with any combination of |
| 133 | // - AddDexFileSource(), |
| 134 | // - AddZippedDexFilesSource(), |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 135 | // - AddRawDexFileSource(), |
| 136 | // - AddVdexDexFilesSource(). |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 137 | // Then the user must call in order |
| 138 | // - WriteAndOpenDexFiles() |
Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 139 | // - Initialize() |
| 140 | // - WriteVerifierDeps() |
| 141 | // - WriteQuickeningInfo() |
Nicolas Geoffray | f54e5df | 2016-12-01 10:45:08 +0000 | [diff] [blame] | 142 | // - WriteChecksumsAndVdexHeader() |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 143 | // - PrepareLayout(), |
| 144 | // - WriteRodata(), |
| 145 | // - WriteCode(), |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 146 | // - WriteDataBimgRelRo() iff GetDataBimgRelRoSize() != 0, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 147 | // - WriteHeader(). |
| 148 | |
| 149 | // Add dex file source(s) from a file, either a plain dex file or |
| 150 | // a zip file with one or more dex files. |
| 151 | bool AddDexFileSource( |
| 152 | const char* filename, |
| 153 | const char* location, |
| 154 | CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault); |
| 155 | // Add dex file source(s) from a zip file specified by a file handle. |
| 156 | bool AddZippedDexFilesSource( |
Andreas Gampe | 43e10b0 | 2016-07-15 17:17:34 -0700 | [diff] [blame] | 157 | File&& zip_fd, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 158 | const char* location, |
| 159 | CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault); |
| 160 | // Add dex file source from raw memory. |
| 161 | bool AddRawDexFileSource( |
| 162 | const ArrayRef<const uint8_t>& data, |
| 163 | const char* location, |
| 164 | uint32_t location_checksum, |
| 165 | CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault); |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 166 | // Add dex file source(s) from a vdex file. |
| 167 | bool AddVdexDexFilesSource( |
| 168 | const VdexFile& vdex_file, |
| 169 | const char* location, |
| 170 | CreateTypeLookupTable create_type_lookup_table = CreateTypeLookupTable::kDefault); |
Calin Juravle | 1ce7085 | 2017-06-28 10:59:03 -0700 | [diff] [blame] | 171 | dchecked_vector<std::string> GetSourceLocations() const; |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 172 | |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 173 | // Write raw dex files to the vdex file, mmap the file and open the dex files from it. |
| 174 | // Supporting data structures are written into the .rodata section of the oat file. |
| 175 | // The `verify` setting dictates whether the dex file verifier should check the dex files. |
| 176 | // This is generally the case, and should only be false for tests. |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 177 | // If `update_input_vdex` is true, then this method won't actually write the dex files, |
| 178 | // and the compiler will just re-use the existing vdex file. |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 179 | bool WriteAndOpenDexFiles(File* vdex_file, |
| 180 | OutputStream* oat_rodata, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 181 | InstructionSet instruction_set, |
| 182 | const InstructionSetFeatures* instruction_set_features, |
| 183 | SafeMap<std::string, std::string>* key_value_store, |
Andreas Gampe | 3a2bd29 | 2016-01-26 17:23:47 -0800 | [diff] [blame] | 184 | bool verify, |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 185 | bool update_input_vdex, |
Nicolas Geoffray | 66ff8a8 | 2018-02-28 13:27:55 +0000 | [diff] [blame] | 186 | CopyOption copy_dex_files, |
Nicolas Geoffray | f307527 | 2018-01-08 12:41:19 +0000 | [diff] [blame] | 187 | /*out*/ std::vector<std::unique_ptr<MemMap>>* opened_dex_files_map, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 188 | /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files); |
Vladimir Marko | dc4bcce | 2018-06-21 16:15:42 +0100 | [diff] [blame] | 189 | // Initialize the writer with the given parameters. |
| 190 | void Initialize(const CompilerDriver* compiler_driver, |
| 191 | ImageWriter* image_writer, |
| 192 | const std::vector<const DexFile*>& dex_files); |
Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 193 | bool WriteQuickeningInfo(OutputStream* vdex_out); |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 194 | bool WriteVerifierDeps(OutputStream* vdex_out, verifier::VerifierDeps* verifier_deps); |
Nicolas Geoffray | f54e5df | 2016-12-01 10:45:08 +0000 | [diff] [blame] | 195 | bool WriteChecksumsAndVdexHeader(OutputStream* vdex_out); |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 196 | |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 197 | // Prepare layout of remaining data. |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 198 | void PrepareLayout(MultiOatRelativePatcher* relative_patcher); |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 199 | // Write the rest of .rodata section (ClassOffsets[], OatClass[], maps). |
| 200 | bool WriteRodata(OutputStream* out); |
| 201 | // Write the code to the .text section. |
| 202 | bool WriteCode(OutputStream* out); |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 203 | // Write the boot image relocation data to the .data.bimg.rel.ro section. |
| 204 | bool WriteDataBimgRelRo(OutputStream* out); |
| 205 | // Check the size of the written oat file. |
| 206 | bool CheckOatSize(OutputStream* out, size_t file_offset, size_t relative_offset); |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 207 | // Write the oat header. This finalizes the oat file. |
| 208 | bool WriteHeader(OutputStream* out, |
| 209 | uint32_t image_file_location_oat_checksum, |
| 210 | uintptr_t image_file_location_oat_begin, |
| 211 | int32_t image_patch_delta); |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 212 | |
Vladimir Marko | 09d0943 | 2015-09-08 13:47:48 +0100 | [diff] [blame] | 213 | // Returns whether the oat file has an associated image. |
| 214 | bool HasImage() const { |
| 215 | // Since the image is being created at the same time as the oat file, |
| 216 | // check if there's an image writer. |
| 217 | return image_writer_ != nullptr; |
| 218 | } |
| 219 | |
Mathieu Chartier | da5b28a | 2015-11-05 08:03:47 -0800 | [diff] [blame] | 220 | bool HasBootImage() const { |
| 221 | return compiling_boot_image_; |
| 222 | } |
| 223 | |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 224 | const OatHeader& GetOatHeader() const { |
| 225 | return *oat_header_; |
| 226 | } |
| 227 | |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 228 | size_t GetCodeSize() const { |
| 229 | return code_size_; |
| 230 | } |
| 231 | |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 232 | size_t GetOatSize() const { |
| 233 | return oat_size_; |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 236 | size_t GetDataBimgRelRoSize() const { |
| 237 | return data_bimg_rel_ro_size_; |
| 238 | } |
| 239 | |
Vladimir Marko | 5c42c29 | 2015-02-25 12:02:49 +0000 | [diff] [blame] | 240 | size_t GetBssSize() const { |
| 241 | return bss_size_; |
| 242 | } |
| 243 | |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 244 | size_t GetBssMethodsOffset() const { |
| 245 | return bss_methods_offset_; |
| 246 | } |
| 247 | |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 248 | size_t GetBssRootsOffset() const { |
| 249 | return bss_roots_offset_; |
| 250 | } |
| 251 | |
David Srbecky | ec2cdf4 | 2017-12-08 16:21:25 +0000 | [diff] [blame] | 252 | size_t GetVdexSize() const { |
| 253 | return vdex_size_; |
| 254 | } |
| 255 | |
Vladimir Marko | 944da60 | 2016-02-19 12:27:55 +0000 | [diff] [blame] | 256 | size_t GetOatDataOffset() const { |
| 257 | return oat_data_offset_; |
| 258 | } |
| 259 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 260 | ~OatWriter(); |
| 261 | |
David Srbecky | 32210b9 | 2017-12-04 14:39:21 +0000 | [diff] [blame] | 262 | debug::DebugInfo GetDebugInfo() const; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 263 | |
Mathieu Chartier | 3957bff | 2017-07-16 13:55:27 -0700 | [diff] [blame] | 264 | const CompilerDriver* GetCompilerDriver() const { |
Vladimir Marko | b163bb7 | 2015-03-31 21:49:49 +0100 | [diff] [blame] | 265 | return compiler_driver_; |
| 266 | } |
| 267 | |
Vladimir Marko | dc4bcce | 2018-06-21 16:15:42 +0100 | [diff] [blame] | 268 | const CompilerOptions& GetCompilerOptions() const { |
| 269 | DCHECK(compiler_options_ != nullptr); |
| 270 | return *compiler_options_; |
| 271 | } |
| 272 | |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 273 | private: |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 274 | class DexFileSource; |
Mathieu Chartier | 3957bff | 2017-07-16 13:55:27 -0700 | [diff] [blame] | 275 | class OatClassHeader; |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 276 | class OatClass; |
| 277 | class OatDexFile; |
| 278 | |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 279 | // The function VisitDexMethods() below iterates through all the methods in all |
| 280 | // the compiled dex files in order of their definitions. The method visitor |
| 281 | // classes provide individual bits of processing for each of the passes we need to |
| 282 | // first collect the data we want to write to the oat file and then, in later passes, |
| 283 | // to actually write it. |
| 284 | class DexMethodVisitor; |
| 285 | class OatDexMethodVisitor; |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 286 | class InitBssLayoutMethodVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 287 | class InitOatClassesMethodVisitor; |
Igor Murashkin | 545412b | 2017-08-17 15:26:54 -0700 | [diff] [blame] | 288 | class LayoutCodeMethodVisitor; |
| 289 | class LayoutReserveOffsetCodeMethodVisitor; |
| 290 | struct OrderedMethodData; |
| 291 | class OrderedMethodVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 292 | class InitCodeMethodVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 293 | class InitMapMethodVisitor; |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 294 | class InitMethodInfoVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 295 | class InitImageMethodVisitor; |
| 296 | class WriteCodeMethodVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 297 | class WriteMapMethodVisitor; |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 298 | class WriteMethodInfoVisitor; |
Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 299 | class WriteQuickeningInfoMethodVisitor; |
Mathieu Chartier | 210531f | 2018-01-12 10:15:51 -0800 | [diff] [blame] | 300 | class WriteQuickeningInfoOffsetsMethodVisitor; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 301 | |
| 302 | // Visit all the methods in all the compiled dex files in their definition order |
| 303 | // with a given DexMethodVisitor. |
| 304 | bool VisitDexMethods(DexMethodVisitor* visitor); |
| 305 | |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 306 | // If `update_input_vdex` is true, then this method won't actually write the dex files, |
| 307 | // and the compiler will just re-use the existing vdex file. |
Mathieu Chartier | 792111c | 2018-02-15 13:02:15 -0800 | [diff] [blame] | 308 | bool WriteDexFiles(OutputStream* out, |
| 309 | File* file, |
| 310 | bool update_input_vdex, |
Nicolas Geoffray | 66ff8a8 | 2018-02-28 13:27:55 +0000 | [diff] [blame] | 311 | CopyOption copy_dex_files); |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 312 | bool WriteDexFile(OutputStream* out, |
| 313 | File* file, |
| 314 | OatDexFile* oat_dex_file, |
| 315 | bool update_input_vdex); |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 316 | bool SeekToDexFile(OutputStream* out, File* file, OatDexFile* oat_dex_file); |
Jeff Hao | 608f2ce | 2016-10-19 11:17:11 -0700 | [diff] [blame] | 317 | bool LayoutAndWriteDexFile(OutputStream* out, OatDexFile* oat_dex_file); |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 318 | bool WriteDexFile(OutputStream* out, |
| 319 | File* file, |
| 320 | OatDexFile* oat_dex_file, |
| 321 | ZipEntry* dex_file); |
| 322 | bool WriteDexFile(OutputStream* out, |
| 323 | File* file, |
| 324 | OatDexFile* oat_dex_file, |
| 325 | File* dex_file); |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 326 | bool WriteDexFile(OutputStream* out, |
| 327 | OatDexFile* oat_dex_file, |
| 328 | const uint8_t* dex_file, |
| 329 | bool update_input_vdex); |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 330 | bool OpenDexFiles(File* file, |
| 331 | bool verify, |
Nicolas Geoffray | f307527 | 2018-01-08 12:41:19 +0000 | [diff] [blame] | 332 | /*out*/ std::vector<std::unique_ptr<MemMap>>* opened_dex_files_map, |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 333 | /*out*/ std::vector<std::unique_ptr<const DexFile>>* opened_dex_files); |
| 334 | |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 335 | size_t InitOatHeader(InstructionSet instruction_set, |
| 336 | const InstructionSetFeatures* instruction_set_features, |
| 337 | uint32_t num_dex_files, |
| 338 | SafeMap<std::string, std::string>* key_value_store); |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 339 | size_t InitClassOffsets(size_t offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 340 | size_t InitOatClasses(size_t offset); |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 341 | size_t InitOatMaps(size_t offset); |
Vladimir Marko | f3c52b4 | 2017-11-17 17:32:12 +0000 | [diff] [blame] | 342 | size_t InitIndexBssMappings(size_t offset); |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 343 | size_t InitOatDexFiles(size_t offset); |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 344 | size_t InitOatCode(size_t offset); |
| 345 | size_t InitOatCodeDexFiles(size_t offset); |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 346 | size_t InitDataBimgRelRoLayout(size_t offset); |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 347 | void InitBssLayout(InstructionSet instruction_set); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 348 | |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 349 | size_t WriteClassOffsets(OutputStream* out, size_t file_offset, size_t relative_offset); |
| 350 | size_t WriteClasses(OutputStream* out, size_t file_offset, size_t relative_offset); |
| 351 | size_t WriteMaps(OutputStream* out, size_t file_offset, size_t relative_offset); |
Vladimir Marko | f3c52b4 | 2017-11-17 17:32:12 +0000 | [diff] [blame] | 352 | size_t WriteIndexBssMappings(OutputStream* out, size_t file_offset, size_t relative_offset); |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 353 | size_t WriteOatDexFiles(OutputStream* out, size_t file_offset, size_t relative_offset); |
| 354 | size_t WriteCode(OutputStream* out, size_t file_offset, size_t relative_offset); |
| 355 | size_t WriteCodeDexFiles(OutputStream* out, size_t file_offset, size_t relative_offset); |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 356 | size_t WriteDataBimgRelRo(OutputStream* out, size_t file_offset, size_t relative_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 357 | |
Vladimir Marko | 944da60 | 2016-02-19 12:27:55 +0000 | [diff] [blame] | 358 | bool RecordOatDataOffset(OutputStream* out); |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 359 | bool WriteTypeLookupTables(OutputStream* oat_rodata, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 360 | const std::vector<std::unique_ptr<const DexFile>>& opened_dex_files); |
Mathieu Chartier | 120aa28 | 2017-08-05 16:03:03 -0700 | [diff] [blame] | 361 | bool WriteDexLayoutSections(OutputStream* oat_rodata, |
| 362 | const std::vector<std::unique_ptr<const DexFile>>& opened_dex_files); |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 363 | bool WriteCodeAlignment(OutputStream* out, uint32_t aligned_code_delta); |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 364 | bool WriteUpTo16BytesAlignment(OutputStream* out, uint32_t size, uint32_t* stat); |
Vladimir Marko | 944da60 | 2016-02-19 12:27:55 +0000 | [diff] [blame] | 365 | void SetMultiOatRelativePatcherAdjustment(); |
Nicolas Geoffray | 81f57d1 | 2016-12-20 13:17:09 +0000 | [diff] [blame] | 366 | void CloseSources(); |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 367 | |
Mathieu Chartier | 3957bff | 2017-07-16 13:55:27 -0700 | [diff] [blame] | 368 | bool MayHaveCompiledMethods() const; |
| 369 | |
David Srbecky | 96c8446 | 2018-02-05 15:42:40 +0000 | [diff] [blame] | 370 | bool VdexWillContainDexFiles() const { |
Mathieu Chartier | 792111c | 2018-02-15 13:02:15 -0800 | [diff] [blame] | 371 | return dex_files_ != nullptr && extract_dex_files_into_vdex_; |
David Srbecky | 96c8446 | 2018-02-05 15:42:40 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 374 | enum class WriteState { |
| 375 | kAddingDexFileSources, |
| 376 | kPrepareLayout, |
| 377 | kWriteRoData, |
| 378 | kWriteText, |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 379 | kWriteDataBimgRelRo, |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 380 | kWriteHeader, |
| 381 | kDone |
| 382 | }; |
| 383 | |
| 384 | WriteState write_state_; |
| 385 | TimingLogger* timings_; |
| 386 | |
| 387 | std::vector<std::unique_ptr<File>> raw_dex_files_; |
| 388 | std::vector<std::unique_ptr<ZipArchive>> zip_archives_; |
| 389 | std::vector<std::unique_ptr<ZipEntry>> zipped_dex_files_; |
| 390 | |
| 391 | // Using std::list<> which doesn't move elements around on push/emplace_back(). |
| 392 | // We need this because we keep plain pointers to the strings' c_str(). |
| 393 | std::list<std::string> zipped_dex_file_locations_; |
| 394 | |
David Srbecky | c5bfa97 | 2016-02-05 15:49:10 +0000 | [diff] [blame] | 395 | dchecked_vector<debug::MethodDebugInfo> method_info_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 396 | |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 397 | const CompilerDriver* compiler_driver_; |
Vladimir Marko | dc4bcce | 2018-06-21 16:15:42 +0100 | [diff] [blame] | 398 | const CompilerOptions* compiler_options_; |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 399 | ImageWriter* image_writer_; |
Mathieu Chartier | da5b28a | 2015-11-05 08:03:47 -0800 | [diff] [blame] | 400 | const bool compiling_boot_image_; |
Mathieu Chartier | 792111c | 2018-02-15 13:02:15 -0800 | [diff] [blame] | 401 | // Whether the dex files being compiled are going to be extracted to the vdex. |
| 402 | bool extract_dex_files_into_vdex_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 403 | |
| 404 | // note OatFile does not take ownership of the DexFiles |
| 405 | const std::vector<const DexFile*>* dex_files_; |
| 406 | |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 407 | // Size required for Vdex data structures. |
| 408 | size_t vdex_size_; |
| 409 | |
| 410 | // Offset of section holding Dex files inside Vdex. |
| 411 | size_t vdex_dex_files_offset_; |
| 412 | |
Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 413 | // Offset of section holding shared dex data section in the Vdex. |
| 414 | size_t vdex_dex_shared_data_offset_; |
| 415 | |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 416 | // Offset of section holding VerifierDeps inside Vdex. |
| 417 | size_t vdex_verifier_deps_offset_; |
| 418 | |
Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 419 | // Offset of section holding quickening info inside Vdex. |
| 420 | size_t vdex_quickening_info_offset_; |
| 421 | |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 422 | // Size of the .text segment. |
| 423 | size_t code_size_; |
| 424 | |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 425 | // Size required for Oat data structures. |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 426 | size_t oat_size_; |
Brian Carlstrom | c50d8e1 | 2013-07-23 22:35:16 -0700 | [diff] [blame] | 427 | |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 428 | // The start of the required .data.bimg.rel.ro section. |
| 429 | size_t data_bimg_rel_ro_start_; |
| 430 | |
| 431 | // The size of the required .data.bimg.rel.ro section holding the boot image relocations. |
| 432 | size_t data_bimg_rel_ro_size_; |
| 433 | |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 434 | // The start of the required .bss section. |
| 435 | size_t bss_start_; |
| 436 | |
| 437 | // The size of the required .bss section holding the DexCache data and GC roots. |
Vladimir Marko | 5c42c29 | 2015-02-25 12:02:49 +0000 | [diff] [blame] | 438 | size_t bss_size_; |
| 439 | |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 440 | // The offset of the methods in .bss section. |
| 441 | size_t bss_methods_offset_; |
| 442 | |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 443 | // The offset of the GC roots in .bss section. |
| 444 | size_t bss_roots_offset_; |
| 445 | |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 446 | // Map for allocating .data.bimg.rel.ro entries. Indexed by the boot image offset of the |
| 447 | // relocation. The value is the assigned offset within the .data.bimg.rel.ro section. |
| 448 | SafeMap<uint32_t, size_t> data_bimg_rel_ro_entries_; |
| 449 | |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 450 | // Map for recording references to ArtMethod entries in .bss. |
| 451 | SafeMap<const DexFile*, BitVector> bss_method_entry_references_; |
| 452 | |
Vladimir Marko | f3c52b4 | 2017-11-17 17:32:12 +0000 | [diff] [blame] | 453 | // Map for recording references to GcRoot<mirror::Class> entries in .bss. |
| 454 | SafeMap<const DexFile*, BitVector> bss_type_entry_references_; |
| 455 | |
| 456 | // Map for recording references to GcRoot<mirror::String> entries in .bss. |
| 457 | SafeMap<const DexFile*, BitVector> bss_string_entry_references_; |
| 458 | |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 459 | // Map for allocating ArtMethod entries in .bss. Indexed by MethodReference for the target |
| 460 | // method in the dex file with the "method reference value comparator" for deduplication. |
| 461 | // The value is the target offset for patching, starting at `bss_start_ + bss_methods_offset_`. |
| 462 | SafeMap<MethodReference, size_t, MethodReferenceValueComparator> bss_method_entries_; |
| 463 | |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 464 | // Map for allocating Class entries in .bss. Indexed by TypeReference for the source |
| 465 | // type in the dex file with the "type value comparator" for deduplication. The value |
| 466 | // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`. |
| 467 | SafeMap<TypeReference, size_t, TypeReferenceValueComparator> bss_type_entries_; |
| 468 | |
Vladimir Marko | aad75c6 | 2016-10-03 08:46:48 +0000 | [diff] [blame] | 469 | // Map for allocating String entries in .bss. Indexed by StringReference for the source |
| 470 | // string in the dex file with the "string value comparator" for deduplication. The value |
| 471 | // is the target offset for patching, starting at `bss_start_ + bss_roots_offset_`. |
| 472 | SafeMap<StringReference, size_t, StringReferenceValueComparator> bss_string_entries_; |
| 473 | |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 474 | // Offset of the oat data from the start of the mmapped region of the elf file. |
| 475 | size_t oat_data_offset_; |
| 476 | |
Mathieu Chartier | 1b86849 | 2016-11-16 16:22:37 -0800 | [diff] [blame] | 477 | // Fake OatDexFiles to hold type lookup tables for the compiler. |
| 478 | std::vector<std::unique_ptr<art::OatDexFile>> type_lookup_table_oat_dex_files_; |
| 479 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 480 | // data to write |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 481 | std::unique_ptr<OatHeader> oat_header_; |
| 482 | dchecked_vector<OatDexFile> oat_dex_files_; |
Mathieu Chartier | 3957bff | 2017-07-16 13:55:27 -0700 | [diff] [blame] | 483 | dchecked_vector<OatClassHeader> oat_class_headers_; |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 484 | dchecked_vector<OatClass> oat_classes_; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 485 | std::unique_ptr<const std::vector<uint8_t>> jni_dlsym_lookup_; |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 486 | std::unique_ptr<const std::vector<uint8_t>> quick_generic_jni_trampoline_; |
| 487 | std::unique_ptr<const std::vector<uint8_t>> quick_imt_conflict_trampoline_; |
| 488 | std::unique_ptr<const std::vector<uint8_t>> quick_resolution_trampoline_; |
| 489 | std::unique_ptr<const std::vector<uint8_t>> quick_to_interpreter_bridge_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 490 | |
| 491 | // output stats |
David Brazdil | 7b49e6c | 2016-09-01 11:06:18 +0100 | [diff] [blame] | 492 | uint32_t size_vdex_header_; |
Nicolas Geoffray | f54e5df | 2016-12-01 10:45:08 +0000 | [diff] [blame] | 493 | uint32_t size_vdex_checksums_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 494 | uint32_t size_dex_file_alignment_; |
| 495 | uint32_t size_executable_offset_alignment_; |
| 496 | uint32_t size_oat_header_; |
Andreas Gampe | 22f8e5c | 2014-07-09 11:38:21 -0700 | [diff] [blame] | 497 | uint32_t size_oat_header_key_value_store_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 498 | uint32_t size_dex_file_; |
David Brazdil | 5d5a36b | 2016-09-14 15:34:10 +0100 | [diff] [blame] | 499 | uint32_t size_verifier_deps_; |
| 500 | uint32_t size_verifier_deps_alignment_; |
Nicolas Geoffray | 4acefd3 | 2016-10-24 13:14:58 +0100 | [diff] [blame] | 501 | uint32_t size_quickening_info_; |
| 502 | uint32_t size_quickening_info_alignment_; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 503 | uint32_t size_interpreter_to_interpreter_bridge_; |
| 504 | uint32_t size_interpreter_to_compiled_code_bridge_; |
| 505 | uint32_t size_jni_dlsym_lookup_; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 506 | uint32_t size_quick_generic_jni_trampoline_; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 507 | uint32_t size_quick_imt_conflict_trampoline_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 508 | uint32_t size_quick_resolution_trampoline_; |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 509 | uint32_t size_quick_to_interpreter_bridge_; |
| 510 | uint32_t size_trampoline_alignment_; |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 511 | uint32_t size_method_header_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 512 | uint32_t size_code_; |
| 513 | uint32_t size_code_alignment_; |
Vladimir Marko | b066d43 | 2018-01-03 13:14:37 +0000 | [diff] [blame] | 514 | uint32_t size_data_bimg_rel_ro_; |
| 515 | uint32_t size_data_bimg_rel_ro_alignment_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 516 | uint32_t size_relative_call_thunks_; |
Vladimir Marko | c74658b | 2015-03-31 10:26:41 +0100 | [diff] [blame] | 517 | uint32_t size_misc_thunks_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 518 | uint32_t size_vmap_table_; |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 519 | uint32_t size_method_info_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 520 | uint32_t size_oat_dex_file_location_size_; |
| 521 | uint32_t size_oat_dex_file_location_data_; |
| 522 | uint32_t size_oat_dex_file_location_checksum_; |
| 523 | uint32_t size_oat_dex_file_offset_; |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 524 | uint32_t size_oat_dex_file_class_offsets_offset_; |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 525 | uint32_t size_oat_dex_file_lookup_table_offset_; |
Mathieu Chartier | 120aa28 | 2017-08-05 16:03:03 -0700 | [diff] [blame] | 526 | uint32_t size_oat_dex_file_dex_layout_sections_offset_; |
| 527 | uint32_t size_oat_dex_file_dex_layout_sections_; |
| 528 | uint32_t size_oat_dex_file_dex_layout_sections_alignment_; |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 529 | uint32_t size_oat_dex_file_method_bss_mapping_offset_; |
Vladimir Marko | f3c52b4 | 2017-11-17 17:32:12 +0000 | [diff] [blame] | 530 | uint32_t size_oat_dex_file_type_bss_mapping_offset_; |
| 531 | uint32_t size_oat_dex_file_string_bss_mapping_offset_; |
Vladimir Marko | 49b0f45 | 2015-12-10 13:49:19 +0000 | [diff] [blame] | 532 | uint32_t size_oat_lookup_table_alignment_; |
| 533 | uint32_t size_oat_lookup_table_; |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 534 | uint32_t size_oat_class_offsets_alignment_; |
| 535 | uint32_t size_oat_class_offsets_; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 536 | uint32_t size_oat_class_type_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 537 | uint32_t size_oat_class_status_; |
Brian Carlstrom | ba150c3 | 2013-08-27 17:31:03 -0700 | [diff] [blame] | 538 | uint32_t size_oat_class_method_bitmaps_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 539 | uint32_t size_oat_class_method_offsets_; |
Vladimir Marko | 0eb882b | 2017-05-15 13:39:18 +0100 | [diff] [blame] | 540 | uint32_t size_method_bss_mappings_; |
Vladimir Marko | f3c52b4 | 2017-11-17 17:32:12 +0000 | [diff] [blame] | 541 | uint32_t size_type_bss_mappings_; |
| 542 | uint32_t size_string_bss_mappings_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 543 | |
Vladimir Marko | 944da60 | 2016-02-19 12:27:55 +0000 | [diff] [blame] | 544 | // The helper for processing relative patches is external so that we can patch across oat files. |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 545 | MultiOatRelativePatcher* relative_patcher_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 546 | |
David Srbecky | f898087 | 2015-05-22 17:04:47 +0100 | [diff] [blame] | 547 | // The locations of absolute patches relative to the start of the executable section. |
Vladimir Marko | 9bdf108 | 2016-01-21 12:15:52 +0000 | [diff] [blame] | 548 | dchecked_vector<uintptr_t> absolute_patch_locations_; |
Vladimir Marko | f4da675 | 2014-08-01 19:04:18 +0100 | [diff] [blame] | 549 | |
Jeff Hao | 608f2ce | 2016-10-19 11:17:11 -0700 | [diff] [blame] | 550 | // Profile info used to generate new layout of files. |
| 551 | ProfileCompilationInfo* profile_compilation_info_; |
| 552 | |
Mathieu Chartier | 603ccab | 2017-10-20 14:34:28 -0700 | [diff] [blame] | 553 | // Compact dex level that is generated. |
| 554 | CompactDexLevel compact_dex_level_; |
| 555 | |
Igor Murashkin | 545412b | 2017-08-17 15:26:54 -0700 | [diff] [blame] | 556 | using OrderedMethodList = std::vector<OrderedMethodData>; |
| 557 | |
| 558 | // List of compiled methods, sorted by the order defined in OrderedMethodData. |
| 559 | // Methods can be inserted more than once in case of duplicated methods. |
| 560 | // This pointer is only non-null after InitOatCodeDexFiles succeeds. |
| 561 | std::unique_ptr<OrderedMethodList> ordered_methods_; |
| 562 | |
Mathieu Chartier | c3a22aa | 2018-01-19 18:58:34 -0800 | [diff] [blame] | 563 | // Container of shared dex data. |
| 564 | std::unique_ptr<DexContainer> dex_container_; |
| 565 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 566 | DISALLOW_COPY_AND_ASSIGN(OatWriter); |
| 567 | }; |
| 568 | |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 569 | } // namespace linker |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 570 | } // namespace art |
| 571 | |
Vladimir Marko | 7452797 | 2016-11-29 15:57:32 +0000 | [diff] [blame] | 572 | #endif // ART_DEX2OAT_LINKER_OAT_WRITER_H_ |