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

Enable inlining P/Invokes into try blocks with no catch or filter clauses V2 #73661

Merged
merged 6 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
10 changes: 5 additions & 5 deletions src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1837,11 +1837,9 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
// 1) ICF address is higher than the current frame's SP (which we get from DispatcherContext), AND
// 2) ICF address is below callerSP.
// 3) ICF is active.
// - IL stubs link the frame in for the whole stub, so if an exception is thrown during marshalling,
// the ICF will be on the frame chain and inactive.
// -
if ((GetSP(pDispatcherContext->ContextRecord) < (TADDR)pICF)
&& ((UINT_PTR)pICF < uCallerSP)
&& InlinedCallFrame::FrameHasActiveCall(pICF))
&& ((UINT_PTR)pICF < uCallerSP))
Copy link
Member

Choose a reason for hiding this comment

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

So we don't link the ICF frame for the whole stub on any platform in any case anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still link it for the whole stub on 32-bit platforms. This condition didn't change between main and this PR (the V1 version of the change added the IsActiveCall check, but the V2 version doesn't include it).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll get rid of the diff here since I'm not changing the logic any more

{
pICFForUnwindTarget = pFrame;

Expand All @@ -1856,7 +1854,9 @@ CLRUnwindStatus ExceptionTracker::ProcessOSExceptionNotification(
#ifdef USE_PER_FRAME_PINVOKE_INIT
// If we're setting up the frame for each P/Invoke for the given platform,
// then we do this for all P/Invokes except ones in IL stubs.
if (!ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub())
// IL stubs link the frame in for the whole stub, so if an exception is thrown during marshalling,
// the ICF will be on the frame chain and inactive.
if (returnAddress != NULL && !ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub())
#else
// If we aren't setting up the frame for each P/Invoke (instead setting up once per method),
// then ReadyToRun code is the only code using the per-P/Invoke logic.
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/i386/excepx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ void ResumeAtJitEH(CrawlFrame* pCf,
// Check that the InlinedCallFrame is in the method with the exception handler. There can be other
// InlinedCallFrame somewhere up the call chain that is not related to the current exception
// handling.

// See the usages for USE_PER_FRAME_PINVOKE_INIT for more information.

#ifdef DEBUG
Expand All @@ -2991,7 +2991,7 @@ void ResumeAtJitEH(CrawlFrame* pCf,
#ifdef USE_PER_FRAME_PINVOKE_INIT
// If we're setting up the frame for each P/Invoke for the given platform,
// then we do this for all P/Invokes except ones in IL stubs.
if (!ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub())
if (returnAddress != NULL && !ExecutionManager::GetCodeMethodDesc(returnAddress)->IsILStub())
#else
// If we aren't setting up the frame for each P/Invoke (instead setting up once per method),
// then ReadyToRun code is the only code using the per-P/Invoke logic.
Expand Down