deps: V8: cherry-pick 1648e050cade

Original commit message:

    torque: workaround stod() limitations on Solaris

    std::stod() on Solaris does not currently handle hex strings.
    This commit provides a workaround based on strtol() until proper
    stod() support is available.

    This was encountered while updating Node.js to V8 8.8. For more
    details see the following comment:

    https://github.com/nodejs/node/pull/36139#issuecomment-740131942

    Change-Id: I16ed80a817f6d9105e7153b10824b1fee8520432
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2692746
    Reviewed-by: Michael Stanton <mvstanton@chromium.org>
    Commit-Queue: Michael Stanton <mvstanton@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#73255}

Refs: 1648e050ca

PR-URL: https://github.com/nodejs/node/pull/37587
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
This commit is contained in:
Michaël Zasso 2021-03-12 08:28:36 +01:00
parent 621b544909
commit 64d5be25ab
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2 changed files with 12 additions and 1 deletions

View File

@ -36,7 +36,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.6',
'v8_embedder_string': '-node.7',
##### V8 defaults for Node.js #####

View File

@ -1834,7 +1834,18 @@ base::Optional<ParseResult> MakeNumberLiteralExpression(
// Meanwhile, we type it as constexpr float64 when out of int32 range.
double value = 0;
try {
#if defined(V8_OS_SOLARIS)
// stod() on Solaris does not currently support hex strings. Use strtol()
// specifically for hex literals until stod() support is available.
if (number.find("0x") == std::string::npos &&
number.find("0X") == std::string::npos) {
value = std::stod(number);
} else {
value = static_cast<double>(strtol(number.c_str(), nullptr, 0));
}
#else
value = std::stod(number);
#endif // !defined(V8_OS_SOLARIS)
} catch (const std::out_of_range&) {
Error("double literal out-of-range").Throw();
}