Chromium Code Reviews| Index: runtime/vm/flow_graph_optimizer.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_optimizer.cc (revision 13385) |
| +++ runtime/vm/flow_graph_optimizer.cc (working copy) |
| @@ -887,7 +887,7 @@ |
| ASSERT(call->HasICData()); |
| const ICData& ic_data = *call->ic_data(); |
| if ((ic_data.NumberOfChecks() == 0) || !ic_data.HasOneTarget()) { |
| - // No type feedback collected. |
| + // No type feedback collected or multiple targets found. |
| return false; |
| } |
| Function& target = Function::Handle(); |
| @@ -914,6 +914,31 @@ |
| return true; |
| } |
| + if ((recognized_kind == MethodRecognizer::kIntegerToInteger) && |
| + (class_ids[0] == kSmiCid)) { |
| + // TODO(srdjan): implement also for BigInt and Mint. |
| + InsertBefore(call, |
| + new CheckSmiInstr(call->ArgumentAt(0)->value()->Copy(), |
| + call->deopt_id()), |
| + call->env(), |
| + Definition::kEffect); |
| + IntegerToIntegerInstr* int2int_instr = |
| + new IntegerToIntegerInstr(call->ArgumentAt(0)->value(), call, kSmiCid); |
| + call->ReplaceWith(int2int_instr, current_iterator()); |
|
Florian Schneider
2012/10/09 11:13:58
Since IntegerToInteger itself is a nop, I think yo
srdjan
2012/10/09 21:23:04
Done.
|
| + RemovePushArguments(call); |
| + return true; |
| + } |
| + |
| + if ((recognized_kind == MethodRecognizer::kDoubleToInteger) && |
| + (class_ids[0] == kDoubleCid)) { |
| + AddCheckClass(call, call->ArgumentAt(0)->value()->Copy()); |
| + DoubleToIntegerInstr* d2int_instr = new DoubleToIntegerInstr(call); |
| + call->ReplaceWith(d2int_instr, current_iterator()); |
| + // Pushed arguments are not removed because DoubleToInt is implemented |
| + // as a call. |
| + return true; |
| + } |
| + |
| if (recognized_kind == MethodRecognizer::kStringBaseIsEmpty) { |
| if (!ic_data.HasOneTarget()) { |
| // Target is not only StringBase_get_length. |
| @@ -927,6 +952,8 @@ |
| } |
| +// Tries to optimize instance call by replacing it with a faster instruction |
| +// (e.g, binary op, field load, ..). |
| void FlowGraphOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
| if (instr->HasICData() && (instr->ic_data()->NumberOfChecks() > 0)) { |
| const Token::Kind op_kind = instr->token_kind(); |
| @@ -3049,6 +3076,23 @@ |
| } |
| +void ConstantPropagator::VisitIntegerToInteger(IntegerToIntegerInstr* instr) { |
| + const Object& value = instr->value()->definition()->constant_value(); |
| + if (IsNonConstant(value)) { |
| + SetValue(instr, non_constant_); |
| + } else if (IsConstant(value)) { |
| + // TODO(kmillikin): Handle conversion. |
| + SetValue(instr, non_constant_); |
| + } |
| +} |
| + |
| + |
| +void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { |
| + // TODO(kmillikin): Handle conversion. |
| + SetValue(instr, non_constant_); |
| +} |
| + |
| + |
| void ConstantPropagator::VisitConstant(ConstantInstr* instr) { |
| SetValue(instr, instr->value()); |
| } |