Bug 1147491, part 2 - Disable use of BaseTimeDuration::operator/ with floating point values. r=ehsan
authorJonathan Watt <jwatt@jwatt.org>
Mon, 30 Mar 2015 16:27:13 +0100
changeset 237011 fba3aaf06f106b4aa9aab2d6299b6b35abcf8df9
parent 237010 505c191fb5dc7de1f0cc5f2384b2a21c6dcdb742
child 237012 295db120bf1294195fdee467ba8fded9caae4842
push id28521
push userryanvm@gmail.com
push dateWed, 01 Apr 2015 16:35:21 +0000
treeherdermozilla-central@e5b72a8edb82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1147491
milestone40.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 1147491, part 2 - Disable use of BaseTimeDuration::operator/ with floating point values. r=ehsan
mfbt/RollingMean.h
xpcom/ds/TimeStamp.h
--- a/mfbt/RollingMean.h
+++ b/mfbt/RollingMean.h
@@ -81,17 +81,17 @@ public:
   }
 
   /**
    * Calculate the rolling mean.
    */
   T mean()
   {
     MOZ_ASSERT(!empty());
-    return T(mTotal / mValues.length());
+    return T(mTotal / int64_t(mValues.length()));
   }
 
   bool empty()
   {
     return mValues.empty();
   }
 
   /**
--- a/xpcom/ds/TimeStamp.h
+++ b/xpcom/ds/TimeStamp.h
@@ -176,16 +176,21 @@ public:
     return FromTicks(ticks);
   }
 
 private:
   // Block double multiplier (slower, imprecise if long duration) - Bug 853398.
   // If required, use MultDouble explicitly and with care.
   BaseTimeDuration operator*(const double aMultiplier) const = delete;
 
+  // Block double divisor (for the same reason, and because dividing by
+  // fractional values would otherwise invoke the int64_t variant, and rounding
+  // the passed argument can then cause divide-by-zero) - Bug 1147491.
+  BaseTimeDuration operator/(const double aDivisor) const = delete;
+
 public:
   BaseTimeDuration MultDouble(double aMultiplier) const
   {
     return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier));
   }
   BaseTimeDuration operator*(const int32_t aMultiplier) const
   {
     return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier));