Bug 1402344 - Update mfbt-double-conversion to the latest upstream rev. r=froydnj
authorJeff Walden <jwalden@mit.edu>
Mon, 09 Oct 2017 22:15:37 -0700
changeset 438766 840478b0ff4953b59756d206dc37bf0eb0babf36
parent 438765 022145f347d963fc1fb6b13b34acd10376d18434
child 438767 a993d7bc665860b2ea7df689adc6643fa3819815
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1402344
milestone58.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 1402344 - Update mfbt-double-conversion to the latest upstream rev. r=froydnj
media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
mfbt/decimal/moz-decimal-utils.h
mfbt/double-conversion.h
mfbt/double-conversion/GIT-INFO
mfbt/double-conversion/ToPrecision-exponential.patch
mfbt/double-conversion/add-mfbt-api-markers.patch
mfbt/double-conversion/double-conversion/LICENSE
mfbt/double-conversion/double-conversion/README.md
mfbt/double-conversion/double-conversion/bignum-dtoa.cc
mfbt/double-conversion/double-conversion/bignum-dtoa.h
mfbt/double-conversion/double-conversion/bignum.cc
mfbt/double-conversion/double-conversion/bignum.h
mfbt/double-conversion/double-conversion/cached-powers.cc
mfbt/double-conversion/double-conversion/cached-powers.h
mfbt/double-conversion/double-conversion/diy-fp.cc
mfbt/double-conversion/double-conversion/diy-fp.h
mfbt/double-conversion/double-conversion/double-conversion.cc
mfbt/double-conversion/double-conversion/double-conversion.h
mfbt/double-conversion/double-conversion/fast-dtoa.cc
mfbt/double-conversion/double-conversion/fast-dtoa.h
mfbt/double-conversion/double-conversion/fixed-dtoa.cc
mfbt/double-conversion/double-conversion/fixed-dtoa.h
mfbt/double-conversion/double-conversion/ieee.h
mfbt/double-conversion/double-conversion/strtod.cc
mfbt/double-conversion/double-conversion/strtod.h
mfbt/double-conversion/double-conversion/utils.h
mfbt/double-conversion/source/LICENSE
mfbt/double-conversion/source/README.md
mfbt/double-conversion/source/bignum-dtoa.cc
mfbt/double-conversion/source/bignum-dtoa.h
mfbt/double-conversion/source/bignum.cc
mfbt/double-conversion/source/bignum.h
mfbt/double-conversion/source/cached-powers.cc
mfbt/double-conversion/source/cached-powers.h
mfbt/double-conversion/source/diy-fp.cc
mfbt/double-conversion/source/diy-fp.h
mfbt/double-conversion/source/double-conversion.cc
mfbt/double-conversion/source/double-conversion.h
mfbt/double-conversion/source/fast-dtoa.cc
mfbt/double-conversion/source/fast-dtoa.h
mfbt/double-conversion/source/fixed-dtoa.cc
mfbt/double-conversion/source/fixed-dtoa.h
mfbt/double-conversion/source/ieee.h
mfbt/double-conversion/source/strtod.cc
mfbt/double-conversion/source/strtod.h
mfbt/double-conversion/source/utils.h
mfbt/double-conversion/update.sh
mfbt/double-conversion/use-StandardInteger.patch
mfbt/double-conversion/use-mozilla-assertions.patch
mfbt/moz.build
mfbt/objs.mozbuild
mfbt/staticruntime/moz.build
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
@@ -6,17 +6,17 @@
 #define MEDIA_CONDUIT_ABSTRACTION_
 
 #include "nsISupportsImpl.h"
 #include "nsXPCOM.h"
 #include "nsDOMNavigationTiming.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/RefCounted.h"
 #include "mozilla/UniquePtr.h"
-#include "mozilla/utils.h"
+#include "double-conversion/utils.h" // for DISALLOW_COPY_AND_ASSIGN
 #include "CodecConfig.h"
 #include "VideoTypes.h"
 #include "MediaConduitErrors.h"
 
 #include "ImageContainer.h"
 
 #include "webrtc/call.h"
 #include "webrtc/config.h"
--- a/mfbt/decimal/moz-decimal-utils.h
+++ b/mfbt/decimal/moz-decimal-utils.h
@@ -5,17 +5,17 @@
 
 #ifndef MOZ_DECIMAL_UTILS_H
 #define MOZ_DECIMAL_UTILS_H
 
 // This file contains extra includes, defines and typedefs to allow compilation
 // of Decimal.cpp under the Mozilla source without blink core dependencies. Do
 // not include it into any file other than Decimal.cpp.
 
-#include "../double-conversion/source/double-conversion.h"
+#include "../double-conversion/double-conversion/double-conversion.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Casting.h"
 #include "mozilla/FloatingPoint.h"
 
 #include <cmath>
 #include <cstring>
 #include <iomanip>
 #include <limits>
new file mode 100644
--- /dev/null
+++ b/mfbt/double-conversion.h
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * A temporary header providing double-conversion functionality until we change
+ * our code to use the double-conversion header directly.
+ */
+
+#ifndef mozilla_double_conversion_h
+#define mozilla_double_conversion_h
+
+#include "double-conversion/double-conversion.h"
+
+#endif /* mozilla_double_conversion_h */
--- a/mfbt/double-conversion/GIT-INFO
+++ b/mfbt/double-conversion/GIT-INFO
@@ -1,9 +1,9 @@
-commit d8d4e668ee1e6e10b728f0671a89b07d7c4d45be
-Merge: 79fb300 48b5e70
-Author: Florian Loitsch <florian@loitsch.com>
-Date:   Wed Nov 23 19:14:38 2016 +0100
+commit fe9b384793c4e79bd32133dc9053f27b75a5eeae
+Merge: 2a257b7 1d5a688
+Author: Florian Loitsch <floitsch@google.com>
+Date:   Fri Sep 15 11:32:00 2017 +0200
 
-    Merge pull request #39 from uburuntu/master
+    Merge pull request #52 from uburuntu/master
     
-    Some small fixes: compilation, null ptr derefence and const qualifiers
+    Some refactorings: remove unused static, replace deprecated headers, init member in constructor
 
--- a/mfbt/double-conversion/ToPrecision-exponential.patch
+++ b/mfbt/double-conversion/ToPrecision-exponential.patch
@@ -1,35 +1,62 @@
-1e7bf0c636b8cca54dd83456a0f8fa219343e2a1 Bug 608195 - part 2 - extend ToPrecision to tell use whether exponential notation was used
-diff --git a/mfbt/double-conversion/source/double-conversion.cc b/mfbt/double-conversion/source/double-conversion.cc
-index febba6c..394b6a0 100644
---- a/mfbt/double-conversion/source/double-conversion.cc
-+++ b/mfbt/double-conversion/source/double-conversion.cc
-@@ -283,7 +283,9 @@ bool DoubleToStringConverter::ToExponential(
+diff --git a/mfbt/double-conversion/double-conversion/double-conversion.cc b/mfbt/double-conversion/double-conversion/double-conversion.cc
+--- a/mfbt/double-conversion/double-conversion/double-conversion.cc
++++ b/mfbt/double-conversion/double-conversion/double-conversion.cc
+@@ -279,17 +279,19 @@ bool DoubleToStringConverter::ToExponent
+                                   exponent,
+                                   result_builder);
+   return true;
+ }
+ 
  
  bool DoubleToStringConverter::ToPrecision(double value,
                                            int precision,
 +                                          bool* used_exponential_notation,
                                            StringBuilder* result_builder) const {
 +  *used_exponential_notation = false;
    if (Double(value).IsSpecial()) {
      return HandleSpecialValues(value, result_builder);
    }
-@@ -325,6 +327,7 @@ bool DoubleToStringConverter::ToPrecision(double value,
+ 
+   if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) {
+     return false;
+   }
+ 
+@@ -321,16 +323,17 @@ bool DoubleToStringConverter::ToPrecisio
+        max_trailing_padding_zeroes_in_precision_mode_)) {
+     // Fill buffer to contain 'precision' digits.
+     // Usually the buffer is already at the correct length, but 'DoubleToAscii'
+     // is allowed to return less characters.
+     for (int i = decimal_rep_length; i < precision; ++i) {
        decimal_rep[i] = '0';
      }
  
 +    *used_exponential_notation = true;
      CreateExponentialRepresentation(decimal_rep,
                                      precision,
                                      exponent,
-diff --git a/mfbt/double-conversion/source/double-conversion.h b/mfbt/double-conversion/source/double-conversion.h
-index 0900ba0..957575c 100644
---- a/mfbt/double-conversion/source/double-conversion.h
-+++ b/mfbt/double-conversion/source/double-conversion.h
-@@ -270,6 +270,7 @@ class DoubleToStringConverter {
+                                     result_builder);
+   } else {
+     CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
+                                 Max(0, precision - decimal_point),
+                                 result_builder);
+diff --git a/mfbt/double-conversion/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion/double-conversion.h
+--- a/mfbt/double-conversion/double-conversion/double-conversion.h
++++ b/mfbt/double-conversion/double-conversion/double-conversion.h
+@@ -265,16 +265,17 @@ class DoubleToStringConverter {
+   //     been provided to the constructor,
+   //   - precision < kMinPericisionDigits
+   //   - precision > kMaxPrecisionDigits
+   // The last condition implies that the result will never contain more than
+   // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
    // exponent character, the exponent's sign, and at most 3 exponent digits).
    MFBT_API bool ToPrecision(double value,
                     int precision,
 +                   bool* used_exponential_notation,
                     StringBuilder* result_builder) const;
  
    enum DtoaMode {
+     // Produce the shortest correct representation.
+     // For example the output of 0.299999999999999988897 is (the less accurate
+     // but correct) 0.3.
+     SHORTEST,
+     // Same as SHORTEST, but for single-precision floats.
--- a/mfbt/double-conversion/add-mfbt-api-markers.patch
+++ b/mfbt/double-conversion/add-mfbt-api-markers.patch
@@ -1,84 +1,151 @@
-diff --git a/mfbt/double-conversion/source/double-conversion.h b/mfbt/double-conversion/source/double-conversion.h
-index f98edae..c62b16b 100644
---- a/mfbt/double-conversion/source/double-conversion.h
-+++ b/mfbt/double-conversion/source/double-conversion.h
-@@ -28,6 +28,7 @@
+diff --git a/mfbt/double-conversion/double-conversion/double-conversion.h b/mfbt/double-conversion/double-conversion/double-conversion.h
+--- a/mfbt/double-conversion/double-conversion/double-conversion.h
++++ b/mfbt/double-conversion/double-conversion/double-conversion.h
+@@ -23,16 +23,17 @@
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
  #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
  #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
  
 +#include "mozilla/Types.h"
- #include "utils.h"
+ #include <double-conversion/utils.h>
  
  namespace double_conversion {
-@@ -129,7 +130,7 @@ class DoubleToStringConverter {
+ 
+ class DoubleToStringConverter {
+  public:
+   // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
+   // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
+@@ -124,17 +125,17 @@ class DoubleToStringConverter {
+             max_trailing_padding_zeroes_in_precision_mode) {
+     // When 'trailing zero after the point' is set, then 'trailing point'
+     // must be set too.
+     ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) ||
+         !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0));
    }
  
    // Returns a converter following the EcmaScript specification.
 -  static const DoubleToStringConverter& EcmaScriptConverter();
 +  static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
  
    // Computes the shortest string of digits that correctly represent the input
    // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high
-@@ -197,7 +198,7 @@ class DoubleToStringConverter {
+   // (see constructor) it then either returns a decimal representation, or an
+   // exponential representation.
+   // Example with decimal_in_shortest_low = -6,
+   //              decimal_in_shortest_high = 21,
+   //              EMIT_POSITIVE_EXPONENT_SIGN activated, and
+@@ -192,17 +193,17 @@ class DoubleToStringConverter {
+   // except for the following cases:
+   //   - the input value is special and no infinity_symbol or nan_symbol has
+   //     been provided to the constructor,
+   //   - 'value' > 10^kMaxFixedDigitsBeforePoint, or
+   //   - 'requested_digits' > kMaxFixedDigitsAfterPoint.
    // The last two conditions imply that the result will never contain more than
    // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
    // (one additional character for the sign, and one for the decimal point).
 -  bool ToFixed(double value,
 +  MFBT_API bool ToFixed(double value,
                 int requested_digits,
                 StringBuilder* result_builder) const;
  
-@@ -229,7 +230,7 @@ class DoubleToStringConverter {
+   // Computes a representation in exponential format with requested_digits
+   // after the decimal point. The last emitted digit is rounded.
+   // If requested_digits equals -1, then the shortest exponential representation
+   // is computed.
+   //
+@@ -224,17 +225,17 @@ class DoubleToStringConverter {
+   // except for the following cases:
+   //   - the input value is special and no infinity_symbol or nan_symbol has
+   //     been provided to the constructor,
+   //   - 'requested_digits' > kMaxExponentialDigits.
+   // The last condition implies that the result will never contain more than
    // kMaxExponentialDigits + 8 characters (the sign, the digit before the
    // decimal point, the decimal point, the exponent character, the
    // exponent's sign, and at most 3 exponent digits).
 -  bool ToExponential(double value,
 +  MFBT_API bool ToExponential(double value,
                       int requested_digits,
                       StringBuilder* result_builder) const;
  
-@@ -267,7 +268,7 @@ class DoubleToStringConverter {
+   // Computes 'precision' leading digits of the given 'value' and returns them
+   // either in exponential or decimal format, depending on
+   // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
+   // constructor).
+   // The last computed digit is rounded.
+@@ -262,17 +263,17 @@ class DoubleToStringConverter {
+   // except for the following cases:
+   //   - the input value is special and no infinity_symbol or nan_symbol has
+   //     been provided to the constructor,
+   //   - precision < kMinPericisionDigits
+   //   - precision > kMaxPrecisionDigits
    // The last condition implies that the result will never contain more than
    // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
    // exponent character, the exponent's sign, and at most 3 exponent digits).
 -  bool ToPrecision(double value,
 +  MFBT_API bool ToPrecision(double value,
                     int precision,
                     StringBuilder* result_builder) const;
  
-@@ -292,7 +293,7 @@ class DoubleToStringConverter {
+   enum DtoaMode {
+     // Produce the shortest correct representation.
+     // For example the output of 0.299999999999999988897 is (the less accurate
+     // but correct) 0.3.
+     SHORTEST,
+@@ -287,17 +288,17 @@ class DoubleToStringConverter {
+   };
+ 
+   // The maximal number of digits that are needed to emit a double in base 10.
+   // A higher precision can be achieved by using more digits, but the shortest
+   // accurate representation of any double will never use more digits than
    // kBase10MaximalLength.
    // Note that DoubleToAscii null-terminates its input. So the given buffer
    // should be at least kBase10MaximalLength + 1 characters long.
 -  static const int kBase10MaximalLength = 17;
 +  static const MFBT_DATA int kBase10MaximalLength = 17;
  
    // Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or
    // -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v'
-@@ -332,7 +333,7 @@ class DoubleToStringConverter {
+   // after it has been casted to a single-precision float. That is, in this
+   // mode static_cast<float>(v) must not be NaN, +Infinity or -Infinity.
+   //
+   // The result should be interpreted as buffer * 10^(point-length).
+   //
+@@ -327,44 +328,44 @@ class DoubleToStringConverter {
+   // DoubleToAscii expects the given buffer to be big enough to hold all
+   // digits and a terminating null-character. In SHORTEST-mode it expects a
+   // buffer of at least kBase10MaximalLength + 1. In all other modes the
+   // requested_digits parameter and the padding-zeroes limit the size of the
+   // output. Don't forget the decimal point, the exponent character and the
    // terminating null-character when computing the maximal output size.
    // The given length is only used in debug mode to ensure the buffer is big
    // enough.
 -  static void DoubleToAscii(double v,
 +  static MFBT_API void DoubleToAscii(double v,
                              DtoaMode mode,
                              int requested_digits,
                              char* buffer,
-@@ -343,7 +344,7 @@ class DoubleToStringConverter {
+                             int buffer_length,
+                             bool* sign,
+                             int* length,
+                             int* point);
  
   private:
    // Implementation for ToShortest and ToShortestSingle.
 -  bool ToShortestIeeeNumber(double value,
 +  MFBT_API bool ToShortestIeeeNumber(double value,
                              StringBuilder* result_builder,
                              DtoaMode mode) const;
  
-@@ -351,15 +352,15 @@ class DoubleToStringConverter {
+   // If the value is a special value (NaN or Infinity) constructs the
    // corresponding string using the configured infinity/nan-symbol.
    // If either of them is NULL or the value is not special then the
    // function returns false.
 -  bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
 +  MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const;
    // Constructs an exponential representation (i.e. 1.234e56).
    // The given exponent assumes a decimal point after the first decimal digit.
 -  void CreateExponentialRepresentation(const char* decimal_digits,
@@ -87,8 +154,13 @@ index f98edae..c62b16b 100644
                                         int exponent,
                                         StringBuilder* result_builder) const;
    // Creates a decimal representation (i.e 1234.5678).
 -  void CreateDecimalRepresentation(const char* decimal_digits,
 +  MFBT_API void CreateDecimalRepresentation(const char* decimal_digits,
                                     int length,
                                     int decimal_point,
                                     int digits_after_point,
+                                    StringBuilder* result_builder) const;
+ 
+   const int flags_;
+   const char* const infinity_symbol_;
+   const char* const nan_symbol_;
rename from mfbt/double-conversion/source/LICENSE
rename to mfbt/double-conversion/double-conversion/LICENSE
rename from mfbt/double-conversion/source/README.md
rename to mfbt/double-conversion/double-conversion/README.md
rename from mfbt/double-conversion/source/bignum-dtoa.cc
rename to mfbt/double-conversion/double-conversion/bignum-dtoa.cc
--- a/mfbt/double-conversion/source/bignum-dtoa.cc
+++ b/mfbt/double-conversion/double-conversion/bignum-dtoa.cc
@@ -20,22 +20,22 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <math.h>
+#include <cmath>
 
-#include "bignum-dtoa.h"
+#include <double-conversion/bignum-dtoa.h>
 
-#include "bignum.h"
-#include "ieee.h"
+#include <double-conversion/bignum.h>
+#include <double-conversion/ieee.h>
 
 namespace double_conversion {
 
 static int NormalizedExponent(uint64_t significand, int exponent) {
   ASSERT(significand != 0);
   while ((significand & Double::kHiddenBit) == 0) {
     significand = significand << 1;
     exponent = exponent - 1;
rename from mfbt/double-conversion/source/bignum-dtoa.h
rename to mfbt/double-conversion/double-conversion/bignum-dtoa.h
--- a/mfbt/double-conversion/source/bignum-dtoa.h
+++ b/mfbt/double-conversion/double-conversion/bignum-dtoa.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_
 #define DOUBLE_CONVERSION_BIGNUM_DTOA_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 enum BignumDtoaMode {
   // Return the shortest correct representation.
   // For example the output of 0.299999999999999988897 is (the less accurate but
   // correct) 0.3.
   BIGNUM_DTOA_SHORTEST,
rename from mfbt/double-conversion/source/bignum.cc
rename to mfbt/double-conversion/double-conversion/bignum.cc
--- a/mfbt/double-conversion/source/bignum.cc
+++ b/mfbt/double-conversion/double-conversion/bignum.cc
@@ -20,23 +20,23 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include "bignum.h"
-#include "utils.h"
+#include <double-conversion/bignum.h>
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 Bignum::Bignum()
-    : bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
+    : bigits_buffer_(), bigits_(bigits_buffer_, kBigitCapacity), used_digits_(0), exponent_(0) {
   for (int i = 0; i < kBigitCapacity; ++i) {
     bigits_[i] = 0;
   }
 }
 
 
 template<typename S>
 static int BitSize(S value) {
@@ -440,36 +440,37 @@ void Bignum::AssignPowerUInt16(uint16_t 
   while (power_exponent >= mask) mask <<= 1;
 
   // The mask is now pointing to the bit above the most significant 1-bit of
   // power_exponent.
   // Get rid of first 1-bit;
   mask >>= 2;
   uint64_t this_value = base;
 
-  bool delayed_multipliciation = false;
+  bool delayed_multiplication = false;
   const uint64_t max_32bits = 0xFFFFFFFF;
   while (mask != 0 && this_value <= max_32bits) {
     this_value = this_value * this_value;
     // Verify that there is enough space in this_value to perform the
     // multiplication.  The first bit_size bits must be 0.
     if ((power_exponent & mask) != 0) {
+      ASSERT(bit_size > 0);
       uint64_t base_bits_mask =
           ~((static_cast<uint64_t>(1) << (64 - bit_size)) - 1);
       bool high_bits_zero = (this_value & base_bits_mask) == 0;
       if (high_bits_zero) {
         this_value *= base;
       } else {
-        delayed_multipliciation = true;
+        delayed_multiplication = true;
       }
     }
     mask >>= 1;
   }
   AssignUInt64(this_value);
-  if (delayed_multipliciation) {
+  if (delayed_multiplication) {
     MultiplyByUInt32(base);
   }
 
   // Now do the same thing as a bignum.
   while (mask != 0) {
     Square();
     if ((power_exponent & mask) != 0) {
       MultiplyByUInt32(base);
rename from mfbt/double-conversion/source/bignum.h
rename to mfbt/double-conversion/double-conversion/bignum.h
--- a/mfbt/double-conversion/source/bignum.h
+++ b/mfbt/double-conversion/double-conversion/bignum.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_BIGNUM_H_
 #define DOUBLE_CONVERSION_BIGNUM_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 class Bignum {
  public:
   // 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately.
   // This bignum can encode much bigger numbers, since it contains an
   // exponent.
rename from mfbt/double-conversion/source/cached-powers.cc
rename to mfbt/double-conversion/double-conversion/cached-powers.cc
--- a/mfbt/double-conversion/source/cached-powers.cc
+++ b/mfbt/double-conversion/double-conversion/cached-powers.cc
@@ -20,23 +20,23 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <stdarg.h>
-#include <limits.h>
-#include <math.h>
+#include <climits>
+#include <cmath>
+#include <cstdarg>
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
-#include "cached-powers.h"
+#include <double-conversion/cached-powers.h>
 
 namespace double_conversion {
 
 struct CachedPower {
   uint64_t significand;
   int16_t binary_exponent;
   int16_t decimal_exponent;
 };
rename from mfbt/double-conversion/source/cached-powers.h
rename to mfbt/double-conversion/double-conversion/cached-powers.h
--- a/mfbt/double-conversion/source/cached-powers.h
+++ b/mfbt/double-conversion/double-conversion/cached-powers.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
 #define DOUBLE_CONVERSION_CACHED_POWERS_H_
 
-#include "diy-fp.h"
+#include <double-conversion/diy-fp.h>
 
 namespace double_conversion {
 
 class PowersOfTenCache {
  public:
 
   // Not all powers of ten are cached. The decimal exponent of two neighboring
   // cached numbers will differ by kDecimalExponentDistance.
rename from mfbt/double-conversion/source/diy-fp.cc
rename to mfbt/double-conversion/double-conversion/diy-fp.cc
--- a/mfbt/double-conversion/source/diy-fp.cc
+++ b/mfbt/double-conversion/double-conversion/diy-fp.cc
@@ -21,18 +21,18 @@
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-#include "diy-fp.h"
-#include "utils.h"
+#include <double-conversion/diy-fp.h>
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 void DiyFp::Multiply(const DiyFp& other) {
   // Simply "emulates" a 128 bit multiplication.
   // However: the resulting number only contains 64 bits. The least
   // significant 64 bits are only used for rounding the most significant 64
   // bits.
rename from mfbt/double-conversion/source/diy-fp.h
rename to mfbt/double-conversion/double-conversion/diy-fp.h
--- a/mfbt/double-conversion/source/diy-fp.h
+++ b/mfbt/double-conversion/double-conversion/diy-fp.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_DIY_FP_H_
 #define DOUBLE_CONVERSION_DIY_FP_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 // This "Do It Yourself Floating Point" class implements a floating-point number
 // with a uint64 significand and an int exponent. Normalized DiyFp numbers will
 // have the most significant bit of the significand set.
 // Multiplication and Subtraction do not normalize their results.
 // DiyFp are not designed to contain special doubles (NaN and Infinity).
rename from mfbt/double-conversion/source/double-conversion.cc
rename to mfbt/double-conversion/double-conversion/double-conversion.cc
--- a/mfbt/double-conversion/source/double-conversion.cc
+++ b/mfbt/double-conversion/double-conversion/double-conversion.cc
@@ -20,27 +20,28 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <limits.h>
-#include <math.h>
+#include <climits>
+#include <locale>
+#include <cmath>
 
-#include "double-conversion.h"
+#include <double-conversion/double-conversion.h>
 
-#include "bignum-dtoa.h"
-#include "fast-dtoa.h"
-#include "fixed-dtoa.h"
-#include "ieee.h"
-#include "strtod.h"
-#include "utils.h"
+#include <double-conversion/bignum-dtoa.h>
+#include <double-conversion/fast-dtoa.h>
+#include <double-conversion/fixed-dtoa.h>
+#include <double-conversion/ieee.h>
+#include <double-conversion/strtod.h>
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 const DoubleToStringConverter& DoubleToStringConverter::EcmaScriptConverter() {
   int flags = UNIQUE_ZERO | EMIT_POSITIVE_EXPONENT_SIGN;
   static DoubleToStringConverter converter(flags,
                                            "Infinity",
                                            "NaN",
@@ -412,31 +413,65 @@ void DoubleToStringConverter::DoubleToAs
 
   // If the fast dtoa didn't succeed use the slower bignum version.
   BignumDtoaMode bignum_mode = DtoaToBignumDtoaMode(mode);
   BignumDtoa(v, bignum_mode, requested_digits, vector, length, point);
   vector[*length] = '\0';
 }
 
 
+namespace {
+
+inline char ToLower(char ch) {
+  static const std::ctype<char>& cType =
+      std::use_facet<std::ctype<char> >(std::locale::classic());
+  return cType.tolower(ch);
+}
+
+inline char Pass(char ch) {
+  return ch;
+}
+
+template <class Iterator, class Converter>
+static inline bool ConsumeSubStringImpl(Iterator* current,
+                                        Iterator end,
+                                        const char* substring,
+                                        Converter converter) {
+  ASSERT(converter(**current) == *substring);
+  for (substring++; *substring != '\0'; substring++) {
+    ++*current;
+    if (*current == end || converter(**current) != *substring) {
+      return false;
+    }
+  }
+  ++*current;
+  return true;
+}
+
 // Consumes the given substring from the iterator.
 // Returns false, if the substring does not match.
 template <class Iterator>
 static bool ConsumeSubString(Iterator* current,
                              Iterator end,
-                             const char* substring) {
-  ASSERT(**current == *substring);
-  for (substring++; *substring != '\0'; substring++) {
-    ++*current;
-    if (*current == end || **current != *substring) return false;
+                             const char* substring,
+                             bool allow_case_insensibility) {
+  if (allow_case_insensibility) {
+    return ConsumeSubStringImpl(current, end, substring, ToLower);
+  } else {
+    return ConsumeSubStringImpl(current, end, substring, Pass);
   }
-  ++*current;
-  return true;
 }
 
+// Consumes first character of the str is equal to ch
+inline bool ConsumeFirstCharacter(char ch,
+                                         const char* str,
+                                         bool case_insensibility) {
+  return case_insensibility ? ToLower(ch) == str[0] : ch == str[0];
+}
+}  // namespace
 
 // Maximum number of significant digits in decimal representation.
 // The longest possible double in decimal representation is
 // (2^53 - 1) * 2 ^ -1074 that is (2 ^ 53 - 1) * 5 ^ 1074 / 10 ^ 1074
 // (768 digits). If we parse a number whose first digits are equal to a
 // mean of 2 adjacent doubles (that could have up to 769 digits) the result
 // must be rounded to the bigger one unless the tail consists of zeros, so
 // we don't need to preserve all the digits.
@@ -627,32 +662,33 @@ static double RadixStringToIeee(Iterator
     }
     return static_cast<double>(number);
   }
 
   ASSERT(number != 0);
   return Double(DiyFp(number, exponent)).value();
 }
 
-
 template <class Iterator>
 double StringToDoubleConverter::StringToIeee(
     Iterator input,
     int length,
     bool read_as_double,
     int* processed_characters_count) const {
   Iterator current = input;
   Iterator end = input + length;
 
   *processed_characters_count = 0;
 
   const bool allow_trailing_junk = (flags_ & ALLOW_TRAILING_JUNK) != 0;
   const bool allow_leading_spaces = (flags_ & ALLOW_LEADING_SPACES) != 0;
   const bool allow_trailing_spaces = (flags_ & ALLOW_TRAILING_SPACES) != 0;
   const bool allow_spaces_after_sign = (flags_ & ALLOW_SPACES_AFTER_SIGN) != 0;
+  const bool allow_case_insensibility = (flags_ & ALLOW_CASE_INSENSIBILITY) != 0;
+
 
   // To make sure that iterator dereferencing is valid the following
   // convention is used:
   // 1. Each '++current' statement is followed by check for equality to 'end'.
   // 2. If AdvanceToNonspace returned false then current == end.
   // 3. If 'current' becomes equal to 'end' the function returns or goes to
   // 'parsing_done'.
   // 4. 'current' is not dereferenced after the 'parsing_done' label.
@@ -692,18 +728,18 @@ double StringToDoubleConverter::StringTo
     if (!AdvanceToNonspace(&next_non_space, end)) return junk_string_value_;
     if (!allow_spaces_after_sign && (current != next_non_space)) {
       return junk_string_value_;
     }
     current = next_non_space;
   }
 
   if (infinity_symbol_ != NULL) {
-    if (*current == infinity_symbol_[0]) {
-      if (!ConsumeSubString(&current, end, infinity_symbol_)) {
+    if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensibility)) {
+      if (!ConsumeSubString(&current, end, infinity_symbol_, allow_case_insensibility)) {
         return junk_string_value_;
       }
 
       if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
         return junk_string_value_;
       }
       if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
         return junk_string_value_;
@@ -711,18 +747,18 @@ double StringToDoubleConverter::StringTo
 
       ASSERT(buffer_pos == 0);
       *processed_characters_count = static_cast<int>(current - input);
       return sign ? -Double::Infinity() : Double::Infinity();
     }
   }
 
   if (nan_symbol_ != NULL) {
-    if (*current == nan_symbol_[0]) {
-      if (!ConsumeSubString(&current, end, nan_symbol_)) {
+    if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensibility)) {
+      if (!ConsumeSubString(&current, end, nan_symbol_, allow_case_insensibility)) {
         return junk_string_value_;
       }
 
       if (!(allow_trailing_spaces || allow_trailing_junk) && (current != end)) {
         return junk_string_value_;
       }
       if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
         return junk_string_value_;
rename from mfbt/double-conversion/source/double-conversion.h
rename to mfbt/double-conversion/double-conversion/double-conversion.h
--- a/mfbt/double-conversion/source/double-conversion.h
+++ b/mfbt/double-conversion/double-conversion/double-conversion.h
@@ -24,17 +24,17 @@
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
 #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
 
 #include "mozilla/Types.h"
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 class DoubleToStringConverter {
  public:
   // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
   // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
   // function returns false.
@@ -386,17 +386,18 @@ class StringToDoubleConverter {
   // strings to numbers.
   enum Flags {
     NO_FLAGS = 0,
     ALLOW_HEX = 1,
     ALLOW_OCTALS = 2,
     ALLOW_TRAILING_JUNK = 4,
     ALLOW_LEADING_SPACES = 8,
     ALLOW_TRAILING_SPACES = 16,
-    ALLOW_SPACES_AFTER_SIGN = 32
+    ALLOW_SPACES_AFTER_SIGN = 32,
+    ALLOW_CASE_INSENSIBILITY = 64,
   };
 
   // Flags should be a bit-or combination of the possible Flags-enum.
   //  - NO_FLAGS: no special flags.
   //  - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers.
   //      Ex: StringToDouble("0x1234") -> 4660.0
   //          In StringToDouble("0x1234.56") the characters ".56" are trailing
   //          junk. The result of the call is hence dependent on
@@ -418,16 +419,18 @@ class StringToDoubleConverter {
   //  - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of
   //      a double literal.
   //  - ALLOW_LEADING_SPACES: skip over leading whitespace, including spaces,
   //                          new-lines, and tabs.
   //  - ALLOW_TRAILING_SPACES: ignore trailing whitespace.
   //  - ALLOW_SPACES_AFTER_SIGN: ignore whitespace after the sign.
   //       Ex: StringToDouble("-   123.2") -> -123.2.
   //           StringToDouble("+   123.2") -> 123.2
+  //  - ALLOW_CASE_INSENSIBILITY: ignore case of characters for special values:
+  //      infinity and nan.
   //
   // empty_string_value is returned when an empty string is given as input.
   // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string
   // containing only spaces is converted to the 'empty_string_value', too.
   //
   // junk_string_value is returned when
   //  a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not
   //     part of a double-literal) is found.
rename from mfbt/double-conversion/source/fast-dtoa.cc
rename to mfbt/double-conversion/double-conversion/fast-dtoa.cc
--- a/mfbt/double-conversion/source/fast-dtoa.cc
+++ b/mfbt/double-conversion/double-conversion/fast-dtoa.cc
@@ -20,21 +20,21 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include "fast-dtoa.h"
+#include <double-conversion/fast-dtoa.h>
 
-#include "cached-powers.h"
-#include "diy-fp.h"
-#include "ieee.h"
+#include <double-conversion/cached-powers.h>
+#include <double-conversion/diy-fp.h>
+#include <double-conversion/ieee.h>
 
 namespace double_conversion {
 
 // The minimal and maximal target exponent define the range of w's binary
 // exponent, where 'w' is the result of multiplying the input by a cached power
 // of ten.
 //
 // A different range might be chosen on a different platform, to optimize digit
rename from mfbt/double-conversion/source/fast-dtoa.h
rename to mfbt/double-conversion/double-conversion/fast-dtoa.h
--- a/mfbt/double-conversion/source/fast-dtoa.h
+++ b/mfbt/double-conversion/double-conversion/fast-dtoa.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_FAST_DTOA_H_
 #define DOUBLE_CONVERSION_FAST_DTOA_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 enum FastDtoaMode {
   // Computes the shortest representation of the given input. The returned
   // result will be the most accurate number of this length. Longer
   // representations might be more accurate.
   FAST_DTOA_SHORTEST,
rename from mfbt/double-conversion/source/fixed-dtoa.cc
rename to mfbt/double-conversion/double-conversion/fixed-dtoa.cc
--- a/mfbt/double-conversion/source/fixed-dtoa.cc
+++ b/mfbt/double-conversion/double-conversion/fixed-dtoa.cc
@@ -20,20 +20,20 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <math.h>
+#include <cmath>
 
-#include "fixed-dtoa.h"
-#include "ieee.h"
+#include <double-conversion/fixed-dtoa.h>
+#include <double-conversion/ieee.h>
 
 namespace double_conversion {
 
 // Represents a 128bit type. This class should be replaced by a native type on
 // platforms that support 128bit integers.
 class UInt128 {
  public:
   UInt128() : high_bits_(0), low_bits_(0) { }
@@ -254,17 +254,18 @@ static void FillFractionals(uint64_t fra
       point--;
       int digit = static_cast<int>(fractionals >> point);
       ASSERT(digit <= 9);
       buffer[*length] = static_cast<char>('0' + digit);
       (*length)++;
       fractionals -= static_cast<uint64_t>(digit) << point;
     }
     // If the first bit after the point is set we have to round up.
-    if (((fractionals >> (point - 1)) & 1) == 1) {
+    ASSERT(fractionals == 0 || point - 1 >= 0);
+    if ((fractionals != 0) && ((fractionals >> (point - 1)) & 1) == 1) {
       RoundUp(buffer, length, decimal_point);
     }
   } else {  // We need 128 bits.
     ASSERT(64 < -exponent && -exponent <= 128);
     UInt128 fractionals128 = UInt128(fractionals, 0);
     fractionals128.Shift(-exponent - 64);
     int point = 128;
     for (int i = 0; i < fractional_count; ++i) {
rename from mfbt/double-conversion/source/fixed-dtoa.h
rename to mfbt/double-conversion/double-conversion/fixed-dtoa.h
--- a/mfbt/double-conversion/source/fixed-dtoa.h
+++ b/mfbt/double-conversion/double-conversion/fixed-dtoa.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_
 #define DOUBLE_CONVERSION_FIXED_DTOA_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 // Produces digits necessary to print a given number with
 // 'fractional_count' digits after the decimal point.
 // The buffer must be big enough to hold the result plus one terminating null
 // character.
 //
rename from mfbt/double-conversion/source/ieee.h
rename to mfbt/double-conversion/double-conversion/ieee.h
--- a/mfbt/double-conversion/source/ieee.h
+++ b/mfbt/double-conversion/double-conversion/ieee.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_DOUBLE_H_
 #define DOUBLE_CONVERSION_DOUBLE_H_
 
-#include "diy-fp.h"
+#include <double-conversion/diy-fp.h>
 
 namespace double_conversion {
 
 // We assume that doubles and uint64_t have the same endianness.
 static uint64_t double_to_uint64(double d) { return BitCast<uint64_t>(d); }
 static double uint64_to_double(uint64_t d64) { return BitCast<double>(d64); }
 static uint32_t float_to_uint32(float f) { return BitCast<uint32_t>(f); }
 static float uint32_to_float(uint32_t d32) { return BitCast<float>(d32); }
rename from mfbt/double-conversion/source/strtod.cc
rename to mfbt/double-conversion/double-conversion/strtod.cc
--- a/mfbt/double-conversion/source/strtod.cc
+++ b/mfbt/double-conversion/double-conversion/strtod.cc
@@ -20,23 +20,23 @@
 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <stdarg.h>
-#include <limits.h>
+#include <climits>
+#include <cstdarg>
 
-#include "strtod.h"
-#include "bignum.h"
-#include "cached-powers.h"
-#include "ieee.h"
+#include <double-conversion/bignum.h>
+#include <double-conversion/cached-powers.h>
+#include <double-conversion/ieee.h>
+#include <double-conversion/strtod.h>
 
 namespace double_conversion {
 
 // 2^53 = 9007199254740992.
 // Any integer with at most 15 decimal digits will hence fit into a double
 // (which has a 53bit significand) without loss of precision.
 static const int kMaxExactDoubleIntegerDecimalDigits = 15;
 // 2^64 = 18446744073709551616 > 10^19
rename from mfbt/double-conversion/source/strtod.h
rename to mfbt/double-conversion/double-conversion/strtod.h
--- a/mfbt/double-conversion/source/strtod.h
+++ b/mfbt/double-conversion/double-conversion/strtod.h
@@ -23,17 +23,17 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_STRTOD_H_
 #define DOUBLE_CONVERSION_STRTOD_H_
 
-#include "utils.h"
+#include <double-conversion/utils.h>
 
 namespace double_conversion {
 
 // The buffer must only contain digits in the range [0-9]. It must not
 // contain a dot or a sign. It must not start with '0', and must not be empty.
 double Strtod(Vector<const char> buffer, int exponent);
 
 // The buffer must only contain digits in the range [0-9]. It must not
rename from mfbt/double-conversion/source/utils.h
rename to mfbt/double-conversion/double-conversion/utils.h
--- a/mfbt/double-conversion/source/utils.h
+++ b/mfbt/double-conversion/double-conversion/utils.h
@@ -23,18 +23,18 @@
 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef DOUBLE_CONVERSION_UTILS_H_
 #define DOUBLE_CONVERSION_UTILS_H_
 
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
 
 #include "mozilla/Assertions.h"
 #ifndef ASSERT
 #define ASSERT(condition)         \
     MOZ_ASSERT(condition)
 #endif
 #ifndef UNIMPLEMENTED
 #define UNIMPLEMENTED() MOZ_CRASH()
--- a/mfbt/double-conversion/update.sh
+++ b/mfbt/double-conversion/update.sh
@@ -11,28 +11,28 @@ set -e
 LOCAL_PATCHES=""
 
 LOCAL_PATCHES="$LOCAL_PATCHES add-mfbt-api-markers.patch"
 LOCAL_PATCHES="$LOCAL_PATCHES use-StandardInteger.patch"
 LOCAL_PATCHES="$LOCAL_PATCHES use-mozilla-assertions.patch"
 LOCAL_PATCHES="$LOCAL_PATCHES ToPrecision-exponential.patch"
 
 TMPDIR=`mktemp --directory`
-LOCAL_CLONE="$TMPDIR/double-conversion"
+LOCAL_CLONE="$TMPDIR/new-double-conversion"
 
 git clone https://github.com/google/double-conversion.git "$LOCAL_CLONE"
 
 # If a particular revision was requested, check it out.
 if [ "$1" !=  "" ]; then
   git -C "$LOCAL_CLONE" checkout "$1"
 fi
 
 # First clear out everything already present.
-DEST=./source
-mv "$DEST" "$TMPDIR"/
+DEST=./double-conversion
+mv "$DEST" "$TMPDIR"/old-double-conversion
 mkdir "$DEST"
 
 # Copy over critical files.
 cp "$LOCAL_CLONE/LICENSE" "$DEST/"
 cp "$LOCAL_CLONE/README.md" "$DEST/"
 
 # Includes
 for header in "$LOCAL_CLONE/double-conversion/"*.h; do
--- a/mfbt/double-conversion/use-StandardInteger.patch
+++ b/mfbt/double-conversion/use-StandardInteger.patch
@@ -1,11 +1,11 @@
-diff --git a/mfbt/double-conversion/source/utils.h b/mfbt/double-conversion/source/utils.h
---- a/mfbt/double-conversion/source/utils.h
-+++ b/mfbt/double-conversion/source/utils.h
+diff --git a/mfbt/double-conversion/double-conversion/utils.h b/mfbt/double-conversion/double-conversion/utils.h
+--- a/mfbt/double-conversion/double-conversion/utils.h
++++ b/mfbt/double-conversion/double-conversion/utils.h
 @@ -93,34 +93,18 @@ inline void abort_noreturn() { abort(); 
  #endif
  
  #if defined(__GNUC__)
  #define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
  #else
  #define DOUBLE_CONVERSION_UNUSED
  #endif
--- a/mfbt/double-conversion/use-mozilla-assertions.patch
+++ b/mfbt/double-conversion/use-mozilla-assertions.patch
@@ -1,21 +1,21 @@
-diff --git a/mfbt/double-conversion/source/utils.h b/mfbt/double-conversion/source/utils.h
---- a/mfbt/double-conversion/source/utils.h
-+++ b/mfbt/double-conversion/source/utils.h
+diff --git a/mfbt/double-conversion/double-conversion/utils.h b/mfbt/double-conversion/double-conversion/utils.h
+--- a/mfbt/double-conversion/double-conversion/utils.h
++++ b/mfbt/double-conversion/double-conversion/utils.h
 @@ -26,38 +26,38 @@
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
  #ifndef DOUBLE_CONVERSION_UTILS_H_
  #define DOUBLE_CONVERSION_UTILS_H_
  
- #include <stdlib.h>
- #include <string.h>
+ #include <cstdlib>
+ #include <cstring>
  
--#include <assert.h>
+-#include <cassert>
 +#include "mozilla/Assertions.h"
  #ifndef ASSERT
  #define ASSERT(condition)         \
 -    assert(condition);
 +    MOZ_ASSERT(condition)
  #endif
  #ifndef UNIMPLEMENTED
 -#define UNIMPLEMENTED() (abort())
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -29,18 +29,17 @@ EXPORTS.mozilla = [
     'ChaosMode.h',
     'Char16.h',
     'CheckedInt.h',
     'Compiler.h',
     'Compression.h',
     'DebugOnly.h',
     'decimal/Decimal.h',
     'DefineEnum.h',
-    'double-conversion/source/double-conversion.h',
-    'double-conversion/source/utils.h',
+    'double-conversion.h',
     'DoublyLinkedList.h',
     'EndianUtils.h',
     'EnumeratedArray.h',
     'EnumeratedRange.h',
     'EnumSet.h',
     'EnumTypeTraits.h',
     'FastBernoulliTrial.h',
     'FloatingPoint.h',
@@ -101,16 +100,25 @@ EXPORTS.mozilla = [
     'UniquePtrExtensions.h',
     'Unused.h',
     'Variant.h',
     'Vector.h',
     'WeakPtr.h',
     'XorShift128PlusRNG.h',
 ]
 
+EXPORTS["double-conversion"] = [
+    'double-conversion/double-conversion/double-conversion.h',
+    'double-conversion/double-conversion/utils.h',
+]
+
+LOCAL_INCLUDES += [
+    '/mfbt/double-conversion',
+]
+
 if CONFIG['OS_ARCH'] == 'WINNT':
     EXPORTS.mozilla += [
         'WindowsVersion.h',
     ]
 elif CONFIG['OS_ARCH'] == 'Linux':
     EXPORTS.mozilla += [
         'LinuxSignal.h',
     ]
--- a/mfbt/objs.mozbuild
+++ b/mfbt/objs.mozbuild
@@ -2,24 +2,24 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 mfbt_src_lcppsrcs = [
     'Assertions.cpp',
     'ChaosMode.cpp',
-    'double-conversion/source/bignum-dtoa.cc',
-    'double-conversion/source/bignum.cc',
-    'double-conversion/source/cached-powers.cc',
-    'double-conversion/source/diy-fp.cc',
-    'double-conversion/source/double-conversion.cc',
-    'double-conversion/source/fast-dtoa.cc',
-    'double-conversion/source/fixed-dtoa.cc',
-    'double-conversion/source/strtod.cc',
+    'double-conversion/double-conversion/bignum-dtoa.cc',
+    'double-conversion/double-conversion/bignum.cc',
+    'double-conversion/double-conversion/cached-powers.cc',
+    'double-conversion/double-conversion/diy-fp.cc',
+    'double-conversion/double-conversion/double-conversion.cc',
+    'double-conversion/double-conversion/fast-dtoa.cc',
+    'double-conversion/double-conversion/fixed-dtoa.cc',
+    'double-conversion/double-conversion/strtod.cc',
     'FloatingPoint.cpp',
     'HashFunctions.cpp',
     'JSONWriter.cpp',
     'Poison.cpp',
     'SHA1.cpp',
     'TaggedAnonymousMemory.cpp',
     'Unused.cpp',
 ]
--- a/mfbt/staticruntime/moz.build
+++ b/mfbt/staticruntime/moz.build
@@ -1,16 +1,20 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 Library('mfbt_staticruntime')
 
+LOCAL_INCLUDES += [
+    '/mfbt/double-conversion',
+]
+
 include('../objs.mozbuild')
 
 UNIFIED_SOURCES += mfbt_src_cppsrcs
 
 DEFINES['IMPL_MFBT'] = True
 
 SOURCES += mfbt_nonunified_src_cppsrcs