Index: src/hydrogen-instructions.cc |
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
index 16f502ddaf7b11f3d9600ecd40b025dc899e38d1..8cc251c39f69a30d5c33730c7fe2ea57caaeefad 100644 |
--- a/src/hydrogen-instructions.cc |
+++ b/src/hydrogen-instructions.cc |
@@ -2310,7 +2310,7 @@ HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
} |
-HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
+HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) { |
if (has_int32_value_) { |
return new(zone) HConstant(int32_value_, |
Representation::Integer32(), |
@@ -2323,6 +2323,20 @@ HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
is_not_in_new_space_, |
handle_); |
} |
+ HConstant* number = CopyToTruncatedNumber(zone); |
+ return (number != NULL) ? number->CopyToTruncatedInt32(zone) : NULL; |
+} |
+ |
+ |
+HConstant* HConstant::CopyToTruncatedNumber(Zone* zone) { |
Toon Verwaest
2013/07/22 08:31:44
Shouldn't we also return "this" for values that ar
oliv
2013/07/22 13:56:43
there is no point to copying the constant if we ar
|
+ if (handle()->IsBoolean()) { |
+ return handle()->BooleanValue() ? |
+ new(zone) HConstant(1) : new(zone) HConstant(0); |
+ } else if (handle()->IsUndefined()) { |
+ return new(zone) HConstant(OS::nan_value()); |
+ } else if (handle()->IsNull()) { |
+ return new(zone) HConstant(0); |
+ } |
return NULL; |
} |