From 93163edd92664c79da56ffcf5de32b7b872136ce Mon Sep 17 00:00:00 2001 From: Almaz Mingaleev Date: Tue, 22 Aug 2023 15:00:44 +0100 Subject: x86_64: Add instrinsic for MethodHandle::invokeExact... ... which targets invoke-virtual methods. New entrypoint changes deliverException's offset, hence arm test change. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing Test: ./art/test.py --host -g Change-Id: I636fc60c088bfdf9b695c92de47f1c539e3956f1 --- compiler/optimizing/instruction_builder.cc | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index c97c78ca17..d7553dd14f 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1390,8 +1390,20 @@ bool HInstructionBuilder::BuildInvokePolymorphic(uint32_t dex_pc, &is_string_constructor); MethodReference method_reference(&graph_->GetDexFile(), method_idx); + + bool is_invoke_exact = + static_cast(resolved_method->GetIntrinsic()) == + Intrinsics::kMethodHandleInvokeExact; + bool can_be_virtual = number_of_arguments >= 2 && + DataType::FromShorty(shorty[1]) == DataType::Type::kReference; + + bool can_be_intrinsified = is_invoke_exact && can_be_virtual; + + uint32_t number_of_other_inputs = can_be_intrinsified ? 1u : 0u; + HInvoke* invoke = new (allocator_) HInvokePolymorphic(allocator_, number_of_arguments, + number_of_other_inputs, return_type, dex_pc, method_reference, @@ -1402,6 +1414,8 @@ bool HInstructionBuilder::BuildInvokePolymorphic(uint32_t dex_pc, return false; } + DCHECK_EQ(invoke->AsInvokePolymorphic()->CanTargetInvokeVirtual(), can_be_intrinsified); + if (invoke->GetIntrinsic() != Intrinsics::kNone && invoke->GetIntrinsic() != Intrinsics::kMethodHandleInvoke && invoke->GetIntrinsic() != Intrinsics::kMethodHandleInvokeExact && @@ -1879,6 +1893,24 @@ bool HInstructionBuilder::SetupInvokeArguments(HInstruction* invoke, graph_->GetCurrentMethod()); } + if (invoke->IsInvokePolymorphic()) { + HInvokePolymorphic* invoke_polymorphic = invoke->AsInvokePolymorphic(); + + if (invoke_polymorphic->CanTargetInvokeVirtual()) { + HLoadMethodType* load_method_type = + new (allocator_) HLoadMethodType(graph_->GetCurrentMethod(), + invoke_polymorphic->GetProtoIndex(), + graph_->GetDexFile(), + invoke_polymorphic->GetDexPc()); + HSharpening::ProcessLoadMethodType(load_method_type, + code_generator_, + *dex_compilation_unit_, + graph_->GetHandleCache()->GetHandles()); + invoke->SetRawInputAt(invoke_polymorphic->GetNumberOfArguments(), load_method_type); + AppendInstruction(load_method_type); + } + } + return true; } -- cgit v1.2.3-59-g8ed1b