From f2c43572c8bfd97c2d8bd7581d599d1a9fb2eb32 Mon Sep 17 00:00:00 2001 From: Almaz Mingaleev Date: Thu, 29 Aug 2024 09:52:58 +0000 Subject: Address follow-up comments from aosp/2721077. Bug: 297147201 Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: Ie89d310633339b785de5d9f3daf653abfbff875c --- compiler/optimizing/instruction_builder.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index d7553dd14f..356322e85b 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1391,9 +1391,13 @@ bool HInstructionBuilder::BuildInvokePolymorphic(uint32_t dex_pc, MethodReference method_reference(&graph_->GetDexFile(), method_idx); + // MethodHandle.invokeExact intrinsic needs to check whether call-site matches with MethodHandle's + // type. To do that, MethodType corresponding to the call-site is passed as an extra input. + // Other invoke-polymorphic calls do not need it. bool is_invoke_exact = static_cast(resolved_method->GetIntrinsic()) == Intrinsics::kMethodHandleInvokeExact; + // Currently intrinsic works for MethodHandle targeting invoke-virtual calls only. bool can_be_virtual = number_of_arguments >= 2 && DataType::FromShorty(shorty[1]) == DataType::Type::kReference; @@ -1414,7 +1418,7 @@ bool HInstructionBuilder::BuildInvokePolymorphic(uint32_t dex_pc, return false; } - DCHECK_EQ(invoke->AsInvokePolymorphic()->CanTargetInvokeVirtual(), can_be_intrinsified); + DCHECK_EQ(invoke->AsInvokePolymorphic()->CanHaveFastPath(), can_be_intrinsified); if (invoke->GetIntrinsic() != Intrinsics::kNone && invoke->GetIntrinsic() != Intrinsics::kMethodHandleInvoke && @@ -1896,7 +1900,9 @@ bool HInstructionBuilder::SetupInvokeArguments(HInstruction* invoke, if (invoke->IsInvokePolymorphic()) { HInvokePolymorphic* invoke_polymorphic = invoke->AsInvokePolymorphic(); - if (invoke_polymorphic->CanTargetInvokeVirtual()) { + // MethodHandle.invokeExact intrinsic expects MethodType corresponding to the call-site as an + // extra input to determine whether to throw WrongMethodTypeException or execute target method. + if (invoke_polymorphic->CanHaveFastPath()) { HLoadMethodType* load_method_type = new (allocator_) HLoadMethodType(graph_->GetCurrentMethod(), invoke_polymorphic->GetProtoIndex(), -- cgit v1.2.3-59-g8ed1b