Do not build intrinsic graph for signature polymorphic methods.
The InstructionBuilder cannot build HInvokePolymorphic for
an intrinsic graph. It would be rather useless to allow this
as signature polymorphic method intrinsics always need the
slow-path for unhandled cases, and we would therefore reject
the compiled code anyway. Instead, prevent the construction
of the intrinsic graph for signature polymorphic methods.
Test: testrunner.py --host --optimizing -t 712-varhandle-invocations
Bug: 65872996
Change-Id: Id82f1f282383dbd45d6db2bd2a96d838b685d7ed
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 3c168ba..b7e9d63 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -1050,8 +1050,11 @@
/*verified_method=*/ nullptr, // Not needed by the Optimizing compiler.
dex_cache,
compiling_class);
+ // All signature polymorphic methods are native.
+ DCHECK(method == nullptr || !method->IsSignaturePolymorphic());
// Go to native so that we don't block GC during compilation.
ScopedThreadSuspension sts(soa.Self(), kNative);
+ // Try to compile a fully intrinsified implementation.
if (method != nullptr && UNLIKELY(method->IsIntrinsic())) {
DCHECK(compiler_options.IsBootImage());
codegen.reset(
@@ -1154,7 +1157,10 @@
ScopedObjectAccess soa(Thread::Current());
ArtMethod* method = runtime->GetClassLinker()->LookupResolvedMethod(
method_idx, dex_cache.Get(), /*class_loader=*/ nullptr);
- if (method != nullptr && UNLIKELY(method->IsIntrinsic())) {
+ // Try to compile a fully intrinsified implementation. Do not try to do this for
+ // signature polymorphic methods as the InstructionBuilder cannot handle them;
+ // and it would be useless as they always have a slow path for type conversions.
+ if (method != nullptr && UNLIKELY(method->IsIntrinsic()) && !method->IsSignaturePolymorphic()) {
VariableSizedHandleScope handles(soa.Self());
ScopedNullHandle<mirror::ClassLoader> class_loader; // null means boot class path loader.
Handle<mirror::Class> compiling_class = handles.NewHandle(method->GetDeclaringClass());