summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/jit/profile_compilation_info.cc29
-rw-r--r--runtime/jit/profile_compilation_info.h6
2 files changed, 24 insertions, 11 deletions
diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc
index ee2c44a305..77efce2519 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/runtime/jit/profile_compilation_info.cc
@@ -140,8 +140,7 @@ bool ProfileCompilationInfo::AddMethodIndex(MethodHotness::Flag flags, const Met
if (data == nullptr) {
return false;
}
- data->AddMethod(flags, ref.dex_method_index);
- return true;
+ return data->AddMethod(flags, ref.dex_method_index);
}
bool ProfileCompilationInfo::AddMethodIndex(MethodHotness::Flag flags,
@@ -155,8 +154,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) {
@@ -557,7 +555,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;
}
@@ -1251,9 +1256,9 @@ 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.dex_method_index);
- return true;
+ return dex_data->AddMethod(
+ static_cast<MethodHotness::Flag>(hotness.GetFlags()),
+ method_ref.dex_method_index);
}
return false;
}
@@ -1618,7 +1623,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);
}
@@ -1630,6 +1640,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 4ab8be84c3..29fa79c4c6 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/runtime/jit/profile_compilation_info.h
@@ -280,7 +280,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;
}
@@ -428,7 +430,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());