From adc11330e5170e0b1587069ce43a652323a92959 Mon Sep 17 00:00:00 2001 From: Clemens Backes Date: Tue, 7 Dec 2021 18:53:08 +0100 Subject: [PATCH] [counters] Reorganize counter initialization Make the block defining the counter names more organized, and mostly clang-formatted. This slightly changes the name of the CODE_TYPE and FIXED_ARRAY counters ('-' -> '_'), but none of them are used in chrome or in benchmarks, so this should be fine. R=mlippautz@chromium.org Bug: v8:12482 Change-Id: I4aa7d4e11a4f498f9adb092e3b98e1edf68401dc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3320454 Reviewed-by: Michael Lippautz Commit-Queue: Clemens Backes Cr-Commit-Position: refs/heads/main@{#78292} --- src/logging/counters.cc | 48 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/logging/counters.cc b/src/logging/counters.cc index 1ee8b1abe8..fb73184c3f 100644 --- a/src/logging/counters.cc +++ b/src/logging/counters.cc @@ -188,37 +188,33 @@ Counters::Counters(Isolate* isolate) .Initialize(histogram.caption, 1000, 500000, 50, this); } - // clang-format off - static const struct { + static constexpr struct { StatsCounter Counters::*member; const char* caption; } kStatsCounters[] = { -#define SC(name, caption) {&Counters::name##_, "c:" #caption}, - STATS_COUNTER_LIST_1(SC) - STATS_COUNTER_LIST_2(SC) - STATS_COUNTER_NATIVE_CODE_LIST(SC) -#undef SC -#define SC(name) \ - {&Counters::count_of_##name##_, "c:" "V8.CountOf_" #name}, \ - {&Counters::size_of_##name##_, "c:" "V8.SizeOf_" #name}, - INSTANCE_TYPE_LIST(SC) -#undef SC -#define SC(name) \ - {&Counters::count_of_CODE_TYPE_##name##_, \ - "c:" "V8.CountOf_CODE_TYPE-" #name}, \ - {&Counters::size_of_CODE_TYPE_##name##_, \ - "c:" "V8.SizeOf_CODE_TYPE-" #name}, - CODE_KIND_LIST(SC) -#undef SC -#define SC(name) \ - {&Counters::count_of_FIXED_ARRAY_##name##_, \ - "c:" "V8.CountOf_FIXED_ARRAY-" #name}, \ - {&Counters::size_of_FIXED_ARRAY_##name##_, \ - "c:" "V8.SizeOf_FIXED_ARRAY-" #name}, - FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC) +#define SC(name, caption) {&Counters::name##_, "c:" caption}, +#define BARE_SC(name, caption) SC(name, #caption) +#define COUNT_AND_SIZE_SC(name) \ + SC(count_of_##name, "V8.CountOf_" #name) \ + SC(size_of_##name, "V8.SizeOf_" #name) +#define CODE_KIND_SC(name) COUNT_AND_SIZE_SC(CODE_TYPE_##name) +#define FIXED_ARRAY_INSTANCE_TYPE_SC(name) COUNT_AND_SIZE_SC(FIXED_ARRAY_##name) + + // clang-format off + STATS_COUNTER_LIST_1(BARE_SC) + STATS_COUNTER_LIST_2(BARE_SC) + STATS_COUNTER_NATIVE_CODE_LIST(BARE_SC) + INSTANCE_TYPE_LIST(COUNT_AND_SIZE_SC) + CODE_KIND_LIST(CODE_KIND_SC) + FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(FIXED_ARRAY_INSTANCE_TYPE_SC) + // clang-format on + +#undef FIXED_ARRAY_INSTANCE_TYPE_SC +#undef CODE_KIND_SC +#undef COUNT_AND_SIZE_SC +#undef BARE_SC #undef SC }; - // clang-format on for (const auto& counter : kStatsCounters) { (this->*counter.member).Init(this, counter.caption); }