summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2017-09-19 18:20:37 -0700
committer Calin Juravle <calin@google.com> 2017-09-19 18:21:15 -0700
commit1ad1e3f21d02d9f98a8cc527e756fe8795c20b6e (patch)
tree6b6c98ec9233945c035c1c8889a307a1539b868d
parent0588f3aa446b9eb96ee7452d4a4494684b41d039 (diff)
Add more error logs to profile validation
Replace a few DCHECKS with LOG(ERROR). It will avoid crashing and give insights in what could cause the reported crash. Bug: 65812889 Test: m test-art-host Change-Id: I94a85997f865904208ef8e75c7aeb2c0911df765
-rw-r--r--runtime/jit/profile_compilation_info.cc27
-rw-r--r--runtime/jit/profile_compilation_info.h6
2 files changed, 23 insertions, 10 deletions
diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc
index 57fc4976f7..12fa49ea79 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/runtime/jit/profile_compilation_info.cc
@@ -143,8 +143,7 @@ bool ProfileCompilationInfo::AddMethodIndex(MethodHotness::Flag flags, const Met
if (data == nullptr) {
return false;
}
- data->AddMethod(flags, ref.index);
- return true;
+ return data->AddMethod(flags, ref.index);
}
bool ProfileCompilationInfo::AddMethodIndex(MethodHotness::Flag flags,
@@ -158,8 +157,7 @@ bool ProfileCompilationInfo::AddMethodIndex(MethodHotness::Flag flags,
if (data == nullptr) {
return false;
}
- data->AddMethod(flags, method_idx);
- return true;
+ return data->AddMethod(flags, method_idx);
}
bool ProfileCompilationInfo::AddMethods(const std::vector<ProfileMethodInfo>& methods) {
@@ -592,7 +590,14 @@ ProfileCompilationInfo::DexFileData* ProfileCompilationInfo::GetOrAddDexFileData
// This should always be the case since since the cache map is managed by ProfileCompilationInfo.
DCHECK_EQ(profile_key, result->profile_key);
DCHECK_EQ(profile_index, result->profile_index);
- DCHECK_EQ(num_method_ids, result->num_method_ids);
+
+ if (num_method_ids != result->num_method_ids) {
+ // This should not happen... added to help investigating b/65812889.
+ LOG(ERROR) << "num_method_ids mismatch for dex " << profile_key
+ << ", expected=" << num_method_ids
+ << ", actual=" << result->num_method_ids;
+ return nullptr;
+ }
return result;
}
@@ -1342,8 +1347,8 @@ bool ProfileCompilationInfo::AddMethodHotness(const MethodReference& method_ref,
DexFileData* dex_data = GetOrAddDexFileData(method_ref.dex_file);
if (dex_data != nullptr) {
// TODO: Add inline caches.
- dex_data->AddMethod(static_cast<MethodHotness::Flag>(hotness.GetFlags()), method_ref.index);
- return true;
+ return dex_data->AddMethod(
+ static_cast<MethodHotness::Flag>(hotness.GetFlags()), method_ref.index);
}
return false;
}
@@ -1727,7 +1732,12 @@ ProfileCompilationInfo::DexFileData::FindOrAddMethod(uint16_t method_index) {
}
// Mark a method as executed at least once.
-void ProfileCompilationInfo::DexFileData::AddMethod(MethodHotness::Flag flags, size_t index) {
+bool ProfileCompilationInfo::DexFileData::AddMethod(MethodHotness::Flag flags, size_t index) {
+ if (index >= num_method_ids) {
+ LOG(ERROR) << "Invalid method index " << index << ". num_method_ids=" << num_method_ids;
+ return false;
+ }
+
if ((flags & MethodHotness::kFlagStartup) != 0) {
method_bitmap.StoreBit(MethodBitIndex(/*startup*/ true, index), /*value*/ true);
}
@@ -1739,6 +1749,7 @@ void ProfileCompilationInfo::DexFileData::AddMethod(MethodHotness::Flag flags, s
index,
InlineCacheMap(std::less<uint16_t>(), arena_->Adapter(kArenaAllocProfile)));
}
+ return true;
}
ProfileCompilationInfo::MethodHotness ProfileCompilationInfo::DexFileData::GetHotnessInfo(
diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h
index 5c7448fe63..009554c7ca 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/runtime/jit/profile_compilation_info.h
@@ -290,7 +290,9 @@ class ProfileCompilationInfo {
}
for (Iterator it = index_begin; it != index_end; ++it) {
DCHECK_LT(*it, data->num_method_ids);
- data->AddMethod(flags, *it);
+ if (!data->AddMethod(flags, *it)) {
+ return false;
+ }
}
return true;
}
@@ -444,7 +446,7 @@ class ProfileCompilationInfo {
}
// Mark a method as executed at least once.
- void AddMethod(MethodHotness::Flag flags, size_t index);
+ bool AddMethod(MethodHotness::Flag flags, size_t index);
void MergeBitmap(const DexFileData& other) {
DCHECK_EQ(bitmap_storage.size(), other.bitmap_storage.size());