Skip to content

Commit 1fd088c

Browse files
committed
Cleanup
1 parent 64c73c1 commit 1fd088c

File tree

4 files changed

+54
-31
lines changed

4 files changed

+54
-31
lines changed

src/coreclr/vm/excep.cpp

+35-5
Original file line numberDiff line numberDiff line change
@@ -11547,6 +11547,40 @@ void SoftwareExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool u
1154711547
}
1154811548

1154911549
#ifndef DACCESS_COMPILE
11550+
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
11551+
11552+
void SoftwareExceptionFrame::Init(TransitionBlock *pTransitionBlock)
11553+
{
11554+
WRAPPER_NO_CONTRACT;
11555+
11556+
m_Context.Ecx = pTransitionBlock->m_argumentRegisters.ECX;
11557+
m_Context.Edx = pTransitionBlock->m_argumentRegisters.EDX;
11558+
m_ContextPointers.Ecx = &m_Context.Ecx;
11559+
m_ContextPointers.Edx = &m_Context.Edx;
11560+
11561+
#define CALLEE_SAVED_REGISTER(reg) \
11562+
m_Context.reg = pTransitionBlock->m_calleeSavedRegisters.reg; \
11563+
m_ContextPointers.reg = &m_Context.reg;
11564+
ENUM_CALLEE_SAVED_REGISTERS();
11565+
#undef CALLEE_SAVED_REGISTER
11566+
11567+
m_Context.Esp = (UINT_PTR)(pTransitionBlock + 1);
11568+
m_Context.Eip = pTransitionBlock->m_ReturnAddress;
11569+
m_ReturnAddress = pTransitionBlock->m_ReturnAddress;
11570+
11571+
_ASSERTE(ExecutionManager::IsManagedCode(pTransitionBlock->m_ReturnAddress));
11572+
}
11573+
11574+
void SoftwareExceptionFrame::InitAndLink(TransitionBlock *pTransitionBlock, Thread *pThread)
11575+
{
11576+
WRAPPER_NO_CONTRACT;
11577+
11578+
Init(pTransitionBlock);
11579+
Push(pThread);
11580+
}
11581+
11582+
#else
11583+
1155011584
//
1155111585
// Init a new frame
1155211586
//
@@ -11559,11 +11593,7 @@ void SoftwareExceptionFrame::Init()
1155911593
#undef CALLEE_SAVED_REGISTER
1156011594

1156111595
#ifdef TARGET_WINDOWS
11562-
// On Windows/x86 we don't have unwinding available for native code
11563-
// so we capture the context differently in IL_Throw and IL_Rethrow.
11564-
#ifndef TARGET_X86
1156511596
Thread::VirtualUnwindCallFrame(&m_Context, &m_ContextPointers);
11566-
#endif // !TARGET_X86
1156711597
#else // !TARGET_WINDOWS
1156811598
BOOL success = PAL_VirtualUnwind(&m_Context, &m_ContextPointers);
1156911599
if (!success)
@@ -11590,9 +11620,9 @@ void SoftwareExceptionFrame::InitAndLink(Thread *pThread)
1159011620
WRAPPER_NO_CONTRACT;
1159111621

1159211622
Init();
11593-
1159411623
Push(pThread);
1159511624
}
1159611625

11626+
#endif // TARGET_X86 && TARGET_WINDOWS
1159711627
#endif // DACCESS_COMPILE
1159811628
#endif // FEATURE_EH_FUNCLETS

src/coreclr/vm/exceptionhandling.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,15 @@ void ExceptionTracker::UpdateNonvolatileRegisters(CONTEXT *pContextRecord, REGDI
463463
pAbortContext = GetThread()->GetAbortContext();
464464
}
465465

466-
#ifndef TARGET_UNIX
467-
#define HANDLE_NULL_CONTEXT_POINTER _ASSERTE(false)
468-
#else // TARGET_UNIX
466+
// Windows/x86 doesn't have unwinding mechanism for native code. RtlUnwind in
467+
// ProcessCLRException leaves us with the original exception context. Thus we
468+
// rely solely on our frames and managed code unwinding. This also means that
469+
// if we pass through InlinedCallFrame we end up with empty context pointers.
470+
#if defined(TARGET_UNIX) || defined(TARGET_X86)
469471
#define HANDLE_NULL_CONTEXT_POINTER
470-
#endif // TARGET_UNIX
472+
#else // TARGET_UNIX || TARGET_X86
473+
#define HANDLE_NULL_CONTEXT_POINTER _ASSERTE(false)
474+
#endif // TARGET_UNIX || TARGET_X86
471475

472476
#define UPDATEREG(reg) \
473477
do { \

src/coreclr/vm/frames.h

+7
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,15 @@ class SoftwareExceptionFrame : public Frame
10391039
return PTR_HOST_MEMBER_TADDR(SoftwareExceptionFrame, this, m_ReturnAddress);
10401040
}
10411041

1042+
#ifndef DACCESS_COMPILE
1043+
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
1044+
void Init(TransitionBlock *pTransitionBlock);
1045+
void InitAndLink(TransitionBlock *pTransitionBlock, Thread *pThread);
1046+
#else
10421047
void Init();
10431048
void InitAndLink(Thread *pThread);
1049+
#endif
1050+
#endif
10441051

10451052
Interception GetInterception_Impl()
10461053
{

src/coreclr/vm/jithelpers.cpp

+4-22
Original file line numberDiff line numberDiff line change
@@ -1810,24 +1810,6 @@ HCIMPLEND
18101810

18111811
/*************************************************************/
18121812

1813-
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
1814-
static void TransitionBlockToContext(TransitionBlock* transitionBlock, T_CONTEXT *pContext)
1815-
{
1816-
//#define ARGUMENT_REGISTER(reg) pContext->reg = transitionBlock->m_argumentRegisters.reg;
1817-
//ENUM_ARGUMENT_REGISTERS();
1818-
//#undef ARGUMENT_REGISTER
1819-
pContext->Ecx = transitionBlock->m_argumentRegisters.ECX;
1820-
pContext->Edx = transitionBlock->m_argumentRegisters.EDX;
1821-
1822-
#define CALLEE_SAVED_REGISTER(reg) pContext->reg = transitionBlock->m_calleeSavedRegisters.reg;
1823-
ENUM_CALLEE_SAVED_REGISTERS();
1824-
#undef CALLEE_SAVED_REGISTER
1825-
1826-
pContext->Esp = (UINT_PTR)(transitionBlock + 1);
1827-
pContext->Eip = transitionBlock->m_ReturnAddress;
1828-
}
1829-
#endif
1830-
18311813
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
18321814
EXTERN_C FCDECL1(void, IL_Throw, Object* obj);
18331815
EXTERN_C HCIMPL2(void, IL_Throw_x86, Object* obj, TransitionBlock* transitionBlock)
@@ -1851,11 +1833,11 @@ HCIMPL1(void, IL_Throw, Object* obj)
18511833

18521834
SoftwareExceptionFrame exceptionFrame;
18531835
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
1854-
TransitionBlockToContext(transitionBlock, exceptionFrame.GetContext());
1836+
exceptionFrame.InitAndLink(transitionBlock, pThread);
18551837
#else
18561838
ClrCaptureContext(exceptionFrame.GetContext());
1857-
#endif
18581839
exceptionFrame.InitAndLink(pThread);
1840+
#endif
18591841

18601842
FC_CAN_TRIGGER_GC();
18611843

@@ -1950,11 +1932,11 @@ HCIMPL0(void, IL_Rethrow)
19501932

19511933
SoftwareExceptionFrame exceptionFrame;
19521934
#if defined(TARGET_X86) && defined(TARGET_WINDOWS)
1953-
TransitionBlockToContext(transitionBlock, exceptionFrame.GetContext());
1935+
exceptionFrame.InitAndLink(transitionBlock, pThread);
19541936
#else
19551937
ClrCaptureContext(exceptionFrame.GetContext());
1956-
#endif
19571938
exceptionFrame.InitAndLink(pThread);
1939+
#endif
19581940

19591941
ExInfo *pActiveExInfo = (ExInfo*)pThread->GetExceptionState()->GetCurrentExceptionTracker();
19601942

0 commit comments

Comments
 (0)