From 534d18f95fcf11912c155a93969d494bd7eedfef Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 19 Oct 2023 13:51:32 +0000 Subject: [PATCH] riscv64: [codegen] Fix and enable InvokeCustom/-Polymorphic. Test: m # aosp_cf_riscv64_phone-userdebug Test: # Edit `run-test` to disable checker, then testrunner.py --target --64 --ndebug --optimizing # Ignore 3 pre-existing failures. Bug: 283082089 Change-Id: I9802386b32fe6b98142454748404105e5b345c3b --- compiler/optimizing/optimizing_compiler.cc | 2 ++ .../quick/quick_trampoline_entrypoints.cc | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 6062d25eb8..1f71c4d10d 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -837,6 +837,8 @@ static bool CanAssembleGraphForRiscv64(HGraph* graph) { case HInstruction::kInvokeStaticOrDirect: case HInstruction::kInvokeVirtual: case HInstruction::kInvokeInterface: + case HInstruction::kInvokeCustom: + case HInstruction::kInvokePolymorphic: case HInstruction::kCurrentMethod: case HInstruction::kNullCheck: case HInstruction::kDeoptimize: diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index ef9c2d2068..a1afce88c0 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -683,6 +683,12 @@ static void HandleDeoptimization(JValue* result, method_type); } +static int64_t NanBoxResultIfNeeded(int64_t result, char result_shorty) { + return (QuickArgumentVisitor::NaNBoxing() && result_shorty == 'F') + ? result | UINT64_C(0xffffffff00000000) + : result; +} + NO_STACK_PROTECTOR extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, ArtMethod** sp) REQUIRES_SHARED(Locks::mutator_lock_) { @@ -761,12 +767,8 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, self->SetException(Thread::GetDeoptimizationException()); } - if (QuickArgumentVisitor::NaNBoxing() && shorty[0] == 'F') { - result.SetJ(result.GetJ() | UINT64_C(0xffffffff00000000)); - } - // No need to restore the args since the method has already been run by the interpreter. - return result.GetJ(); + return NanBoxResultIfNeeded(result.GetJ(), shorty[0]); } // Visits arguments on the stack placing them into the args vector, Object* arguments are converted @@ -900,11 +902,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler( result); } - if (QuickArgumentVisitor::NaNBoxing() && shorty[0] == 'F') { - result.SetJ(result.GetJ() | UINT64_C(0xffffffff00000000)); - } - - return result.GetJ(); + return NanBoxResultIfNeeded(result.GetJ(), shorty[0]); } // Visitor returning a reference argument at a given position in a Quick stack frame. @@ -2452,7 +2450,7 @@ extern "C" uint64_t artInvokePolymorphic(mirror::Object* raw_receiver, Thread* s Runtime::Current()->GetInstrumentation()->PushDeoptContextIfNeeded( self, DeoptimizationMethodType::kDefault, is_ref, result); - return result.GetJ(); + return NanBoxResultIfNeeded(result.GetJ(), shorty[0]); } // Returns uint64_t representing raw bits from JValue. @@ -2511,7 +2509,7 @@ extern "C" uint64_t artInvokeCustom(uint32_t call_site_idx, Thread* self, ArtMet Runtime::Current()->GetInstrumentation()->PushDeoptContextIfNeeded( self, DeoptimizationMethodType::kDefault, is_ref, result); - return result.GetJ(); + return NanBoxResultIfNeeded(result.GetJ(), shorty[0]); } extern "C" void artJniMethodEntryHook(Thread* self)