diff options
| -rw-r--r-- | compiler/driver/compiler_driver_test.cc | 6 | ||||
| -rw-r--r-- | runtime/jit/offline_profiling_info.cc | 5 | ||||
| -rw-r--r-- | runtime/jit/offline_profiling_info.h | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 4c03e5ddfe..478588561f 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -249,9 +249,9 @@ class CompilerDriverProfileTest : public CompilerDriverTest { ProfileCompilationInfo info; for (const std::unique_ptr<const DexFile>& dex_file : dex_files) { - std::cout << std::string(dex_file->GetLocation()); - profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 1); - profile_info_.AddData(dex_file->GetLocation(), dex_file->GetLocationChecksum(), 2); + std::string key = ProfileCompilationInfo::GetProfileDexFileKey(dex_file->GetLocation()); + profile_info_.AddData(key, dex_file->GetLocationChecksum(), 1); + profile_info_.AddData(key, dex_file->GetLocationChecksum(), 2); } return &profile_info_; } diff --git a/runtime/jit/offline_profiling_info.cc b/runtime/jit/offline_profiling_info.cc index d0d3e705ef..0aff1f7ec3 100644 --- a/runtime/jit/offline_profiling_info.cc +++ b/runtime/jit/offline_profiling_info.cc @@ -37,13 +37,14 @@ namespace art { // Note: this is OK because we don't store profiles of different apps into the same file. // Apps with split apks don't cause trouble because each split has a different name and will not // collide with other entries. -static std::string GetProfileDexFileKey(const std::string& dex_location) { +std::string ProfileCompilationInfo::GetProfileDexFileKey(const std::string& dex_location) { DCHECK(!dex_location.empty()); size_t last_sep_index = dex_location.find_last_of('/'); if (last_sep_index == std::string::npos) { return dex_location; } else { - return dex_location.substr(last_sep_index); + DCHECK(last_sep_index < dex_location.size()); + return dex_location.substr(last_sep_index + 1); } } diff --git a/runtime/jit/offline_profiling_info.h b/runtime/jit/offline_profiling_info.h index ffd14335d7..c388c4a42f 100644 --- a/runtime/jit/offline_profiling_info.h +++ b/runtime/jit/offline_profiling_info.h @@ -66,6 +66,8 @@ class ProfileCompilationInfo { // For testing purposes. bool Equals(ProfileCompilationInfo& other); + // Exposed for testing purpose. + static std::string GetProfileDexFileKey(const std::string& dex_location); private: bool AddData(const std::string& dex_location, uint32_t checksum, uint16_t method_idx); |