Backed out 2 changesets (bug 1451278) for breaking windows pgo builds a=backout

Backed out changeset ac685df07bfc (bug 1451278)
Backed out changeset 5944ccd5060d (bug 1451278)
This commit is contained in:
Margareta Eliza Balazs 2018-04-16 21:41:03 +03:00
Родитель a30a60eadc
Коммит dbef13782c
5 изменённых файлов: 88 добавлений и 33 удалений

Просмотреть файл

@ -289,7 +289,7 @@ GMPChild::RecvPreloadLibs(const nsCString& aLibs)
u"msmpeg2vdec.dll", // H.264 decoder
u"psapi.dll", // For GetMappedFileNameW, see bug 1383611
};
constexpr static bool (*IsASCII)(const char16_t*) = NS_IsAscii;
constexpr static bool (*IsASCII)(const char16_t*) = NS_ConstExprIsAscii;
static_assert(AllOf(std::begin(whitelist), std::end(whitelist), IsASCII),
"Items in the whitelist must not contain non-ASCII "
"characters!");

Просмотреть файл

@ -210,16 +210,29 @@ HashGeneric(Args... aArgs)
namespace detail {
template<typename T>
constexpr uint32_t
uint32_t
HashUntilZero(const T* aStr)
{
uint32_t hash = 0;
for (; T c = *aStr; aStr++) {
for (T c; (c = *aStr); aStr++) {
hash = AddToHash(hash, c);
}
return hash;
}
// This is a `constexpr` alternative to HashUntilZero(const T*). It should
// only be used for compile-time computation because it uses recursion.
// XXX: once support for GCC 4.9 is dropped, this function should be removed
// and HashUntilZero(const T*) should be made `constexpr`.
template<typename T>
constexpr uint32_t
ConstExprHashUntilZero(const T* aStr, uint32_t aHash)
{
return !*aStr
? aHash
: ConstExprHashUntilZero(aStr + 1, AddToHash(aHash, *aStr));
}
template<typename T>
uint32_t
HashKnownLength(const T* aStr, size_t aLength)
@ -258,15 +271,27 @@ HashString(const unsigned char* aStr, size_t aLength)
return detail::HashKnownLength(aStr, aLength);
}
// You may need to use the
// MOZ_{PUSH,POP}_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING macros if you use
// this function. See the comment on those macros' definitions for more detail.
MOZ_MUST_USE constexpr uint32_t
MOZ_MUST_USE inline uint32_t
HashString(const char16_t* aStr)
{
return detail::HashUntilZero(aStr);
}
// This is a `constexpr` alternative to HashString(const char16_t*). It should
// only be used for compile-time computation because it uses recursion.
//
// You may need to use the
// MOZ_{PUSH,POP}_DISABLE_INTEGRAL_CONSTANT_OVERFLOW_WARNING macros if you use
// this function. See the comment on those macros' definitions for more detail.
//
// XXX: once support for GCC 4.9 is dropped, this function should be removed
// and HashString(const char16_t*) should be made `constexpr`.
MOZ_MUST_USE constexpr uint32_t
ConstExprHashString(const char16_t* aStr)
{
return detail::ConstExprHashUntilZero(aStr, 0);
}
MOZ_MUST_USE inline uint32_t
HashString(const char16_t* aStr, size_t aLength)
{

Просмотреть файл

@ -216,6 +216,43 @@ NS_IsLower(char aChar)
return aChar != (char)nsLowerUpperUtils::kLower2Upper[(unsigned char)aChar];
}
bool
NS_IsAscii(const char16_t* aString)
{
while (*aString) {
if (0x0080 <= *aString) {
return false;
}
aString++;
}
return true;
}
bool
NS_IsAscii(const char* aString)
{
while (*aString) {
if (0x80 & *aString) {
return false;
}
aString++;
}
return true;
}
bool
NS_IsAscii(const char* aString, uint32_t aLength)
{
const char* end = aString + aLength;
while (aString < end) {
if (0x80 & *aString) {
return false;
}
++aString;
}
return true;
}
#ifndef XPCOM_GLUE_AVOID_NSPR
void

Просмотреть файл

@ -104,41 +104,34 @@ NS_IsAscii(char16_t aChar)
return (0x0080 > aChar);
}
bool NS_IsAscii(const char16_t* aString);
bool NS_IsAscii(const char* aString);
bool NS_IsAscii(const char* aString, uint32_t aLength);
// These three functions are `constexpr` alternatives to NS_IsAscii. It should
// only be used for compile-time computation because it uses recursion.
// XXX: once support for GCC 4.9 is dropped, this function should be removed
// and NS_IsAscii should be made `constexpr`.
constexpr bool
NS_IsAscii(const char16_t* aString)
NS_ConstExprIsAscii(const char16_t* aString)
{
while (*aString) {
if (0x0080 <= *aString) {
return false;
}
aString++;
}
return true;
return !*aString ? true :
!NS_IsAscii(*aString) ? false : NS_ConstExprIsAscii(aString + 1);
}
constexpr bool
NS_IsAscii(const char* aString)
NS_ConstExprIsAscii(const char* aString)
{
while (*aString) {
if (0x80 & *aString) {
return false;
}
aString++;
}
return true;
return !*aString ? true :
!NS_IsAscii(*aString) ? false : NS_ConstExprIsAscii(aString + 1);
}
constexpr bool
NS_IsAscii(const char* aString, uint32_t aLength)
NS_ConstExprIsAscii(const char* aString, uint32_t aLength)
{
const char* end = aString + aLength;
while (aString < end) {
if (0x80 & *aString) {
return false;
}
aString++;
}
return true;
return aLength == 0 ? true :
!NS_IsAscii(*aString) ? false :
NS_ConstExprIsAscii(aString + 1, aLength - 1);
}
constexpr bool

Просмотреть файл

@ -107,7 +107,7 @@ protected:
constexpr nsAtom(const char16_t* aStr, uint32_t aLength)
: mLength(aLength)
, mKind(static_cast<uint32_t>(nsAtom::AtomKind::Static))
, mHash(mozilla::HashString(aStr))
, mHash(mozilla::ConstExprHashString(aStr))
{}
// Used by nsDynamicAtom.