FFI: Unify stack setup for C calls in interpreter.

This commit is contained in:
Mike Pall
2023-08-29 02:12:13 +02:00
parent 7cc53f0b85
commit cf903edb30
9 changed files with 63 additions and 54 deletions

View File

@@ -3314,19 +3314,25 @@ static void build_subroutines(BuildCtx *ctx)
|
| // Copy stack slots.
| movzx ecx, byte CCSTATE->nsp
| sub ecx, 1
|.if X64
| sub ecx, 8
| js >2
|1:
|.if X64
| mov rax, [CCSTATE+rcx*8+offsetof(CCallState, stack)]
| mov [rsp+rcx*8+CCALL_SPS_EXTRA*8], rax
|.else
| mov eax, [CCSTATE+ecx*4+offsetof(CCallState, stack)]
| mov [esp+ecx*4], eax
|.endif
| sub ecx, 1
| mov rax, [CCSTATE+rcx+offsetof(CCallState, stack)]
| mov [rsp+rcx+CCALL_SPS_EXTRA*8], rax
| sub ecx, 8
| jns <1
|2:
|.else
| sub ecx, 4
| js >2
|1:
| mov eax, [CCSTATE+ecx+offsetof(CCallState, stack)]
| mov [esp+ecx], eax
| sub ecx, 4
| jns <1
|2:
|.endif
|
|.if X64
| movzx eax, byte CCSTATE->nfpr