From ed010d4eebdf12f327856debc2c73694777cccda Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 2 Mar 2018 09:32:03 -0800 Subject: ART: Update dex-file fallback code Allow non-executable oat files when the boot image is out of date. (cherry picked from commit 9ea84d0bd33694162eb27d9d06bb687f8794a6a0) Bug: 73667005 Test: m test-art-host Merged-In: Ib04339bd87fa5e268d0c636c98df62ee72d613c5 Change-Id: Ib04339bd87fa5e268d0c636c98df62ee72d613c5 --- runtime/oat_file_assistant.cc | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'runtime/oat_file_assistant.cc') diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index 6bf05b77a8..c5569ff909 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -1261,18 +1261,33 @@ std::unique_ptr OatFileAssistant::OatFileInfo::ReleaseFileForUse() { return ReleaseFile(); } - if (Status() == kOatRelocationOutOfDate) { - // We are loading an oat file for runtime use that needs relocation. - // Reload the file non-executable to ensure that we interpret out of the - // dex code in the oat file rather than trying to execute the unrelocated - // compiled code. - oat_file_assistant_->load_executable_ = false; - Reset(); - if (IsUseable()) { - CHECK(!IsExecutable()); - return ReleaseFile(); - } + switch (Status()) { + case kOatBootImageOutOfDate: + if (oat_file_assistant_->HasOriginalDexFiles()) { + // If there are original dex files, it is better to use them. + break; + } + FALLTHROUGH_INTENDED; + + case kOatRelocationOutOfDate: + // We are loading an oat file for runtime use that needs relocation. + // Reload the file non-executable to ensure that we interpret out of the + // dex code in the oat file rather than trying to execute the unrelocated + // compiled code. + oat_file_assistant_->load_executable_ = false; + Reset(); + if (IsUseable()) { + CHECK(!IsExecutable()); + return ReleaseFile(); + } + break; + + case kOatUpToDate: + case kOatCannotOpen: + case kOatDexOutOfDate: + break; } + return std::unique_ptr(); } -- cgit v1.2.3-59-g8ed1b