зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374628 - Improve static_asserts in TelemetryHistogram.cpp. r=gfritzsche
With bug 1374419 solved, static asserts in TelemetryHistogram.cpp can be improved. Specifically, JS::gcreason::NUM_TELEMETRY_REASONS can now be compared against GC_MINOR_REASON, GC_MINOR_REASON_LONG, and GC_REASON_2 in the now constexpr gHistograms. Likewise, mozilla::StartupTimeline::MAX_EVENT_ID can be compared against STARTUP_MEASUREMENT_ERRORS. This commit modifies the static asserts to perform these comparisons in place of ones against hardcoded values and modifies the accompanying comment to remove the TODO section.
This commit is contained in:
Родитель
f74e69f0bc
Коммит
d2dc744c5d
|
@ -1883,22 +1883,27 @@ void TelemetryHistogram::InitializeGlobalState(bool canRecordBase,
|
|||
}
|
||||
}
|
||||
|
||||
// Some Telemetry histograms depend on the value of C++ constants and hardcode
|
||||
// their values in Histograms.json.
|
||||
// We add static asserts here for those values to match so that future changes
|
||||
// don't go unnoticed.
|
||||
// TODO: Compare explicitly with gHistograms[<histogram id>].bucketCount here
|
||||
// once we can make gHistograms constexpr (requires VS2015).
|
||||
static_assert((JS::gcreason::NUM_TELEMETRY_REASONS == 100),
|
||||
"NUM_TELEMETRY_REASONS is assumed to be a fixed value in Histograms.json."
|
||||
" If this was an intentional change, update this assert with its value "
|
||||
"and update the n_values for the following in Histograms.json: "
|
||||
"GC_MINOR_REASON, GC_MINOR_REASON_LONG, GC_REASON_2");
|
||||
static_assert((mozilla::StartupTimeline::MAX_EVENT_ID == 16),
|
||||
"MAX_EVENT_ID is assumed to be a fixed value in Histograms.json. If this"
|
||||
" was an intentional change, update this assert with its value and update"
|
||||
" the n_values for the following in Histograms.json:"
|
||||
" STARTUP_MEASUREMENT_ERRORS");
|
||||
// Some Telemetry histograms depend on the value of C++ constants and hardcode
|
||||
// their values in Histograms.json.
|
||||
// We add static asserts here for those values to match so that future changes
|
||||
// don't go unnoticed.
|
||||
static_assert((JS::gcreason::NUM_TELEMETRY_REASONS + 1) ==
|
||||
gHistograms[mozilla::Telemetry::GC_MINOR_REASON].bucketCount &&
|
||||
(JS::gcreason::NUM_TELEMETRY_REASONS + 1) ==
|
||||
gHistograms[mozilla::Telemetry::GC_MINOR_REASON_LONG].bucketCount &&
|
||||
(JS::gcreason::NUM_TELEMETRY_REASONS + 1) ==
|
||||
gHistograms[mozilla::Telemetry::GC_REASON_2].bucketCount,
|
||||
"NUM_TELEMETRY_REASONS is assumed to be a fixed value in Histograms.json."
|
||||
" If this was an intentional change, update the n_values for the "
|
||||
"following in Histograms.json: GC_MINOR_REASON, GC_MINOR_REASON_LONG, "
|
||||
"GC_REASON_2");
|
||||
|
||||
static_assert((mozilla::StartupTimeline::MAX_EVENT_ID + 1) ==
|
||||
gHistograms[mozilla::Telemetry::STARTUP_MEASUREMENT_ERRORS].bucketCount,
|
||||
"MAX_EVENT_ID is assumed to be a fixed value in Histograms.json. If this"
|
||||
" was an intentional change, update the n_values for the following in "
|
||||
"Histograms.json: STARTUP_MEASUREMENT_ERRORS");
|
||||
|
||||
|
||||
gInitDone = true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче