diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/class_linker.cc | 43 | ||||
| -rw-r--r-- | src/class_linker.h | 3 | ||||
| -rw-r--r-- | src/dex2oat.cc | 4 | ||||
| -rw-r--r-- | src/oatdump.cc | 1 |
4 files changed, 32 insertions, 19 deletions
diff --git a/src/class_linker.cc b/src/class_linker.cc index b3858953d6..1355cbf382 100644 --- a/src/class_linker.cc +++ b/src/class_linker.cc @@ -589,7 +589,7 @@ bool ClassLinker::GenerateOatFile(const std::string& dex_filename, const char* dex_file_option = dex_file_option_string.c_str(); std::string oat_fd_option_string("--oat-fd="); - oat_fd_option_string += oat_fd; + StringAppendF(&oat_fd_option_string, "%d", oat_fd); const char* oat_fd_option = oat_fd_option_string.c_str(); std::string oat_name_option_string("--oat-name="); @@ -629,6 +629,16 @@ bool ClassLinker::GenerateOatFile(const std::string& dex_filename, return true; } +void ClassLinker::RegisterOatFile(const OatFile& oat_file) { + MutexLock mu(dex_lock_); + RegisterOatFileLocked(oat_file); +} + +void ClassLinker::RegisterOatFileLocked(const OatFile& oat_file) { + dex_lock_.AssertHeld(); + oat_files_.push_back(&oat_file); +} + OatFile* ClassLinker::OpenOat(const Space* space) { MutexLock mu(dex_lock_); const Runtime* runtime = Runtime::Current(); @@ -648,12 +658,12 @@ OatFile* ClassLinker::OpenOat(const Space* space) { uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); uint32_t image_oat_checksum = image_header.GetOatChecksum(); if (oat_checksum != image_oat_checksum) { - LOG(ERROR) << "Failed to match oat filechecksum " << std::hex << oat_checksum + LOG(ERROR) << "Failed to match oat file checksum " << std::hex << oat_checksum << " to expected oat checksum " << std::hex << oat_checksum << " in image"; return NULL; } - oat_files_.push_back(oat_file); + RegisterOatFileLocked(*oat_file); VLOG(startup) << "ClassLinker::OpenOat exiting"; return oat_file; } @@ -717,19 +727,24 @@ class LockedFd { const OatFile* ClassLinker::FindOatFileForDexFile(const DexFile& dex_file) { MutexLock mu(dex_lock_); - const OatFile* oat_file = FindOpenedOatFileForDexFile(dex_file); - if (oat_file != NULL) { - return oat_file; + const OatFile* open_oat_file = FindOpenedOatFileForDexFile(dex_file); + if (open_oat_file != NULL) { + return open_oat_file; } std::string oat_filename(OatFile::DexFilenameToOatFilename(dex_file.GetLocation())); + open_oat_file = FindOpenedOatFileFromOatLocation(oat_filename); + if (open_oat_file != NULL) { + return open_oat_file; + } + while (true) { - oat_file = FindOatFileFromOatLocation(oat_filename); - if (oat_file != NULL) { + UniquePtr<const OatFile> oat_file(FindOatFileFromOatLocation(oat_filename)); + if (oat_file.get() != NULL) { const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation()); if (dex_file.GetHeader().checksum_ == oat_dex_file->GetDexFileChecksum()) { - oat_files_.push_back(oat_file); - return oat_file; + RegisterOatFileLocked(*oat_file.get()); + return oat_file.release(); } LOG(WARNING) << ".oat file " << oat_file->GetLocation() << " checksum mismatch with " << dex_file.GetLocation() << " --- regenerating"; @@ -796,12 +811,7 @@ const OatFile* ClassLinker::FindOpenedOatFileFromOatLocation(const std::string& } const OatFile* ClassLinker::FindOatFileFromOatLocation(const std::string& oat_location) { - const OatFile* oat_file = FindOpenedOatFileFromOatLocation(oat_location); - if (oat_file != NULL) { - return oat_file; - } - - oat_file = OatFile::Open(oat_location, "", NULL); + const OatFile* oat_file = OatFile::Open(oat_location, "", NULL); if (oat_file == NULL) { if (oat_location.empty() || oat_location[0] != '/') { LOG(ERROR) << "Failed to open oat file from " << oat_location; @@ -822,7 +832,6 @@ const OatFile* ClassLinker::FindOatFileFromOatLocation(const std::string& oat_lo } CHECK(oat_file != NULL) << oat_location; - oat_files_.push_back(oat_file); return oat_file; } diff --git a/src/class_linker.h b/src/class_linker.h index 2c94a93613..7d94e952c9 100644 --- a/src/class_linker.h +++ b/src/class_linker.h @@ -230,6 +230,8 @@ class ClassLinker { void RegisterDexFile(const DexFile& dex_file); void RegisterDexFile(const DexFile& dex_file, SirtRef<DexCache>& dex_cache); + void RegisterOatFile(const OatFile& oat_file); + const std::vector<const DexFile*>& GetBootClassPath() { return boot_class_path_; } @@ -337,6 +339,7 @@ class ClassLinker { void RegisterDexFileLocked(const DexFile& dex_file, SirtRef<DexCache>& dex_cache); bool IsDexFileRegisteredLocked(const DexFile& dex_file) const; + void RegisterOatFileLocked(const OatFile& oat_file); bool InitializeClass(Class* klass, bool can_run_clinit); bool WaitForInitializeClass(Class* klass, Thread* self, ObjectLock& lock); diff --git a/src/dex2oat.cc b/src/dex2oat.cc index 35494cb0ac..2781aae78d 100644 --- a/src/dex2oat.cc +++ b/src/dex2oat.cc @@ -387,7 +387,7 @@ int dex2oat(int argc, char** argv) { } else if (option.starts_with("--zip-fd=")) { const char* zip_fd_str = option.substr(strlen("--zip-fd=")).data(); if (!parse_int(zip_fd_str, &zip_fd)) { - fprintf(stderr, "could not parse --zip-fd argument %s as integer\n", zip_fd_str); + fprintf(stderr, "could not parse --zip-fd argument '%s' as an integer\n", zip_fd_str); usage(); } } else if (option.starts_with("--zip-name=")) { @@ -397,7 +397,7 @@ int dex2oat(int argc, char** argv) { } else if (option.starts_with("--oat-fd=")) { const char* oat_fd_str = option.substr(strlen("--oat-fd=")).data(); if (!parse_int(oat_fd_str, &oat_fd)) { - fprintf(stderr, "could not parse --oat-fd argument %s as integer\n", oat_fd_str); + fprintf(stderr, "could not parse --oat-fd argument '%s' as an integer\n", oat_fd_str); usage(); } } else if (option.starts_with("--oat-name=")) { diff --git a/src/oatdump.cc b/src/oatdump.cc index a6648524ed..dd46896b12 100644 --- a/src/oatdump.cc +++ b/src/oatdump.cc @@ -274,6 +274,7 @@ class ImageDump { os << "\n"; os << std::flush; + class_linker->RegisterOatFile(*oat_file); OatDump::Dump(oat_location, host_prefix, os, *oat_file); } |