Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index 38eabdae06aa5d9968d1479e050e883ff7b707f2..33ab8797252b9880a50fb3a3f2deff5f8a9f9ca9 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -521,19 +521,12 @@ bool HValue::CanReplaceWithDummyUses() { |
| bool HValue::IsInteger32Constant() { |
| - HValue* value_to_check = IsForceRepresentation() |
| - ? HForceRepresentation::cast(this)->value() |
| - : this; |
| - return value_to_check->IsConstant() && |
| - HConstant::cast(value_to_check)->HasInteger32Value(); |
| + return IsConstant() && HConstant::cast(this)->HasInteger32Value(); |
| } |
| int32_t HValue::GetInteger32Constant() { |
| - HValue* constant_value = IsForceRepresentation() |
| - ? HForceRepresentation::cast(this)->value() |
| - : this; |
| - return HConstant::cast(constant_value)->Integer32Value(); |
| + return HConstant::cast(this)->Integer32Value(); |
| } |
| @@ -1328,6 +1321,23 @@ void HTypeof::PrintDataTo(StringStream* stream) { |
| } |
| +HInstruction* HForceRepresentation::New(Zone* zone, HValue* context, |
| + HValue* value, Representation required_representation) { |
| + if (FLAG_fold_constants && value->IsConstant()) { |
| + HConstant* c = HConstant::cast(value); |
| + if ((c->HasNumberValue())) { |
|
mvstanton
2013/11/19 10:22:28
nit: remove extra parens
Igor Sheludko
2013/11/19 11:43:35
Done.
|
| + double double_res = c->DoubleValue(); |
| + if (TypeInfo::IsInt32Double(double_res)) { |
| + return HConstant::New(zone, context, |
| + static_cast<int32_t>(double_res), |
| + required_representation); |
| + } |
| + } |
| + } |
| + return new(zone) HForceRepresentation(value, required_representation); |
| +} |
| + |
| + |
| void HForceRepresentation::PrintDataTo(StringStream* stream) { |
| stream->Add("%s ", representation().Mnemonic()); |
| value()->PrintNameTo(stream); |