Reviewers: jochen (slow),
Description:
Fixed -fsanitize=float-cast-overflow problems.
BUG=v8:3773
LOG=y
Please review this at https://codereview.chromium.org/809293003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+8, -4 lines):
M src/factory.cc
M src/hydrogen-instructions.cc
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index
83e5a440d6591feebe0b4c47392598895c7e8409..a61d6549d40e6ac6fe62020fe048a7298e641a12
100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -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());
}
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index
1c3e1f3956d3e7cba96055054d8a2321a54998f2..60b49b0879f3801d48c20f08a2f63d0b516260b0
100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -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_));
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.