summaryrefslogtreecommitdiff
path: root/runtime/oat/oat_file_assistant.h
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2025-02-14 06:17:42 -0800
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2025-02-14 06:17:42 -0800
commit7a1149b0e29a40dc88562775d76d70eb8c102510 (patch)
treeaced34a19d60367f8f43439262c286a544fff36c /runtime/oat/oat_file_assistant.h
parentb6c6f642fb40465fd3fbc457237d50d0e226da86 (diff)
parent3f48beac60b8d9eee6dca3fe3897730fb69731af (diff)
Refactor OatFileAssistant - Step 3. am: 1802832343 am: 3f48beac60
Original change: https://android-review.googlesource.com/c/platform/art/+/3475953 Change-Id: I9943aa8fb3e46438eccb11571db77578094a94cd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'runtime/oat/oat_file_assistant.h')
-rw-r--r--runtime/oat/oat_file_assistant.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/runtime/oat/oat_file_assistant.h b/runtime/oat/oat_file_assistant.h
index 4526843756..85021bea33 100644
--- a/runtime/oat/oat_file_assistant.h
+++ b/runtime/oat/oat_file_assistant.h
@@ -23,6 +23,7 @@
#include <sstream>
#include <string>
#include <string_view>
+#include <utility>
#include <variant>
#include "arch/instruction_set.h"
@@ -356,10 +357,11 @@ class OatFileAssistant {
// anonymous dex file(s) created by AnonymousDexVdexLocation.
EXPORT static bool IsAnonymousVdexBasename(const std::string& basename);
- bool ClassLoaderContextIsOkay(const OatFile& oat_file) const;
+ bool ClassLoaderContextIsOkay(const OatFile& oat_file, /*out*/ std::string* error_msg) const;
// Validates the boot class path checksum of an OatFile.
- EXPORT bool ValidateBootClassPathChecksums(const OatFile& oat_file);
+ EXPORT bool ValidateBootClassPathChecksums(const OatFile& oat_file,
+ /*out*/ std::string* error_msg);
// Validates the given bootclasspath and bootclasspath checksums found in an oat header.
static bool ValidateBootClassPathChecksums(OatFileAssistantContext* ofa_context,
@@ -393,7 +395,8 @@ class OatFileAssistant {
bool IsUseable();
// Returns the status of this oat file.
- OatStatus Status();
+ // Optionally, returns `error_msg` showing why the status is not `kOatUpToDate`.
+ OatStatus Status(/*out*/ std::string* error_msg = nullptr);
// Return the DexOptNeeded value for this oat file with respect to the given target compilation
// filter and dexopt trigger.
@@ -406,7 +409,8 @@ class OatFileAssistant {
// Returns the loaded file.
// Loads the file if needed. Returns null if the file failed to load.
// The caller shouldn't clean up or free the returned pointer.
- const OatFile* GetFile();
+ // Optionally, returns `error_msg` showing why the file failed to load.
+ const OatFile* GetFile(/*out*/ std::string* error_msg = nullptr);
// Returns true if the file is opened executable.
bool IsExecutable();
@@ -439,6 +443,8 @@ class OatFileAssistant {
bool CheckDisableCompactDex();
private:
+ std::unique_ptr<OatFile> LoadFile(std::string* error_msg) const;
+
// Returns true if the oat file is usable but at least one dexopt trigger is matched. This
// function should only be called if the oat file is usable.
bool ShouldRecompileForFilter(CompilerFilter::Filter target,
@@ -463,11 +469,13 @@ class OatFileAssistant {
int vdex_fd_ = -1;
bool use_fd_ = false;
- bool load_attempted_ = false;
- std::unique_ptr<OatFile> file_;
+ // A pair of the loaded file and the error message, if `GetFile` has been attempted.
+ // `std::nullopt` if `GetFile` has not been attempted.
+ std::optional<std::pair<std::unique_ptr<OatFile>, std::string>> file_ = std::nullopt;
- bool status_attempted_ = false;
- OatStatus status_ = OatStatus::kOatCannotOpen;
+ // A pair of the oat status and the error message, if `Status` has been attempted.
+ // `std::nullopt` if `Status` has not been attempted.
+ std::optional<std::pair<OatStatus, std::string>> status_ = std::nullopt;
// For debugging only.
// If this flag is set, the file has been released to the user and the
@@ -491,7 +499,7 @@ class OatFileAssistant {
// Return the status for a given opened oat file with respect to the dex
// location.
- OatStatus GivenOatFileStatus(const OatFile& file);
+ OatStatus GivenOatFileStatus(const OatFile& file, /*out*/ std::string* error_msg);
// Gets the dex checksum required for an up-to-date oat file.
// Returns cached result from GetMultiDexChecksum.