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
authorJeff Walden <jwalden@mit.edu>
Thu, 29 Aug 2019 23:16:33 +0000
changeset 551277 0948113e9229226dc4d126a21fa1b00ba9f75b08
parent 551276 acf99165d2fd365d6dc54c9a848ddb2caf757820
child 551278 6fe9875279652b5818d36fc0025af1e84f5e6ae1
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1577066
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
js/src/gc/Nursery.cpp
--- a/js/src/gc/Nursery.cpp
+++ b/js/src/gc/Nursery.cpp
@@ -1374,17 +1374,24 @@ void js::Nursery::maybeResizeNursery(JS:
   // relationship that works for all programs and can be predicted in
   // advance doesn't exist.
   static const float GrowThreshold = 0.03f;
   static const float ShrinkThreshold = 0.01f;
   static const float PromotionGoal = (GrowThreshold + ShrinkThreshold) / 2.0f;
   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());
   MOZ_ASSERT(minNurseryBytes >= ArenaSize);
 
   // If one of these conditions is true then we always shrink or grow the
   // nursery. This way the thresholds still have an effect even if the goal
   // seeking says the current size is ideal.