зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1461556 - Replace a PodZero of js::gcstats::Statistics::totalTimes_ with a loop asserting every element was default-initialized to zero. r=jandem
--HG-- extra : rebase_source : e05859608c689e3d9dac671292ad7ed2522fad66
This commit is contained in:
Родитель
890404de4b
Коммит
2b6f63de78
|
@ -15,6 +15,7 @@
|
|||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include "jsutil.h"
|
||||
|
||||
|
@ -711,7 +712,26 @@ Statistics::Statistics(JSRuntime* rt)
|
|||
{
|
||||
for (auto& count : counts)
|
||||
count = 0;
|
||||
PodZero(&totalTimes_);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (const auto& duration : totalTimes_) {
|
||||
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(XP_UNIX) && !defined(__clang__))
|
||||
// build-linux64-asan/debug and static-analysis-linux64-st-an/debug
|
||||
// currently use an STL that lacks std::is_trivially_constructible.
|
||||
// This #ifdef probably isn't as precise as it could be, but given
|
||||
// |totalTimes_| contains |TimeDuration| defined platform-independently
|
||||
// it's not worth the trouble to nail down a more exact condition.
|
||||
using ElementType = typename mozilla::RemoveReference<decltype(duration)>::Type;
|
||||
static_assert(!std::is_trivially_constructible<ElementType>::value,
|
||||
"Statistics::Statistics will only initialize "
|
||||
"totalTimes_'s elements if their default constructor is "
|
||||
"non-trivial");
|
||||
#endif // mess'o'tests
|
||||
MOZ_ASSERT(duration.IsZero(),
|
||||
"totalTimes_ default-initialization should have "
|
||||
"default-initialized every element of totalTimes_ to zero");
|
||||
}
|
||||
#endif
|
||||
|
||||
MOZ_ALWAYS_TRUE(phaseStack.reserve(MAX_PHASE_NESTING));
|
||||
MOZ_ALWAYS_TRUE(suspendedPhases.reserve(MAX_SUSPENDED_PHASES));
|
||||
|
|
Загрузка…
Ссылка в новой задаче