diff options
author | 2024-12-24 09:03:35 +0000 | |
---|---|---|
committer | 2025-03-21 09:37:10 -0700 | |
commit | f1cf622ecc1a27d95236dd0ec1da0936182ecafd (patch) | |
tree | c1c78799a3a1b64ec9e0a31e3fc74d75311bd2f4 /runtime/oat/oat_file_assistant.cc | |
parent | 751ffe4a74b5b7aa11f8449ed5d48e5f1a23e0fa (diff) |
Support loading SDM files at runtime.
This is the last piece of platform support for Cloud Compilation.
Bug: 377474232
Test: m test-art-host-gtest-art_runtime_tests
Test: atest art_standalone_runtime_tests
Change-Id: I3a7c1774c75334e55e9c98610745707dfcec35a2
Diffstat (limited to 'runtime/oat/oat_file_assistant.cc')
-rw-r--r-- | runtime/oat/oat_file_assistant.cc | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/runtime/oat/oat_file_assistant.cc b/runtime/oat/oat_file_assistant.cc index 8df8459589..53f412908d 100644 --- a/runtime/oat/oat_file_assistant.cc +++ b/runtime/oat/oat_file_assistant.cc @@ -191,6 +191,12 @@ OatFileAssistant::OatFileAssistant(const char* dex_location, oat_file_name, /*is_oat_location=*/true, /*use_fd=*/false)); + info_list_.push_back( + std::make_unique<OatFileInfoBackedBySdm>(this, + GetSdmFilename(dex_location_, isa), + /*is_oat_location=*/true, + GetDmFilename(dex_location_), + GetSdcFilename(oat_file_name))); } if (!odex_file_name.empty()) { @@ -202,6 +208,12 @@ OatFileAssistant::OatFileAssistant(const char* dex_location, zip_fd, vdex_fd, oat_fd)); + info_list_.push_back( + std::make_unique<OatFileInfoBackedBySdm>(this, + GetSdmFilename(dex_location_, isa), + /*is_oat_location=*/false, + GetDmFilename(dex_location_), + GetSdcFilename(odex_file_name))); } // When there is no odex/oat available (e.g., they are both out of date), we look for a useable @@ -324,7 +336,8 @@ int OatFileAssistant::GetDexOptNeeded(CompilerFilter::Filter target_compiler_fil OatFileInfo& info = GetBestInfo(); DexOptNeeded dexopt_needed = info.GetDexOptNeeded( target_compiler_filter, GetDexOptTrigger(target_compiler_filter, profile_changed, downgrade)); - if (dexopt_needed != kNoDexOptNeeded && info.GetType() == OatFileType::kDm) { + if (dexopt_needed != kNoDexOptNeeded && + (info.GetType() == OatFileType::kDm || info.GetType() == OatFileType::kSdm)) { // The usable vdex file is in the DM file. This information cannot be encoded in the integer. // Return kDex2OatFromScratch so that neither the vdex in the "oat" location nor the vdex in the // "odex" location will be picked by installd. @@ -956,6 +969,10 @@ bool OatFileAssistant::OatFileInfoBackedByOat::FileExists() const { return use_fd_ || OatFileInfo::FileExists(); } +bool OatFileAssistant::OatFileInfoBackedBySdm::FileExists() const { + return OatFileInfo::FileExists() && OS::FileExists(sdc_filename_.c_str()); +} + bool OatFileAssistant::OatFileInfoBackedByVdex::FileExists() const { return use_fd_ || OatFileInfo::FileExists(); } @@ -1015,6 +1032,21 @@ std::unique_ptr<OatFile> OatFileAssistant::OatFileInfoBackedByOat::LoadFile( } } +std::unique_ptr<OatFile> OatFileAssistant::OatFileInfoBackedBySdm::LoadFile( + std::string* error_msg) const { + bool executable = oat_file_assistant_->load_executable_; + if (executable && oat_file_assistant_->only_load_trusted_executable_) { + executable = LocationIsTrusted(filename_, /*trust_art_apex_data_files=*/true); + } + + return std::unique_ptr<OatFile>(OatFile::OpenFromSdm(filename_, + sdc_filename_, + dm_filename_, + oat_file_assistant_->dex_location_, + executable, + error_msg)); +} + std::unique_ptr<OatFile> OatFileAssistant::OatFileInfoBackedByVdex::LoadFile( std::string* error_msg) const { // Check to see if there is a vdex file we can make use of. @@ -1289,7 +1321,13 @@ bool OatFileAssistant::ZipFileOnlyContainsUncompressedDex() { OatFileAssistant::Location OatFileAssistant::GetLocation(OatFileInfo& info) { if (info.IsUseable()) { - if (info.GetType() == OatFileType::kDm) { + if (info.GetType() == OatFileType::kSdm) { + if (info.IsOatLocation()) { + return kLocationSdmOat; + } else { + return kLocationSdmOdex; + } + } else if (info.GetType() == OatFileType::kDm) { return kLocationDm; } else if (info.IsOatLocation()) { return kLocationOat; |