From 14567fd24894a56070f891b1b8810cdcf51d0254 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 28 Jan 2016 20:33:36 -0800 Subject: [PATCH] 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 --- compiler/image_writer.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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; -- 2.11.0