.global C_FUNC(\Name\()_End)
LEAF_END \Name, \Section
.endm
+
+.macro PROLOG_BEG
+ push ebp
+ .cfi_def_cfa_offset 8
+ .cfi_offset ebp, -8
+ mov ebp, esp
+.endm
+
+.macro PROLOG_PUSH Reg
+ push \Reg
+ .cfi_adjust_cfa_offset 4
+ .cfi_rel_offset \Reg, 0
+.endm
+
+.macro PROLOG_END
+ .cfi_def_cfa_register ebp
+ .cfi_def_cfa_offset 8
+.endm
+
+.macro EPILOG_BEG
+.endm
+
+.macro EPILOG_POP Reg
+ pop \Reg
+ .cfi_restore \Reg
+.endm
+
+.macro EPILOG_END
+ pop ebp
+.endm
//
.macro STUB_PROLOG
// push ebp-frame
- push ebp
- mov ebp, esp
+ PROLOG_BEG
// save CalleeSavedRegisters
- push ebx
- push esi
- push edi
+ PROLOG_PUSH ebx
+ PROLOG_PUSH esi
+ PROLOG_PUSH edi
// push ArgumentRegisters
- push ecx
- push edx
+ PROLOG_PUSH ecx
+ PROLOG_PUSH edx
+
+ // set frame pointer
+ PROLOG_END
.endm
//
// FramedMethodFrame epilog
//
.macro STUB_EPILOG
+ // restore stack pointer
+ EPILOG_BEG
+
// pop ArgumentRegisters
- pop edx
- pop ecx
+ EPILOG_POP edx
+ EPILOG_POP ecx
// pop CalleeSavedRegisters
- pop edi
- pop esi
- pop ebx
- pop ebp
+ EPILOG_POP edi
+ EPILOG_POP esi
+ EPILOG_POP ebx
+
+ // pop ebp-frame
+ EPILOG_END
.endm
//
// ------------------------------------------------------------------------------
// void STDCALL CallDescrWorkerInternal(CallDescrWorkerParams * pParams)
NESTED_ENTRY CallDescrWorkerInternal, _TEXT, NoHandler
+ PROLOG_BEG
+ PROLOG_PUSH ebx
+ PROLOG_END
- mov ebx, [esp + 4] // pParams = esp + 4
+ mov ebx, [esp + ((2 + 1) * 4)]
// copy the stack
mov ecx, [ebx +CallDescrData__numStackSlots]
mov [ebx + CallDescrData__returnValue + 4], edx
LOCAL_LABEL(Epilog):
+ EPILOG_BEG
+ EPILOG_POP ebx
+ EPILOG_END
ret 4
LOCAL_LABEL(ReturnsFloat):
sub eax, 5
// Push ebp frame to get good callstack under debugger
- push ebp
- mov ebp, esp
+ PROLOG_BEG
// Preserve argument registers
- push ecx
- push edx
+ PROLOG_PUSH ecx
+ PROLOG_PUSH edx
+
+ // Set frame pointer
+ PROLOG_END
push eax // address of the thunk
push ecx // this ptr
call C_FUNC(VirtualMethodFixupWorker)
+ // Restore stack pointer
+ EPILOG_BEG
+
// Restore argument registers
- pop edx
- pop ecx
+ EPILOG_POP edx
+ EPILOG_POP ecx
// Pop ebp frame
- pop ebp
+ EPILOG_END
PATCH_LABEL VirtualMethodFixupPatchLabel
// Proceed to execute the actual method.