From 8d34a182fea1b24f7b8361b55e930cb953cf3fb2 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 16 Sep 2020 09:46:58 +0100 Subject: Change interface conflict stub to take the interface method. To avoid doing dex cache lookup, pass the interface method instead. This costs a few hundred KBs on speed compiled APKs (< 0.5% code size), but improves performance when hitting a conflict (as seen on dogfood data). For nterp, we currently pass the conflict method instead of the interface method. We need to handle default methods before optimizing it. This removes our last use of dex cache in compiled code. A follow-up CL will remove the NeedsDexCacheOfDeclaringClass from HInvokeInterface. Test: test.py Change-Id: I3cdd4543ad7d904b3e81950af46a48a48af6991a --- compiler/optimizing/instruction_builder.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index f917500dac..0531d725e7 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1104,9 +1104,9 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, } } HInvokeStaticOrDirect::DispatchInfo dispatch_info = - HSharpening::SharpenInvokeStaticOrDirect(resolved_method, - has_method_id, - code_generator_); + HSharpening::SharpenLoadMethod(resolved_method, + has_method_id, + code_generator_); if (dispatch_info.code_ptr_location == CodePtrLocation::kCallCriticalNative) { graph_->SetHasDirectCriticalNativeCall(true); } @@ -1138,6 +1138,13 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, /*vtable_index=*/ imt_or_vtable_index); } else { DCHECK_EQ(invoke_type, kInterface); + if (kIsDebugBuild) { + ScopedObjectAccess soa(Thread::Current()); + DCHECK(resolved_method->GetDeclaringClass()->IsInterface()); + } + MethodLoadKind load_kind = + HSharpening::SharpenLoadMethod(resolved_method, /* has_method_id= */ true, code_generator_) + .method_load_kind; invoke = new (allocator_) HInvokeInterface(allocator_, number_of_arguments, return_type, @@ -1145,7 +1152,8 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, method_reference, resolved_method, resolved_method_reference, - /*imt_index=*/ imt_or_vtable_index); + /*imt_index=*/ imt_or_vtable_index, + load_kind); } return HandleInvoke(invoke, operands, shorty, /* is_unresolved= */ false); } @@ -1669,6 +1677,12 @@ bool HInstructionBuilder::SetupInvokeArguments(HInstruction* invoke, invoke->SetRawInputAt(argument_index, graph_->GetCurrentMethod()); } + if (invoke->IsInvokeInterface() && + (invoke->AsInvokeInterface()->GetHiddenArgumentLoadKind() == MethodLoadKind::kRecursive)) { + invoke->SetRawInputAt(invoke->AsInvokeInterface()->GetNumberOfArguments() - 1, + graph_->GetCurrentMethod()); + } + return true; } -- cgit v1.2.3-59-g8ed1b