Inline across dex files for compiler options' non-BCP methods
We are now able to inline across dexfiles for the dexfiles present
in compiler options' dex_files_for_oat_file_.
Note that the dex files in the Class Loader Context are not included
in this implementation since they will not have an OatDexFile.
Bug: 154012332
Test: ART tests
Change-Id: I7704217d936afecb66fc952c10529bb1030d6981
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 0b3c52c..7bdf70f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4114,6 +4114,26 @@
UNREACHABLE();
}
+ObjPtr<mirror::DexCache> ClassLinker::FindDexCache(Thread* self,
+ const OatDexFile* const oat_dex_file) {
+ ReaderMutexLock mu(self, *Locks::dex_lock_);
+ const DexCacheData* dex_cache_data = FindDexCacheDataLocked(oat_dex_file);
+ ObjPtr<mirror::DexCache> dex_cache = DecodeDexCacheLocked(self, dex_cache_data);
+ if (dex_cache != nullptr) {
+ return dex_cache;
+ }
+ // Failure, dump diagnostic and abort.
+ for (const auto& entry : dex_caches_) {
+ const DexCacheData& data = entry.second;
+ if (DecodeDexCacheLocked(self, &data) != nullptr) {
+ LOG(FATAL_WITHOUT_ABORT) << "Registered dex file " << entry.first->GetLocation();
+ }
+ }
+ LOG(FATAL) << "Failed to find DexCache for OatDexFile " << oat_dex_file->GetDexFileLocation()
+ << " " << &oat_dex_file;
+ UNREACHABLE();
+}
+
ClassTable* ClassLinker::FindClassTable(Thread* self, ObjPtr<mirror::DexCache> dex_cache) {
const DexFile* dex_file = dex_cache->GetDexFile();
DCHECK(dex_file != nullptr);
@@ -4130,6 +4150,17 @@
return nullptr;
}
+const ClassLinker::DexCacheData* ClassLinker::FindDexCacheDataLocked(
+ const OatDexFile* const oat_dex_file) {
+ // DexFiles are not guaranteed to have an non-null OatDexFile*. If we pass a nullptr as parameter,
+ // we might not get back the DexCacheData we are expecting.
+ DCHECK_NE(oat_dex_file, nullptr);
+ auto it = std::find_if(dex_caches_.begin(), dex_caches_.end(), [oat_dex_file](const auto& entry) {
+ return entry.first->GetOatDexFile() == oat_dex_file;
+ });
+ return it != dex_caches_.end() ? &it->second : nullptr;
+}
+
const ClassLinker::DexCacheData* ClassLinker::FindDexCacheDataLocked(const DexFile& dex_file) {
auto it = dex_caches_.find(&dex_file);
return it != dex_caches_.end() ? &it->second : nullptr;