diff options
author | 2024-08-29 09:52:58 +0000 | |
---|---|---|
committer | 2024-09-02 11:14:57 +0000 | |
commit | f2c43572c8bfd97c2d8bd7581d599d1a9fb2eb32 (patch) | |
tree | bfd4f80a3825bf1b3def119e635aad03d27248bc /compiler/optimizing/instruction_builder.cc | |
parent | ab13b431d44add08b68d96d99bbb0d0b3f2ce86d (diff) |
Address follow-up comments from aosp/2721077.
Bug: 297147201
Test: ./art/test/testrunner/testrunner.py --host --64 -b --optimizing
Change-Id: Ie89d310633339b785de5d9f3daf653abfbff875c
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 10 |
1 files changed, 8 insertions, 2 deletions
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<Intrinsics>(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(), |