diff options
| author | 2017-02-09 22:44:36 +0000 | |
|---|---|---|
| committer | 2017-02-09 22:44:36 +0000 | |
| commit | 9260b991fe2dff691936b3e5c8c6a84b104d1b9b (patch) | |
| tree | f5b2036706f0a0af75cfc35c147d00d3ff593529 | |
| parent | e4530079672682ff3900d84c08b666a6a899d973 (diff) | |
| parent | b18991b5d4c47e813874563916c5e017655d6f65 (diff) | |
Merge "Fix ownership of DexFile in profman"
| -rw-r--r-- | profman/profman.cc | 11 | ||||
| -rw-r--r-- | runtime/jit/profile_compilation_info.cc | 18 | ||||
| -rw-r--r-- | runtime/jit/profile_compilation_info.h | 3 |
3 files changed, 28 insertions, 4 deletions
diff --git a/profman/profman.cc b/profman/profman.cc index ffebb6a2ea..b0cbed1ef9 100644 --- a/profman/profman.cc +++ b/profman/profman.cc @@ -248,8 +248,11 @@ class ProfMan FINAL { return result; } - int DumpOneProfile(const std::string& banner, const std::string& filename, int fd, - const std::vector<const DexFile*>* dex_files, std::string* dump) { + int DumpOneProfile(const std::string& banner, + const std::string& filename, + int fd, + const std::vector<std::unique_ptr<const DexFile>>* dex_files, + std::string* dump) { if (!filename.empty()) { fd = open(filename.c_str(), O_RDWR); if (fd < 0) { @@ -277,7 +280,7 @@ class ProfMan FINAL { // Open apk/zip files and and read dex files. MemMap::Init(); // for ZipArchive::OpenFromFd - std::vector<const DexFile*> dex_files; + std::vector<std::unique_ptr<const DexFile>> dex_files; assert(dex_locations_.size() == apks_fd_.size()); static constexpr bool kVerifyChecksum = true; for (size_t i = 0; i < dex_locations_.size(); ++i) { @@ -293,7 +296,7 @@ class ProfMan FINAL { continue; } for (std::unique_ptr<const DexFile>& dex_file : dex_files_for_location) { - dex_files.push_back(dex_file.release()); + dex_files.emplace_back(std::move(dex_file)); } } diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc index 1405c40096..9ba2d1a355 100644 --- a/runtime/jit/profile_compilation_info.cc +++ b/runtime/jit/profile_compilation_info.cc @@ -597,6 +597,24 @@ uint32_t ProfileCompilationInfo::GetNumberOfResolvedClasses() const { return total; } +// Produce a non-owning vector from a vector. +template<typename T> +const std::vector<T*>* MakeNonOwningVector(const std::vector<std::unique_ptr<T>>* owning_vector) { + auto non_owning_vector = new std::vector<T*>(); + for (auto& element : *owning_vector) { + non_owning_vector->push_back(element.get()); + } + return non_owning_vector; +} + +std::string ProfileCompilationInfo::DumpInfo( + const std::vector<std::unique_ptr<const DexFile>>* dex_files, + bool print_full_dex_location) const { + std::unique_ptr<const std::vector<const DexFile*>> non_owning_dex_files( + MakeNonOwningVector(dex_files)); + return DumpInfo(non_owning_dex_files.get(), print_full_dex_location); +} + std::string ProfileCompilationInfo::DumpInfo(const std::vector<const DexFile*>* dex_files, bool print_full_dex_location) const { std::ostringstream os; diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h index f8061bcfd8..b1587c0070 100644 --- a/runtime/jit/profile_compilation_info.h +++ b/runtime/jit/profile_compilation_info.h @@ -17,6 +17,7 @@ #ifndef ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_ #define ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_ +#include <memory> #include <set> #include <vector> @@ -72,6 +73,8 @@ class ProfileCompilationInfo { // If dex_files is not null then the method indices will be resolved to their // names. // This is intended for testing and debugging. + std::string DumpInfo(const std::vector<std::unique_ptr<const DexFile>>* dex_files, + bool print_full_dex_location = true) const; std::string DumpInfo(const std::vector<const DexFile*>* dex_files, bool print_full_dex_location = true) const; |