diff options
| author | 2015-11-09 11:16:49 -0800 | |
|---|---|---|
| committer | 2016-01-22 15:01:55 -0800 | |
| commit | f7fd970244f143b1abb956e29794c446e4d57f46 (patch) | |
| tree | aac1f57ac70747957f609bb46305dfeca87645a1 /runtime/oat_file_assistant.cc | |
| parent | 95005291d8ebdd1d2ac58ffc5181fef4fbbf2383 (diff) | |
Load app images
Support in-place patching of the app image based on boot image
location and app oat location. Only loads for art run test so far
since we do not automatically generate app images for app installs.
N5 maps launch time (~200 runs):
Before: 930ms
After: 878.18ms
After + image class table: 864.57ms
TODO:
Oatdump support.
Store class loaders as class roots in image.
Bug: 22858531
Change-Id: I9cbc645645e62ea2ed1ad8e139e91af7d88514c1
Diffstat (limited to 'runtime/oat_file_assistant.cc')
| -rw-r--r-- | runtime/oat_file_assistant.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc index d6b08684b9..2bd5c76c00 100644 --- a/runtime/oat_file_assistant.cc +++ b/runtime/oat_file_assistant.cc @@ -38,6 +38,7 @@ #include "os.h" #include "profiler.h" #include "runtime.h" +#include "scoped_thread_state_change.h" #include "ScopedFd.h" #include "utils.h" @@ -326,6 +327,17 @@ bool OatFileAssistant::OdexFileIsUpToDate() { return cached_odex_file_is_up_to_date_; } +std::string OatFileAssistant::ArtFileName(const OatFile* oat_file) const { + const std::string oat_file_location = oat_file->GetLocation(); + // Replace extension with .art + const size_t last_ext = oat_file_location.find_last_of('.'); + if (last_ext == std::string::npos) { + LOG(ERROR) << "No extension in oat file " << oat_file_location; + return std::string(); + } + return oat_file_location.substr(0, last_ext) + ".art"; +} + const std::string* OatFileAssistant::OatFileName() { if (!cached_oat_file_name_attempted_) { cached_oat_file_name_attempted_ = true; @@ -1003,5 +1015,22 @@ ProfileFile* OatFileAssistant::GetOldProfile() { return old_profile_load_succeeded_ ? &cached_old_profile_ : nullptr; } +gc::space::ImageSpace* OatFileAssistant::OpenImageSpace(const OatFile* oat_file) { + DCHECK(oat_file != nullptr); + std::string art_file = ArtFileName(oat_file); + if (art_file.empty()) { + return nullptr; + } + std::string error_msg; + ScopedObjectAccess soa(Thread::Current()); + gc::space::ImageSpace* ret = gc::space::ImageSpace::CreateFromAppImage(art_file.c_str(), + oat_file, + &error_msg); + if (ret == nullptr) { + LOG(INFO) << "Failed to open app image " << art_file.c_str() << " " << error_msg; + } + return ret; +} + } // namespace art |