Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 050115e9be61db40272a0b0a26c98be92869d138..084b088926271468a1823f7a4cfccd808b0c52bc 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -2079,6 +2079,7 @@ static bool IsInteger32(double value) { |
HConstant::HConstant(Handle<Object> handle, Representation r) |
: handle_(handle), |
unique_id_(), |
+ has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
is_internalized_string_(false), |
@@ -2092,21 +2093,13 @@ HConstant::HConstant(Handle<Object> handle, Representation r) |
double n = handle_->Number(); |
has_int32_value_ = IsInteger32(n); |
int32_value_ = DoubleToInt32(n); |
+ has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
double_value_ = n; |
has_double_value_ = true; |
} else { |
type_from_value_ = HType::TypeFromValue(handle_); |
is_internalized_string_ = handle_->IsInternalizedString(); |
} |
- if (r.IsNone()) { |
- if (has_int32_value_) { |
- r = Representation::Integer32(); |
- } else if (has_double_value_) { |
- r = Representation::Double(); |
- } else { |
- r = Representation::Tagged(); |
- } |
- } |
Initialize(r); |
} |
@@ -2120,6 +2113,7 @@ HConstant::HConstant(Handle<Object> handle, |
bool boolean_value) |
: handle_(handle), |
unique_id_(unique_id), |
+ has_smi_value_(false), |
has_int32_value_(false), |
has_double_value_(false), |
is_internalized_string_(is_internalize_string), |
@@ -2146,6 +2140,7 @@ HConstant::HConstant(int32_t integer_value, |
boolean_value_(integer_value != 0), |
int32_value_(integer_value), |
double_value_(FastI2D(integer_value)) { |
+ has_smi_value_ = Smi::IsValid(int32_value_); |
Initialize(r); |
} |
@@ -2163,11 +2158,21 @@ HConstant::HConstant(double double_value, |
boolean_value_(double_value != 0 && !std::isnan(double_value)), |
int32_value_(DoubleToInt32(double_value)), |
double_value_(double_value) { |
+ has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
Initialize(r); |
} |
void HConstant::Initialize(Representation r) { |
+ if (r.IsNone()) { |
+ if (has_int32_value_) { |
+ r = Representation::Integer32(); |
+ } else if (has_double_value_) { |
+ r = Representation::Double(); |
+ } else { |
+ r = Representation::Tagged(); |
+ } |
+ } |
set_representation(r); |
SetFlag(kUseGVN); |
if (representation().IsInteger32()) { |
@@ -2177,6 +2182,7 @@ void HConstant::Initialize(Representation r) { |
HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
+ if (r.IsSmi() && !has_smi_value_) return NULL; |
if (r.IsInteger32() && !has_int32_value_) return NULL; |
if (r.IsDouble() && !has_double_value_) return NULL; |
if (has_int32_value_) { |