Unify interpreter reg saves/restores for WIN64 prolog/epilog req.

This commit is contained in:
Mike Pall 2009-12-15 21:36:42 +01:00
parent 1eedc6d2f1
commit 8df9603888
2 changed files with 814 additions and 815 deletions

View File

@ -82,23 +82,27 @@
|.macro pop_eax; .if X64; pop rax; .else; pop eax; .endif; .endmacro |.macro pop_eax; .if X64; pop rax; .else; pop eax; .endif; .endmacro
| |
|// Stack layout while in interpreter. Must match with lj_frame.h. |// Stack layout while in interpreter. Must match with lj_frame.h.
|.define CFRAME_SPACE, aword*7 // Delta for esp (see <--).
|.macro saveregs |.macro saveregs
| .if X64 | .if X64
| .if X64WIN; push rdi; push rsi; .endif | .if X64WIN; push rdi; push rsi; .endif
| push rbp; push rbx; push r12; push r13; push r14; push r15 | push rbp; push rbx; push r12; push r13; push r14; push r15
| sub rsp, CFRAME_SPACE
| .else | .else
| push ebp; push edi; push esi; push ebx | push ebp; push edi; push esi; push ebx
| sub esp, CFRAME_SPACE
| .endif | .endif
|.endmacro |.endmacro
|.macro restoreregs |.macro restoreregs
| .if X64 | .if X64
| add rsp, CFRAME_SPACE
| pop r15; pop r14; pop r13; pop r12; pop rbx; pop rbp | pop r15; pop r14; pop r13; pop r12; pop rbx; pop rbp
| .if X64WIN; pop rsi; pop rdi; .endif | .if X64WIN; pop rsi; pop rdi; .endif
| .else | .else
| add esp, CFRAME_SPACE
| pop ebx; pop esi; pop edi; pop ebp | pop ebx; pop esi; pop edi; pop ebp
| .endif | .endif
|.endmacro |.endmacro
|.define CFRAME_SPACE, aword*7 // Delta for esp (see <--).
| |
|.define INARG_4, aword [esp+aword*15] |.define INARG_4, aword [esp+aword*15]
|.define INARG_3, aword [esp+aword*14] |.define INARG_3, aword [esp+aword*14]
@ -430,7 +434,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov)
| xor eax, eax // Ok return status for vm_pcall. | xor eax, eax // Ok return status for vm_pcall.
| |
|->vm_leave_unw: |->vm_leave_unw:
| add esp, CFRAME_SPACE
| restoreregs | restoreregs
| ret | ret
| |
@ -550,7 +553,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov)
| // (lua_State *L, StkId base, int nres1 = 0, ptrdiff_t ef = 0) | // (lua_State *L, StkId base, int nres1 = 0, ptrdiff_t ef = 0)
| saveregs | saveregs
| mov PC, FRAME_C | mov PC, FRAME_C
| sub esp, CFRAME_SPACE
| xor RD, RD | xor RD, RD
| mov L:RB, SAVE_L | mov L:RB, SAVE_L
| lea KBASE, [esp+CFRAME_RESUME] | lea KBASE, [esp+CFRAME_RESUME]
@ -590,7 +592,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov)
| mov PC, FRAME_C | mov PC, FRAME_C
| |
|1: // Entry point for vm_pcall above (PC = ftype). |1: // Entry point for vm_pcall above (PC = ftype).
| sub esp, CFRAME_SPACE
| mov L:RB, SAVE_L | mov L:RB, SAVE_L
| mov RA, INARG_BASE | mov RA, INARG_BASE
| |
@ -623,8 +624,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov)
|->vm_cpcall: // Setup protected C frame, call C. |->vm_cpcall: // Setup protected C frame, call C.
| // (lua_State *L, lua_CPFunction cp, lua_CFunction func, void *ud) | // (lua_State *L, lua_CPFunction cp, lua_CFunction func, void *ud)
| saveregs | saveregs
| sub esp, CFRAME_SPACE
|
| mov L:RB, SAVE_L | mov L:RB, SAVE_L
| mov RC, INARG_CP_UD | mov RC, INARG_CP_UD
| mov RA, INARG_CP_FUNC | mov RA, INARG_CP_FUNC

File diff suppressed because it is too large Load Diff