Rewrite OatFileManager::OpenDexFilesFromOat.
- Remove obsolete option -Xno-dex-file-fallback
- Only load an oat file when class loader context matches.
- Remove obsolete duplicate class check code.
Bug: 132357300
Bug: 156250899
Change-Id: I78e645806e0de2f35ce2614285f1a7cbc705484c
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index f374883..9c169e6 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -305,8 +305,8 @@
return true;
}
-bool OatFileAssistant::HasOriginalDexFiles() {
- ScopedTrace trace("HasOriginalDexFiles");
+bool OatFileAssistant::HasDexFiles() {
+ ScopedTrace trace("HasDexFiles");
// Ensure GetRequiredDexChecksums has been run so that
// has_original_dex_files_ is initialized. We don't care about the result of
// GetRequiredDexChecksums.
@@ -633,20 +633,7 @@
if (!result) {
VLOG(oat) << "Failed to verify checksums of oat file " << oat_file.GetLocation()
<< " error: " << error_msg;
-
- if (HasOriginalDexFiles()) {
- return false;
- }
-
- // If there is no original dex file to fall back to, grudgingly accept
- // the oat file. This could technically lead to crashes, but there's no
- // way we could find a better oat file to use for this dex location,
- // and it's better than being stuck in a boot loop with no way out.
- // The problem will hopefully resolve itself the next time the runtime
- // starts up.
- LOG(WARNING) << "Dex location " << dex_location_ << " does not seem to include dex file. "
- << "Allow oat file use. This is potentially dangerous.";
- return true;
+ return false;
}
// This checksum has been validated, so save it.
@@ -683,13 +670,6 @@
return odex_;
}
- // The oat file is not usable and the odex file is not up to date.
- // However we have access to the original dex file which means we can make
- // the oat location up to date.
- if (HasOriginalDexFiles()) {
- return oat_;
- }
-
// We got into the worst situation here:
// - the oat location is not usable
// - the prebuild odex location is not up to date
@@ -822,10 +802,10 @@
}
}
- if (oat_file_assistant_->HasOriginalDexFiles()) {
+ if (oat_file_assistant_->HasDexFiles()) {
return kDex2OatFromScratch;
} else {
- // Otherwise there is nothing we can do, even if we want to.
+ // No dex file, there is nothing we need to do.
return kNoDexOptNeeded;
}
}
@@ -969,27 +949,6 @@
return ReleaseFile();
}
- VLOG(oat) << "Oat File Assistant: No relocated oat file found,"
- << " attempting to fall back to interpreting oat file instead.";
-
- switch (Status()) {
- case kOatBootImageOutOfDate:
- // OutOfDate may be either a mismatched image, or a missing image.
- if (oat_file_assistant_->HasOriginalDexFiles()) {
- // If there are original dex files, it is better to use them (to avoid a potential
- // quickening mismatch because the boot image changed).
- break;
- }
- // If we do not accept the oat file, we may not have access to dex bytecode at all. Grudgingly
- // go forward.
- FALLTHROUGH_INTENDED;
-
- case kOatUpToDate:
- case kOatCannotOpen:
- case kOatDexOutOfDate:
- break;
- }
-
return std::unique_ptr<OatFile>();
}
@@ -1030,11 +989,8 @@
case kOatBootImageOutOfDate:
FALLTHROUGH_INTENDED;
case kOatDexOutOfDate:
- if (oat_file_assistant.HasOriginalDexFiles()) {
- *out_compilation_filter = "run-from-apk-fallback";
- } else {
- *out_compilation_filter = "run-from-vdex-fallback";
- }
+ DCHECK(oat_file_assistant.HasDexFiles());
+ *out_compilation_filter = "run-from-apk-fallback";
return;
}
LOG(FATAL) << "Unreachable";