Skip to content

Commit

Permalink
Fix codegen on ARM in NativeAOT (dotnet#57948)
Browse files Browse the repository at this point in the history
NativeAOT has different ABI, so it produce Relative Indirection Virtual Stub when invoke virtual methods on generic interface.

Actual idea by @SingleAccretion, I do just troubleshooting.
See dotnet/runtimelab#1426 for a bit more contex and how issue appears..
  • Loading branch information
kant2002 authored Aug 26, 2021
1 parent 3010642 commit e1cbd62
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
}
else if (call->IsR2ROrVirtualStubRelativeIndir())
{
// Generate a direct call to a non-virtual user defined or helper method
// Generate a indirect call to a virtual user defined function or helper method
assert(callType == CT_HELPER || callType == CT_USER_FUNC);
#ifdef FEATURE_READYTORUN
assert(((call->IsR2RRelativeIndir()) && (call->gtEntryPoint.accessType == IAT_PVALUE)) ||
Expand All @@ -2458,7 +2458,9 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
assert(!call->IsTailCall());

regNumber tmpReg = call->GetSingleTempReg();
GetEmitter()->emitIns_R_R(ins_Load(TYP_I_IMPL), emitActualTypeSize(TYP_I_IMPL), tmpReg, REG_R2R_INDIRECT_PARAM);
regNumber callAddrReg =
call->IsVirtualStubRelativeIndir() ? compiler->virtualStubParamInfo->GetReg() : REG_R2R_INDIRECT_PARAM;
GetEmitter()->emitIns_R_R(ins_Load(TYP_I_IMPL), emitActualTypeSize(TYP_I_IMPL), tmpReg, callAddrReg);

// We have now generated code for gtControlExpr evaluating it into `tmpReg`.
// We just need to emit "call tmpReg" in this case.
Expand Down

0 comments on commit e1cbd62

Please sign in to comment.