Chromium Code Reviews| Index: runtime/vm/flow_graph_optimizer.cc |
| diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc |
| index e5019017db1d796a316dc58b159f2ee608384e6c..8c4babef444ecaf1569d5c11395e6883a2941f82 100644 |
| --- a/runtime/vm/flow_graph_optimizer.cc |
| +++ b/runtime/vm/flow_graph_optimizer.cc |
| @@ -8505,19 +8505,28 @@ void ConstantPropagator::VisitMaterializeObject(MaterializeObjectInstr* instr) { |
| } |
| +static bool IsIntegerOrDouble(const Object& value) { |
| + return value.IsInteger() || value.IsDouble(); |
| +} |
| + |
| + |
| +static double ToDouble(const Object& value) { |
| + return value.IsInteger() ? Integer::Cast(value).AsDoubleValue() |
| + : Double::Cast(value).value(); |
|
Florian Schneider
2014/09/18 12:33:14
Please align : and ?.
Vyacheslav Egorov (Google)
2014/09/18 12:46:53
Done.
|
| +} |
| + |
| + |
| void ConstantPropagator::VisitBinaryDoubleOp( |
| BinaryDoubleOpInstr* instr) { |
| const Object& left = instr->left()->definition()->constant_value(); |
| const Object& right = instr->right()->definition()->constant_value(); |
| if (IsNonConstant(left) || IsNonConstant(right)) { |
| SetValue(instr, non_constant_); |
| - } else if (IsConstant(left) && IsConstant(right)) { |
| - ASSERT(left.IsSmi() || left.IsDouble()); |
| - ASSERT(right.IsSmi() || right.IsDouble()); |
| - double left_val = left.IsSmi() |
| - ? Smi::Cast(left).AsDoubleValue() : Double::Cast(left).value(); |
| - double right_val = right.IsSmi() |
| - ? Smi::Cast(right).AsDoubleValue() : Double::Cast(right).value(); |
| + } else if (left.IsInteger() && right.IsInteger()) { |
| + SetValue(instr, non_constant_); |
| + } else if (IsIntegerOrDouble(left) && IsIntegerOrDouble(right)) { |
| + const double left_val = ToDouble(left); |
| + const double right_val = ToDouble(right); |
| double result_val = 0.0; |
| switch (instr->op_kind()) { |
| case Token::kADD: |