[x86/Linux] Clean up EHContext-related code (dotnet/coreclr#9395)
authorJonghyun Park <parjong@gmail.com>
Tue, 7 Feb 2017 14:08:15 +0000 (23:08 +0900)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 7 Feb 2017 14:08:15 +0000 (15:08 +0100)
Commit migrated from https://github.com/dotnet/coreclr/commit/35e91e578712bdcc881c56e515dba07e6be3f15d

src/coreclr/src/vm/i386/asmconstants.h
src/coreclr/src/vm/i386/asmhelpers.S
src/coreclr/src/vm/i386/cgencpu.h
src/coreclr/src/vm/i386/cgenx86.cpp

index 2590174..ce64851 100644 (file)
@@ -97,6 +97,7 @@ ASMCONSTANTS_C_ASSERT(SpinConstants_dwMaximumDuration == offsetof(SpinConstants,
 #define SpinConstants_dwBackoffFactor 8
 ASMCONSTANTS_C_ASSERT(SpinConstants_dwBackoffFactor == offsetof(SpinConstants,dwBackoffFactor))
 
+#ifndef WIN64EXCEPTIONS
 // EHContext from clr/src/vm/i386/cgencpu.h
 #define EHContext_Eax 0x00
 ASMCONSTANTS_C_ASSERT(EHContext_Eax == offsetof(EHContext,Eax))
@@ -124,6 +125,7 @@ ASMCONSTANTS_C_ASSERT(EHContext_Esp == offsetof(EHContext,Esp))
 
 #define EHContext_Eip 0x20
 ASMCONSTANTS_C_ASSERT(EHContext_Eip == offsetof(EHContext,Eip))
+#endif // WIN64EXCEPTIONS
 
 
 // from clr/src/fjit/helperframe.h
index 9445fa0..2bb9560 100644 (file)
@@ -127,110 +127,6 @@ LEAF_ENTRY RestoreFPUContext, _TEXT
     ret     4
 LEAF_END RestoreFPUContext, _TEXT
 
-LEAF_ENTRY ResumeAtJitEHHelper, _TEXT
-    mov     edx, [esp + 4]     // edx = pContext (EHContext*)
-
-    mov     ebx, [edx + EHContext_Ebx]
-    mov     esi, [edx + EHContext_Esi]
-    mov     edi, [edx + EHContext_Edi]
-    mov     ebp, [edx + EHContext_Ebp]
-    mov     ecx, [edx + EHContext_Esp]
-    mov     eax, [edx + EHContext_Eip]
-    mov     [ecx - 4], eax
-    mov     eax, [edx + EHContext_Eax]
-    mov     [ecx - 8], eax
-    mov     eax, [edx + EHContext_Ecx]
-    mov     [ecx - 0Ch], eax
-    mov     eax, [edx + EHContext_Edx]
-    mov     [ecx - 10h], eax
-    lea     esp, [ecx - 10h]
-    pop     edx
-    pop     ecx
-    pop     eax
-    ret
-LEAF_END ResumeAtJitEHHelper, _TEXT
-
-// int __stdcall CallJitEHFilterHelper(size_t *pShadowSP, EHContext *pContext);
-//   on entry, only the pContext->Esp, Ebx, Esi, Edi, Ebp, and Eip are initialized
-NESTED_ENTRY CallJitEHFilterHelper, _TEXT, NoHandler
-    push    ebp
-    mov     ebp, esp
-    push    ebx
-    push    esi
-    push    edi
-
-    // Write esp-4 to the shadowSP slot
-    mov     eax, [ebp + 8] // pShadowSP = [ebp+8]
-    test    eax, eax
-    jz      LOCAL_LABEL(DONE_SHADOWSP_FILTER)
-    mov     ebx, esp
-    sub     ebx, 4
-    or      ebx, SHADOW_SP_IN_FILTER_ASM
-    mov     [eax], ebx
-
-LOCAL_LABEL(DONE_SHADOWSP_FILTER):
-    mov     edx, [ebp + 12]       // pContext = [ebp+12]
-    mov     eax, [edx + EHContext_Eax]
-    mov     ebx, [edx + EHContext_Ebx]
-    mov     esi, [edx + EHContext_Esi]
-    mov     edi, [edx + EHContext_Edi]
-    mov     ebp, [edx + EHContext_Ebp]
-
-    call    DWORD PTR [edx + EHContext_Eip]
-#ifdef _DEBUG
-    nop  // Indicate that it is OK to call managed code directly from here
-#endif // _DEBUG
-
-    pop     edi
-    pop     esi
-    pop     ebx
-    pop     ebp // don't use 'leave' here, as ebp as been trashed
-    ret     8
-NESTED_END CallJitEHFilterHelper, _TEXT
-
-// void __stdcall CallJITEHFinallyHelper(size_t *pShadowSP, EHContext *pContext);
-//   on entry, only the pContext->Esp, Ebx, Esi, Edi, Ebp, and Eip are initialized
-NESTED_ENTRY CallJitEHFinallyHelper, _TEXT, NoHandler
-    push    ebp
-    mov     ebp, esp
-    push    ebx
-    push    esi
-    push    edi
-
-    // Write esp-4 to the shadowSP slot
-    mov     eax, [ebp + 8]  // pShadowSP = [ebp+8]
-    test    eax, eax
-    jz      LOCAL_LABEL(DONE_SHADOWSP_FINALLY)
-    mov     ebx, esp
-    sub     ebx, 4
-    mov     [eax], ebx
-
-LOCAL_LABEL(DONE_SHADOWSP_FINALLY):
-    mov     edx, [ebp + 12] // pContext = [ebp+12]
-    mov     eax, [edx + EHContext_Eax]
-    mov     ebx, [edx + EHContext_Ebx]
-    mov     esi, [edx + EHContext_Esi]
-    mov     edi, [edx + EHContext_Edi]
-    mov     ebp, [edx + EHContext_Ebp]
-    call    DWORD PTR [edx + EHContext_Eip]
-#ifdef _DEBUG
-    nop  // Indicate that it is OK to call managed code directly from here
-#endif // _DEBUG
-
-    // Reflect the changes to the context and only update non-volatile registers.
-    // This will be used later to update REGDISPLAY
-    mov     edx, [esp + 12 + 12]
-    mov     [edx + EHContext_Ebx], ebx
-    mov     [edx + EHContext_Esi], esi
-    mov     [edx + EHContext_Edi], edi
-    mov     [edx + EHContext_Ebp], ebp
-
-    pop     edi
-    pop     esi
-    pop     ebx
-    pop     ebp // don't use 'leave' here, as ebp as been trashed
-    ret     8
-NESTED_END CallJitEHFinallyHelper, _TEXT
 
 LEAF_ENTRY GetSpecificCpuTypeAsm, _TEXT
     push    ebx         // ebx is trashed by the cpuid calls
index 8a437f7..2e47a6a 100644 (file)
@@ -208,6 +208,7 @@ struct ArgumentRegisters {
 struct REGDISPLAY;
 typedef REGDISPLAY *PREGDISPLAY;
 
+#ifndef WIN64EXCEPTIONS
 // Sufficient context for Try/Catch restoration.
 struct EHContext {
     INT32       Eax;
@@ -256,6 +257,7 @@ struct EHContext {
         Eip = 0;
     }
 };
+#endif // !WIN64EXCEPTIONS
 
 #define ARGUMENTREGISTERS_SIZE sizeof(ArgumentRegisters)
 
index b551ab1..528629c 100644 (file)
@@ -219,6 +219,7 @@ void GetSpecificCpuInfo(CORINFO_CPU * cpuInfo)
 #endif // #ifndef DACCESS_COMPILE
 
 
+#ifndef WIN64EXCEPTIONS
 //---------------------------------------------------------------------------------------
 //
 // Initialize the EHContext using the resume PC and the REGDISPLAY.  The EHContext is currently used in two
@@ -240,10 +241,10 @@ void EHContext::Setup(PCODE resumePC, PREGDISPLAY regs)
 
     // EAX ECX EDX are scratch
     this->Esp  = regs->SP;
-    this->Ebx = *regs->GetEbxLocation();
-    this->Esi = *regs->GetEsiLocation();
-    this->Edi = *regs->GetEdiLocation();
-    this->Ebp = *regs->GetEbpLocation();
+    this->Ebx = *regs->pEbx;
+    this->Esi = *regs->pEsi;
+    this->Edi = *regs->pEdi;
+    this->Ebp = *regs->pEbp;
 
     this->Eip = (ULONG)(size_t)resumePC;
 }
@@ -272,16 +273,17 @@ void EHContext::UpdateFrame(PREGDISPLAY regs)
     // EAX ECX EDX are scratch. 
     // No need to update ESP as unwinder takes care of that for us
 
-    LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->GetEbxLocation(), this->Ebx));
-    LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->GetEsiLocation(), this->Esi));
-    LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->GetEdiLocation(), this->Edi));
-    LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->GetEbpLocation(), this->Ebp));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EBX: *%p= %p\n", regs->pEbx, this->Ebx));
+    LOG((LF_EH, LL_INFO1000, "Updating saved ESI: *%p= %p\n", regs->pEsi, this->Esi));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EDI: *%p= %p\n", regs->pEdi, this->Edi));
+    LOG((LF_EH, LL_INFO1000, "Updating saved EBP: *%p= %p\n", regs->pEbp, this->Ebp));
     
-    *regs->GetEbxLocation() = this->Ebx;
-    *regs->GetEsiLocation() = this->Esi;
-    *regs->GetEdiLocation() = this->Edi;
-    *regs->GetEbpLocation() = this->Ebp;
+    *regs->pEbx = this->Ebx;
+    *regs->pEsi = this->Esi;
+    *regs->pEdi = this->Edi;
+    *regs->pEbp = this->Ebp;
 }
+#endif // WIN64EXCEPTIONS
 
 void TransitionFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
 {