Skip to content

Commit d24e80e

Browse files
committed
[JSC] JSON.parse should convert doubles without scanning them twice
https://bugs.webkit.org/show_bug.cgi?id=329545 rdar://191382963 Reviewed by Keith Miller. lexNumber scanned the integer part of a number, then handed anything with a fraction, an exponent, or more than nine digits to WTF::parseJSONDouble, which scanned it again from the start. This patch finishes the scan in place with scanJSONDecimal, reading fraction digits eight at a time for both 8-bit and 16-bit sources, and converts the result directly: a single exact multiplication or division for at most 15 digits and a small exponent, and fast_float's compute_float otherwise. Numbers with more than 19 significant digits and malformed numbers still go to WTF::parseJSONDouble, so results and error messages are unchanged. The loop over cached keys uses the same scan for doubles and long integers. Tests: JSTests/stress/json-parse-cached-number-values.js JSTests/stress/json-parse-doubles.js Tools/TestWebKitAPI/Tests/WTF/FastFloat.cpp * JSTests/stress/json-parse-cached-number-values.js: Renamed from JSTests/stress/json-parse-cached-integer-values.js. * JSTests/stress/json-parse-doubles-near-halfway.js: Added. (shouldBe): (rand): (midpointDigits): (join): * JSTests/stress/json-parse-doubles.js: Added. (shouldBe): (rand): (parseObjects): (length.string_appeared_here.catch): * Source/JavaScriptCore/runtime/LiteralParser.cpp: (JSC::scanJSONIntegerDigits): (JSC::scanJSONDecimal): (JSC::reviverMode>::Lexer::lexNumber): (JSC::reviverMode>::Lexer::lexDouble): (JSC::requires): * Source/JavaScriptCore/runtime/LiteralParser.h: * Source/WTF/wtf/FastFloat.cpp: (WTF::parseJSONDoubleFromDigitsSlow): * Source/WTF/wtf/FastFloat.h: (WTF::parseJSONDoubleFromDigits): * Source/WTF/wtf/SIMDHelpers.h: (WTF::SIMD::loadAndSaturateNarrowToU64): * Tools/TestWebKitAPI/CMakeLists.txt: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WTF/FastFloat.cpp: Added. (TestWebKitAPI::expectSameAsParseJSONDouble): (TestWebKitAPI::TEST(WTF_FastFloat, ParseJSONDoubleFromDigits)): Canonical link: https://commits.webkit.org/325669@main
1 parent 532abac commit d24e80e

11 files changed

Lines changed: 426 additions & 8 deletions

File tree

JSTests/stress/json-parse-cached-integer-values.js renamed to JSTests/stress/json-parse-cached-number-values.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ function shouldThrow(text, message) {
3232
const numbers = [
3333
"0", "7", "10", "123456789", "999999999", "1000000000", "1234567890", "2147483647", "2147483648",
3434
"4294967295", "4294967296", "99999999999999999999", "1.5", "1e5", "1E5", "1e-5", "0.0", "-0", "-1", "-123",
35+
"18.284176027984360", "0.10271949699381366", "17.72309872598271", "1234567890123456789", "12345678901234567890",
36+
"9007199254740993", "1.7976931348623157e308", "2e308", "5e-324", "1e-400", "0.1", "123.456e-7", "1.000000000000000000001",
3537
];
36-
const invalid = ["00", "01", "1.", "1e", "1a", "1-", "-", "-a", "0x1", "1.e5"];
38+
const invalid = ["00", "01", "1.", "1e", "1a", "1-", "-", "-a", "0x1", "1.e5", "1.5.5", "1e5e5", "01.5", "1.5x"];
3739
const beforeComma = [",", " ,", "\n,", "\t,"];
3840
const beforeBrace = ["}", " }", "\n}", "\t}"];
3941
// The second prefix holds a character outside Latin-1, which makes the source 16-bit.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function shouldBe(actual, expected, text) {
2+
if (!Object.is(actual, expected))
3+
throw new Error(`bad value for ${text}: ${actual}, expected: ${expected}`);
4+
}
5+
6+
// Decimals of 19 significant digits within one unit in the last digit of the exact midpoint between two
7+
// adjacent doubles. These are the numbers whose rounding is hardest to decide from an approximate product.
8+
let seed = 4242;
9+
function rand() { seed = (seed * 16807) % 2147483647; return seed / 2147483647; }
10+
11+
function midpointDigits(bits) {
12+
let biasedExponent = Number((bits >> 52n) & 0x7ffn);
13+
let fraction = bits & ((1n << 52n) - 1n);
14+
let significand = biasedExponent ? fraction | (1n << 52n) : fraction;
15+
let exponent = (biasedExponent ? biasedExponent - 1075 : -1074) - 1;
16+
let numerator = 2n * significand + 1n;
17+
if (exponent >= 0)
18+
return { digits: (numerator << BigInt(exponent)).toString(), decimalExponent: 0 };
19+
return { digits: (numerator * 5n ** BigInt(-exponent)).toString(), decimalExponent: exponent };
20+
}
21+
22+
let texts = [];
23+
for (let i = 0; i < 1500; ++i) {
24+
let bits;
25+
if (i % 10 === 0)
26+
bits = BigInt(1 + Math.floor(rand() * 2 ** 26)) * BigInt(1 + Math.floor(rand() * 2 ** 26));
27+
else
28+
bits = (BigInt(1 + Math.floor(rand() * 2045)) << 52n) | (BigInt(Math.floor(rand() * 2 ** 26)) << 26n) | BigInt(Math.floor(rand() * 2 ** 26));
29+
let { digits, decimalExponent } = midpointDigits(bits);
30+
let dropped = Math.max(digits.length - 19, 0);
31+
let head = BigInt(digits.slice(0, 19));
32+
for (let delta of [-1n, 0n, 1n]) {
33+
let text = (head + delta).toString();
34+
texts.push(`${text[0]}.${text.slice(1)}e${decimalExponent + dropped + text.length - 1}`);
35+
}
36+
}
37+
38+
// JSONCache matches a key only when at least 32 characters of source remain.
39+
const padding = " ".repeat(40);
40+
let array = JSON.parse(`[${texts.join(",")}]`);
41+
let wide = JSON.parse(`["\u3042",${texts.join(",")}]`);
42+
let objectsText = `[${texts.map(text => `{"a":${text}}`).join(",")}]${padding}`;
43+
let objects;
44+
for (let i = 0; i < 3; ++i)
45+
objects = JSON.parse(objectsText);
46+
for (let i = 0; i < texts.length; ++i) {
47+
let expected = Number(texts[i]);
48+
shouldBe(array[i], expected, texts[i]);
49+
shouldBe(wide[i + 1], expected, texts[i]);
50+
shouldBe(objects[i].a, expected, texts[i]);
51+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
function shouldBe(actual, expected, text) {
2+
if (!Object.is(actual, expected))
3+
throw new Error(`bad value for ${text}: ${actual}, expected: ${expected}`);
4+
}
5+
6+
let texts = [
7+
"0.1", "0.2", "0.3", "-0.0", "-0e5", "0e999999", "1e0", "1E-0", "1e+0", "1e23", "1e22", "1e-22", "1e-23",
8+
"9007199254740992", "9007199254740993", "9007199254740993.0", "9007199254740992.5", "18014398509481985",
9+
"1.7976931348623157e308", "1.7976931348623159e308", "2.2250738585072011e-308", "2.2250738585072012e-308",
10+
"4.9e-324", "5e-324", "2.4703282292062327e-324", "2.4703282292062328e-324", "1e-400", "1e400", "-1e400",
11+
"0.9999999999999999", "0.99999999999999999", "3.0000000000000004", "1.0000000000000002",
12+
"1.00000000000000011102230246251565404236316680908203125", "123456789012345678901234567890",
13+
"9999999999999999999", "99999999999999999999", "10000000000000000000", "12345678901", "-123456789012",
14+
"0.12345678", "0.123456789", "0.1234567890123456", "0.12345678901234567", "12345678.12345678",
15+
"0.0000000000000000000000001", "0.000000012345678901234567", "1.12345678e5", "0.99999999e-5",
16+
"0.0012345678901234567", "0.0000000000000000000012345678901234567", "0.00000000000000000000123456789012345678901",
17+
"0.1234567890123456789", "0.12345678901234567890", "0.000000000000000000000", "1700000000000", "1234567890123456789",
18+
"1e" + "0".repeat(50) + "5", "1e-0000000000000000000001", "1e99999", "1e100000", "1e-99999", "1e-100000",
19+
];
20+
// Leading zeros of the fraction that offset an exponent too large to be read exactly.
21+
for (let [zeros, exponent] of [[99998, 99999], [100004, 100005], [999999, 1000000]]) {
22+
let text = "0." + "0".repeat(zeros) + "1e" + exponent;
23+
texts.push(text, "-" + text, "0." + "0".repeat(zeros) + "12345678901234567e" + (exponent + 1));
24+
}
25+
let seed = 7;
26+
function rand() { seed = (seed * 16807) % 2147483647; return seed / 2147483647; }
27+
for (let i = 0; i < 400; ++i) {
28+
let value = (rand() - 0.5) * Math.pow(10, (i % 60) - 30);
29+
texts.push(String(value), value.toPrecision(1 + (i % 21)), value.toExponential(i % 21), value.toFixed(i % 21));
30+
}
31+
for (let digits = 1; digits <= 22; ++digits) {
32+
let s = "";
33+
for (let j = 0; j < digits; ++j)
34+
s += String((j * 7 + digits) % 10);
35+
s = s.replace(/^0+(?=\d)/, "");
36+
for (let dot = 1; dot < s.length; ++dot)
37+
texts.push(s.slice(0, dot) + "." + s.slice(dot));
38+
}
39+
40+
// Objects of one shape, parsed more than once, have their keys found in JSONCache, and the values after them are
41+
// read from its cursor. JSONCache matches a key only when at least 32 characters of source remain.
42+
const padding = " ".repeat(40);
43+
function parseObjects(prefix) {
44+
let text = `[${prefix}${texts.map(text => `{"a":${text},"b":${text}}`).join(",")}]${padding}`;
45+
let result;
46+
for (let i = 0; i < 3; ++i)
47+
result = JSON.parse(text);
48+
return result.slice(prefix ? 1 : 0);
49+
}
50+
51+
let array = JSON.parse(`[${texts.join(",")}]`);
52+
let values = Object.values(JSON.parse(`{${texts.map((text, i) => `"k${i}":${text}`).join(",")}}`));
53+
let wide = JSON.parse(`["\u3042",${texts.join(",")}]`);
54+
let objects = parseObjects("");
55+
let wideObjects = parseObjects(`"\u3042",`);
56+
for (let i = 0; i < texts.length; ++i) {
57+
let expected = Number(texts[i]);
58+
shouldBe(JSON.parse(texts[i]), expected, texts[i]);
59+
shouldBe(array[i], expected, texts[i]);
60+
shouldBe(values[i], expected, texts[i]);
61+
shouldBe(wide[i + 1], expected, texts[i]);
62+
shouldBe(objects[i].a, expected, texts[i]);
63+
shouldBe(objects[i].b, expected, texts[i]);
64+
shouldBe(wideObjects[i].a, expected, texts[i]);
65+
shouldBe(wideObjects[i].b, expected, texts[i]);
66+
}
67+
68+
// Characters above Latin-1 whose low byte is a digit must still end the fraction, at every position in the word.
69+
for (let length = 1; length <= 17; ++length) {
70+
let fraction = "1234567890123456789".slice(0, length);
71+
for (let character of ["\u0130", "\u0139", "\u3030", "\uff10"]) {
72+
for (let text of [`[0.${fraction}${character}]`, `[0.${fraction}${character}12345678]`, `{"a":1.${fraction}${character}}`]) {
73+
let error = null;
74+
try {
75+
JSON.parse(text);
76+
} catch (e) {
77+
error = e;
78+
}
79+
if (!(error instanceof SyntaxError))
80+
throw new Error(`did not throw SyntaxError: ${escape(text)}`);
81+
}
82+
}
83+
}

‎Source/JavaScriptCore/runtime/LiteralParser.cpp‎

Lines changed: 135 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
#include "SourceCharacters.h"
3939
#include <wtf/ASCIICType.h>
4040
#include <wtf/Range.h>
41+
#include <wtf/SIMDHelpers.h>
4142
#include <wtf/TZoneMallocInlines.h>
43+
#include <wtf/UnalignedAccess.h>
4244
#include <wtf/text/FastCharacterComparison.h>
4345
#include <wtf/text/MakeString.h>
4446

@@ -756,9 +758,9 @@ static ALWAYS_INLINE bool LEGACY_NODELETE isJSONWhiteSpace(const CharType& c)
756758
}
757759

758760
// Scans (0 | [1-9][0-9]*) from a digit and returns the end of the scan. The value can wrap beyond
759-
// numberOfDigitsForSafeInt32 digits, so the caller must check the length before using it.
761+
// maxMantissaDigitsForJSONDouble digits, so the caller must check the length before using it.
760762
template<typename CharType>
761-
static ALWAYS_INLINE const CharType* scanJSONIntegerDigits(const CharType* ptr, const CharType* end, uint32_t& accumulated)
763+
static ALWAYS_INLINE const CharType* scanJSONIntegerDigits(const CharType* ptr, const CharType* end, uint64_t& accumulated)
762764
{
763765
ASSERT(ptr < end && isASCIIDigit(*ptr));
764766
auto character = *ptr++;
@@ -1275,6 +1277,112 @@ TokenType LiteralParser<CharType, reviverMode>::Lexer::lexStringSlow(LiteralPars
12751277
return TokString;
12761278
}
12771279

1280+
static constexpr size_t maxMantissaDigitsForJSONDouble = 19;
1281+
1282+
template<typename CharType>
1283+
struct JSONDecimal {
1284+
const CharType* end;
1285+
uint64_t mantissa;
1286+
int64_t exponent;
1287+
size_t digitCount;
1288+
};
1289+
1290+
// Finishes scanning a number without a sign whose integer part, start to integerEnd, has the value integer,
1291+
// rather than having the double parser scan it again from the start. Returns std::nullopt for more than
1292+
// maxMantissaDigitsForJSONDouble significant digits, and for every syntax error, which are left to the double parser.
1293+
template<typename CharType>
1294+
static ALWAYS_INLINE std::optional<JSONDecimal<CharType>> scanJSONDecimal(const CharType* start, const CharType* integerEnd, const CharType* end, uint64_t integer)
1295+
{
1296+
size_t integerDigits = integerEnd - start;
1297+
if (integerDigits > maxMantissaDigitsForJSONDouble) [[unlikely]]
1298+
return std::nullopt;
1299+
1300+
uint64_t mantissa = integer;
1301+
const CharType* cursor = integerEnd;
1302+
const CharType* fractionStart = integerEnd;
1303+
if (cursor < end && *cursor == '.') [[likely]] {
1304+
fractionStart = ++cursor;
1305+
bool sawNonDigit = false;
1306+
// Full precision doubles have long fractions, so take eight digits at a time, and the digits
1307+
// left before the first non-digit in the last step.
1308+
static constexpr std::array<uint64_t, 8> powersOfTen { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
1309+
auto valueOfDigits = [](uint64_t digits) ALWAYS_INLINE_LAMBDA {
1310+
digits = digits * 10 + (digits >> 8);
1311+
return static_cast<uint32_t>((((digits & 0x000000FF000000FFULL) * 0x000F424000000064ULL) + (((digits >> 16) & 0x000000FF000000FFULL) * 0x0000271000000001ULL)) >> 32);
1312+
};
1313+
while (end - cursor >= 8) {
1314+
uint64_t characters;
1315+
if constexpr (sizeof(CharType) == 1)
1316+
characters = WTF::unalignedLoad<uint64_t>(cursor);
1317+
else {
1318+
// Saturating each character to a byte turns every character above Latin-1 into a non-digit.
1319+
characters = SIMD::loadAndSaturateNarrowToU64(std::bit_cast<const uint16_t*>(cursor));
1320+
}
1321+
#if CPU(BIG_ENDIAN)
1322+
// The arithmetic below needs the first character in the lowest byte.
1323+
characters = std::byteswap(characters);
1324+
#endif
1325+
uint64_t nonDigits = ((characters + 0x4646464646464646ULL) | (characters - 0x3030303030303030ULL)) & 0x8080808080808080ULL;
1326+
uint64_t digits = characters - 0x3030303030303030ULL;
1327+
if (nonDigits) {
1328+
// Carries and borrows only reach later characters, so the first non-digit is flagged exactly.
1329+
unsigned count = std::countr_zero(nonDigits) / 8;
1330+
if (count) {
1331+
mantissa = mantissa * powersOfTen[count] + valueOfDigits(digits << (64 - 8 * count));
1332+
cursor += count;
1333+
}
1334+
sawNonDigit = true;
1335+
break;
1336+
}
1337+
mantissa = mantissa * 100000000 + valueOfDigits(digits);
1338+
cursor += 8;
1339+
}
1340+
if (!sawNonDigit) [[unlikely]] {
1341+
while (cursor < end && isASCIIDigit(*cursor)) {
1342+
mantissa = mantissa * 10 + (*cursor - '0');
1343+
++cursor;
1344+
}
1345+
}
1346+
if (cursor == fractionStart) [[unlikely]]
1347+
return std::nullopt;
1348+
}
1349+
size_t fractionDigits = cursor - fractionStart;
1350+
int64_t exponent = -static_cast<int64_t>(fractionDigits);
1351+
if (cursor < end && (*cursor == 'e' || *cursor == 'E')) [[unlikely]] {
1352+
++cursor;
1353+
bool negativeExponent = false;
1354+
if (cursor < end && (*cursor == '+' || *cursor == '-'))
1355+
negativeExponent = *cursor++ == '-';
1356+
if (cursor >= end || !isASCIIDigit(*cursor)) [[unlikely]]
1357+
return std::nullopt;
1358+
// An exponent this large gives zero or infinity, unless as many leading zeros in the fraction offset it,
1359+
// so it is left to the double parser.
1360+
constexpr int64_t maxExplicitExponent = 100000;
1361+
int64_t explicitExponent = 0;
1362+
while (cursor < end && isASCIIDigit(*cursor)) {
1363+
explicitExponent = explicitExponent * 10 + (*cursor - '0');
1364+
if (explicitExponent >= maxExplicitExponent) [[unlikely]]
1365+
return std::nullopt;
1366+
++cursor;
1367+
}
1368+
exponent += negativeExponent ? -explicitExponent : explicitExponent;
1369+
}
1370+
1371+
size_t digitCount = integerDigits + fractionDigits;
1372+
if (digitCount > maxMantissaDigitsForJSONDouble) [[unlikely]] {
1373+
// An integer part of 0 and the zeros after it are not significant, and add nothing to the mantissa.
1374+
if (integer)
1375+
return std::nullopt;
1376+
const CharType* firstSignificant = fractionStart;
1377+
while (firstSignificant < cursor && *firstSignificant == '0')
1378+
++firstSignificant;
1379+
digitCount = fractionStart + fractionDigits - firstSignificant;
1380+
if (digitCount > maxMantissaDigitsForJSONDouble)
1381+
return std::nullopt;
1382+
}
1383+
return JSONDecimal<CharType> { cursor, mantissa, exponent, digitCount };
1384+
}
1385+
12781386
template<typename CharType, JSONReviverMode reviverMode>
12791387
TokenType LiteralParser<CharType, reviverMode>::Lexer::lexNumber(LiteralParserToken<CharType>& token)
12801388
{
@@ -1302,7 +1410,7 @@ TokenType LiteralParser<CharType, reviverMode>::Lexer::lexNumber(LiteralParserTo
13021410
auto* start = m_ptr; // Do not include '-'.
13031411

13041412
// (0 | [1-9][0-9]*)
1305-
uint32_t accumulated = 0;
1413+
uint64_t accumulated = 0;
13061414
if (m_ptr < m_end && isASCIIDigit(*m_ptr)) [[likely]]
13071415
m_ptr = scanJSONIntegerDigits(m_ptr, m_end, accumulated);
13081416
else {
@@ -1328,6 +1436,22 @@ TokenType LiteralParser<CharType, reviverMode>::Lexer::lexNumber(LiteralParserTo
13281436
return TokNumberInt32;
13291437
}
13301438

1439+
return lexDouble(token, initial, start, accumulated);
1440+
}
1441+
1442+
// Out of line, so that lexing the integers that most JSON numbers are does not pay for converting doubles.
1443+
template<typename CharType, JSONReviverMode reviverMode>
1444+
NEVER_INLINE TokenType LiteralParser<CharType, reviverMode>::Lexer::lexDouble(LiteralParserToken<CharType>& token, const CharType* initial, const CharType* start, uint64_t integer)
1445+
{
1446+
bool negative = initial != start;
1447+
if (auto decimal = scanJSONDecimal(start, m_ptr, m_end, integer)) {
1448+
double value = WTF::parseJSONDoubleFromDigits(decimal->mantissa, decimal->exponent, decimal->digitCount);
1449+
m_ptr = decimal->end;
1450+
token.type = TokNumber;
1451+
token.numberToken = negative ? -value : value;
1452+
return TokNumber;
1453+
}
1454+
13311455
size_t parsedLength = 0;
13321456
auto result = WTF::parseJSONDouble(std::span { initial, m_end }, parsedLength);
13331457
if (result) [[likely]] {
@@ -1760,13 +1884,17 @@ JSValue LiteralParser<CharType, reviverMode>::parseRecursively(VM& vm, uint8_t*
17601884
}
17611885
}
17621886
} else if (isASCIIDigit(*cursor)) {
1763-
// An integer of at most nine digits that ends the property is always an int32. Anything
1764-
// else, including a fraction, an exponent, or a leading zero, is left to the lexer.
1765-
uint32_t integer;
1887+
auto endsProperty = [&](const CharType* position) ALWAYS_INLINE_LAMBDA {
1888+
return position < end && (*position == ',' || *position == '}');
1889+
};
1890+
uint64_t integer;
17661891
const CharType* digits = scanJSONIntegerDigits(cursor, end, integer);
1767-
if (static_cast<size_t>(digits - cursor) <= numberOfDigitsForSafeInt32 && digits < end && (*digits == ',' || *digits == '}')) {
1892+
if (static_cast<size_t>(digits - cursor) <= numberOfDigitsForSafeInt32 && endsProperty(digits)) {
17681893
value = jsNumber(static_cast<int32_t>(integer));
17691894
cursor = digits;
1895+
} else if (auto decimal = scanJSONDecimal(cursor, digits, end, integer); decimal && endsProperty(decimal->end)) {
1896+
value = jsNumber(WTF::parseJSONDoubleFromDigits(decimal->mantissa, decimal->exponent, decimal->digitCount));
1897+
cursor = decimal->end;
17701898
}
17711899
}
17721900
}

‎Source/JavaScriptCore/runtime/LiteralParser.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class LiteralParser {
292292
ALWAYS_INLINE const CharType* findUnsafeStringCharacter(const CharType* start, const CharType* end, CharType terminator) const;
293293
TokenType lexStringSlow(LiteralParserToken<CharType>&, const CharType* runStart, CharType terminator);
294294
ALWAYS_INLINE TokenType lexNumber(LiteralParserToken<CharType>&);
295+
TokenType lexDouble(LiteralParserToken<CharType>&, const CharType* initial, const CharType* start, uint64_t integer);
295296
TokenType lexNumberError(LiteralParserToken<CharType>&);
296297

297298
String m_lexErrorMessage;

‎Source/WTF/wtf/FastFloat.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,15 @@ std::optional<double> parseJSONDouble(std::span<const char16_t> string, size_t&
9191
return doubleValue;
9292
}
9393

94+
double parseJSONDoubleFromDigitsSlow(uint64_t mantissa, int64_t exponent)
95+
{
96+
// compute_float needs the digits themselves, for a slower comparison, only when the mantissa has been
97+
// truncated, and a mantissa of at most 19 digits is exact.
98+
auto adjusted = fast_float::compute_float<fast_float::binary_format<double>>(exponent, mantissa);
99+
RELEASE_ASSERT(adjusted.power2 >= 0);
100+
double doubleValue = 0;
101+
fast_float::to_float(false, adjusted, doubleValue);
102+
return doubleValue;
103+
}
104+
94105
} // namespace WTF

0 commit comments

Comments
 (0)