Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
janvorli merged 11 commits intodotnet:mainfromjanvorli:new-stubs
Mar 17, 2022
Merged
Changes from1 commit
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Reflect feedback and improve some JIT helpers perf
  • Loading branch information
@janvorli
janvorli committedMar 3, 2022
commit118b427ff677cb6354e458ef284109b303ea43fe
36 changes: 26 additions & 10 deletionssrc/coreclr/vm/jitinterface.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9006,28 +9006,27 @@ void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd,
// Resolve methodImpl.
ftn = ftn->GetMethodTable()->MapMethodDeclToMethodImpl(ftn);

if (!ftn->IsFCall() && ftn->MayHavePrecode() && ftn->GetPrecodeType() == PRECODE_FIXUP)
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());
// 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();
ret = (void *)ftn->GetAddrOfSlot();

accessType = IAT_PVALUE;
accessType = IAT_PVALUE;
}
}


#if defined(FEATURE_GDBJIT)
CalledMethod * pCM = new CalledMethod(orig_ftn, ret, m_pCalledMethods);
m_pCalledMethods = pCM;
Expand DownExpand Up@@ -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();
Copy link
Member

Choose a reason for hiding this comment

The 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 fillinghlpDynamicFuncTable.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We can modify thehlpDynamicFuncTable entry to be able to carry either the indirection or the target address and a flag indicating which one it is. I was going back and forth in my head whether to do that or do it the way I've ended up doing it.

However, there is a_AddrIsJITHelper function on 32 bit Windows in the debugger controller code that compares addresses of all the helpers with an address that the debugger has stepped into to avoid the debugger stopping in unmanaged runtime code. While I believe we should not call this methods that code for prefix stubs (we should get TRACE_STUB tracetype), I need to double check that. I am talking about the case when the helper was not JITted yet and so the indirection would go to the middle of the fixup stub and the code there would not detect it was in a helper.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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.

Ah ok, I have missed that.

return NULL;
}

pfnHelper = hlpDynamicFuncTable[dynamicFtnNum].pfnHelper;

#ifdef _PREFAST_
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp