ART: Update dex-file fallback code
Allow non-executable oat files when the boot image is out of
date.
Bug: 73667005
Test: m test-art-host
Change-Id: Ib04339bd87fa5e268d0c636c98df62ee72d613c5
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 6bf05b7..c5569ff 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -1261,18 +1261,33 @@
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<OatFile>();
}