Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e1efbf4

Browse files
parjongjanvorli
authored andcommitted
[x86/Linux] Remove unnecessary ResumeEsp field (#11167)
1 parent 3b0f7a9 commit e1efbf4

File tree

10 files changed

+7
-32
lines changed

10 files changed

+7
-32
lines changed

src/pal/inc/pal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,8 +1783,6 @@ typedef struct _CONTEXT {
17831783
ULONG SegSs;
17841784

17851785
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
1786-
1787-
ULONG ResumeEsp;
17881786
} CONTEXT, *PCONTEXT, *LPCONTEXT;
17891787

17901788
// To support saving and loading xmm register context we need to know the offset in the ExtendedRegisters

src/pal/src/arch/i386/asmconstants.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@
2828
#define CONTEXT_Xmm5 CONTEXT_Xmm4+16
2929
#define CONTEXT_Xmm6 CONTEXT_Xmm5+16
3030
#define CONTEXT_Xmm7 CONTEXT_Xmm6+16
31-
#define CONTEXT_ResumeEsp CONTEXT_ExtendedRegisters+512

src/pal/src/arch/i386/context2.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ LEAF_ENTRY CONTEXT_CaptureContext, _TEXT
4242
mov [eax + CONTEXT_Ebp], ebp
4343
lea ebx, [esp + 12]
4444
mov [eax + CONTEXT_Esp], ebx
45-
mov [eax + CONTEXT_ResumeEsp], ebx
4645
mov ebx, [esp + 8]
4746
mov [eax + CONTEXT_Eip], ebx
4847

@@ -115,7 +114,7 @@ LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT):
115114
LOCAL_LABEL(Done_Restore_CONTEXT_EXTENDED_REGISTERS):
116115

117116
// Restore Stack
118-
mov esp, [eax + CONTEXT_ResumeEsp]
117+
mov esp, [eax + CONTEXT_Esp]
119118

120119
// Create a minimal frame
121120
push DWORD PTR [eax + CONTEXT_Eip]

src/pal/src/arch/i386/exceptionhelper.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT
2323
mov eax, [esp + 8] // ebx: CONTEXT *
2424

2525
mov ebp, [eax + CONTEXT_Ebp]
26-
mov esp, [eax + CONTEXT_ResumeEsp]
26+
mov esp, [eax + CONTEXT_Esp]
2727
mov ebx, [eax + CONTEXT_Ebx]
2828
mov esi, [eax + CONTEXT_Esi]
2929
mov edi, [eax + CONTEXT_Edi]

src/pal/src/arch/i386/signalhandlerhelper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context,
7070
// We don't care about the other registers state since the stack unwinding restores
7171
// them for the target frame directly from the signal context.
7272
context2.Esp = (size_t)sp;
73-
context2.ResumeEsp = (size_t)sp;
7473
context2.Ebp = (size_t)fp;
7574
context2.Eip = (size_t)signal_handler_worker;
7675

src/pal/src/exception/seh-unwind.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ static void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext)
155155
#elif defined(_X86_)
156156
unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip);
157157
unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp);
158-
unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->ResumeEsp);
159158
unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp);
160159
unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx);
161160
unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi);

src/pal/src/thread/context.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContex
506506
// although the pc value retrived from native context might not have set the least bit.
507507
// This becomes especially problematic if the context is on the JIT_WRITEBARRIER.
508508
lpContext->Pc |= 0x1;
509-
#elif defined(_X86_)
510-
lpContext->ResumeEsp = MCREG_Esp(native->uc_mcontext);
511509
#endif
512510
}
513511

@@ -978,7 +976,6 @@ CONTEXT_GetThreadContextFromThreadState(
978976
lpContext->Esi = pState->esi;
979977
lpContext->Ebp = pState->ebp;
980978
lpContext->Esp = pState->esp;
981-
lpContext->ResumeEsp = pState->esp;
982979
lpContext->SegSs = pState->ss;
983980
lpContext->EFlags = pState->eflags;
984981
lpContext->Eip = pState->eip;

src/unwinder/i386/unwinder_i386.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,7 @@ OOPStackUnwinderX86::VirtualUnwind(
105105
ENUM_CALLEE_SAVED_REGISTERS();
106106
#undef CALLEE_SAVED_REGISTER
107107

108-
SIZE_T paramSize = codeInfo.GetCodeManager()->GetStackParameterSize(&codeInfo);
109-
SIZE_T paddingSize = 0;
110-
111-
#ifdef UNIX_X86_ABI
112-
// On UNIX_X86_ABI, function call may have stack alignment padding.
113-
if (paramSize % 16 != 0)
114-
{
115-
paddingSize += 16 - (paramSize % 16);
116-
}
117-
#endif // UNIX_X86_ABI
118-
119-
ContextRecord->Esp = rd.SP - paramSize;
120-
ContextRecord->ResumeEsp = ExecutionManager::IsManagedCode((PCODE) rd.ControlPC)
121-
? rd.SP + paddingSize
122-
: ContextRecord->Esp;
108+
ContextRecord->Esp = rd.SP - codeInfo.GetCodeManager()->GetStackParameterSize(&codeInfo);
123109
ContextRecord->Eip = rd.ControlPC;
124110

125111
// For x86, the value of Establisher Frame Pointer is Caller SP

src/vm/exceptionhandling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void FixContext(PCONTEXT pContextRecord)
135135

136136
#ifdef _TARGET_X86_
137137
size_t resumeSp = EECodeManager::GetResumeSp(pContextRecord);
138-
FIXUPREG(ResumeEsp, resumeSp);
138+
FIXUPREG(Esp, resumeSp);
139139
#endif // _TARGET_X86_
140140

141141
#undef FIXUPREG

src/vm/i386/cgenx86.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ void TransitionFrame::UpdateRegDisplayHelper(const PREGDISPLAY pRD, UINT cbStack
331331

332332
pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);;
333333
pRD->pCurrentContext->Esp = CallerSP;
334-
pRD->pCurrentContext->ResumeEsp = CallerSP + cbStackPop;
335334

336335
UpdateRegDisplayFromCalleeSavedRegisters(pRD, regs);
337336
ClearRegDisplayArgumentAndScratchRegisters(pRD);
@@ -384,7 +383,7 @@ void HelperMethodFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
384383
#endif // DACCESS_COMPILE
385384

386385
pRD->pCurrentContext->Eip = pRD->ControlPC = m_MachState.GetRetAddr();
387-
pRD->pCurrentContext->Esp = pRD->pCurrentContext->ResumeEsp = pRD->SP = (DWORD) m_MachState.esp();
386+
pRD->pCurrentContext->Esp = pRD->SP = (DWORD) m_MachState.esp();
388387

389388
#define CALLEE_SAVED_REGISTER(regname) pRD->pCurrentContext->regname = *((DWORD*) m_MachState.p##regname());
390389
ENUM_CALLEE_SAVED_REGISTERS();
@@ -689,7 +688,6 @@ void InlinedCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
689688

690689
pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
691690
pRD->pCurrentContext->Esp = (DWORD) dac_cast<TADDR>(m_pCallSiteSP);
692-
pRD->pCurrentContext->ResumeEsp = (DWORD) dac_cast<TADDR>(m_pCallSiteSP) + stackArgSize;
693691
pRD->pCurrentContext->Ebp = (DWORD) m_pCalleeSavedFP;
694692

695693
ClearRegDisplayArgumentAndScratchRegisters(pRD);
@@ -829,7 +827,7 @@ void HijackFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
829827
pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
830828

831829
pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
832-
pRD->pCurrentContext->Esp = pRD->pCurrentContext->ResumeEsp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
830+
pRD->pCurrentContext->Esp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
833831

834832
#define RESTORE_REG(reg) { pRD->pCurrentContext->reg = m_Args->reg; pRD->pCurrentContextPointers->reg = &m_Args->reg; }
835833
#define CALLEE_SAVED_REGISTER(reg) RESTORE_REG(reg)
@@ -908,7 +906,7 @@ void TailCallFrame::UpdateRegDisplay(const PREGDISPLAY pRD)
908906
pRD->IsCallerSPValid = FALSE; // Don't add usage of this field. This is only temporary.
909907

910908
pRD->pCurrentContext->Eip = *PTR_PCODE(pRD->PCTAddr);
911-
pRD->pCurrentContext->Esp = pRD->pCurrentContext->ResumeEsp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
909+
pRD->pCurrentContext->Esp = (DWORD)(pRD->PCTAddr + sizeof(TADDR));
912910

913911
UpdateRegDisplayFromCalleeSavedRegisters(pRD, &m_regs);
914912
ClearRegDisplayArgumentAndScratchRegisters(pRD);

0 commit comments

Comments
 (0)