Skip to content

Commit

Permalink
update explicit tail call info
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyAyersMS committed May 5, 2021
1 parent 2f0cc5b commit 5544f84
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21230,13 +21230,17 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
*pExactContextHandle = MAKE_CLASSCONTEXT(derivedClass);
}

// To update info for explicit tail calls and ready to run,
// we also need to create a resolved token.

#ifdef FEATURE_READYTORUN_COMPILER
if (opts.IsReadyToRun())
const bool needResolvedToken = isExplicitTailCall || opts.IsReadyToRun();
#else
const bool needResolvedToken = isExplicitTailCall;
#endif

if (needResolvedToken)
{
// For R2R, getCallInfo triggers bookkeeping on the zap
// side so we need to call it here.
//
// First, cons up a suitable resolved token.
CORINFO_RESOLVED_TOKEN derivedResolvedToken = {};

derivedResolvedToken.tokenScope = info.compCompHnd->getMethodModule(derivedMethod);
Expand All @@ -21246,16 +21250,36 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
derivedResolvedToken.hClass = derivedClass;
derivedResolvedToken.hMethod = derivedMethod;

// Look up the new call info.
CORINFO_CALL_INFO derivedCallInfo;
eeGetCallInfo(&derivedResolvedToken, nullptr, addVerifyFlag(CORINFO_CALLINFO_ALLOWINSTPARAM), &derivedCallInfo);
// If this call is an explicit tail call, update the tail call info.
//
if (isExplicitTailCall)
{
TailCallSiteInfo* const tailCallInfo = call->tailCallInfo;
assert(tailCallInfo != nullptr);
CORINFO_SIG_INFO sig;
info.compCompHnd->getMethodSig(derivedMethod, &sig);
tailCallInfo->SetCall(&sig, &derivedResolvedToken);
}

// Update the call.
call->gtCallMoreFlags &= ~GTF_CALL_M_VIRTSTUB_REL_INDIRECT;
call->gtCallMoreFlags &= ~GTF_CALL_M_R2R_REL_INDIRECT;
call->setEntryPoint(derivedCallInfo.codePointerLookup.constLookup);
}
#ifdef FEATURE_READYTORUN_COMPILER
if (opts.IsReadyToRun())
{
// For R2R, getCallInfo triggers bookkeeping on the zap
// side so we need to call it here.
//
// Look up the new call info.
CORINFO_CALL_INFO derivedCallInfo;
eeGetCallInfo(&derivedResolvedToken, nullptr, addVerifyFlag(CORINFO_CALLINFO_ALLOWINSTPARAM),
&derivedCallInfo);

// Update the call.
//
call->gtCallMoreFlags &= ~GTF_CALL_M_VIRTSTUB_REL_INDIRECT;
call->gtCallMoreFlags &= ~GTF_CALL_M_R2R_REL_INDIRECT;
call->setEntryPoint(derivedCallInfo.codePointerLookup.constLookup);
}
#endif // FEATURE_READYTORUN_COMPILER
}
}

//------------------------------------------------------------------------
Expand Down

0 comments on commit 5544f84

Please sign in to comment.