Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index c93bc1144af36376167cbac155e664ec57cda72c..cd9186c00106b0a23fcc96adcb78ad5265c9454e 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -1432,20 +1432,32 @@ void HTypeof::PrintDataTo(StringStream* stream) { |
} |
+static bool CanRepresentationContainDouble(Representation rep, double value) { |
Jakob Kummerow
2014/03/12 09:16:24
nit: How about moving this to Representation::CanR
|
+ if (rep.IsDouble() || rep.is_more_general_than(Representation::Double())) { |
+ return true; |
+ } |
+ if (IsInt32Double(value)) { |
+ if (rep.IsInteger32()) return true; |
+ if (rep.IsSmi()) return Smi::IsValid(static_cast<int32_t>(value)); |
+ } |
+ return false; |
+} |
+ |
+ |
HInstruction* HForceRepresentation::New(Zone* zone, HValue* context, |
- HValue* value, Representation required_representation) { |
+ HValue* value, Representation representation) { |
if (FLAG_fold_constants && value->IsConstant()) { |
HConstant* c = HConstant::cast(value); |
if (c->HasNumberValue()) { |
double double_res = c->DoubleValue(); |
- if (IsInt32Double(double_res)) { |
+ if (CanRepresentationContainDouble(representation, double_res)) { |
return HConstant::New(zone, context, |
static_cast<int32_t>(double_res), |
- required_representation); |
+ representation); |
} |
} |
} |
- return new(zone) HForceRepresentation(value, required_representation); |
+ return new(zone) HForceRepresentation(value, representation); |
} |