Skip to content

Commit

Permalink
riscv64: [codegen] Fix and enable InvokeCustom/-Polymorphic.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vmarko committed Oct 19, 2023
1 parent b851fb4 commit 534d18f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions compiler/optimizing/optimizing_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 10 additions & 12 deletions runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 534d18f

Please sign in to comment.