Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: src/hydrogen-instructions.cc

Issue 809293003: Fixed -fsanitize=float-cast-overflow problems. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_));
« no previous file with comments | « src/factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698