From: Mathieu Chartier Date: Fri, 29 Jan 2016 04:33:36 +0000 (-0800) Subject: Clean up UpdateOatFile for app images X-Git-Tag: android-x86-7.1-r1~424^2~81^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=14567fd24894a56070f891b1b8810cdcf51d0254;p=android-x86%2Fart.git Clean up UpdateOatFile for app images Check that for the there is only one oat file name for the app image case. Avoid calling GetOatElfInformation unless necessary. Bug: 22858531 Change-Id: I88d258a1cc2823956ecc4fca9a6f7b2d3c4b986e --- diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 8b7fbf691..60dfcfb50 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -2276,10 +2276,10 @@ const ImageWriter::ImageInfo& ImageWriter::GetImageInfo(size_t index) const { void ImageWriter::UpdateOatFile(File* oat_file, const char* oat_filename) { DCHECK(oat_file != nullptr); - size_t oat_loaded_size = 0; - size_t oat_data_offset = 0; - ElfWriter::GetOatElfInformation(oat_file, &oat_loaded_size, &oat_data_offset); - + if (compile_app_image_) { + CHECK_EQ(oat_filenames_.size(), 1u) << "App image should have no next image."; + return; + } ImageInfo& cur_image_info = GetImageInfo(oat_filename); // Update the oat_offset of the next image info. @@ -2288,6 +2288,9 @@ void ImageWriter::UpdateOatFile(File* oat_file, const char* oat_filename) { it++; if (it != oat_filenames_.end()) { + size_t oat_loaded_size = 0; + size_t oat_data_offset = 0; + ElfWriter::GetOatElfInformation(oat_file, &oat_loaded_size, &oat_data_offset); // There is a following one. ImageInfo& next_image_info = GetImageInfo(*it); next_image_info.oat_offset_ = cur_image_info.oat_offset_ + oat_loaded_size;