diff options
author | Jonghyun Park <parjong@gmail.com> | 2017-01-26 08:59:20 +0900 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2017-01-26 00:59:20 +0100 |
commit | 8f4cb1beaa68e74a16492510c86d9b2fec539e60 (patch) | |
tree | 71c927fa46a5a575a1546afbede6919576906406 /src | |
parent | a042c4cfdf5549e26dd19cdd7aa68cbab393a7ea (diff) | |
download | coreclr-8f4cb1beaa68e74a16492510c86d9b2fec539e60.tar.gz coreclr-8f4cb1beaa68e74a16492510c86d9b2fec539e60.tar.bz2 coreclr-8f4cb1beaa68e74a16492510c86d9b2fec539e60.zip |
Introduce REGDISPLAY_BASE (#9095)
* Introduce REGDISPLAY_BASE
Diffstat (limited to 'src')
-rw-r--r-- | src/inc/regdisp.h | 114 | ||||
-rw-r--r-- | src/vm/exceptionhandling.cpp | 5 |
2 files changed, 40 insertions, 79 deletions
diff --git a/src/inc/regdisp.h b/src/inc/regdisp.h index 4e2a5657b3..46550838f0 100644 --- a/src/inc/regdisp.h +++ b/src/inc/regdisp.h @@ -12,20 +12,16 @@ struct REGDISPLAY; void CheckRegDisplaySP (REGDISPLAY *pRD); #endif // DEBUG_REGDISPLAY - -#if defined(_TARGET_X86_) - -struct REGDISPLAY { - PCONTEXT pContext; // points to current Context; either - // returned by GetContext or provided - // at exception time. - -#ifndef WIN64EXCEPTIONS - // TODO: Unify with pCurrentContext / pCallerContext used on 64-bit - PCONTEXT pContextForUnwind; // scratch context for unwinding - // used to preserve context saved in the frame that - // could be otherwise wiped by the unwinding -#else // !WIN64EXCEPTIONS +struct REGDISPLAY_BASE { + PT_CONTEXT pContext; // This is the context of the active call frame; + // either returned by GetContext or provided at + // exception time. + // + // This will be used to resume execution, so + // do NOT trash it! But DO update any static + // registers here. + +#ifdef WIN64EXCEPTIONS PT_CONTEXT pCurrentContext; // [trashed] points to current Context of stackwalk PT_CONTEXT pCallerContext; // [trashed] points to the Context of the caller during stackwalk -- used for GC crawls @@ -42,12 +38,32 @@ struct REGDISPLAY { T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsOne; // used by stackwalk T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsTwo; // used by stackwalk -#endif // !WIN64EXCEPTIONS +#endif // WIN64EXCEPTIONS #ifdef DEBUG_REGDISPLAY Thread *_pThread; #endif // DEBUG_REGDISPLAY +#if defined(_TARGET_X86_) || defined(_TARGET_ARM_) + DWORD SP; // Stack Pointer + PCODE ControlPC; +#else // _TARGET_X86_ || _TARGET_ARM_ + size_t SP; + size_t ControlPC; +#endif // !_TARGET_X86_ && !_TARGET_ARM +}; + +#if defined(_TARGET_X86_) + +struct REGDISPLAY : public REGDISPLAY_BASE { + +#ifndef WIN64EXCEPTIONS + // TODO: Unify with pCurrentContext / pCallerContext used on 64-bit + PCONTEXT pContextForUnwind; // scratch context for unwinding + // used to preserve context saved in the frame that + // could be otherwise wiped by the unwinding +#endif // !WIN64EXCEPTIONS + DWORD * pEdi; DWORD * pEsi; DWORD * pEbx; @@ -56,10 +72,7 @@ struct REGDISPLAY { DWORD * pEax; DWORD * pEbp; - DWORD SP; // Stack Pointer - PCODE ControlPC; TADDR PCTAddr; - }; inline TADDR GetRegdisplaySP(REGDISPLAY *display) { @@ -135,36 +148,16 @@ typedef struct _Arm64VolatileContextPointer }; } Arm64VolatileContextPointer; #endif //_TARGET_ARM64_ -struct REGDISPLAY { - PT_CONTEXT pContext; // This is the context of the active call frame. This - // will be used to resume execution, so do not use trash it! - // But DO update any static registers here. - - PT_CONTEXT pCurrentContext; // [trashed] points to current Context of stackwalk - PT_CONTEXT pCallerContext; // [trashed] points to the Context of the caller during stackwalk -- used for GC crawls - - size_t ControlPC; - - size_t SP; - - T_KNONVOLATILE_CONTEXT_POINTERS *pCurrentContextPointers; // [trashed] points to current context pointers of stackwalk - T_KNONVOLATILE_CONTEXT_POINTERS *pCallerContextPointers; // [trashed] points to the context pointers of the caller during stackwalk -- used for GC crawls +struct REGDISPLAY : public REGDISPLAY_BASE { #ifdef _TARGET_ARM64_ Arm64VolatileContextPointer volatileCurrContextPointers; #endif - BOOL IsCallerContextValid; // TRUE if pCallerContext really contains the caller's context - BOOL IsCallerSPValid; // Don't add usage of this field. This is only temporary. - - T_CONTEXT ctxOne; // used by stackwalk - T_CONTEXT ctxTwo; // used by stackwalk - - T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsOne; // used by stackwalk - T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsTwo; // used by stackwalk - -#ifdef DEBUG_REGDISPLAY - Thread *_pThread; -#endif // DEBUG_REGDISPLAY + REGDISPLAY() + { + // Initialize + memset(this, 0, sizeof(REGDISPLAY)); + } }; inline TADDR GetRegdisplaySP(REGDISPLAY *display) { @@ -235,31 +228,11 @@ typedef struct _ArmVolatileContextPointer PDWORD R12; } ArmVolatileContextPointer; -struct REGDISPLAY { - PT_CONTEXT pContext; // points to current Context; either - // returned by GetContext or provided - // at exception time. - - PT_CONTEXT pCurrentContext; // [trashed] points to current Context of stackwalk - PT_CONTEXT pCallerContext; // [trashed] points to the Context of the caller during stackwalk -- used for GC crawls - - T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsOne; // used by stackwalk - T_KNONVOLATILE_CONTEXT_POINTERS ctxPtrsTwo; // used by stackwalk - - PT_KNONVOLATILE_CONTEXT_POINTERS pCurrentContextPointers; - PT_KNONVOLATILE_CONTEXT_POINTERS pCallerContextPointers; +struct REGDISPLAY : public REGDISPLAY_BASE { ArmVolatileContextPointer volatileCurrContextPointers; - BOOL IsCallerContextValid; // TRUE if pCallerContext really contains the caller's context - BOOL IsCallerSPValid; // Don't add usage of this field. This is only temporary. - - DWORD SP; - DWORD ControlPC; DWORD * pPC; // processor neutral name - T_CONTEXT ctxOne; // used by stackwalk - T_CONTEXT ctxTwo; // used in ExceptionTracker::InitializeCrawlFrame - REGDISPLAY() { // Initialize regdisplay @@ -268,11 +241,6 @@ struct REGDISPLAY { // Setup the pointer to ControlPC field pPC = &ControlPC; } - -#ifdef DEBUG_REGDISPLAY - Thread *_pThread; -#endif // DEBUG_REGDISPLAY - }; inline TADDR GetRegdisplaySP(REGDISPLAY *display) { @@ -299,15 +267,11 @@ inline TADDR GetRegdisplayStackMark(REGDISPLAY *display) { return GetSP(display->pCallerContext); } - - #else // none of the above processors PORTABILITY_WARNING("RegDisplay functions are not implemented on this platform.") -struct REGDISPLAY { - PCONTEXT pContext; // points to current Context - size_t SP; +struct REGDISPLAY : public REGDISPLAY_BASE { size_t * FramePtr; SLOT * pPC; }; diff --git a/src/vm/exceptionhandling.cpp b/src/vm/exceptionhandling.cpp index d3485e3671..055e5b24ec 100644 --- a/src/vm/exceptionhandling.cpp +++ b/src/vm/exceptionhandling.cpp @@ -1208,12 +1208,9 @@ bool FixNonvolatileRegisters(UINT_PTR uOriginalSP, CONTRACTL_END; CONTEXT _ctx = {0}; -#if defined(_TARGET_AMD64_) - REGDISPLAY regdisp = {0}; -#else + // Ctor will initialize it to NULL REGDISPLAY regdisp; -#endif // _TARGET_AMD64_ pThread->FillRegDisplay(®disp, &_ctx); |