Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM/ARM64: Optimize virtual call stub for R2R and JIT #36817

Merged
merged 9 commits into from
May 28, 2020
Merged
8 changes: 4 additions & 4 deletions src/coreclr/src/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,13 +2520,14 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
INDEBUG_LDISASM_COMMA(sigInfo) nullptr, // addr
retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize), ilOffset, target->GetRegNum());
}
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
else if (call->IsR2RRelativeIndir())
else if (call->IsR2ROrVirtualStubRelativeIndir())
{
// Generate a direct call to a non-virtual user defined or helper method
assert(callType == CT_HELPER || callType == CT_USER_FUNC);
assert(call->gtEntryPoint.accessType == IAT_PVALUE);
assert(((call->IsR2RRelativeIndir()) && (call->gtEntryPoint.accessType == IAT_PVALUE)) ||
((call->IsVirtualStubRelativeIndir()) && (call->gtEntryPoint.accessType == IAT_VALUE)));
assert(call->gtControlExpr == nullptr);
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);
Expand All @@ -2540,7 +2541,6 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
INDEBUG_LDISASM_COMMA(sigInfo) nullptr, // addr
retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize), ilOffset, tmpReg);
}
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
else
{
// Generate a direct call to a non-virtual user defined or helper method
Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,16 @@ struct GenTreeCall final : public GenTree
return (gtFlags & GTF_CALL_INLINE_CANDIDATE) != 0;
}

bool IsR2ROrVirtualStubRelativeIndir()
{
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
bool isVirtualStub = (gtFlags & GTF_CALL_VIRT_KIND_MASK) == GTF_CALL_VIRT_STUB;
return ((IsR2RRelativeIndir()) || (isVirtualStub && (IsVirtualStubRelativeIndir())));
#else
return false;
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
}

bool HasNonStandardAddedArgs(Compiler* compiler) const;
int GetNonStandardAddedArgCount(Compiler* compiler) const;

Expand Down
11 changes: 10 additions & 1 deletion src/coreclr/src/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4529,7 +4529,16 @@ GenTree* Lowering::LowerVirtualStubCall(GenTreeCall* call)
}
else
{
result = Ind(addr);

bool shouldOptimizeVirtualStubCall = false;
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
shouldOptimizeVirtualStubCall = !call->IsTailCall();
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH

if (!shouldOptimizeVirtualStubCall)
{
result = Ind(addr);
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/src/jit/lsraarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,10 @@ int LinearScan::BuildCall(GenTreeCall* call)
ctrlExprCandidates = RBM_FASTTAILCALL_TARGET;
}
}
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
else if (call->IsR2RRelativeIndir())
else if (call->IsR2ROrVirtualStubRelativeIndir())
{
buildInternalIntRegisterDefForNode(call);
}
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
#ifdef TARGET_ARM
else
{
Expand Down