Chromium Code Reviews| Index: runtime/vm/jit_optimizer.cc |
| diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc |
| index fb6ee1d43be1d01be334cbb573a14b2f57af868e..0a24f30f44839f9b0179445f298650239c1bd050 100644 |
| --- a/runtime/vm/jit_optimizer.cc |
| +++ b/runtime/vm/jit_optimizer.cc |
| @@ -199,9 +199,6 @@ void JitOptimizer::SpecializePolymorphicInstanceCall( |
| // Specialization adds receiver checks which can lead to deoptimization. |
| return; |
| } |
| - if (!call->with_checks()) { |
| - return; // Already specialized. |
| - } |
| const intptr_t receiver_cid = |
| call->PushArgumentAt(0)->value()->Type()->ToCid(); |
| @@ -220,11 +217,17 @@ void JitOptimizer::SpecializePolymorphicInstanceCall( |
| return; |
| } |
| - const bool with_checks = false; |
| - const bool complete = false; |
| - PolymorphicInstanceCallInstr* specialized = |
| - new (Z) PolymorphicInstanceCallInstr(call->instance_call(), *targets, |
| - with_checks, complete); |
| + ASSERT(targets->HasSingleTarget()); |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
ditto: abstract this pattern into a function
|
| + const Function& target = targets->FirstTarget(); |
| + ZoneGrowableArray<PushArgumentInstr*>* args = |
| + new (Z) ZoneGrowableArray<PushArgumentInstr*>( |
| + call->instance_call()->ArgumentCount()); |
| + for (intptr_t i = 0; i < call->instance_call()->ArgumentCount(); i++) { |
| + args->Add(call->instance_call()->PushArgumentAt(i)); |
| + } |
| + StaticCallInstr* specialized = new (Z) StaticCallInstr( |
| + call->token_pos(), target, call->instance_call()->argument_names(), args, |
| + call->deopt_id(), call->CallCount()); |
| call->ReplaceWith(specialized, current_iterator()); |
| } |
| @@ -1531,10 +1534,14 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
| const Function& target = Function::Handle(Z, unary_checks.GetTargetAt(0)); |
| const RawFunction::Kind function_kind = target.kind(); |
| if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { |
| - PolymorphicInstanceCallInstr* call = |
| - new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
| - /* call_with_checks = */ false, |
| - /* complete = */ false); |
| + ZoneGrowableArray<PushArgumentInstr*>* args = |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
ditto
|
| + new (Z) ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); |
| + for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { |
| + args->Add(instr->PushArgumentAt(i)); |
| + } |
| + StaticCallInstr* call = new (Z) |
| + StaticCallInstr(instr->token_pos(), target, instr->argument_names(), |
| + args, instr->deopt_id(), instr->CallCount()); |
| instr->ReplaceWith(call, current_iterator()); |
| return; |
| } |
| @@ -1550,7 +1557,6 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
| // very polymorphic sites we don't make this optimization, keeping it as a |
| // regular checked PolymorphicInstanceCall, which falls back to the slow but |
| // non-deopting megamorphic call stub when it sees new receiver classes. |
| - bool call_with_checks; |
| if (has_one_target && FLAG_polymorphic_with_deopt && |
| (!instr->ic_data()->HasDeoptReason(ICData::kDeoptCheckClass) || |
| unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks)) { |
| @@ -1559,14 +1565,22 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
| // array, not the IC array. |
| AddReceiverCheck(instr); |
| // Call can still deoptimize, do not detach environment from instr. |
| - call_with_checks = false; |
| + const Function& target = Function::Handle(Z, unary_checks.GetTargetAt(0)); |
| + ZoneGrowableArray<PushArgumentInstr*>* args = |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
ditto
|
| + new (Z) ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); |
| + for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { |
| + args->Add(instr->PushArgumentAt(i)); |
| + } |
| + StaticCallInstr* call = new (Z) |
| + StaticCallInstr(instr->token_pos(), target, instr->argument_names(), |
| + args, instr->deopt_id(), instr->CallCount()); |
| + instr->ReplaceWith(call, current_iterator()); |
| } else { |
| - call_with_checks = true; |
| + PolymorphicInstanceCallInstr* call = |
| + new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
| + /* complete = */ false); |
| + instr->ReplaceWith(call, current_iterator()); |
| } |
| - PolymorphicInstanceCallInstr* call = |
| - new (Z) PolymorphicInstanceCallInstr(instr, *targets, call_with_checks, |
| - /* complete = */ false); |
| - instr->ReplaceWith(call, current_iterator()); |
| } |