5#ifndef V8_ZONE_TYPE_STATS_H_
6#define V8_ZONE_TYPE_STATS_H_
11#include <unordered_map>
20#ifdef V8_ENABLE_PRECISE_ZONE_STATS
24 TypeStats() =
default;
26 template <
typename TypeTag>
27 void AddAllocated(
size_t bytes) {
28 StatsEntry& entry =
map_[std::type_index(
typeid(TypeTag))];
29 entry.allocation_count++;
30 entry.allocated_bytes += bytes;
32 constexpr bool kIsIncomplete =
33 std::is_same<TypeTag, void>::value || std::is_array<TypeTag>::value;
34 using TypeTagForSizeof =
35 typename std::conditional<kIsIncomplete, char, TypeTag>::type;
36 entry.instance_size =
sizeof(TypeTagForSizeof);
39 template <
typename TypeTag>
40 void AddDeallocated(
size_t bytes) {
41 StatsEntry& entry =
map_[std::type_index(
typeid(TypeTag))];
42 entry.deallocated_bytes += bytes;
46 void MergeWith(
const TypeStats& other);
53 size_t allocation_count = 0;
54 size_t allocated_bytes = 0;
55 size_t deallocated_bytes = 0;
56 size_t instance_size = 0;
59 void Add(std::type_index type_id,
const StatsEntry& other_entry) {
60 StatsEntry& entry =
map_[type_id];
61 entry.allocation_count += other_entry.allocation_count;
62 entry.allocated_bytes += other_entry.allocated_bytes;
63 entry.deallocated_bytes += other_entry.deallocated_bytes;
64 entry.instance_size = other_entry.instance_size;
67 using HashMap = std::unordered_map<std::type_index, StatsEntry>;
PointerTemplateHashMapImpl< DefaultAllocationPolicy > HashMap
void Add(RWDigits Z, Digits X, Digits Y)