diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2020-09-16 09:46:58 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2020-10-07 08:32:52 +0000 |
commit | 8d34a182fea1b24f7b8361b55e930cb953cf3fb2 (patch) | |
tree | 4f5ed9d9ac417dfd69fd18f64412b2272c448e05 /compiler/optimizing/instruction_builder.cc | |
parent | 8ecbc4e844fc3b73e6a5c5151eda914d53297180 (diff) |
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
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 22 |
1 files changed, 18 insertions, 4 deletions
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; } |