diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.h b/src/coreclr/debug/runtimeinfo/datadescriptor.h index c51980d8cf4dae..6ccf9ca684d2e7 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.h +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.h @@ -677,13 +677,11 @@ CDAC_TYPE_FIELD(InlinedCallFrame, /*pointer*/, CallerReturnAddress, offsetof(Inl CDAC_TYPE_FIELD(InlinedCallFrame, /*pointer*/, CalleeSavedFP, offsetof(InlinedCallFrame, m_pCalleeSavedFP)) CDAC_TYPE_END(InlinedCallFrame) -#ifdef FEATURE_EH_FUNCLETS CDAC_TYPE_BEGIN(SoftwareExceptionFrame) CDAC_TYPE_SIZE(sizeof(SoftwareExceptionFrame)) CDAC_TYPE_FIELD(SoftwareExceptionFrame, /*T_CONTEXT*/, TargetContext, cdac_data::TargetContext) CDAC_TYPE_FIELD(SoftwareExceptionFrame, /*pointer*/, ReturnAddress, cdac_data::ReturnAddress) CDAC_TYPE_END(SoftwareExceptionFrame) -#endif // FEATURE_EH_FUNCLETS CDAC_TYPE_BEGIN(FramedMethodFrame) CDAC_TYPE_SIZE(sizeof(FramedMethodFrame)) diff --git a/src/coreclr/vm/FrameTypes.h b/src/coreclr/vm/FrameTypes.h index cbbfb028d5592b..19c5092466ee07 100644 --- a/src/coreclr/vm/FrameTypes.h +++ b/src/coreclr/vm/FrameTypes.h @@ -14,9 +14,7 @@ FRAME_TYPE_NAME(ResumableFrame) FRAME_TYPE_NAME(RedirectedThreadFrame) #endif // FEATURE_HIJACK FRAME_TYPE_NAME(FaultingExceptionFrame) -#ifdef FEATURE_EH_FUNCLETS FRAME_TYPE_NAME(SoftwareExceptionFrame) -#endif // FEATURE_EH_FUNCLETS #ifdef DEBUGGING_SUPPORTED FRAME_TYPE_NAME(FuncEvalFrame) #endif // DEBUGGING_SUPPORTED diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index d1e96f793f4eae..726384d64950db 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -11315,12 +11315,11 @@ MethodDesc * GetUserMethodForILStub(Thread * pThread, UINT_PTR uStubSP, MethodDe } -#ifdef FEATURE_EH_FUNCLETS - void SoftwareExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats) { LIMITED_METHOD_DAC_CONTRACT; +#ifdef FEATURE_EH_FUNCLETS #define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *dac_cast((TADDR)m_ContextPointers.regname); ENUM_CALLEE_SAVED_REGISTERS(); #undef CALLEE_SAVED_REGISTER @@ -11341,6 +11340,16 @@ void SoftwareExceptionFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool u pRD->IsCallerContextValid = FALSE; pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary. +#elif defined(TARGET_X86) +#define CALLEE_SAVED_REGISTER(regname) pRD->Set##regname##Location(m_ContextPointers.regname); + ENUM_CALLEE_SAVED_REGISTERS(); +#undef CALLEE_SAVED_REGISTER + + pRD->ControlPC = ::GetIP(&m_Context); + pRD->SP = ::GetSP(&m_Context); +#else // FEATURE_EH_FUNCLETS + PORTABILITY_ASSERT("SoftwareExceptionFrame::UpdateRegDisplay_Impl"); +#endif // FEATURE_EH_FUNCLETS } #ifndef DACCESS_COMPILE @@ -11421,4 +11430,3 @@ void SoftwareExceptionFrame::InitAndLink(Thread *pThread) } #endif // DACCESS_COMPILE -#endif // FEATURE_EH_FUNCLETS diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index e2923f567c6c2d..9636dd9ee73c24 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -1035,8 +1035,6 @@ struct cdac_data #endif // FEATURE_EH_FUNCLETS }; -#ifdef FEATURE_EH_FUNCLETS - typedef DPTR(class SoftwareExceptionFrame) PTR_SoftwareExceptionFrame; class SoftwareExceptionFrame : public Frame @@ -1108,7 +1106,6 @@ struct cdac_data static constexpr size_t TargetContext = offsetof(SoftwareExceptionFrame, m_Context); static constexpr size_t ReturnAddress = offsetof(SoftwareExceptionFrame, m_ReturnAddress); }; -#endif // FEATURE_EH_FUNCLETS //----------------------------------------------------------------------- // Frame for debugger function evaluation diff --git a/src/coreclr/vm/i386/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index df93ca0be0a88f..740b3de93a79db 100644 --- a/src/coreclr/vm/i386/asmhelpers.asm +++ b/src/coreclr/vm/i386/asmhelpers.asm @@ -90,11 +90,9 @@ EXTERN g_chained_lookup_miss_counter:DWORD EXTERN g_dispatch_cache_chain_success_counter:DWORD endif -ifdef FEATURE_EH_FUNCLETS EXTERN @IL_Throw_x86@8:PROC EXTERN @IL_ThrowExact_x86@8:PROC EXTERN @IL_Rethrow_x86@4:PROC -endif ; FEATURE_EH_FUNCLETS UNREFERENCED macro arg local unref @@ -1894,7 +1892,6 @@ _BackPatchWorkerAsmStub@0 proc public ret _BackPatchWorkerAsmStub@0 endp -ifdef FEATURE_EH_FUNCLETS ;========================================================================== ; Capture a transition block with register values and call the IL_Throw ; implementation written in C. @@ -1942,6 +1939,5 @@ FASTCALL_FUNC IL_Rethrow, 0 STUB_EPILOG ret 4 FASTCALL_ENDFUNC IL_Rethrow -endif ; FEATURE_EH_FUNCLETS end diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 4cad7fef302410..3bdde3488e08ee 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -1225,7 +1225,7 @@ HCIMPLEND /*************************************************************/ -#if defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS) +#if defined(TARGET_X86) EXTERN_C FCDECL1(void, IL_Throw, Object* obj); EXTERN_C HCIMPL2(void, IL_Throw_x86, Object* obj, TransitionBlock* transitionBlock) #else @@ -1241,8 +1241,6 @@ HCIMPL1(void, IL_Throw, Object* obj) OBJECTREF oref = ObjectToOBJECTREF(obj); -#ifdef FEATURE_EH_FUNCLETS - Thread *pThread = GetThread(); SoftwareExceptionFrame exceptionFrame; @@ -1255,6 +1253,7 @@ HCIMPL1(void, IL_Throw, Object* obj) FC_CAN_TRIGGER_GC(); +#ifdef FEATURE_EH_FUNCLETS if (oref == 0) DispatchManagedException(kNullReferenceException); else @@ -1282,15 +1281,12 @@ HCIMPL1(void, IL_Throw, Object* obj) } DispatchManagedException(oref, exceptionFrame.GetContext()); - FC_CAN_TRIGGER_GC_END(); - UNREACHABLE(); -#endif // FEATURE_EH_FUNCLETS - - HELPER_METHOD_FRAME_BEGIN_ATTRIB_NOPOLL(Frame::FRAME_ATTR_EXCEPTION); // Set up a frame +#elif defined(TARGET_X86) + INSTALL_MANAGED_EXCEPTION_DISPATCHER; + INSTALL_UNWIND_AND_CONTINUE_HANDLER; #if defined(_DEBUG) && defined(TARGET_X86) - __helperframe.EnsureInit(NULL); - g_ExceptionEIP = (LPVOID)__helperframe.GetReturnAddress(); + g_ExceptionEIP = (PVOID)transitionBlock->m_ReturnAddress; #endif // defined(_DEBUG) && defined(TARGET_X86) if (oref == 0) @@ -1321,13 +1317,20 @@ HCIMPL1(void, IL_Throw, Object* obj) RaiseTheExceptionInternalOnly(oref, FALSE); - HELPER_METHOD_FRAME_END(); + UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; + UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; +#else // FEATURE_EH_FUNCLETS + PORTABILITY_ASSERT("IL_Throw"); +#endif // FEATURE_EH_FUNCLETS + + FC_CAN_TRIGGER_GC_END(); + UNREACHABLE(); } HCIMPLEND /*************************************************************/ -#if defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS) +#if defined(TARGET_X86) EXTERN_C FCDECL0(void, IL_Rethrow); EXTERN_C HCIMPL1(void, IL_Rethrow_x86, TransitionBlock* transitionBlock) #else @@ -1338,7 +1341,6 @@ HCIMPL0(void, IL_Rethrow) FC_GC_POLL_NOT_NEEDED(); // throws always open up for GC -#ifdef FEATURE_EH_FUNCLETS Thread *pThread = GetThread(); SoftwareExceptionFrame exceptionFrame; @@ -1349,12 +1351,13 @@ HCIMPL0(void, IL_Rethrow) #endif exceptionFrame.InitAndLink(pThread); + FC_CAN_TRIGGER_GC(); + +#ifdef FEATURE_EH_FUNCLETS ExInfo *pActiveExInfo = (ExInfo*)pThread->GetExceptionState()->GetCurrentExceptionTracker(); ExInfo exInfo(pThread, pActiveExInfo->m_ptrs.ExceptionRecord, exceptionFrame.GetContext(), ExKind::None); - FC_CAN_TRIGGER_GC(); - GCPROTECT_BEGIN(exInfo.m_exception); PREPARE_NONVIRTUAL_CALLSITE(METHOD__EH__RH_RETHROW); DECLARE_ARGHOLDER_ARRAY(args, 2); @@ -1367,12 +1370,9 @@ HCIMPL0(void, IL_Rethrow) //Ex.RhRethrow(ref ExInfo activeExInfo, ref ExInfo exInfo) CALL_MANAGED_METHOD_NORET(args) GCPROTECT_END(); - - FC_CAN_TRIGGER_GC_END(); - UNREACHABLE(); -#endif - - HELPER_METHOD_FRAME_BEGIN_ATTRIB_NOPOLL(Frame::FRAME_ATTR_EXCEPTION); // Set up a frame +#elif defined(TARGET_X86) + INSTALL_MANAGED_EXCEPTION_DISPATCHER; + INSTALL_UNWIND_AND_CONTINUE_HANDLER; OBJECTREF throwable = GetThread()->GetThrowable(); if (throwable != NULL) @@ -1386,11 +1386,18 @@ HCIMPL0(void, IL_Rethrow) RealCOMPlusThrow(kInvalidProgramException, (UINT)IDS_EE_RETHROW_NOT_ALLOWED); } - HELPER_METHOD_FRAME_END(); + UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; + UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; +#else // FEATURE_EH_FUNCLETS + PORTABILITY_ASSERT("IL_Rethrow"); +#endif // FEATURE_EH_FUNCLETS + + FC_CAN_TRIGGER_GC_END(); + UNREACHABLE(); } HCIMPLEND -#if defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS) +#if defined(TARGET_X86) EXTERN_C FCDECL1(void, IL_ThrowExact, Object* obj); EXTERN_C HCIMPL2(void, IL_ThrowExact_x86, Object* obj, TransitionBlock* transitionBlock) #else @@ -1407,7 +1414,6 @@ HCIMPL1(void, IL_ThrowExact, Object* obj) OBJECTREF oref = ObjectToOBJECTREF(obj); GetThread()->GetExceptionState()->SetRaisingForeignException(); -#ifdef FEATURE_EH_FUNCLETS Thread *pThread = GetThread(); SoftwareExceptionFrame exceptionFrame; @@ -1419,19 +1425,27 @@ HCIMPL1(void, IL_ThrowExact, Object* obj) exceptionFrame.InitAndLink(pThread); FC_CAN_TRIGGER_GC(); + +#ifdef FEATURE_EH_FUNCLETS DispatchManagedException(oref, exceptionFrame.GetContext()); - FC_CAN_TRIGGER_GC_END(); - UNREACHABLE(); -#else - HELPER_METHOD_FRAME_BEGIN_ATTRIB_NOPOLL(Frame::FRAME_ATTR_EXCEPTION); // Set up a frame +#elif defined(TARGET_X86) + INSTALL_MANAGED_EXCEPTION_DISPATCHER; + INSTALL_UNWIND_AND_CONTINUE_HANDLER; + #if defined(_DEBUG) && defined(TARGET_X86) - __helperframe.EnsureInit(NULL); - g_ExceptionEIP = (LPVOID)__helperframe.GetReturnAddress(); + g_ExceptionEIP = (PVOID)transitionBlock->m_ReturnAddress; #endif // defined(_DEBUG) && defined(TARGET_X86) RaiseTheExceptionInternalOnly(oref, FALSE); - HELPER_METHOD_FRAME_END(); -#endif + + UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; + UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; +#else // FEATURE_EH_FUNCLETS + PORTABILITY_ASSERT("IL_ThrowExact"); +#endif // FEATURE_EH_FUNCLETS + + FC_CAN_TRIGGER_GC_END(); + UNREACHABLE(); } HCIMPLEND