summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
author Almaz Mingaleev <mingaleev@google.com> 2024-09-02 11:15:31 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2024-09-02 11:15:31 +0000
commitd2aa4a0e53b6e60208d9dac5461355461db34a8c (patch)
treee71b14ee55b67a7dd8a87b795090d47bf621645d /compiler/optimizing/instruction_builder.cc
parent19fdc432ba5bfce77785cdc209bc62da0c71f9b8 (diff)
parentf2c43572c8bfd97c2d8bd7581d599d1a9fb2eb32 (diff)
Address follow-up comments from aosp/2721077. am: f2c43572c8
Original change: https://android-review.googlesource.com/c/platform/art/+/3247494 Change-Id: I00cdb5fad02e6d8c8f0364164f1e42ae29c7e94c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc10
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(),