mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix various 32/64 bit issues in interpreter.
This commit is contained in:
parent
241e8db3f1
commit
81c9f5de89
@ -23,16 +23,19 @@
|
|||||||
|.define KBASE, edi // Must be C callee-save.
|
|.define KBASE, edi // Must be C callee-save.
|
||||||
|.define KBASEa, KBASE
|
|.define KBASEa, KBASE
|
||||||
|.define PC, esi // Must be C callee-save.
|
|.define PC, esi // Must be C callee-save.
|
||||||
|
|.define PCa, PC
|
||||||
|.define DISPATCH, ebx // Must be C callee-save.
|
|.define DISPATCH, ebx // Must be C callee-save.
|
||||||
|.elif X64WIN
|
|.elif X64WIN
|
||||||
|.define KBASE, edi // Must be C callee-save.
|
|.define KBASE, edi // Must be C callee-save.
|
||||||
|.define KBASEa, rdi
|
|.define KBASEa, rdi
|
||||||
|.define PC, esi // Must be C callee-save.
|
|.define PC, esi // Must be C callee-save.
|
||||||
|
|.define PCa, rsi
|
||||||
|.define DISPATCH, ebx // Must be C callee-save.
|
|.define DISPATCH, ebx // Must be C callee-save.
|
||||||
|.else
|
|.else
|
||||||
|.define KBASE, r15d // Must be C callee-save.
|
|.define KBASE, r15d // Must be C callee-save.
|
||||||
|.define KBASEa, r15
|
|.define KBASEa, r15
|
||||||
|.define PC, ebx // Must be C callee-save.
|
|.define PC, ebx // Must be C callee-save.
|
||||||
|
|.define PCa, rbx
|
||||||
|.define DISPATCH, r14d // Must be C callee-save.
|
|.define DISPATCH, r14d // Must be C callee-save.
|
||||||
|.endif
|
|.endif
|
||||||
|
|
|
|
||||||
@ -262,10 +265,10 @@
|
|||||||
| movzx OP, RCL
|
| movzx OP, RCL
|
||||||
| add PC, 4
|
| add PC, 4
|
||||||
| shr RC, 16
|
| shr RC, 16
|
||||||
|.if not X64
|
|.if X64
|
||||||
| jmp aword [DISPATCH+OP*4]
|
|
||||||
|.else
|
|
||||||
| jmp aword [DISPATCH+OP*8]
|
| jmp aword [DISPATCH+OP*8]
|
||||||
|
|.else
|
||||||
|
| jmp aword [DISPATCH+OP*4]
|
||||||
|.endif
|
|.endif
|
||||||
|.endmacro
|
|.endmacro
|
||||||
|
|
|
|
||||||
@ -640,7 +643,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
| mov esp, ecx
|
| mov esp, ecx
|
||||||
|.endif
|
|.endif
|
||||||
| mov L:RB, SAVE_L
|
| mov L:RB, SAVE_L
|
||||||
| mov RA, -8 // Results start at BASE+RA = BASE-8.
|
| mov RAa, -8 // Results start at BASE+RA = BASE-8.
|
||||||
| mov RD, 1+1 // Really 1+2 results, incr. later.
|
| mov RD, 1+1 // Really 1+2 results, incr. later.
|
||||||
| mov BASE, L:RB->base
|
| mov BASE, L:RB->base
|
||||||
| mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
|
| mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
|
||||||
@ -657,7 +660,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
| // Return from pcall or xpcall fast func.
|
| // Return from pcall or xpcall fast func.
|
||||||
| and PC, -8
|
| and PC, -8
|
||||||
| sub BASE, PC // Restore caller base.
|
| sub BASE, PC // Restore caller base.
|
||||||
| lea RA, [RA+PC-8] // Rebase RA and prepend one result.
|
| lea RAa, [RA+PC-8] // Rebase RA and prepend one result.
|
||||||
| mov PC, [BASE-4] // Fetch PC of previous frame.
|
| mov PC, [BASE-4] // Fetch PC of previous frame.
|
||||||
| // Prepending may overwrite the pcall frame, so do it at the end.
|
| // Prepending may overwrite the pcall frame, so do it at the end.
|
||||||
| mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results.
|
| mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results.
|
||||||
@ -719,10 +722,10 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
|.endif
|
|.endif
|
||||||
| mov PC, FRAME_C
|
| mov PC, FRAME_C
|
||||||
| xor RD, RD
|
| xor RD, RD
|
||||||
| lea KBASE, [esp+CFRAME_RESUME]
|
| lea KBASEa, [esp+CFRAME_RESUME]
|
||||||
| mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
|
| mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
|
||||||
| add DISPATCH, GG_G2DISP
|
| add DISPATCH, GG_G2DISP
|
||||||
| mov L:RB->cframe, KBASE
|
| mov L:RB->cframe, KBASEa
|
||||||
| mov SAVE_PC, RD // Any value outside of bytecode is ok.
|
| mov SAVE_PC, RD // Any value outside of bytecode is ok.
|
||||||
| mov SAVE_CFRAME, RDa
|
| mov SAVE_CFRAME, RDa
|
||||||
|.if X64
|
|.if X64
|
||||||
@ -1270,7 +1273,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
| movzx RA, RCH
|
| movzx RA, RCH
|
||||||
| movzx OP, RCL
|
| movzx OP, RCL
|
||||||
| shr RC, 16
|
| shr RC, 16
|
||||||
|
|.if X64
|
||||||
|
| jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Retry FORI or JFORI.
|
||||||
|
|.else
|
||||||
| jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Retry FORI or JFORI.
|
| jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Retry FORI or JFORI.
|
||||||
|
|.endif
|
||||||
|
|
|
|
||||||
|//-----------------------------------------------------------------------
|
|//-----------------------------------------------------------------------
|
||||||
|//-- Fast functions -----------------------------------------------------
|
|//-- Fast functions -----------------------------------------------------
|
||||||
@ -1738,7 +1745,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
|.else
|
|.else
|
||||||
| lea RA, [RA+NARGS:RC*8-16] // RA = end of source for stack move.
|
| lea RA, [RA+NARGS:RC*8-16] // RA = end of source for stack move.
|
||||||
|.endif
|
|.endif
|
||||||
| sub RA, PC // Relative to PC.
|
| sub RAa, PCa // Relative to PC.
|
||||||
|
|
|
|
||||||
| cmp PC, RB
|
| cmp PC, RB
|
||||||
| je >3
|
| je >3
|
||||||
@ -1784,7 +1791,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
| ja >9 // Need to grow stack?
|
| ja >9 // Need to grow stack?
|
||||||
|
|
|
|
||||||
| mov RB, BASE
|
| mov RB, BASE
|
||||||
| sub RB, RA
|
| sub RBa, RAa
|
||||||
|5: // Move results from coroutine.
|
|5: // Move results from coroutine.
|
||||||
| mov RD, [RA]
|
| mov RD, [RA]
|
||||||
| mov [RA+RB], RD
|
| mov [RA+RB], RD
|
||||||
@ -1804,7 +1811,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
| mov PC, SAVE_PC
|
| mov PC, SAVE_PC
|
||||||
| mov NRESULTS, RD
|
| mov NRESULTS, RD
|
||||||
|.if resume
|
|.if resume
|
||||||
| mov RA, -8
|
| mov RAa, -8
|
||||||
|.else
|
|.else
|
||||||
| xor RA, RA
|
| xor RA, RA
|
||||||
|.endif
|
|.endif
|
||||||
@ -2633,7 +2640,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
|||||||
|5:
|
|5:
|
||||||
| movzx OP, PC_OP
|
| movzx OP, PC_OP
|
||||||
| movzx RD, PC_RD
|
| movzx RD, PC_RD
|
||||||
|
|.if X64
|
||||||
|
| jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Re-dispatch to static ins.
|
||||||
|
|.else
|
||||||
| jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins.
|
| jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins.
|
||||||
|
|.endif
|
||||||
|
|
|
|
||||||
|->vm_hotloop: // Hot loop counter underflow.
|
|->vm_hotloop: // Hot loop counter underflow.
|
||||||
#if LJ_HASJIT
|
#if LJ_HASJIT
|
||||||
|
Loading…
Reference in New Issue
Block a user