summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
authorAndra Danciu <andradanciu@google.com>2020-07-23 12:34:56 +0000
committerOrion Hodson <oth@google.com>2020-07-24 10:11:54 +0000
commita0130e8d2842a9a82e4fd4e811ee699272eb2e0b (patch)
tree1468e015b7c4b001e40d847cf1448311706516e7 /compiler/optimizing/instruction_builder.cc
parent75c8b635178d0c59691c2bc22f3bd1101d5516b5 (diff)
Prepare compiler for adding VarHandle support.
This commit prepares the ground for adding VarHandle support in the compiler. The intrinsic locations builder and code generator are now triggered for HInvokePolymorphic nodes. VarHandle and MethodHandle intrinsics are marked as unimplemented rather than unreachable. Since the Varhandle intrinsics are not implemented yet, the functionality is not changed (i.e. the intrinsics are evaluated at runtime and not compiled). I manually tested that the intrinsic Visit* methods are triggered for the VarHandle methods. Bug: b/65872996 Test: art/test.py --host -r -t 713-varhandle-invokers Test: art/test.py --host --all-compiler -r Change-Id: I3333728c5f16d8dc4f92ceae2738ed59b3e31e6a
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 60e1279685..ac714abd59 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -931,10 +931,13 @@ static ArtMethod* ResolveMethod(uint16_t method_idx,
} else if (*invoke_type == kVirtual) {
// For HInvokeVirtual we need the vtable index.
*target_method = MethodReference(/*file=*/ nullptr, resolved_method->GetVtableIndex());
- } else {
- DCHECK_EQ(*invoke_type, kInterface);
+ } else if (*invoke_type == kInterface) {
// For HInvokeInterface we need the IMT index.
*target_method = MethodReference(/*file=*/ nullptr, ImTable::GetImtIndex(resolved_method));
+ } else {
+ // For HInvokePolymorphic we don't need the target method yet
+ DCHECK_EQ(*invoke_type, kPolymorphic);
+ DCHECK(target_method == nullptr);
}
*is_string_constructor =
@@ -1082,11 +1085,23 @@ bool HInstructionBuilder::BuildInvokePolymorphic(uint32_t dex_pc,
DCHECK_EQ(1 + ArtMethod::NumArgRegisters(shorty), operands.GetNumberOfOperands());
DataType::Type return_type = DataType::FromShorty(shorty[0]);
size_t number_of_arguments = strlen(shorty);
+ // We use ResolveMethod which is also used in BuildInvoke in order to
+ // not duplicate code. As such, we need to provide is_string_constructor
+ // even if we don't need it afterwards.
+ InvokeType invoke_type = InvokeType::kPolymorphic;
+ bool is_string_constructor = false;
+ ArtMethod* resolved_method = ResolveMethod(method_idx,
+ graph_->GetArtMethod(),
+ *dex_compilation_unit_,
+ &invoke_type,
+ /* target_method= */ nullptr,
+ &is_string_constructor);
HInvoke* invoke = new (allocator_) HInvokePolymorphic(allocator_,
number_of_arguments,
return_type,
dex_pc,
- method_idx);
+ method_idx,
+ resolved_method);
return HandleInvoke(invoke, operands, shorty, /* is_unresolved= */ false);
}