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