Skip to content

Commit dcef272

Browse files
committed
Use stack peeling instead of PCTAddr check; re-add optimization for EECodeManager::UnwindStackFrame
1 parent 17c9f05 commit dcef272

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/coreclr/vm/eetwain.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,30 @@ bool EECodeManager::UnwindStackFrame(PREGDISPLAY pContext,
11891189
SUPPORTS_DAC;
11901190
} CONTRACTL_END;
11911191

1192+
#ifdef FEATURE_EH_FUNCLETS
1193+
if (pContext->IsCallerContextValid)
1194+
{
1195+
// We already have the caller's frame context
1196+
// We just switch the pointers
1197+
PT_CONTEXT temp = pContext->pCurrentContext;
1198+
pContext->pCurrentContext = pContext->pCallerContext;
1199+
pContext->pCallerContext = temp;
1200+
1201+
PT_KNONVOLATILE_CONTEXT_POINTERS tempPtrs = pContext->pCurrentContextPointers;
1202+
pContext->pCurrentContextPointers = pContext->pCallerContextPointers;
1203+
pContext->pCallerContextPointers = tempPtrs;
1204+
1205+
SyncRegDisplayToCurrentContext(pContext);
1206+
1207+
pContext->PCTAddr = pContext->SP - GetStackParameterSize(pCodeInfo) - sizeof(DWORD);
1208+
1209+
pContext->IsCallerContextValid = FALSE;
1210+
pContext->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
1211+
1212+
return true;
1213+
}
1214+
#endif
1215+
11921216
bool updateAllRegs = flags & UpdateAllRegs;
11931217

11941218
// Address where the method has been interrupted

src/coreclr/vm/threadsuspend.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4783,16 +4783,9 @@ StackWalkAction SWCB_GetExecutionState(CrawlFrame *pCF, VOID *pData)
47834783
#endif
47844784
}
47854785
#elif defined(TARGET_X86)
4786-
if (pRDT->PCTAddr == 0)
4787-
{
4788-
// Initial context doesn't have PCTAddr so we have to compute it
4789-
EECodeInfo codeInfo(pRDT->ControlPC);
4790-
pES->m_ppvRetAddrPtr = (void **) (EECodeManager::GetCallerSp(pRDT) - codeInfo.GetCodeManager()->GetStackParameterSize(&codeInfo) - sizeof(void*));
4791-
}
4792-
else
4793-
{
4794-
pES->m_ppvRetAddrPtr = (void **) pRDT->PCTAddr;
4795-
}
4786+
// peel off the next frame to expose the return address on the stack
4787+
pES->m_FirstPass = FALSE;
4788+
action = SWA_CONTINUE;
47964789
#elif defined(TARGET_AMD64)
47974790
pES->m_ppvRetAddrPtr = (void **) (EECodeManager::GetCallerSp(pRDT) - sizeof(void*));
47984791
#else // TARGET_X86 || TARGET_AMD64

0 commit comments

Comments
 (0)