Bug 1833859 - Update double-conversion to version 3.3.0. r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D178437
This commit is contained in:
Ryan VanderMeulen 2023-05-23 04:01:10 +00:00
parent 29239058b2
commit 6af5555c16
6 changed files with 51 additions and 20 deletions

View File

@ -1,5 +1,5 @@
commit af09fd65fcf24eee95dc62813ba9123414635428
Author: Sean McBride <sean@rogue-research.com>
Date: Thu Jul 7 13:58:23 2022 -0400
commit 4f7a25d8ced8c7cf6eee6fd09d6788eaa23c9afe
Author: Florian Loitsch <florian@loitsch.com>
Date: Thu May 18 14:20:37 2023 +0200
Issue #184 : Fixed all -Wzero-as-null-pointer-constant warnings (#185)
Prepare v3.2.0 release. (#196)

View File

@ -1,5 +1,4 @@
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.h b/mfbt/double-conversion/double-conversion/double-to-string.h
index 6317a08a72aeb..6b7d30a63138c 100644
--- a/mfbt/double-conversion/double-conversion/double-to-string.h
+++ b/mfbt/double-conversion/double-conversion/double-to-string.h
@@ -23,16 +23,17 @@
@ -20,7 +19,7 @@ index 6317a08a72aeb..6b7d30a63138c 100644
public:
// When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
// or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
@@ -167,17 +168,17 @@ class DoubleToStringConverter {
@@ -192,17 +193,17 @@ class DoubleToStringConverter {
//
// Flags: UNIQUE_ZERO and EMIT_POSITIVE_EXPONENT_SIGN.
// Special values: "Infinity" and "NaN".
@ -39,7 +38,7 @@ index 6317a08a72aeb..6b7d30a63138c 100644
// Example with decimal_in_shortest_low = -6,
// decimal_in_shortest_high = 21,
// EMIT_POSITIVE_EXPONENT_SIGN activated, and
@@ -252,17 +253,17 @@ class DoubleToStringConverter {
@@ -277,17 +278,17 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - 'value' > 10^kMaxFixedDigitsBeforePoint, or
// - 'requested_digits' > kMaxFixedDigitsAfterPoint.
@ -58,7 +57,7 @@ index 6317a08a72aeb..6b7d30a63138c 100644
// If requested_digits equals -1, then the shortest exponential representation
// is computed.
//
@@ -286,17 +287,17 @@ class DoubleToStringConverter {
@@ -311,17 +312,17 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - 'requested_digits' > kMaxExponentialDigits.
//
@ -77,7 +76,7 @@ index 6317a08a72aeb..6b7d30a63138c 100644
// either in exponential or decimal format, depending on
// max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
// constructor).
@@ -327,17 +328,17 @@ class DoubleToStringConverter {
@@ -352,17 +353,17 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - precision < kMinPericisionDigits
// - precision > kMaxPrecisionDigits
@ -96,7 +95,7 @@ index 6317a08a72aeb..6b7d30a63138c 100644
// For example the output of 0.299999999999999988897 is (the less accurate
// but correct) 0.3.
SHORTEST,
@@ -389,44 +390,44 @@ class DoubleToStringConverter {
@@ -414,44 +415,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
@ -167,7 +166,7 @@ diff --git a/mfbt/double-conversion/double-conversion/string-to-double.h b/mfbt/
public:
// Enumeration for allowing octals and ignoring junk when converting
// strings to numbers.
@@ -178,22 +179,22 @@ class StringToDoubleConverter {
@@ -178,34 +179,34 @@ class StringToDoubleConverter {
separator_(separator) {
}

View File

@ -147,7 +147,7 @@ void Bignum::AssignHexString(Vector<const char> value) {
}
if (tmp > 0) {
DOUBLE_CONVERSION_ASSERT(tmp <= kBigitMask);
RawBigit(used_bigits_++) = (tmp & kBigitMask);
RawBigit(used_bigits_++) = static_cast<Bignum::Chunk>(tmp & kBigitMask);
}
Clamp();
}
@ -204,7 +204,7 @@ void Bignum::AddBignum(const Bignum& other) {
carry = sum >> kBigitSize;
++bigit_pos;
}
used_bigits_ = (std::max)(bigit_pos, static_cast<int>(used_bigits_));
used_bigits_ = static_cast<int16_t>(std::max(bigit_pos, static_cast<int>(used_bigits_)));
DOUBLE_CONVERSION_ASSERT(IsClamped());
}
@ -240,7 +240,7 @@ void Bignum::ShiftLeft(const int shift_amount) {
if (used_bigits_ == 0) {
return;
}
exponent_ += (shift_amount / kBigitSize);
exponent_ += static_cast<int16_t>(shift_amount / kBigitSize);
const int local_shift = shift_amount % kBigitSize;
EnsureCapacity(used_bigits_ + 1);
BigitsShiftLeft(local_shift);
@ -418,7 +418,7 @@ void Bignum::Square() {
DOUBLE_CONVERSION_ASSERT(accumulator == 0);
// Don't forget to update the used_digits and the exponent.
used_bigits_ = product_length;
used_bigits_ = static_cast<int16_t>(product_length);
exponent_ *= 2;
Clamp();
}
@ -739,8 +739,8 @@ void Bignum::Align(const Bignum& other) {
for (int i = 0; i < zero_bigits; ++i) {
RawBigit(i) = 0;
}
used_bigits_ += zero_bigits;
exponent_ -= zero_bigits;
used_bigits_ += static_cast<int16_t>(zero_bigits);
exponent_ -= static_cast<int16_t>(zero_bigits);
DOUBLE_CONVERSION_ASSERT(used_bigits_ >= 0);
DOUBLE_CONVERSION_ASSERT(exponent_ >= 0);

View File

@ -79,7 +79,14 @@ void DoubleToStringConverter::CreateExponentialRepresentation(
StringBuilder* result_builder) const {
DOUBLE_CONVERSION_ASSERT(length != 0);
result_builder->AddCharacter(decimal_digits[0]);
if (length != 1) {
if (length == 1) {
if ((flags_ & EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL) != 0) {
result_builder->AddCharacter('.');
if ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL) != 0) {
result_builder->AddCharacter('0');
}
}
} else {
result_builder->AddCharacter('.');
result_builder->AddSubstring(&decimal_digits[1], length-1);
}

View File

@ -79,7 +79,9 @@ class DoubleToStringConverter {
EMIT_TRAILING_DECIMAL_POINT = 2,
EMIT_TRAILING_ZERO_AFTER_POINT = 4,
UNIQUE_ZERO = 8,
NO_TRAILING_ZERO = 16
NO_TRAILING_ZERO = 16,
EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL = 32,
EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL = 64
};
// Flags should be a bit-or combination of the possible Flags-enum.
@ -98,6 +100,13 @@ class DoubleToStringConverter {
// of the result in precision mode. Matches printf's %g.
// When EMIT_TRAILING_ZERO_AFTER_POINT is also given, one trailing zero is
// preserved.
// - EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL: when the input number has
// exactly one significant digit and is converted into exponent form then a
// trailing decimal point is appended to the significand in shortest mode
// or in precision mode with one requested digit.
// - EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL: in addition to a trailing
// decimal point emits a trailing '0'-character. This flag requires the
// EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag.
//
// Infinity symbol and nan_symbol provide the string representation for these
// special values. If the string is NULL and the special value is encountered
@ -133,6 +142,22 @@ class DoubleToStringConverter {
// ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT.
// ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
//
// When converting numbers with exactly one significant digit to exponent
// form in shortest mode or in precision mode with one requested digit, the
// EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT flags have
// no effect. Use the EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL flag to
// append a decimal point in this case and the
// EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL flag to also append a
// '0'-character in this case.
// Example with decimal_in_shortest_low = 0:
// ToShortest(0.0009) -> "9e-4"
// with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL deactivated.
// ToShortest(0.0009) -> "9.e-4"
// with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated.
// ToShortest(0.0009) -> "9.0e-4"
// with EMIT_TRAILING_DECIMAL_POINT_IN_EXPONENTIAL activated and
// EMIT_TRAILING_ZERO_AFTER_POINT_IN_EXPONENTIAL activated.
//
// The min_exponent_width is used for exponential representations.
// The converter adds leading '0's to the exponent until the exponent
// is at least min_exponent_width digits long.

View File

@ -1,7 +1,7 @@
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.cc b/mfbt/double-conversion/double-conversion/double-to-string.cc
--- a/mfbt/double-conversion/double-conversion/double-to-string.cc
+++ b/mfbt/double-conversion/double-conversion/double-to-string.cc
@@ -200,25 +200,21 @@ bool DoubleToStringConverter::ToShortest
@@ -207,25 +207,21 @@ bool DoubleToStringConverter::ToShortest
}
return true;
}