Add OatFileManager
Takes over a large amount of functionality from the class linker.
Changed OatFile to loading the same OatFile multiple times. This is
required for unloading OatFiles and moving dex caches to BSS since
these require a different OatFile for each dex cache and class
loader.
Bug: 22720414
Change-Id: I0321096723a294dc72949f21e66da82727b512fc
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9fb21a8..7a1f0af 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -115,6 +115,7 @@
#include "native/sun_misc_Unsafe.h"
#include "native_bridge_art_interface.h"
#include "oat_file.h"
+#include "oat_file_manager.h"
#include "os.h"
#include "parsed_options.h"
#include "profiler.h"
@@ -281,6 +282,7 @@
delete monitor_list_;
delete monitor_pool_;
delete class_linker_;
+ oat_file_manager_.reset();
delete heap_;
delete intern_table_;
delete java_vm_;
@@ -698,7 +700,7 @@
}
bool Runtime::IsDebuggable() const {
- const OatFile* oat_file = GetClassLinker()->GetPrimaryOatFile();
+ const OatFile* oat_file = GetOatFileManager().GetPrimaryOatFile();
return oat_file != nullptr && oat_file->IsDebuggable();
}
@@ -756,9 +758,9 @@
if (elf_file.get() == nullptr) {
return false;
}
- std::unique_ptr<OatFile> oat_file(OatFile::OpenWithElfFile(elf_file.release(), oat_location,
- nullptr, &error_msg));
- if (oat_file.get() == nullptr) {
+ std::unique_ptr<const OatFile> oat_file(
+ OatFile::OpenWithElfFile(elf_file.release(), oat_location, nullptr, &error_msg));
+ if (oat_file == nullptr) {
LOG(INFO) << "Unable to use '" << oat_filename << "' because " << error_msg;
return false;
}
@@ -775,7 +777,7 @@
dex_files->push_back(std::move(dex_file));
}
}
- Runtime::Current()->GetClassLinker()->RegisterOatFile(oat_file.release());
+ Runtime::Current()->GetOatFileManager().RegisterOatFile(std::move(oat_file));
return true;
}
@@ -831,6 +833,8 @@
QuasiAtomic::Startup();
+ oat_file_manager_.reset(new OatFileManager);
+
Monitor::Init(runtime_options.GetOrDefault(Opt::LockProfThreshold),
runtime_options.GetOrDefault(Opt::HookIsSensitiveThread));