| Index: runtime/vm/aot_optimizer.cc
|
| diff --git a/runtime/vm/aot_optimizer.cc b/runtime/vm/aot_optimizer.cc
|
| index a30e36b328a0b24abbbb54cc6b4e084b11729764..9b09a891fa1c401dc161f1109c267047601faa09 100644
|
| --- a/runtime/vm/aot_optimizer.cc
|
| +++ b/runtime/vm/aot_optimizer.cc
|
| @@ -122,14 +122,8 @@ bool AotOptimizer::RecognizeRuntimeTypeGetter(InstanceCallInstr* call) {
|
| cls, call->function_name(), args_desc));
|
| ASSERT(!function.IsNull());
|
|
|
| - ZoneGrowableArray<PushArgumentInstr*>* args =
|
| - new (Z) ZoneGrowableArray<PushArgumentInstr*>(call->ArgumentCount());
|
| - for (intptr_t i = 0; i < call->ArgumentCount(); i++) {
|
| - args->Add(call->PushArgumentAt(i));
|
| - }
|
| - StaticCallInstr* static_call = new (Z) StaticCallInstr(
|
| - call->token_pos(), Function::ZoneHandle(Z, function.raw()),
|
| - call->argument_names(), args, call->deopt_id());
|
| + const Function& target = Function::ZoneHandle(Z, function.raw());
|
| + StaticCallInstr* static_call = StaticCallInstr::FromCall(Z, call, target);
|
| static_call->set_result_cid(kTypeCid);
|
| call->ReplaceWith(static_call, current_iterator());
|
| return true;
|
| @@ -652,7 +646,7 @@ bool AotOptimizer::TryReplaceWithHaveSameRuntimeType(InstanceCallInstr* call) {
|
| StaticCallInstr* static_call =
|
| new (Z) StaticCallInstr(call->token_pos(), have_same_runtime_type,
|
| Object::null_array(), // argument_names
|
| - args, call->deopt_id());
|
| + args, call->deopt_id(), call->CallCount());
|
| static_call->set_result_cid(kBoolCid);
|
| ReplaceCall(call, static_call);
|
| return true;
|
| @@ -1518,7 +1512,7 @@ void AotOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
|
| StaticCallInstr* new_call =
|
| new (Z) StaticCallInstr(call->token_pos(), target,
|
| Object::null_array(), // argument_names
|
| - args, call->deopt_id());
|
| + args, call->deopt_id(), call->CallCount());
|
| Environment* copy = call->env()->DeepCopy(
|
| Z, call->env()->Length() - call->ArgumentCount());
|
| for (intptr_t i = 0; i < args->length(); ++i) {
|
| @@ -1610,7 +1604,7 @@ void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) {
|
| StaticCallInstr* new_call =
|
| new (Z) StaticCallInstr(call->token_pos(), target,
|
| Object::null_array(), // argument_names
|
| - args, call->deopt_id());
|
| + args, call->deopt_id(), call->CallCount());
|
| Environment* copy =
|
| call->env()->DeepCopy(Z, call->env()->Length() - call->ArgumentCount());
|
| for (intptr_t i = 0; i < args->length(); ++i) {
|
| @@ -1673,7 +1667,7 @@ void AotOptimizer::ReplaceWithTypeCast(InstanceCallInstr* call) {
|
| StaticCallInstr* new_call =
|
| new (Z) StaticCallInstr(call->token_pos(), target,
|
| Object::null_array(), // argument_names
|
| - args, call->deopt_id());
|
| + args, call->deopt_id(), call->CallCount());
|
| Environment* copy = call->env()->DeepCopy(
|
| Z, call->env()->Length() - call->ArgumentCount());
|
| for (intptr_t i = 0; i < args->length(); ++i) {
|
| @@ -1843,10 +1837,9 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
| Function::Handle(Z, unary_checks.GetTargetAt(0)).kind();
|
| if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) {
|
| CallTargets* targets = CallTargets::Create(Z, unary_checks);
|
| - PolymorphicInstanceCallInstr* call =
|
| - new (Z) PolymorphicInstanceCallInstr(instr, *targets,
|
| - /* with_checks = */ false,
|
| - /* complete = */ true);
|
| + ASSERT(targets->HasSingleTarget());
|
| + const Function& target = targets->FirstTarget();
|
| + StaticCallInstr* call = StaticCallInstr::FromCall(Z, instr, target);
|
| instr->ReplaceWith(call, current_iterator());
|
| return;
|
| }
|
| @@ -1909,14 +1902,8 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
| Z, Resolver::ResolveDynamicForReceiverClass(
|
| receiver_class, instr->function_name(), args_desc));
|
| if (!function.IsNull()) {
|
| - CallTargets* targets = new (Z) CallTargets();
|
| - Function& target = Function::ZoneHandle(Z, function.raw());
|
| - targets->Add(CidRangeTarget(receiver_class.id(), receiver_class.id(),
|
| - &target, /*count = */ 1));
|
| - PolymorphicInstanceCallInstr* call =
|
| - new (Z) PolymorphicInstanceCallInstr(instr, *targets,
|
| - /* with_checks = */ false,
|
| - /* complete = */ true);
|
| + const Function& target = Function::ZoneHandle(Z, function.raw());
|
| + StaticCallInstr* call = StaticCallInstr::FromCall(Z, instr, target);
|
| instr->ReplaceWith(call, current_iterator());
|
| return;
|
| }
|
| @@ -2025,14 +2012,8 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
|
|
| // We have computed that there is only a single target for this call
|
| // within the whole hierarchy. Replace InstanceCall with StaticCall.
|
| - ZoneGrowableArray<PushArgumentInstr*>* args = 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(), Function::ZoneHandle(Z, single_target.raw()),
|
| - instr->argument_names(), args, instr->deopt_id());
|
| + const Function& target = Function::ZoneHandle(Z, single_target.raw());
|
| + StaticCallInstr* call = StaticCallInstr::FromCall(Z, instr, target);
|
| instr->ReplaceWith(call, current_iterator());
|
| return;
|
| } else if ((ic_data.raw() != ICData::null()) &&
|
| @@ -2040,7 +2021,6 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
| CallTargets* targets = CallTargets::Create(Z, ic_data);
|
| PolymorphicInstanceCallInstr* call =
|
| new (Z) PolymorphicInstanceCallInstr(instr, *targets,
|
| - /* with_checks = */ true,
|
| /* complete = */ true);
|
| instr->ReplaceWith(call, current_iterator());
|
| return;
|
| @@ -2057,7 +2037,6 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
| CallTargets* targets = CallTargets::Create(Z, *instr->ic_data());
|
| PolymorphicInstanceCallInstr* call =
|
| new (Z) PolymorphicInstanceCallInstr(instr, *targets,
|
| - /* with_checks = */ true,
|
| /* complete = */ false);
|
| instr->ReplaceWith(call, current_iterator());
|
| return;
|
| @@ -2067,24 +2046,24 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
|
|
|
| void AotOptimizer::VisitPolymorphicInstanceCall(
|
| PolymorphicInstanceCallInstr* call) {
|
| - if (call->with_checks()) {
|
| - const intptr_t receiver_cid =
|
| - call->PushArgumentAt(0)->value()->Type()->ToCid();
|
| - if (receiver_cid != kDynamicCid) {
|
| - const Class& receiver_class =
|
| - Class::Handle(Z, isolate()->class_table()->At(receiver_cid));
|
| -
|
| - const Array& args_desc_array = Array::Handle(
|
| - Z, ArgumentsDescriptor::New(call->ArgumentCount(),
|
| - call->instance_call()->argument_names()));
|
| - ArgumentsDescriptor args_desc(args_desc_array);
|
| - const Function& function = Function::Handle(
|
| - Z, Resolver::ResolveDynamicForReceiverClass(
|
| - receiver_class, call->instance_call()->function_name(),
|
| - args_desc));
|
| - if (!function.IsNull()) {
|
| - call->set_with_checks(false);
|
| - }
|
| + const intptr_t receiver_cid =
|
| + call->PushArgumentAt(0)->value()->Type()->ToCid();
|
| + if (receiver_cid != kDynamicCid) {
|
| + const Class& receiver_class =
|
| + Class::Handle(Z, isolate()->class_table()->At(receiver_cid));
|
| +
|
| + const Array& args_desc_array = Array::Handle(
|
| + Z, ArgumentsDescriptor::New(call->ArgumentCount(),
|
| + call->instance_call()->argument_names()));
|
| + ArgumentsDescriptor args_desc(args_desc_array);
|
| + const Function& function = Function::Handle(
|
| + Z,
|
| + Resolver::ResolveDynamicForReceiverClass(
|
| + receiver_class, call->instance_call()->function_name(), args_desc));
|
| + if (!function.IsNull()) {
|
| + // Only one target. Replace by static call.
|
| + StaticCallInstr* new_call = StaticCallInstr::FromCall(Z, call, function);
|
| + call->ReplaceWith(new_call, current_iterator());
|
| }
|
| }
|
| }
|
|
|