blob: bdc714663271aa32d58f4026429cec7001200359 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_IMAGE_WRITER_H_
18#define ART_COMPILER_IMAGE_WRITER_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
20#include <stdint.h>
Evgenii Stepanov1e133742015-05-20 12:30:59 -070021#include "base/memory_tool.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070022
23#include <cstddef>
Ian Rogers700a4022014-05-19 16:49:03 -070024#include <memory>
Brian Carlstrom7940e442013-07-12 13:46:57 -070025#include <set>
Mathieu Chartier496577f2016-09-20 15:33:31 -070026#include <stack>
Brian Carlstrom7940e442013-07-12 13:46:57 -070027#include <string>
Igor Murashkinf5b4c502014-11-14 15:01:59 -080028#include <ostream>
Brian Carlstrom7940e442013-07-12 13:46:57 -070029
Alex Lightdba61482016-12-21 08:20:29 -080030#include "art_method.h"
Vladimir Marko80afd022015-05-19 18:08:00 +010031#include "base/bit_utils.h"
Vladimir Marko944da602016-02-19 12:27:55 +000032#include "base/dchecked_vector.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070033#include "base/enums.h"
Alex Lighte64300b2015-12-15 15:02:47 -080034#include "base/length_prefixed_array.h"
Igor Murashkin46774762014-10-22 11:37:02 -070035#include "base/macros.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070036#include "driver/compiler_driver.h"
Mathieu Chartierfd04b6f2014-11-14 19:34:18 -080037#include "gc/space/space.h"
Mathieu Chartierceb07b32015-12-10 09:33:21 -080038#include "image.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070039#include "lock_word.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070040#include "mem_map.h"
41#include "oat_file.h"
42#include "mirror/dex_cache.h"
43#include "os.h"
44#include "safe_map.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070045#include "utils.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070046
47namespace art {
Mathieu Chartierda5b28a2015-11-05 08:03:47 -080048namespace gc {
49namespace space {
50class ImageSpace;
51} // namespace space
52} // namespace gc
Brian Carlstrom7940e442013-07-12 13:46:57 -070053
Vladimir Marko8d6768d2017-03-14 10:13:21 +000054namespace mirror {
55class ClassLoader;
56} // namespace mirror
57
Vladimir Markoc5798bf2016-12-09 10:20:54 +000058class ClassLoaderVisitor;
Mathieu Chartier1f47b672016-01-07 16:29:01 -080059class ClassTable;
Vladimir Marko8d6768d2017-03-14 10:13:21 +000060class ImtConflictTable;
Mathieu Chartier1f47b672016-01-07 16:29:01 -080061
Mathieu Chartierfbc31082016-01-24 11:59:56 -080062static constexpr int kInvalidFd = -1;
Mathieu Chartiera90c7722015-10-29 15:41:36 -070063
Brian Carlstrom7940e442013-07-12 13:46:57 -070064// Write a Space built during compilation for use during execution.
Igor Murashkin46774762014-10-22 11:37:02 -070065class ImageWriter FINAL {
Brian Carlstrom7940e442013-07-12 13:46:57 -070066 public:
Mathieu Chartierda5b28a2015-11-05 08:03:47 -080067 ImageWriter(const CompilerDriver& compiler_driver,
68 uintptr_t image_begin,
69 bool compile_pic,
Mathieu Chartierceb07b32015-12-10 09:33:21 -080070 bool compile_app_image,
Jeff Haodcdc85b2015-12-04 14:06:18 -080071 ImageHeader::StorageMode image_storage_mode,
Vladimir Marko944da602016-02-19 12:27:55 +000072 const std::vector<const char*>& oat_filenames,
73 const std::unordered_map<const DexFile*, size_t>& dex_file_oat_index_map);
Brian Carlstrom7940e442013-07-12 13:46:57 -070074
Vladimir Markof4da6752014-08-01 19:04:18 +010075 bool PrepareImageAddressSpace();
76
77 bool IsImageAddressSpaceReady() const {
Vladimir Marko944da602016-02-19 12:27:55 +000078 DCHECK(!image_infos_.empty());
79 for (const ImageInfo& image_info : image_infos_) {
Jeff Haodcdc85b2015-12-04 14:06:18 -080080 if (image_info.image_roots_address_ == 0u) {
81 return false;
82 }
83 }
Vladimir Marko944da602016-02-19 12:27:55 +000084 return true;
Vladimir Markof4da6752014-08-01 19:04:18 +010085 }
86
Vladimir Marko8d6768d2017-03-14 10:13:21 +000087 ObjPtr<mirror::ClassLoader> GetClassLoader() {
88 CHECK_EQ(class_loaders_.size(), compile_app_image_ ? 1u : 0u);
89 return compile_app_image_ ? *class_loaders_.begin() : nullptr;
90 }
91
Mathieu Chartiere401d142015-04-22 13:56:20 -070092 template <typename T>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070093 T* GetImageAddress(T* object) const REQUIRES_SHARED(Locks::mutator_lock_) {
Jeff Haodcdc85b2015-12-04 14:06:18 -080094 if (object == nullptr || IsInBootImage(object)) {
95 return object;
96 } else {
Vladimir Marko944da602016-02-19 12:27:55 +000097 size_t oat_index = GetOatIndex(object);
98 const ImageInfo& image_info = GetImageInfo(oat_index);
Jeff Haodcdc85b2015-12-04 14:06:18 -080099 return reinterpret_cast<T*>(image_info.image_begin_ + GetImageOffset(object));
100 }
Vladimir Markof4da6752014-08-01 19:04:18 +0100101 }
102
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700103 ArtMethod* GetImageMethodAddress(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700104
Vladimir Marko05792b92015-08-03 11:56:49 +0100105 template <typename PtrType>
106 PtrType GetDexCacheArrayElementImageAddress(const DexFile* dex_file, uint32_t offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700107 const REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko944da602016-02-19 12:27:55 +0000108 auto oat_it = dex_file_oat_index_map_.find(dex_file);
109 DCHECK(oat_it != dex_file_oat_index_map_.end());
110 const ImageInfo& image_info = GetImageInfo(oat_it->second);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800111 auto it = image_info.dex_cache_array_starts_.find(dex_file);
112 DCHECK(it != image_info.dex_cache_array_starts_.end());
Vladimir Marko05792b92015-08-03 11:56:49 +0100113 return reinterpret_cast<PtrType>(
Jeff Haodcdc85b2015-12-04 14:06:18 -0800114 image_info.image_begin_ + image_info.bin_slot_offsets_[kBinDexCacheArray] +
115 it->second + offset);
Vladimir Marko20f85592015-03-19 10:07:02 +0000116 }
117
Vladimir Marko944da602016-02-19 12:27:55 +0000118 size_t GetOatFileOffset(size_t oat_index) const {
119 return GetImageInfo(oat_index).oat_offset_;
120 }
121
122 const uint8_t* GetOatFileBegin(size_t oat_index) const {
123 return GetImageInfo(oat_index).oat_file_begin_;
124 }
Vladimir Markof4da6752014-08-01 19:04:18 +0100125
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800126 // If image_fd is not kInvalidFd, then we use that for the image file. Otherwise we open
Jeff Haodcdc85b2015-12-04 14:06:18 -0800127 // the names in image_filenames.
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800128 // If oat_fd is not kInvalidFd, then we use that for the oat file. Otherwise we open
129 // the names in oat_filenames.
Mathieu Chartiera90c7722015-10-29 15:41:36 -0700130 bool Write(int image_fd,
Jeff Haodcdc85b2015-12-04 14:06:18 -0800131 const std::vector<const char*>& image_filenames,
Vladimir Marko944da602016-02-19 12:27:55 +0000132 const std::vector<const char*>& oat_filenames)
Mathieu Chartier90443472015-07-16 20:32:27 -0700133 REQUIRES(!Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700134
Vladimir Marko944da602016-02-19 12:27:55 +0000135 uintptr_t GetOatDataBegin(size_t oat_index) {
136 return reinterpret_cast<uintptr_t>(GetImageInfo(oat_index).oat_data_begin_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700137 }
138
Vladimir Marko944da602016-02-19 12:27:55 +0000139 // Get the index of the oat file containing the dex file.
140 //
141 // This "oat_index" is used to retrieve information about the the memory layout
142 // of the oat file and its associated image file, needed for link-time patching
143 // of references to the image or across oat files.
144 size_t GetOatIndexForDexFile(const DexFile* dex_file) const;
145
146 // Get the index of the oat file containing the dex file served by the dex cache.
Mathieu Chartierc4f39252016-10-05 18:32:08 -0700147 size_t GetOatIndexForDexCache(ObjPtr<mirror::DexCache> dex_cache) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700148 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800149
Vladimir Marko944da602016-02-19 12:27:55 +0000150 // Update the oat layout for the given oat file.
151 // This will make the oat_offset for the next oat file valid.
152 void UpdateOatFileLayout(size_t oat_index,
153 size_t oat_loaded_size,
154 size_t oat_data_offset,
155 size_t oat_data_size);
156 // Update information about the oat header, i.e. checksum and trampoline offsets.
157 void UpdateOatFileHeader(size_t oat_index, const OatHeader& oat_header);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800158
Brian Carlstrom7940e442013-07-12 13:46:57 -0700159 private:
Mathieu Chartier496577f2016-09-20 15:33:31 -0700160 using WorkStack = std::stack<std::pair<mirror::Object*, size_t>>;
161
Brian Carlstrom7940e442013-07-12 13:46:57 -0700162 bool AllocMemory();
163
Mathieu Chartier31e89252013-08-28 11:29:12 -0700164 // Mark the objects defined in this space in the given live bitmap.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700165 void RecordImageAllocations() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier31e89252013-08-28 11:29:12 -0700166
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800167 // Classify different kinds of bins that objects end up getting packed into during image writing.
Mathieu Chartier2ba04ea2016-04-08 19:01:05 -0700168 // Ordered from dirtiest to cleanest (until ArtMethods).
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800169 enum Bin {
Mathieu Chartier2ba04ea2016-04-08 19:01:05 -0700170 kBinMiscDirty, // Dex caches, object locks, etc...
171 kBinClassVerified, // Class verified, but initializers haven't been run
Mathieu Chartierd464fa12016-04-08 18:54:36 -0700172 // Unknown mix of clean/dirty:
173 kBinRegular,
Mathieu Chartier2ba04ea2016-04-08 19:01:05 -0700174 kBinClassInitialized, // Class initializers have been run
Mathieu Chartierd464fa12016-04-08 18:54:36 -0700175 // All classes get their own bins since their fields often dirty
176 kBinClassInitializedFinalStatics, // Class initializers have been run, no non-final statics
Mathieu Chartier2ba04ea2016-04-08 19:01:05 -0700177 // Likely-clean:
178 kBinString, // [String] Almost always immutable (except for obj header).
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800179 // Add more bins here if we add more segregation code.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700180 // Non mirror fields must be below.
181 // ArtFields should be always clean.
Mathieu Chartierc7853442015-03-27 14:35:38 -0700182 kBinArtField,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700183 // If the class is initialized, then the ArtMethods are probably clean.
184 kBinArtMethodClean,
185 // ArtMethods may be dirty if the class has native methods or a declaring class that isn't
186 // initialized.
187 kBinArtMethodDirty,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000188 // IMT (clean)
189 kBinImTable,
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700190 // Conflict tables (clean).
191 kBinIMTConflictTable,
192 // Runtime methods (always clean, do not have a length prefix array).
193 kBinRuntimeMethod,
Vladimir Marko05792b92015-08-03 11:56:49 +0100194 // Dex cache arrays have a special slot for PC-relative addressing. Since they are
195 // huge, and as such their dirtiness is not important for the clean/dirty separation,
196 // we arbitrarily keep them at the end of the native data.
197 kBinDexCacheArray, // Arrays belonging to dex cache.
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800198 kBinSize,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700199 // Number of bins which are for mirror objects.
200 kBinMirrorCount = kBinArtField,
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800201 };
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800202 friend std::ostream& operator<<(std::ostream& stream, const Bin& bin);
203
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700204 enum NativeObjectRelocationType {
205 kNativeObjectRelocationTypeArtField,
206 kNativeObjectRelocationTypeArtFieldArray,
207 kNativeObjectRelocationTypeArtMethodClean,
208 kNativeObjectRelocationTypeArtMethodArrayClean,
209 kNativeObjectRelocationTypeArtMethodDirty,
210 kNativeObjectRelocationTypeArtMethodArrayDirty,
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700211 kNativeObjectRelocationTypeRuntimeMethod,
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000212 kNativeObjectRelocationTypeIMTable,
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700213 kNativeObjectRelocationTypeIMTConflictTable,
Vladimir Marko05792b92015-08-03 11:56:49 +0100214 kNativeObjectRelocationTypeDexCacheArray,
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700215 };
216 friend std::ostream& operator<<(std::ostream& stream, const NativeObjectRelocationType& type);
217
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800218 enum OatAddress {
219 kOatAddressInterpreterToInterpreterBridge,
220 kOatAddressInterpreterToCompiledCodeBridge,
221 kOatAddressJNIDlsymLookup,
222 kOatAddressQuickGenericJNITrampoline,
223 kOatAddressQuickIMTConflictTrampoline,
224 kOatAddressQuickResolutionTrampoline,
225 kOatAddressQuickToInterpreterBridge,
226 // Number of elements in the enum.
227 kOatAddressCount,
228 };
229 friend std::ostream& operator<<(std::ostream& stream, const OatAddress& oat_address);
230
Vladimir Marko80afd022015-05-19 18:08:00 +0100231 static constexpr size_t kBinBits = MinimumBitsToStore<uint32_t>(kBinMirrorCount - 1);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800232 // uint32 = typeof(lockword_)
Mathieu Chartiere401d142015-04-22 13:56:20 -0700233 // Subtract read barrier bits since we want these to remain 0, or else it may result in DCHECK
234 // failures due to invalid read barrier bits during object field reads.
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700235 static const size_t kBinShift = BitSizeOf<uint32_t>() - kBinBits - LockWord::kGCStateSize;
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800236 // 111000.....0
Mathieu Chartiere401d142015-04-22 13:56:20 -0700237 static const size_t kBinMask = ((static_cast<size_t>(1) << kBinBits) - 1) << kBinShift;
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800238
239 // We use the lock word to store the bin # and bin index of the object in the image.
240 //
241 // The struct size must be exactly sizeof(LockWord), currently 32-bits, since this will end up
242 // stored in the lock word bit-for-bit when object forwarding addresses are being calculated.
243 struct BinSlot {
244 explicit BinSlot(uint32_t lockword);
245 BinSlot(Bin bin, uint32_t index);
246
247 // The bin an object belongs to, i.e. regular, class/verified, class/initialized, etc.
248 Bin GetBin() const;
249 // The offset in bytes from the beginning of the bin. Aligned to object size.
250 uint32_t GetIndex() const;
251 // Pack into a single uint32_t, for storing into a lock word.
Mathieu Chartierd39645e2015-06-09 17:50:29 -0700252 uint32_t Uint32Value() const { return lockword_; }
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800253 // Comparison operator for map support
254 bool operator<(const BinSlot& other) const { return lockword_ < other.lockword_; }
255
256 private:
257 // Must be the same size as LockWord, any larger and we would truncate the data.
258 const uint32_t lockword_;
259 };
260
Jeff Haodcdc85b2015-12-04 14:06:18 -0800261 struct ImageInfo {
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800262 ImageInfo();
263 ImageInfo(ImageInfo&&) = default;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800264
Mathieu Chartiera06ba052016-01-06 13:51:52 -0800265 // Create the image sections into the out sections variable, returns the size of the image
266 // excluding the bitmap.
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700267 size_t CreateImageSections(ImageSection* out_sections) const;
Mathieu Chartiera06ba052016-01-06 13:51:52 -0800268
Jeff Haodcdc85b2015-12-04 14:06:18 -0800269 std::unique_ptr<MemMap> image_; // Memory mapped for generating the image.
270
271 // Target begin of this image. Notes: It is not valid to write here, this is the address
272 // of the target image, not necessarily where image_ is mapped. The address is only valid
273 // after layouting (otherwise null).
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800274 uint8_t* image_begin_ = nullptr;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800275
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800276 // Offset to the free space in image_, initially size of image header.
277 size_t image_end_ = RoundUp(sizeof(ImageHeader), kObjectAlignment);
278 uint32_t image_roots_address_ = 0; // The image roots address in the image.
279 size_t image_offset_ = 0; // Offset of this image from the start of the first image.
Jeff Haodcdc85b2015-12-04 14:06:18 -0800280
281 // Image size is the *address space* covered by this image. As the live bitmap is aligned
282 // to the page size, the live bitmap will cover more address space than necessary. But live
283 // bitmaps may not overlap, so an image has a "shadow," which is accounted for in the size.
284 // The next image may only start at image_begin_ + image_size_ (which is guaranteed to be
285 // page-aligned).
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800286 size_t image_size_ = 0;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800287
288 // Oat data.
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800289 // Offset of the oat file for this image from start of oat files. This is
290 // valid when the previous oat file has been written.
291 size_t oat_offset_ = 0;
Vladimir Marko944da602016-02-19 12:27:55 +0000292 // Layout of the loaded ELF file containing the oat file, valid after UpdateOatFileLayout().
293 const uint8_t* oat_file_begin_ = nullptr;
294 size_t oat_loaded_size_ = 0;
295 const uint8_t* oat_data_begin_ = nullptr;
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800296 size_t oat_size_ = 0; // Size of the corresponding oat data.
Vladimir Marko944da602016-02-19 12:27:55 +0000297 // The oat header checksum, valid after UpdateOatFileHeader().
298 uint32_t oat_checksum_ = 0u;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800299
300 // Image bitmap which lets us know where the objects inside of the image reside.
301 std::unique_ptr<gc::accounting::ContinuousSpaceBitmap> image_bitmap_;
302
303 // The start offsets of the dex cache arrays.
304 SafeMap<const DexFile*, size_t> dex_cache_array_starts_;
305
306 // Offset from oat_data_begin_ to the stubs.
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800307 uint32_t oat_address_offsets_[kOatAddressCount] = {};
Jeff Haodcdc85b2015-12-04 14:06:18 -0800308
309 // Bin slot tracking for dirty object packing.
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800310 size_t bin_slot_sizes_[kBinSize] = {}; // Number of bytes in a bin.
311 size_t bin_slot_offsets_[kBinSize] = {}; // Number of bytes in previous bins.
312 size_t bin_slot_count_[kBinSize] = {}; // Number of objects in a bin.
313
314 // Cached size of the intern table for when we allocate memory.
315 size_t intern_table_bytes_ = 0;
316
Mathieu Chartier1f47b672016-01-07 16:29:01 -0800317 // Number of image class table bytes.
318 size_t class_table_bytes_ = 0;
319
320 // Intern table associated with this image for serialization.
Mathieu Chartierea0831f2015-12-29 13:17:37 -0800321 std::unique_ptr<InternTable> intern_table_;
Mathieu Chartier1f47b672016-01-07 16:29:01 -0800322
323 // Class table associated with this image for serialization.
324 std::unique_ptr<ClassTable> class_table_;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800325 };
326
Mathieu Chartier31e89252013-08-28 11:29:12 -0700327 // We use the lock word to store the offset of the object in the image.
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800328 void AssignImageOffset(mirror::Object* object, BinSlot bin_slot)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700329 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierd39645e2015-06-09 17:50:29 -0700330 void SetImageOffset(mirror::Object* object, size_t offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700331 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700332 bool IsImageOffsetAssigned(mirror::Object* object) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700333 REQUIRES_SHARED(Locks::mutator_lock_);
334 size_t GetImageOffset(mirror::Object* object) const REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700335 void UpdateImageOffset(mirror::Object* obj, uintptr_t offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700336 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700337
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700338 void PrepareDexCacheArraySlots() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier496577f2016-09-20 15:33:31 -0700339 void AssignImageBinSlot(mirror::Object* object, size_t oat_index)
340 REQUIRES_SHARED(Locks::mutator_lock_);
341 mirror::Object* TryAssignBinSlot(WorkStack& work_stack, mirror::Object* obj, size_t oat_index)
342 REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800343 void SetImageBinSlot(mirror::Object* object, BinSlot bin_slot)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700344 REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800345 bool IsImageBinSlotAssigned(mirror::Object* object) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700346 REQUIRES_SHARED(Locks::mutator_lock_);
347 BinSlot GetImageBinSlot(mirror::Object* object) const REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800348
Mathieu Chartierc4f39252016-10-05 18:32:08 -0700349 void AddDexCacheArrayRelocation(void* array, size_t offset, ObjPtr<mirror::DexCache> dex_cache)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700350 REQUIRES_SHARED(Locks::mutator_lock_);
351 void AddMethodPointerArray(mirror::PointerArray* arr) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700352
Alex Lighta59dd802014-07-02 16:28:08 -0700353 static void* GetImageAddressCallback(void* writer, mirror::Object* obj)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700354 REQUIRES_SHARED(Locks::mutator_lock_) {
Alex Lighta59dd802014-07-02 16:28:08 -0700355 return reinterpret_cast<ImageWriter*>(writer)->GetImageAddress(obj);
356 }
357
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700358 mirror::Object* GetLocalAddress(mirror::Object* object) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700359 REQUIRES_SHARED(Locks::mutator_lock_) {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700360 size_t offset = GetImageOffset(object);
Vladimir Marko944da602016-02-19 12:27:55 +0000361 size_t oat_index = GetOatIndex(object);
362 const ImageInfo& image_info = GetImageInfo(oat_index);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800363 uint8_t* dst = image_info.image_->Begin() + offset;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700364 return reinterpret_cast<mirror::Object*>(dst);
365 }
366
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800367 // Returns the address in the boot image if we are compiling the app image.
368 const uint8_t* GetOatAddress(OatAddress type) const;
369
Jeff Haodcdc85b2015-12-04 14:06:18 -0800370 const uint8_t* GetOatAddressForOffset(uint32_t offset, const ImageInfo& image_info) const {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700371 // With Quick, code is within the OatFile, as there are all in one
Jeff Haodcdc85b2015-12-04 14:06:18 -0800372 // .o ELF object. But interpret it as signed.
373 DCHECK_LE(static_cast<int32_t>(offset), static_cast<int32_t>(image_info.oat_size_));
374 DCHECK(image_info.oat_data_begin_ != nullptr);
375 return offset == 0u ? nullptr : image_info.oat_data_begin_ + static_cast<int32_t>(offset);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700376 }
377
Brian Carlstrom7940e442013-07-12 13:46:57 -0700378 // Returns true if the class was in the original requested image classes list.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700379 bool KeepClass(mirror::Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700380
381 // Debug aid that list of requested image classes.
382 void DumpImageClasses();
383
384 // Preinitializes some otherwise lazy fields (such as Class name) to avoid runtime image dirtying.
385 void ComputeLazyFieldsForImageClasses()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700386 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700387
Vladimir Markoc5798bf2016-12-09 10:20:54 +0000388 // Visit all class loaders.
389 void VisitClassLoaders(ClassLoaderVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
390
Brian Carlstrom7940e442013-07-12 13:46:57 -0700391 // Remove unwanted classes from various roots.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700392 void PruneNonImageClasses() REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700393
394 // Verify unwanted classes removed.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700395 void CheckNonImageClassesRemoved() REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700396 static void CheckNonImageClassesRemovedCallback(mirror::Object* obj, void* arg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700397 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700398
399 // Lays out where the image objects will be at runtime.
Vladimir Markof4da6752014-08-01 19:04:18 +0100400 void CalculateNewObjectOffsets()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700401 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier496577f2016-09-20 15:33:31 -0700402 void ProcessWorkStack(WorkStack* work_stack)
403 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko944da602016-02-19 12:27:55 +0000404 void CreateHeader(size_t oat_index)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700405 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko944da602016-02-19 12:27:55 +0000406 mirror::ObjectArray<mirror::Object>* CreateImageRoots(size_t oat_index) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700407 REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800408 void CalculateObjectBinSlots(mirror::Object* obj)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700409 REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800410 void UnbinObjectsIntoOffset(mirror::Object* obj)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700411 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700412
Mathieu Chartier496577f2016-09-20 15:33:31 -0700413 static void EnsureBinSlotAssignedCallback(mirror::Object* obj, void* arg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700414 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier496577f2016-09-20 15:33:31 -0700415 static void DeflateMonitorCallback(mirror::Object* obj, void* arg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700416 REQUIRES_SHARED(Locks::mutator_lock_);
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800417 static void UnbinObjectsIntoOffsetCallback(mirror::Object* obj, void* arg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700418 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700419
420 // Creates the contiguous image in memory and adjusts pointers.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700421 void CopyAndFixupNativeData(size_t oat_index) REQUIRES_SHARED(Locks::mutator_lock_);
422 void CopyAndFixupObjects() REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700423 static void CopyAndFixupObjectsCallback(mirror::Object* obj, void* arg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700424 REQUIRES_SHARED(Locks::mutator_lock_);
425 void CopyAndFixupObject(mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800426 void CopyAndFixupMethod(ArtMethod* orig, ArtMethod* copy, const ImageInfo& image_info)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700427 REQUIRES_SHARED(Locks::mutator_lock_);
428 void CopyAndFixupImTable(ImTable* orig, ImTable* copy) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700429 void CopyAndFixupImtConflictTable(ImtConflictTable* orig, ImtConflictTable* copy)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700430 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -0700431 void FixupClass(mirror::Class* orig, mirror::Class* copy)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700432 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800433 void FixupObject(mirror::Object* orig, mirror::Object* copy)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700434 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko05792b92015-08-03 11:56:49 +0100435 void FixupDexCache(mirror::DexCache* orig_dex_cache, mirror::DexCache* copy_dex_cache)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700436 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera808bac2015-11-05 16:33:15 -0800437 void FixupPointerArray(mirror::Object* dst,
438 mirror::PointerArray* arr,
439 mirror::Class* klass,
440 Bin array_type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700441 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700442
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700443 // Get quick code for non-resolution/imt_conflict/abstract method.
Jeff Haodcdc85b2015-12-04 14:06:18 -0800444 const uint8_t* GetQuickCode(ArtMethod* method,
445 const ImageInfo& image_info,
446 bool* quick_is_interpreted)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700447 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700448
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800449 // Calculate the sum total of the bin slot sizes in [0, up_to). Defaults to all bins.
Jeff Haodcdc85b2015-12-04 14:06:18 -0800450 size_t GetBinSizeSum(ImageInfo& image_info, Bin up_to = kBinSize) const;
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800451
Mathieu Chartiere401d142015-04-22 13:56:20 -0700452 // Return true if a method is likely to be dirtied at runtime.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700453 bool WillMethodBeDirty(ArtMethod* m) const REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700454
455 // Assign the offset for an ArtMethod.
Jeff Haodcdc85b2015-12-04 14:06:18 -0800456 void AssignMethodOffset(ArtMethod* method,
457 NativeObjectRelocationType type,
Vladimir Marko944da602016-02-19 12:27:55 +0000458 size_t oat_index)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700459 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700460
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700461 void TryAssignImTableOffset(ImTable* imt, size_t oat_index) REQUIRES_SHARED(Locks::mutator_lock_);
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000462
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700463 // Assign the offset for an IMT conflict table. Does nothing if the table already has a native
464 // relocation.
465 void TryAssignConflictTableOffset(ImtConflictTable* table, size_t oat_index)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700466 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700467
Mathieu Chartiera808bac2015-11-05 16:33:15 -0800468 // Return true if klass is loaded by the boot class loader but not in the boot image.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700469 bool IsBootClassLoaderNonImageClass(mirror::Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800470
Mathieu Chartier901e0702016-02-19 13:42:48 -0800471 // Return true if klass depends on a boot class loader non image class. We want to prune these
472 // classes since we do not want any boot class loader classes in the image. This means that
Mathieu Chartiera808bac2015-11-05 16:33:15 -0800473 // we also cannot have any classes which refer to these boot class loader non image classes.
Mathieu Chartier901e0702016-02-19 13:42:48 -0800474 // PruneAppImageClass also prunes if klass depends on a non-image class according to the compiler
475 // driver.
476 bool PruneAppImageClass(mirror::Class* klass)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700477 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800478
Mathieu Chartier945c1c12015-11-24 15:37:12 -0800479 // early_exit is true if we had a cyclic dependency anywhere down the chain.
Mathieu Chartier901e0702016-02-19 13:42:48 -0800480 bool PruneAppImageClassInternal(mirror::Class* klass,
481 bool* early_exit,
482 std::unordered_set<mirror::Class*>* visited)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700483 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier945c1c12015-11-24 15:37:12 -0800484
Mathieu Chartier496577f2016-09-20 15:33:31 -0700485 bool IsMultiImage() const {
486 return image_infos_.size() > 1;
487 }
488
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700489 static Bin BinTypeForNativeRelocationType(NativeObjectRelocationType type);
490
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700491 uintptr_t NativeOffsetInImage(void* obj) REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko05792b92015-08-03 11:56:49 +0100492
Mathieu Chartier4b00d342015-11-13 10:42:08 -0800493 // Location of where the object will be when the image is loaded at runtime.
Vladimir Marko05792b92015-08-03 11:56:49 +0100494 template <typename T>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700495 T* NativeLocationInImage(T* obj) REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe245ee002014-12-04 21:25:04 -0800496
Mathieu Chartier4b00d342015-11-13 10:42:08 -0800497 // Location of where the temporary copy of the object currently is.
498 template <typename T>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700499 T* NativeCopyLocation(T* obj, mirror::DexCache* dex_cache) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4b00d342015-11-13 10:42:08 -0800500
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800501 // Return true of obj is inside of the boot image space. This may only return true if we are
502 // compiling an app image.
503 bool IsInBootImage(const void* obj) const;
504
505 // Return true if ptr is within the boot oat file.
506 bool IsInBootOatFile(const void* ptr) const;
507
Vladimir Marko944da602016-02-19 12:27:55 +0000508 // Get the index of the oat file associated with the object.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700509 size_t GetOatIndex(mirror::Object* object) const REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Haodcdc85b2015-12-04 14:06:18 -0800510
Vladimir Marko944da602016-02-19 12:27:55 +0000511 // The oat index for shared data in multi-image and all data in single-image compilation.
512 size_t GetDefaultOatIndex() const {
513 return 0u;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800514 }
515
Vladimir Marko944da602016-02-19 12:27:55 +0000516 ImageInfo& GetImageInfo(size_t oat_index) {
517 return image_infos_[oat_index];
518 }
519
520 const ImageInfo& GetImageInfo(size_t oat_index) const {
521 return image_infos_[oat_index];
522 }
Jeff Haodcdc85b2015-12-04 14:06:18 -0800523
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800524 // Find an already strong interned string in the other images or in the boot image. Used to
525 // remove duplicates in the multi image and app image case.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700526 mirror::String* FindInternedString(mirror::String* string) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800527
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700528 // Return true if there already exists a native allocation for an object.
529 bool NativeRelocationAssigned(void* ptr) const;
530
Brian Carlstrom7940e442013-07-12 13:46:57 -0700531 const CompilerDriver& compiler_driver_;
532
Jeff Haodcdc85b2015-12-04 14:06:18 -0800533 // Beginning target image address for the first image.
534 uint8_t* global_image_begin_;
Vladimir Markof4da6752014-08-01 19:04:18 +0100535
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800536 // Offset from image_begin_ to where the first object is in image_.
537 size_t image_objects_offset_begin_;
538
Mathieu Chartiere401d142015-04-22 13:56:20 -0700539 // Pointer arrays that need to be updated. Since these are only some int and long arrays, we need
540 // to keep track. These include vtable arrays, iftable arrays, and dex caches.
541 std::unordered_map<mirror::PointerArray*, Bin> pointer_arrays_;
542
Mathieu Chartierd39645e2015-06-09 17:50:29 -0700543 // Saved hash codes. We use these to restore lockwords which were temporarily used to have
544 // forwarding addresses as well as copying over hash codes.
545 std::unordered_map<mirror::Object*, uint32_t> saved_hashcode_map_;
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800546
Mathieu Chartier496577f2016-09-20 15:33:31 -0700547 // Oat index map for objects.
548 std::unordered_map<mirror::Object*, uint32_t> oat_index_map_;
549
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800550 // Boolean flags.
Igor Murashkin46774762014-10-22 11:37:02 -0700551 const bool compile_pic_;
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800552 const bool compile_app_image_;
553
Mathieu Chartier2d721012014-11-10 11:08:06 -0800554 // Size of pointers on the target architecture.
Andreas Gampe542451c2016-07-26 09:02:02 -0700555 PointerSize target_ptr_size_;
Mathieu Chartier2d721012014-11-10 11:08:06 -0800556
Vladimir Marko944da602016-02-19 12:27:55 +0000557 // Image data indexed by the oat file index.
558 dchecked_vector<ImageInfo> image_infos_;
Igor Murashkinf5b4c502014-11-14 15:01:59 -0800559
Mathieu Chartiere401d142015-04-22 13:56:20 -0700560 // ArtField, ArtMethod relocating map. These are allocated as array of structs but we want to
561 // have one entry per art field for convenience. ArtFields are placed right after the end of the
562 // image objects (aka sum of bin_slot_sizes_). ArtMethods are placed right after the ArtFields.
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700563 struct NativeObjectRelocation {
Vladimir Marko944da602016-02-19 12:27:55 +0000564 size_t oat_index;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700565 uintptr_t offset;
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700566 NativeObjectRelocationType type;
567
568 bool IsArtMethodRelocation() const {
569 return type == kNativeObjectRelocationTypeArtMethodClean ||
Mathieu Chartiere42888f2016-04-14 10:49:19 -0700570 type == kNativeObjectRelocationTypeArtMethodDirty ||
571 type == kNativeObjectRelocationTypeRuntimeMethod;
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700572 }
Mathieu Chartiere401d142015-04-22 13:56:20 -0700573 };
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700574 std::unordered_map<void*, NativeObjectRelocation> native_object_relocations_;
Mathieu Chartierc7853442015-03-27 14:35:38 -0700575
Mathieu Chartiere401d142015-04-22 13:56:20 -0700576 // Runtime ArtMethods which aren't reachable from any Class but need to be copied into the image.
577 ArtMethod* image_methods_[ImageHeader::kImageMethodsCount];
578
579 // Counters for measurements, used for logging only.
580 uint64_t dirty_methods_;
581 uint64_t clean_methods_;
Andreas Gampe245ee002014-12-04 21:25:04 -0800582
Mathieu Chartiera808bac2015-11-05 16:33:15 -0800583 // Prune class memoization table to speed up ContainsBootClassLoaderNonImageClass.
Mathieu Chartierda5b28a2015-11-05 08:03:47 -0800584 std::unordered_map<mirror::Class*, bool> prune_class_memo_;
585
Mathieu Chartier67ad20e2015-12-09 15:41:09 -0800586 // Class loaders with a class table to write out. There should only be one class loader because
587 // dex2oat loads the dex files to be compiled into a single class loader. For the boot image,
588 // null is a valid entry.
Mathieu Chartier208a5cb2015-12-02 15:44:07 -0800589 std::unordered_set<mirror::ClassLoader*> class_loaders_;
590
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800591 // Which mode the image is stored as, see image.h
592 const ImageHeader::StorageMode image_storage_mode_;
593
Vladimir Marko944da602016-02-19 12:27:55 +0000594 // The file names of oat files.
595 const std::vector<const char*>& oat_filenames_;
596
597 // Map of dex files to the indexes of oat files that they were compiled into.
598 const std::unordered_map<const DexFile*, size_t>& dex_file_oat_index_map_;
Jeff Haodcdc85b2015-12-04 14:06:18 -0800599
Vladimir Markoad06b982016-11-17 16:38:59 +0000600 class ComputeLazyFieldsForClassesVisitor;
601 class FixupClassVisitor;
602 class FixupRootVisitor;
603 class FixupVisitor;
Mathieu Chartier496577f2016-09-20 15:33:31 -0700604 class GetRootsVisitor;
Vladimir Markoad06b982016-11-17 16:38:59 +0000605 class NativeLocationVisitor;
Vladimir Markoc5798bf2016-12-09 10:20:54 +0000606 class PruneClassesVisitor;
607 class PruneClassLoaderClassesVisitor;
Mathieu Chartier496577f2016-09-20 15:33:31 -0700608 class VisitReferencesVisitor;
Vladimir Markoad06b982016-11-17 16:38:59 +0000609
Mathieu Chartierb7ea3ac2014-03-24 16:54:46 -0700610 DISALLOW_COPY_AND_ASSIGN(ImageWriter);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700611};
612
613} // namespace art
614
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700615#endif // ART_COMPILER_IMAGE_WRITER_H_