Bug 1967062 - Partial Backout of "Bug 933149 - Remove PodCopy loop heuristic r=mstange" on Linux only. a=dmeehan
We'll remove the loop heuristic on non-linux platforms, but keep it there as that's where it continues to be effective. Differential Revision: https://phabricator.services.mozilla.com/D250470
This commit is contained in:
committed by
dmeehan@mozilla.com
parent
c00915984c
commit
f5f4c2a04d
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/CheckedInt.h"
|
#include "mozilla/CheckedInt.h"
|
||||||
|
#include "mozilla/Compiler.h"
|
||||||
#include "mozilla/FloatingPoint.h"
|
#include "mozilla/FloatingPoint.h"
|
||||||
#if JS_HAS_INTL_API
|
#if JS_HAS_INTL_API
|
||||||
# include "mozilla/intl/String.h"
|
# include "mozilla/intl/String.h"
|
||||||
@@ -544,7 +545,12 @@ template <typename DestChar, typename SrcChar>
|
|||||||
static inline void CopyChars(DestChar* destChars, const SrcChar* srcChars,
|
static inline void CopyChars(DestChar* destChars, const SrcChar* srcChars,
|
||||||
size_t length) {
|
size_t length) {
|
||||||
if constexpr (std::is_same_v<DestChar, SrcChar>) {
|
if constexpr (std::is_same_v<DestChar, SrcChar>) {
|
||||||
|
#if MOZ_IS_GCC
|
||||||
|
// Directly call memcpy to work around bug 1863131.
|
||||||
|
memcpy(destChars, srcChars, length * sizeof(DestChar));
|
||||||
|
#else
|
||||||
PodCopy(destChars, srcChars, length);
|
PodCopy(destChars, srcChars, length);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
destChars[i] = srcChars[i];
|
destChars[i] = srcChars[i];
|
||||||
|
|||||||
@@ -96,6 +96,19 @@ static MOZ_ALWAYS_INLINE void PodCopy(T* aDst, const T* aSrc, size_t aNElem) {
|
|||||||
MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst,
|
MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst,
|
||||||
"destination and source must not overlap");
|
"destination and source must not overlap");
|
||||||
|
|
||||||
|
// Linux memcpy for small sizes seems slower than on other
|
||||||
|
// platforms. So we use a loop for small sizes there only.
|
||||||
|
//
|
||||||
|
// See Bug 1967062 for details.
|
||||||
|
#if defined(XP_LINUX)
|
||||||
|
if (aNElem < 128) {
|
||||||
|
for (const T* srcend = aSrc + aNElem; aSrc < srcend; aSrc++, aDst++) {
|
||||||
|
*aDst = *aSrc;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memcpy(aDst, aSrc, aNElem * sizeof(T));
|
memcpy(aDst, aSrc, aNElem * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user