-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Ensure we do not try to inline async versions of pinvokes #129797
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
Open
jakobbotsch
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
jakobbotsch:fix-129782
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−19
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7514,6 +7514,7 @@ static bool getILIntrinsicImplementationForActivator(MethodDesc* ftn, | |
| // | ||
| COR_ILMETHOD_DECODER* CEEInfo::getMethodInfoWorker( | ||
| MethodDesc* ftn, | ||
| MethodDesc* ilFtn, | ||
| COR_ILMETHOD_DECODER* header, | ||
| CORINFO_METHOD_INFO* methInfo, | ||
| CORINFO_CONTEXT_HANDLE exactContext) | ||
|
|
@@ -7530,10 +7531,6 @@ COR_ILMETHOD_DECODER* CEEInfo::getMethodInfoWorker( | |
| /* Grab information from the IL header */ | ||
| SigPointer localSig{}; | ||
|
|
||
| // For async versions we get the IL of the ordinary variant and pass the | ||
| // JIT a flag indicating that. | ||
| MethodDesc* ilFtn = ftn->SupportsAsyncVersionCodegen() ? ftn->GetOrdinaryVariant() : ftn; | ||
|
|
||
| MethodInfoWorkerContext cxt{ ftn, header }; | ||
|
|
||
| TransientMethodDetails* detailsMaybe = NULL; | ||
|
|
@@ -7740,22 +7737,24 @@ CEEInfo::getMethodInfo( | |
| JIT_TO_EE_TRANSITION(); | ||
|
|
||
| MethodDesc* ftn = GetMethod(ftnHnd); | ||
| MethodDesc* ilFtn = ftn->GetOrdinaryVariantIfAsyncVersion(); | ||
|
|
||
| COR_ILMETHOD* pILHeader; | ||
| if (ftn->MayHaveILHeader() && (pILHeader = ftn->GetILHeader()) != NULL) | ||
| if (ilFtn->MayHaveILHeader() && (pILHeader = ilFtn->GetILHeader()) != NULL) | ||
| { | ||
| // Get the IL header and set it. | ||
| COR_ILMETHOD_DECODER header(pILHeader, ftn->GetMDImport(), NULL); | ||
| getMethodInfoWorker(ftn, &header, methInfo, context); | ||
| COR_ILMETHOD_DECODER header(pILHeader, ilFtn->GetMDImport(), NULL); | ||
| getMethodInfoWorker(ftn, ilFtn, &header, methInfo, context); | ||
| result = true; | ||
| } | ||
| else if (ftn->IsIL() || ftn->IsDynamicMethod()) | ||
| else if (ilFtn->IsIL() || ilFtn->IsDynamicMethod()) | ||
|
Member
Author
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. The change to use |
||
| { | ||
| // IL methods with no IL header indicate there is no implementation defined in metadata. | ||
| // NOTE: P/Invoke methods are also IL methods with no IL header, | ||
| // but it is generally not profitable to inline the marshalling IL. | ||
| // As a result, we skip inlining the marshalling IL. | ||
| // NOTE: P/Invoke methods have marshalling IL but it is generally not | ||
| // profitable to inline it. The IsIL check above returns false for them | ||
| // and thus we will not inline them. | ||
| // P/Invokes that don't require marshalling can still be inlined directly by the JIT. | ||
| getMethodInfoWorker(ftn, NULL, methInfo, context); | ||
| getMethodInfoWorker(ftn, ilFtn, NULL, methInfo, context); | ||
| result = true; | ||
| } | ||
|
|
||
|
|
@@ -7940,7 +7939,7 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller, | |
| else if (pCallee->IsIL()) | ||
| { | ||
| CORINFO_METHOD_INFO methodInfo; | ||
| getMethodInfoWorker(pCallee, NULL, &methodInfo); | ||
| getMethodInfoWorker(pCallee, pCallee->GetOrdinaryVariantIfAsyncVersion(), NULL, &methodInfo); | ||
| if (methodInfo.EHcount > 0) | ||
| { | ||
| result = INLINE_FAIL; | ||
|
|
@@ -10975,7 +10974,7 @@ CEECodeGenInfo::CEECodeGenInfo(PrepareCodeConfig* config, MethodDesc* fd, COR_IL | |
| { | ||
| STANDARD_VM_CONTRACT; | ||
| _ASSERTE(config != NULL); | ||
| COR_ILMETHOD_DECODER* ilHeader = getMethodInfoWorker(m_pMethodBeingCompiled, m_ILHeader, &m_MethodInfo); | ||
| COR_ILMETHOD_DECODER* ilHeader = getMethodInfoWorker(m_pMethodBeingCompiled, m_pMethodBeingCompiled->GetOrdinaryVariantIfAsyncVersion(), m_ILHeader, &m_MethodInfo); | ||
|
|
||
| // The header maybe replaced during the call to getMethodInfoWorker. This is most probable | ||
| // when the input is null (that is, no metadata), but we can also examine the method and generate | ||
|
|
@@ -13150,11 +13149,7 @@ void CEECodeGenInfo::getEHinfo( | |
|
|
||
| bool isMethodBeingCompiled = pMD == m_pMethodBeingCompiled; | ||
|
|
||
| if (pMD->SupportsAsyncVersionCodegen()) | ||
| { | ||
| // Get the EH info from the ordinary variant. | ||
| pMD = pMD->GetOrdinaryVariant(); | ||
| } | ||
| pMD = pMD->GetOrdinaryVariantIfAsyncVersion(); | ||
|
|
||
| COR_ILMETHOD* pILHeader; | ||
| if (pMD->IsDynamicMethod()) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.