Commit 89b2c7bc authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[heap] Update HeapStats map type

Use `const void*` to signal that we are not hashing for the
`char*` contents.

Change-Id: Ib8c31e293ec1e57a7799a68cfd2d59ce39076d43
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3190108
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77119}
parent 69e1a42e
......@@ -73,7 +73,7 @@ void FinalizeSpace(HeapStatistics* stats,
}
void RecordObjectType(
std::unordered_map<const char*, size_t>& type_map,
std::unordered_map<const void*, size_t>& type_map,
std::vector<HeapStatistics::ObjectStatsEntry>& object_statistics,
HeapObjectHeader* header, size_t object_size) {
if (!NameProvider::HideInternalNames()) {
......@@ -109,7 +109,7 @@ HeapStatistics HeapStatisticsCollector::CollectDetailedStatistics(
if (!NameProvider::HideInternalNames()) {
stats.type_names.resize(type_name_to_index_map_.size());
for (auto& it : type_name_to_index_map_) {
stats.type_names[it.second] = it.first;
stats.type_names[it.second] = reinterpret_cast<const char*>(it.first);
}
}
......
......@@ -30,10 +30,10 @@ class HeapStatisticsCollector : private HeapVisitor<HeapStatisticsCollector> {
HeapStatistics::SpaceStatistics* current_space_stats_ = nullptr;
HeapStatistics::PageStatistics* current_page_stats_ = nullptr;
// Index from type name to final index in `HeapStats::type_names`.
// Canonicalizing based on `const char*` assuming stable addresses. If the
// Canonicalizing based on `const void*` assuming stable addresses. If the
// implementation of `NameProvider` decides to return different type name
// c-strings, the final outcome is less compact.
std::unordered_map<const char*, size_t> type_name_to_index_map_;
std::unordered_map<const void*, size_t> type_name_to_index_map_;
};
} // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment