Skip profiling if the dex file is fully compiled
The OatFile does not store the original dex location that was used to
compile the file. So in order to get the oat file for a given code path
we need to iterate over the inner oat dex files and check against them.
Also, we used to pass the unfiltered code_paths set to the saver which
would make the filtering useless. This fixes the parameter passing as
well.
Bug: 27893309
(cherry picked from commit 7506423b2b9ea13fc5fa9711ab0106977876a5a2)
Change-Id: I99388dee40f2d0e70f970b3f5c6a4171a7e97c0e
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 9894353..9ab0072 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -74,6 +74,20 @@
compare.release();
}
+const OatFile* OatFileManager::FindOpenedOatFileFromDexLocation(
+ const std::string& dex_base_location) const {
+ ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
+ for (const std::unique_ptr<const OatFile>& oat_file : oat_files_) {
+ const std::vector<const OatDexFile*>& oat_dex_files = oat_file->GetOatDexFiles();
+ for (const OatDexFile* oat_dex_file : oat_dex_files) {
+ if (DexFile::GetBaseLocation(oat_dex_file->GetDexFileLocation()) == dex_base_location) {
+ return oat_file.get();
+ }
+ }
+ }
+ return nullptr;
+}
+
const OatFile* OatFileManager::FindOpenedOatFileFromOatLocation(const std::string& oat_location)
const {
ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);