Reland "Fix -Wimplicit-int-float-conversions."
This is a reland of edab873071
It was speculatively reverted but the issue turned out to just be slow
tests.
Original change's description:
> Fix -Wimplicit-int-float-conversions.
>
> Bug: chromium:989932
> Change-Id: Ief917b023cb079f5ff87dc8963d74f225d074d7a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2989096
> Reviewed-by: Bill Budge <bbudge@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Auto-Submit: Peter Kasting <pkasting@chromium.org>
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#75413}
Bug: chromium:989932
Change-Id: Iec8ac8ee32705c6a699a2df2f292ffe07cde99f7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2994802
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75443}
This commit is contained in:
parent
67cac2c51a
commit
6f6bfe146f
@ -7,6 +7,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/safe_conversions.h"
|
||||
#include "src/codegen/code-factory.h"
|
||||
#include "src/compiler/js-heap-broker.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
@ -1090,8 +1091,7 @@ Node* RepresentationChanger::GetWord64RepresentationFor(
|
||||
case IrOpcode::kNumberConstant: {
|
||||
if (use_info.type_check() != TypeCheckKind::kBigInt) {
|
||||
double const fv = OpParameter<double>(node->op());
|
||||
using limits = std::numeric_limits<int64_t>;
|
||||
if (fv <= limits::max() && fv >= limits::min()) {
|
||||
if (base::IsValueInRangeForNumericType<int64_t>(fv)) {
|
||||
int64_t const iv = static_cast<int64_t>(fv);
|
||||
if (static_cast<double>(iv) == fv) {
|
||||
return jsgraph()->Int64Constant(iv);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/objects/elements.h"
|
||||
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/safe_conversions.h"
|
||||
#include "src/common/message-template.h"
|
||||
#include "src/execution/arguments.h"
|
||||
#include "src/execution/frames.h"
|
||||
@ -3367,8 +3368,8 @@ class TypedElementsAccessor
|
||||
}
|
||||
return Just(false);
|
||||
}
|
||||
} else if (search_value < std::numeric_limits<ElementType>::lowest() ||
|
||||
search_value > std::numeric_limits<ElementType>::max()) {
|
||||
} else if (!base::IsValueInRangeForNumericType<ElementType>(
|
||||
search_value)) {
|
||||
// Return false if value can't be represented in this space.
|
||||
return Just(false);
|
||||
}
|
||||
@ -3414,8 +3415,8 @@ class TypedElementsAccessor
|
||||
if (std::isnan(search_value)) {
|
||||
return Just<int64_t>(-1);
|
||||
}
|
||||
} else if (search_value < std::numeric_limits<ElementType>::lowest() ||
|
||||
search_value > std::numeric_limits<ElementType>::max()) {
|
||||
} else if (!base::IsValueInRangeForNumericType<ElementType>(
|
||||
search_value)) {
|
||||
// Return false if value can't be represented in this ElementsKind.
|
||||
return Just<int64_t>(-1);
|
||||
}
|
||||
@ -3467,8 +3468,8 @@ class TypedElementsAccessor
|
||||
// Strict Equality Comparison of NaN is always false.
|
||||
return Just<int64_t>(-1);
|
||||
}
|
||||
} else if (search_value < std::numeric_limits<ElementType>::lowest() ||
|
||||
search_value > std::numeric_limits<ElementType>::max()) {
|
||||
} else if (!base::IsValueInRangeForNumericType<ElementType>(
|
||||
search_value)) {
|
||||
// Return -1 if value can't be represented in this ElementsKind.
|
||||
return Just<int64_t>(-1);
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
|
||||
if (fp > len) return Smi::FromInt(-1);
|
||||
if (V8_LIKELY(fp >=
|
||||
static_cast<double>(std::numeric_limits<int64_t>::min()))) {
|
||||
DCHECK(fp < std::numeric_limits<int64_t>::max());
|
||||
DCHECK(fp < static_cast<double>(std::numeric_limits<int64_t>::max()));
|
||||
start_from = static_cast<int64_t>(fp);
|
||||
} else {
|
||||
start_from = std::numeric_limits<int64_t>::min();
|
||||
|
@ -238,7 +238,7 @@ void float32_to_uint64_sat_wrapper(Address data) {
|
||||
WriteUnalignedValue<uint64_t>(data, static_cast<uint64_t>(input));
|
||||
return;
|
||||
}
|
||||
if (input >= std::numeric_limits<uint64_t>::max()) {
|
||||
if (input >= static_cast<float>(std::numeric_limits<uint64_t>::max())) {
|
||||
WriteUnalignedValue<uint64_t>(data, std::numeric_limits<uint64_t>::max());
|
||||
return;
|
||||
}
|
||||
@ -268,7 +268,7 @@ void float64_to_uint64_sat_wrapper(Address data) {
|
||||
WriteUnalignedValue<uint64_t>(data, static_cast<uint64_t>(input));
|
||||
return;
|
||||
}
|
||||
if (input >= std::numeric_limits<uint64_t>::max()) {
|
||||
if (input >= static_cast<double>(std::numeric_limits<uint64_t>::max())) {
|
||||
WriteUnalignedValue<uint64_t>(data, std::numeric_limits<uint64_t>::max());
|
||||
return;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ struct ConvertJSValue<int64_t> {
|
||||
constexpr uint64_t kMaxULL = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
// -2^{64} < fmod_value < 2^{64}.
|
||||
double fmod_value = fmod(result, kMaxULL + 1.0);
|
||||
double fmod_value = fmod(result, static_cast<double>(kMaxULL));
|
||||
if (fmod_value >= 0) {
|
||||
if (fmod_value < pow(2, 63)) {
|
||||
// 0 <= fmod_value < 2^{63}.
|
||||
@ -133,7 +133,7 @@ struct ConvertJSValue<uint64_t> {
|
||||
constexpr uint64_t kMaxULL = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
// -2^{64} < fmod_value < 2^{64}.
|
||||
double fmod_value = fmod(result, kMaxULL + 1.0);
|
||||
double fmod_value = fmod(result, static_cast<double>(kMaxULL));
|
||||
if (fmod_value >= 0) {
|
||||
return v8::Just(static_cast<uint64_t>(fmod_value));
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ TEST(GCIdleTimeHandler, EstimateMarkingStepSizeNonZero) {
|
||||
|
||||
TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow1) {
|
||||
size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
|
||||
10, std::numeric_limits<size_t>::max());
|
||||
10, static_cast<double>(std::numeric_limits<size_t>::max()));
|
||||
EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
|
||||
step_size);
|
||||
}
|
||||
@ -65,7 +65,7 @@ TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow1) {
|
||||
|
||||
TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) {
|
||||
size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
|
||||
std::numeric_limits<size_t>::max(), 10);
|
||||
static_cast<double>(std::numeric_limits<size_t>::max()), 10);
|
||||
EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize),
|
||||
step_size);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user