Bug 1577066 - Fix an implicit-conversion-changes-value warning with new-enough clang in Nursery.cpp by doing a less-than comparison with the actually-representable next higher value. r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D43708

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Walden 2019-08-29 23:16:33 +00:00
Родитель 1f7de4f614
Коммит 6dfc6a5499
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -1379,7 +1379,14 @@ void js::Nursery::maybeResizeNursery(JS::GCReason reason) {
const float factor = promotionRate / PromotionGoal;
MOZ_ASSERT(factor >= 0.0f);
MOZ_ASSERT((float(capacity()) * factor) <= float(SIZE_MAX));
#ifdef DEBUG
// This is |... <= SIZE_MAX|, just without the implicit value-changing
// conversion that expression would involve and modern clang would warn about.
static const float SizeMaxPlusOne =
2.0f * float(1ULL << (sizeof(void*) * CHAR_BIT - 1));
MOZ_ASSERT((float(capacity()) * factor) < SizeMaxPlusOne);
#endif
size_t newCapacity = size_t(float(capacity()) * factor);
const size_t minNurseryBytes = roundSize(tunables().gcMinNurseryBytes());