summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Hao <jeffhao@google.com> 2016-04-26 14:27:31 -0700
committer Jeff Hao <jeffhao@google.com> 2016-05-17 14:10:46 -0700
commitfbeb132d96b5957bd61620c35b0eb64f7a9a992b (patch)
treedfbdfdc9ac1c52ad2e49af8c681b00a5fb3d9b3a
parent8f2ea28b2504dcd86dc3bbcea4a5a800eede9f5b (diff)
Keep oat file unique pointers until they are no longer used.
Before, the unique pointer would be deleted before we were finished using the dex file we opened from the oat file. Bug: 28359191 (cherry-picked from commit a6d46161aea07ebd1cbd6ab78b2b323f940e9c1e) Change-Id: I737d17536967af48d8748bde2b266a82410830b7
-rw-r--r--dex2oat/dex2oat.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 58651060ce..cb274dcc09 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1348,7 +1348,10 @@ class Dex2Oat FINAL {
// Open dex files for class path.
const std::vector<std::string> class_path_locations =
GetClassPathLocations(runtime_->GetClassPathString());
- OpenClassPathFiles(class_path_locations, &class_path_files_, runtime_->GetInstructionSet());
+ OpenClassPathFiles(class_path_locations,
+ &class_path_files_,
+ &opened_oat_files_,
+ runtime_->GetInstructionSet());
// Store the classpath we have right now.
std::vector<const DexFile*> class_path_files = MakeNonOwningPointerVector(class_path_files_);
@@ -1971,11 +1974,14 @@ class Dex2Oat FINAL {
return parsed;
}
- // Opens requested class path files and appends them to opened_dex_files.
+ // Opens requested class path files and appends them to opened_dex_files. If the dex files have
+ // been stripped, this opens them from their oat files and appends them to opened_oat_files.
static void OpenClassPathFiles(const std::vector<std::string>& class_path_locations,
std::vector<std::unique_ptr<const DexFile>>* opened_dex_files,
+ std::vector<std::unique_ptr<OatFile>>* opened_oat_files,
InstructionSet isa) {
- DCHECK(opened_dex_files != nullptr) << "OpenClassPathFiles out-param is nullptr";
+ DCHECK(opened_dex_files != nullptr) << "OpenClassPathFiles dex out-param is nullptr";
+ DCHECK(opened_oat_files != nullptr) << "OpenClassPathFiles oat out-param is nullptr";
for (const std::string& location : class_path_locations) {
// Stop early if we detect the special shared library, which may be passed as the classpath
// for dex2oat when we want to skip the shared libraries check.
@@ -1994,6 +2000,7 @@ class Dex2Oat FINAL {
} else {
std::vector<std::unique_ptr<const DexFile>> oat_dex_files =
oat_file_assistant.LoadDexFiles(*oat_file, location.c_str());
+ opened_oat_files->push_back(std::move(oat_file));
opened_dex_files->insert(opened_dex_files->end(),
std::make_move_iterator(oat_dex_files.begin()),
std::make_move_iterator(oat_dex_files.end()));
@@ -2467,6 +2474,7 @@ class Dex2Oat FINAL {
std::unique_ptr<CompilerDriver> driver_;
std::vector<std::unique_ptr<MemMap>> opened_dex_files_maps_;
+ std::vector<std::unique_ptr<OatFile>> opened_oat_files_;
std::vector<std::unique_ptr<const DexFile>> opened_dex_files_;
std::vector<const DexFile*> no_inline_from_dex_files_;