Make explicit which methods retrieve info about *hot* methods

Rename some methods to better highlight that they refer to hot methods and not
to any method (e.g. a non-hot, startup methods).

Bug: 139884006
Test: m test-art-host

Change-Id: Ieb3a36c434104d1cde28ca18a5b335cc8a24e537
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 0922b42..d57b916 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -692,9 +692,8 @@
   }
 
   std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> offline_profile =
-      pci->GetMethod(caller_dex_file.GetLocation(),
-                     caller_dex_file.GetLocationChecksum(),
-                     caller_compilation_unit_.GetDexMethodIndex());
+      pci->GetHotMethodInfo(MethodReference(
+          &caller_dex_file, caller_compilation_unit_.GetDexMethodIndex()));
   if (offline_profile == nullptr) {
     return kInlineCacheNoData;  // no profile information for this invocation.
   }
diff --git a/libprofile/profile/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
index 1791610..42b90f3 100644
--- a/libprofile/profile/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -655,7 +655,7 @@
   }
 
   // Add inline caches.
-  InlineCacheMap* inline_cache = data->FindOrAddMethod(pmi.ref.index);
+  InlineCacheMap* inline_cache = data->FindOrAddHotMethod(pmi.ref.index);
   DCHECK(inline_cache != nullptr);
 
   for (const ProfileMethodInfo::ProfileInlineCache& cache : pmi.inline_caches) {
@@ -758,7 +758,7 @@
     READ_UINT(uint16_t, buffer, diff_with_last_method_index, error);
     uint16_t method_index = last_method_index + diff_with_last_method_index;
     last_method_index = method_index;
-    InlineCacheMap* inline_cache = data->FindOrAddMethod(method_index);
+    InlineCacheMap* inline_cache = data->FindOrAddHotMethod(method_index);
     if (inline_cache == nullptr) {
       return false;
     }
@@ -1477,7 +1477,7 @@
     // Merge the methods and the inline caches.
     for (const auto& other_method_it : other_dex_data->method_map) {
       uint16_t other_method_index = other_method_it.first;
-      InlineCacheMap* inline_cache = dex_data->FindOrAddMethod(other_method_index);
+      InlineCacheMap* inline_cache = dex_data->FindOrAddHotMethod(other_method_index);
       if (inline_cache == nullptr) {
         return false;
       }
@@ -1529,11 +1529,9 @@
 }
 
 
-std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> ProfileCompilationInfo::GetMethod(
-    const std::string& dex_location,
-    uint32_t dex_checksum,
-    uint16_t dex_method_index) const {
-  MethodHotness hotness(GetMethodHotness(dex_location, dex_checksum, dex_method_index));
+std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo>
+ProfileCompilationInfo::GetHotMethodInfo(const MethodReference& method_ref) const {
+  MethodHotness hotness(GetMethodHotness(method_ref));
   if (!hotness.IsHot()) {
     return nullptr;
   }
@@ -1949,7 +1947,7 @@
 }
 
 ProfileCompilationInfo::InlineCacheMap*
-ProfileCompilationInfo::DexFileData::FindOrAddMethod(uint16_t method_index) {
+ProfileCompilationInfo::DexFileData::FindOrAddHotMethod(uint16_t method_index) {
   if (method_index >= num_method_ids) {
     LOG(ERROR) << "Invalid method index " << method_index << ". num_method_ids=" << num_method_ids;
     return nullptr;
@@ -1969,7 +1967,7 @@
   SetMethodHotness(index, flags);
 
   if ((flags & MethodHotness::kFlagHot) != 0) {
-    ProfileCompilationInfo::InlineCacheMap* result = FindOrAddMethod(index);
+    ProfileCompilationInfo::InlineCacheMap* result = FindOrAddHotMethod(index);
     DCHECK(result != nullptr);
   }
   return true;
diff --git a/libprofile/profile/profile_compilation_info.h b/libprofile/profile/profile_compilation_info.h
index 3cd3bfa..250dfa0 100644
--- a/libprofile/profile/profile_compilation_info.h
+++ b/libprofile/profile/profile_compilation_info.h
@@ -369,13 +369,12 @@
   // Return true if the class's type is present in the profiling info.
   bool ContainsClass(const DexFile& dex_file, dex::TypeIndex type_idx) const;
 
-  // Return the method data for the given location and index from the profiling info.
+  // Return the hot method info for the given location and index from the profiling info.
   // If the method index is not found or the checksum doesn't match, null is returned.
   // Note: the inline cache map is a pointer to the map stored in the profile and
   // its allocation will go away if the profile goes out of scope.
-  std::unique_ptr<OfflineProfileMethodInfo> GetMethod(const std::string& dex_location,
-                                                      uint32_t dex_checksum,
-                                                      uint16_t dex_method_index) const;
+  std::unique_ptr<OfflineProfileMethodInfo> GetHotMethodInfo(
+      const MethodReference& method_ref) const;
 
   // Dump all the loaded profile info into a string and returns it.
   // If dex_files is not empty then the method indices will be resolved to their
@@ -559,7 +558,7 @@
     ArenaSet<dex::TypeIndex> class_set;
     // Find the inline caches of the the given method index. Add an empty entry if
     // no previous data is found.
-    InlineCacheMap* FindOrAddMethod(uint16_t method_index);
+    InlineCacheMap* FindOrAddHotMethod(uint16_t method_index);
     // Num method ids.
     uint32_t num_method_ids;
     ArenaVector<uint8_t> bitmap_storage;
diff --git a/libprofile/profile/profile_compilation_info_test.cc b/libprofile/profile/profile_compilation_info_test.cc
index a9c4b46..7b4ad5a 100644
--- a/libprofile/profile/profile_compilation_info_test.cc
+++ b/libprofile/profile/profile_compilation_info_test.cc
@@ -103,7 +103,7 @@
       const ProfileCompilationInfo& info,
       const DexFile* dex,
       uint16_t method_idx) {
-    return info.GetMethod(dex->GetLocation(), dex->GetLocationChecksum(), method_idx);
+    return info.GetHotMethodInfo(MethodReference(dex, method_idx));
   }
 
   // Creates an inline cache which will be destructed at the end of the test.
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index e6ff745..62df160 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -328,9 +328,8 @@
                           bool is_missing_types)
       REQUIRES_SHARED(Locks::mutator_lock_) {
     std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi =
-        info.GetMethod(method->GetDexFile()->GetLocation(),
-                       method->GetDexFile()->GetLocationChecksum(),
-                       method->GetDexMethodIndex());
+        info.GetHotMethodInfo(MethodReference(
+            method->GetDexFile(), method->GetDexMethodIndex()));
     ASSERT_TRUE(pmi != nullptr);
     ASSERT_EQ(pmi->inline_caches->size(), 1u);
     const ProfileCompilationInfo::DexPcData& dex_pc_data = pmi->inline_caches->begin()->second;
@@ -721,9 +720,7 @@
     if (!method.IsCopied() && method.GetCodeItem() != nullptr) {
       ++method_count;
       std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi =
-          info.GetMethod(method.GetDexFile()->GetLocation(),
-                         method.GetDexFile()->GetLocationChecksum(),
-                         method.GetDexMethodIndex());
+          info.GetHotMethodInfo(MethodReference(method.GetDexFile(), method.GetDexMethodIndex()));
       ASSERT_TRUE(pmi != nullptr) << method.PrettyMethod();
     }
   }
@@ -980,9 +977,8 @@
     ArtMethod* no_inline_cache = GetVirtualMethod(class_loader, "LTestInline;", "noInlineCache");
     ASSERT_TRUE(no_inline_cache != nullptr);
     std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi_no_inline_cache =
-        info.GetMethod(no_inline_cache->GetDexFile()->GetLocation(),
-                       no_inline_cache->GetDexFile()->GetLocationChecksum(),
-                       no_inline_cache->GetDexMethodIndex());
+        info.GetHotMethodInfo(MethodReference(
+            no_inline_cache->GetDexFile(), no_inline_cache->GetDexMethodIndex()));
     ASSERT_TRUE(pmi_no_inline_cache != nullptr);
     ASSERT_TRUE(pmi_no_inline_cache->inline_caches->empty());
   }
@@ -1064,9 +1060,7 @@
 
   // Verify that the inline cache contains the invalid type.
   std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi =
-      info.GetMethod(dex_file->GetLocation(),
-                     dex_file->GetLocationChecksum(),
-                     inline_monomorphic->GetDexMethodIndex());
+      info.GetHotMethodInfo(MethodReference(dex_file, inline_monomorphic->GetDexMethodIndex()));
   ASSERT_TRUE(pmi != nullptr);
   ASSERT_EQ(pmi->inline_caches->size(), 1u);
   const ProfileCompilationInfo::DexPcData& dex_pc_data = pmi->inline_caches->begin()->second;
@@ -1281,12 +1275,12 @@
 
   // Verify that the renaming was done.
   for (uint16_t i = 0; i < num_methods_to_add; i ++) {
-      std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi;
-      ASSERT_TRUE(result.GetMethod(d1.GetLocation(), d1.GetLocationChecksum(), i) != nullptr) << i;
-      ASSERT_TRUE(result.GetMethod(d2.GetLocation(), d2.GetLocationChecksum(), i) != nullptr) << i;
+    std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> pmi;
+    ASSERT_TRUE(result.GetHotMethodInfo(MethodReference(&d1, i)) != nullptr) << i;
+    ASSERT_TRUE(result.GetHotMethodInfo(MethodReference(&d2, i)) != nullptr) << i;
 
-      ASSERT_TRUE(result.GetMethod("fake-location1", d1.GetLocationChecksum(), i) == nullptr);
-      ASSERT_TRUE(result.GetMethod("fake-location2", d2.GetLocationChecksum(), i) == nullptr);
+    ASSERT_TRUE(result.GetHotMethodInfo(MethodReference(dex_to_be_updated1, i)) == nullptr);
+    ASSERT_TRUE(result.GetHotMethodInfo(MethodReference(dex_to_be_updated2, i)) == nullptr);
   }
 }
 
diff --git a/runtime/jit/profiling_info_test.cc b/runtime/jit/profiling_info_test.cc
index 6b82411..319a3e1 100644
--- a/runtime/jit/profiling_info_test.cc
+++ b/runtime/jit/profiling_info_test.cc
@@ -282,14 +282,13 @@
   {
     ScopedObjectAccess soa(self);
     for (ArtMethod* m : main_methods) {
-      Hotness h = info.GetMethodHotness(MethodReference(m->GetDexFile(), m->GetDexMethodIndex()));
+      MethodReference method_ref(m->GetDexFile(), m->GetDexMethodIndex());
+      Hotness h = info.GetMethodHotness(method_ref);
       ASSERT_TRUE(h.IsHot());
       ASSERT_TRUE(h.IsStartup());
       const ProfileMethodInfo& pmi = profile_methods_map.find(m)->second;
       std::unique_ptr<ProfileCompilationInfo::OfflineProfileMethodInfo> offline_pmi =
-          info.GetMethod(m->GetDexFile()->GetLocation(),
-                         m->GetDexFile()->GetLocationChecksum(),
-                         m->GetDexMethodIndex());
+          info.GetHotMethodInfo(method_ref);
       ASSERT_TRUE(offline_pmi != nullptr);
       ProfileCompilationInfo::OfflineProfileMethodInfo converted_pmi =
           ConvertProfileMethodInfo(pmi);