Revert "ART: Conditionally remove loaded-oat-count check"
Bug: 128688902
Bug: 150032912
Test: boots
This reverts commit e912955b98cdc224f2f13455f592b63e96bf5634.
(cherry-picked from commit 3734c2822fe2dc8eaaedbc311f9828ce443b02e6)
Merged-In: I209489f69e4f2b02e7fa93090539575098a28025
Change-Id: I209489f69e4f2b02e7fa93090539575098a28025
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index c010082..c37b8bb 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -311,7 +311,7 @@
}
if ((runtime_flags & ONLY_USE_SYSTEM_OAT_FILES) != 0 || is_system_server) {
- runtime->GetOatFileManager().SetOnlyUseSystemOatFiles(!is_system_server);
+ runtime->GetOatFileManager().SetOnlyUseSystemOatFiles();
runtime_flags &= ~ONLY_USE_SYSTEM_OAT_FILES;
}
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 3839dca..22ebc73 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -1037,18 +1037,17 @@
}
}
-void OatFileManager::SetOnlyUseSystemOatFiles(bool assert_no_files_loaded) {
+void OatFileManager::SetOnlyUseSystemOatFiles() {
ReaderMutexLock mu(Thread::Current(), *Locks::oat_file_manager_lock_);
- if (assert_no_files_loaded) {
- // Make sure all files that were loaded up to this point are on /system. Skip the image
- // files.
- std::vector<const OatFile*> boot_vector = GetBootOatFiles();
- std::unordered_set<const OatFile*> boot_set(boot_vector.begin(), boot_vector.end());
+ // Make sure all files that were loaded up to this point are on /system.
+ // Skip the image files as they can encode locations that don't exist (eg not
+ // containing the arch in the path, or for JIT zygote /nonx/existent).
+ std::vector<const OatFile*> boot_vector = GetBootOatFiles();
+ std::unordered_set<const OatFile*> boot_set(boot_vector.begin(), boot_vector.end());
- for (const std::unique_ptr<const OatFile>& oat_file : oat_files_) {
- if (boot_set.find(oat_file.get()) == boot_set.end()) {
- CHECK(LocationIsOnSystem(oat_file->GetLocation().c_str())) << oat_file->GetLocation();
- }
+ for (const std::unique_ptr<const OatFile>& oat_file : oat_files_) {
+ if (boot_set.find(oat_file.get()) == boot_set.end()) {
+ CHECK(LocationIsOnSystem(oat_file->GetLocation().c_str())) << oat_file->GetLocation();
}
}
only_use_system_oat_files_ = true;
diff --git a/runtime/oat_file_manager.h b/runtime/oat_file_manager.h
index ef03f06..71eab16 100644
--- a/runtime/oat_file_manager.h
+++ b/runtime/oat_file_manager.h
@@ -120,7 +120,7 @@
void DumpForSigQuit(std::ostream& os);
- void SetOnlyUseSystemOatFiles(bool assert_no_files_loaded);
+ void SetOnlyUseSystemOatFiles();
// Spawn a background thread which verifies all classes in the given dex files.
void RunBackgroundVerification(const std::vector<const DexFile*>& dex_files,
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 3a94ef6..1a83372 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1785,7 +1785,7 @@
// Set OnlyUseSystemOatFiles only after boot classpath has been set up.
if (runtime_options.Exists(Opt::OnlyUseSystemOatFiles)) {
- oat_file_manager_->SetOnlyUseSystemOatFiles(/*assert_no_files_loaded=*/ true);
+ oat_file_manager_->SetOnlyUseSystemOatFiles();
}
return true;