Commit bb65d40d authored by svenpanne's avatar svenpanne Committed by Commit bot

Fixed -fsanitize=float-cast-overflow problems.

BUG=v8:3773
LOG=y

Review URL: https://codereview.chromium.org/809293003

Cr-Commit-Position: refs/heads/master@{#25880}
parent a09168be
......@@ -1035,7 +1035,7 @@ Handle<Object> Factory::NewNumber(double value,
// patterns is faster than using fpclassify() et al.
if (IsMinusZero(value)) return NewHeapNumber(-0.0, IMMUTABLE, pretenure);
int int_value = FastD2I(value);
int int_value = FastD2IChecked(value);
if (value == int_value && Smi::IsValid(int_value)) {
return handle(Smi::FromInt(int_value), isolate());
}
......
......@@ -2672,8 +2672,12 @@ std::ostream& HEnterInlined::PrintDataTo(std::ostream& os) const { // NOLINT
static bool IsInteger32(double value) {
double roundtrip_value = static_cast<double>(static_cast<int32_t>(value));
return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value);
if (value >= std::numeric_limits<int32_t>::min() &&
value <= std::numeric_limits<int32_t>::max()) {
double roundtrip_value = static_cast<double>(static_cast<int32_t>(value));
return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value);
}
return false;
}
......@@ -2779,7 +2783,7 @@ HConstant::HConstant(double double_value, Representation r,
!std::isnan(double_value)) |
IsUndetectableField::encode(false) |
InstanceTypeField::encode(kUnknownInstanceType)),
int32_value_(DoubleToInt32(double_value)),
int32_value_(HasInteger32Value() ? DoubleToInt32(double_value) : 0),
double_value_(double_value) {
bit_field_ = HasSmiValueField::update(
bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment