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