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

Unified Diff: src/crankshaft/hydrogen-instructions.cc

Issue 2106393002: Fix double canonicalization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 6 months 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 | « no previous file | test/mjsunit/regress/regress-double-canonicalization.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen-instructions.cc
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc
index 6036d3fb68c6e99f250c8a1c22da9fe9aeefa79b..74a83c06a175fa13f4ee59f974eae8035c120c0d 100644
--- a/src/crankshaft/hydrogen-instructions.cc
+++ b/src/crankshaft/hydrogen-instructions.cc
@@ -2195,7 +2195,11 @@ HConstant::HConstant(Handle<Object> object, Representation r)
int32_value_ = DoubleToInt32(n);
bit_field_ = HasSmiValueField::update(
bit_field_, has_int32_value && Smi::IsValid(int32_value_));
- double_value_ = n;
+ if (std::isnan(n)) {
+ double_value_ = std::numeric_limits<double>::quiet_NaN();
+ } else {
+ double_value_ = n;
+ }
bit_field_ = HasDoubleValueField::update(bit_field_, true);
}
@@ -2248,7 +2252,6 @@ HConstant::HConstant(int32_t integer_value, Representation r,
Initialize(r);
}
-
HConstant::HConstant(double double_value, Representation r,
bool is_not_in_new_space, Unique<Object> object)
: object_(object),
@@ -2262,8 +2265,7 @@ HConstant::HConstant(double double_value, Representation r,
!std::isnan(double_value)) |
IsUndetectableField::encode(false) |
InstanceTypeField::encode(kUnknownInstanceType)),
- int32_value_(DoubleToInt32(double_value)),
- double_value_(double_value) {
+ int32_value_(DoubleToInt32(double_value)) {
bit_field_ = HasSmiValueField::update(
bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
// It's possible to create a constant with a value in Smi-range but stored
@@ -2271,6 +2273,11 @@ HConstant::HConstant(double double_value, Representation r,
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
+ if (std::isnan(double_value)) {
+ double_value_ = std::numeric_limits<double>::quiet_NaN();
+ } else {
+ double_value_ = double_value;
+ }
Initialize(r);
}
@@ -3289,13 +3296,11 @@ bool HStoreKeyed::NeedsCanonicalization() {
Representation from = HChange::cast(value())->from();
return from.IsTagged() || from.IsHeapObject();
}
- case kLoadNamedField:
- case kPhi: {
- // Better safe than sorry...
- return true;
- }
- default:
+ case kConstant:
+ // Double constants are canonicalized upon construction.
return false;
+ default:
+ return !value()->IsBinaryOperation();
}
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-double-canonicalization.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698