aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2009-12-29 03:03:09 +0100
committerMike Pall <mike>2009-12-29 03:03:09 +0100
commit81c9f5de89a03396ca80cd84e7c68552df7fd9f4 (patch)
tree5b214c3013dfad09f96924f51493ef387637b517 /src
parent241e8db3f10570411d92d0905eed32fd3c9a9631 (diff)
downloadluajit-81c9f5de89a03396ca80cd84e7c68552df7fd9f4.tar.gz
luajit-81c9f5de89a03396ca80cd84e7c68552df7fd9f4.tar.bz2
luajit-81c9f5de89a03396ca80cd84e7c68552df7fd9f4.zip
Fix various 32/64 bit issues in interpreter.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_x86.dasc31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index 53ce9c99..0fe7cd88 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -23,16 +23,19 @@
23|.define KBASE, edi // Must be C callee-save. 23|.define KBASE, edi // Must be C callee-save.
24|.define KBASEa, KBASE 24|.define KBASEa, KBASE
25|.define PC, esi // Must be C callee-save. 25|.define PC, esi // Must be C callee-save.
26|.define PCa, PC
26|.define DISPATCH, ebx // Must be C callee-save. 27|.define DISPATCH, ebx // Must be C callee-save.
27|.elif X64WIN 28|.elif X64WIN
28|.define KBASE, edi // Must be C callee-save. 29|.define KBASE, edi // Must be C callee-save.
29|.define KBASEa, rdi 30|.define KBASEa, rdi
30|.define PC, esi // Must be C callee-save. 31|.define PC, esi // Must be C callee-save.
32|.define PCa, rsi
31|.define DISPATCH, ebx // Must be C callee-save. 33|.define DISPATCH, ebx // Must be C callee-save.
32|.else 34|.else
33|.define KBASE, r15d // Must be C callee-save. 35|.define KBASE, r15d // Must be C callee-save.
34|.define KBASEa, r15 36|.define KBASEa, r15
35|.define PC, ebx // Must be C callee-save. 37|.define PC, ebx // Must be C callee-save.
38|.define PCa, rbx
36|.define DISPATCH, r14d // Must be C callee-save. 39|.define DISPATCH, r14d // Must be C callee-save.
37|.endif 40|.endif
38| 41|
@@ -262,10 +265,10 @@
262| movzx OP, RCL 265| movzx OP, RCL
263| add PC, 4 266| add PC, 4
264| shr RC, 16 267| shr RC, 16
265|.if not X64 268|.if X64
266| jmp aword [DISPATCH+OP*4]
267|.else
268| jmp aword [DISPATCH+OP*8] 269| jmp aword [DISPATCH+OP*8]
270|.else
271| jmp aword [DISPATCH+OP*4]
269|.endif 272|.endif
270|.endmacro 273|.endmacro
271| 274|
@@ -640,7 +643,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
640 | mov esp, ecx 643 | mov esp, ecx
641 |.endif 644 |.endif
642 | mov L:RB, SAVE_L 645 | mov L:RB, SAVE_L
643 | mov RA, -8 // Results start at BASE+RA = BASE-8. 646 | mov RAa, -8 // Results start at BASE+RA = BASE-8.
644 | mov RD, 1+1 // Really 1+2 results, incr. later. 647 | mov RD, 1+1 // Really 1+2 results, incr. later.
645 | mov BASE, L:RB->base 648 | mov BASE, L:RB->base
646 | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. 649 | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
@@ -657,7 +660,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
657 | // Return from pcall or xpcall fast func. 660 | // Return from pcall or xpcall fast func.
658 | and PC, -8 661 | and PC, -8
659 | sub BASE, PC // Restore caller base. 662 | sub BASE, PC // Restore caller base.
660 | lea RA, [RA+PC-8] // Rebase RA and prepend one result. 663 | lea RAa, [RA+PC-8] // Rebase RA and prepend one result.
661 | mov PC, [BASE-4] // Fetch PC of previous frame. 664 | mov PC, [BASE-4] // Fetch PC of previous frame.
662 | // Prepending may overwrite the pcall frame, so do it at the end. 665 | // Prepending may overwrite the pcall frame, so do it at the end.
663 | mov dword [BASE+RA+4], LJ_TTRUE // Prepend true to results. 666 | 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)
719 |.endif 722 |.endif
720 | mov PC, FRAME_C 723 | mov PC, FRAME_C
721 | xor RD, RD 724 | xor RD, RD
722 | lea KBASE, [esp+CFRAME_RESUME] 725 | lea KBASEa, [esp+CFRAME_RESUME]
723 | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. 726 | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table.
724 | add DISPATCH, GG_G2DISP 727 | add DISPATCH, GG_G2DISP
725 | mov L:RB->cframe, KBASE 728 | mov L:RB->cframe, KBASEa
726 | mov SAVE_PC, RD // Any value outside of bytecode is ok. 729 | mov SAVE_PC, RD // Any value outside of bytecode is ok.
727 | mov SAVE_CFRAME, RDa 730 | mov SAVE_CFRAME, RDa
728 |.if X64 731 |.if X64
@@ -1270,7 +1273,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
1270 | movzx RA, RCH 1273 | movzx RA, RCH
1271 | movzx OP, RCL 1274 | movzx OP, RCL
1272 | shr RC, 16 1275 | shr RC, 16
1276 |.if X64
1277 | jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Retry FORI or JFORI.
1278 |.else
1273 | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Retry FORI or JFORI. 1279 | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Retry FORI or JFORI.
1280 |.endif
1274 | 1281 |
1275 |//----------------------------------------------------------------------- 1282 |//-----------------------------------------------------------------------
1276 |//-- Fast functions ----------------------------------------------------- 1283 |//-- Fast functions -----------------------------------------------------
@@ -1738,7 +1745,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
1738 |.else 1745 |.else
1739 | lea RA, [RA+NARGS:RC*8-16] // RA = end of source for stack move. 1746 | lea RA, [RA+NARGS:RC*8-16] // RA = end of source for stack move.
1740 |.endif 1747 |.endif
1741 | sub RA, PC // Relative to PC. 1748 | sub RAa, PCa // Relative to PC.
1742 | 1749 |
1743 | cmp PC, RB 1750 | cmp PC, RB
1744 | je >3 1751 | je >3
@@ -1784,7 +1791,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
1784 | ja >9 // Need to grow stack? 1791 | ja >9 // Need to grow stack?
1785 | 1792 |
1786 | mov RB, BASE 1793 | mov RB, BASE
1787 | sub RB, RA 1794 | sub RBa, RAa
1788 |5: // Move results from coroutine. 1795 |5: // Move results from coroutine.
1789 | mov RD, [RA] 1796 | mov RD, [RA]
1790 | mov [RA+RB], RD 1797 | mov [RA+RB], RD
@@ -1804,7 +1811,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
1804 | mov PC, SAVE_PC 1811 | mov PC, SAVE_PC
1805 | mov NRESULTS, RD 1812 | mov NRESULTS, RD
1806 |.if resume 1813 |.if resume
1807 | mov RA, -8 1814 | mov RAa, -8
1808 |.else 1815 |.else
1809 | xor RA, RA 1816 | xor RA, RA
1810 |.endif 1817 |.endif
@@ -2633,7 +2640,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2633 |5: 2640 |5:
2634 | movzx OP, PC_OP 2641 | movzx OP, PC_OP
2635 | movzx RD, PC_RD 2642 | movzx RD, PC_RD
2643 |.if X64
2644 | jmp aword [DISPATCH+OP*8+GG_DISP_STATIC*8] // Re-dispatch to static ins.
2645 |.else
2636 | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins. 2646 | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins.
2647 |.endif
2637 | 2648 |
2638 |->vm_hotloop: // Hot loop counter underflow. 2649 |->vm_hotloop: // Hot loop counter underflow.
2639#if LJ_HASJIT 2650#if LJ_HASJIT