tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 01cd3e11390dbc8a0347441e74fb3fd6fd398bf5
parent 481df5890a9398688e21d226a5ae773d81e05389
Author: Cristina Horotan <chorotan@mozilla.com>
Date:   Tue, 21 Oct 2025 18:59:40 +0300

Revert "Bug 1993199 - Adjust implementation of mozilla::PodZero r=emilio" for causing build bustages at TestJSHandleRootedTypedef.o

This reverts commit 60ddde8182fef6c697f9f40d3b76136b6653cc96.

Diffstat:
Mdom/base/nsWindowMemoryReporter.h | 1+
Mdom/base/nsWindowSizes.h | 1+
Mmfbt/PodOperations.h | 27++++++++++++---------------
3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h @@ -7,6 +7,7 @@ #ifndef nsWindowMemoryReporter_h__ #define nsWindowMemoryReporter_h__ +#include "mozilla/PodOperations.h" #include "mozilla/TimeStamp.h" #include "nsIMemoryReporter.h" #include "nsIObserver.h" diff --git a/dom/base/nsWindowSizes.h b/dom/base/nsWindowSizes.h @@ -8,6 +8,7 @@ #define nsWindowSizes_h #include "mozilla/Assertions.h" +#include "mozilla/PodOperations.h" #include "mozilla/SizeOfState.h" #include "nsStyleStructList.h" diff --git a/mfbt/PodOperations.h b/mfbt/PodOperations.h @@ -18,10 +18,8 @@ #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" -#include <cstdint> -#include <cstring> -#include <limits> -#include <type_traits> +#include <stdint.h> +#include <string.h> namespace mozilla { @@ -41,18 +39,17 @@ static MOZ_ALWAYS_INLINE void PodZero(T* aT) { /** Set the contents of |aNElem| elements starting at |aT| to 0. */ template <typename T> -static MOZ_ALWAYS_INLINE void PodZero(T* aT, size_t aNElem) { static_assert(std::is_trivially_copyable_v<T>, "PodZero requires - trivially copyable types"); +static MOZ_ALWAYS_INLINE void PodZero(T* aT, size_t aNElem) { + static_assert(std::is_trivially_copyable_v<T>, + "PodZero requires trivially copyable types"); /* - * NB: If the caller uses a constant size, both GCC and Clang inline the - * memset call if they find it profitable. - * - * If the value is dynamic, some might think that it's more profitable to - * perform an explicit loop over the aNElem. It turns out Clang rolls back the - * loop anyway, so even if GCC doesn't, keep the codebase simple and clearly - * convey the intent instead of trying to outsmart the compiler. + * This function is often called with 'aNElem' small; we use an inline loop + * instead of calling 'memset' with a non-constant length. The compiler + * should inline the memset call with constant size, though. */ - memset(aT, 0, sizeof(T) * aNElem); + for (T* end = aT + aNElem; aT < end; aT++) { + memset(aT, 0, sizeof(T)); + } } /** Set the contents of |aNElem| elements starting at |aT| to 0. */ @@ -154,7 +151,7 @@ template <typename T> static MOZ_ALWAYS_INLINE void PodMove(T* aDst, const T* aSrc, size_t aNElem) { static_assert(std::is_trivially_copyable_v<T>, "PodMove requires trivially copyable types"); - MOZ_ASSERT(aNElem <= std::numeric_limits<size_t>::max() / sizeof(T), + MOZ_ASSERT(aNElem <= SIZE_MAX / sizeof(T), "trying to move an impossible number of elements"); memmove(aDst, aSrc, aNElem * sizeof(T)); }