- Notifications
You must be signed in to change notification settings - Fork5.1k
Reimplement stubs to improve performance#65738
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
efe9210
9114ae8
9e5211a
5e0d202
ad97eed
c769d0f
4dd122b
118b427
346af35
bd1c8ba
33703aa
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -9006,28 +9006,27 @@ void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd, | ||
// Resolve methodImpl. | ||
ftn = ftn->GetMethodTable()->MapMethodDeclToMethodImpl(ftn); | ||
if (!ftn->IsFCall() && ftn->IsVersionableWithPrecode() &&(ftn->GetPrecodeType() == PRECODE_FIXUP) && !ftn->IsPointingToStableNativeCode()) | ||
{ | ||
ret = ((FixupPrecode*)ftn->GetOrCreatePrecode())->GetTargetSlot(); | ||
accessType = IAT_PVALUE; | ||
} | ||
else | ||
{ | ||
ret = (void *)ftn->TryGetMultiCallableAddrOfCode(accessFlags); | ||
// TryGetMultiCallableAddrOfCode returns NULL if indirect access is desired | ||
if (ret == NULL) | ||
{ | ||
// should never get here for EnC methods or if interception via remoting stub is required | ||
_ASSERTE(!ftn->IsEnCMethod()); | ||
ret = (void *)ftn->GetAddrOfSlot(); | ||
accessType = IAT_PVALUE; | ||
} | ||
} | ||
#if defined(FEATURE_GDBJIT) | ||
CalledMethod * pCM = new CalledMethod(orig_ftn, ret, m_pCalledMethods); | ||
m_pCalledMethods = pCM; | ||
@@ -11134,6 +11133,23 @@ void* CEEJitInfo::getHelperFtn(CorInfoHelpFunc ftnNum, /* IN */ | ||
} | ||
#endif | ||
if (dynamicFtnNum == DYNAMIC_CORINFO_HELP_ISINSTANCEOFINTERFACE || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_ISINSTANCEOFANY || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_ISINSTANCEOFARRAY || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_ISINSTANCEOFCLASS || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_CHKCASTANY || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_CHKCASTARRAY || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_CHKCASTINTERFACE || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_CHKCASTCLASS || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_CHKCASTCLASS_SPECIAL || | ||
dynamicFtnNum == DYNAMIC_CORINFO_HELP_UNBOX) | ||
{ | ||
Precode* pPrecode = Precode::GetPrecodeFromEntryPoint((PCODE)hlpDynamicFuncTable[dynamicFtnNum].pfnHelper); | ||
_ASSERTE(pPrecode->GetType() == PRECODE_FIXUP); | ||
*ppIndirection = ((FixupPrecode*)pPrecode)->GetTargetSlot(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. What guarantees that we have the final code of the method by this point? If this is a valid optimization, we should be doing it when filling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We don't need to have the final code. This just passes the fixup precode indirection slot to the JIT. If we don't have the final code, the slot points to the fixup part of the slot. When we have the JITted code, the slot points to it. Without this optimization, JIT would jump to the beginning of the fixup stub and the indirect jump in there would jump through the slot. So we save one jump by this. I have found this using the performance repo microbenchmarks where the casting benchmarks were consistently slower with my change. With this fix, they are now consistently faster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We can modify the However, there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
Ah ok, I have missed that. | ||
return NULL; | ||
} | ||
pfnHelper = hlpDynamicFuncTable[dynamicFtnNum].pfnHelper; | ||
#ifdef _PREFAST_ | ||