diff options
Diffstat (limited to 'src/buildvm_x86.dasc')
-rw-r--r-- | src/buildvm_x86.dasc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index b64617f9..67282163 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -691,12 +691,12 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
691 | |->vm_call_dispatch: | 691 | |->vm_call_dispatch: |
692 | | mov LFUNC:RB, [RA-8] | 692 | | mov LFUNC:RB, [RA-8] |
693 | | cmp dword [RA-4], LJ_TFUNC | 693 | | cmp dword [RA-4], LJ_TFUNC |
694 | | jne ->vmeta_call // Ensure KBASE defined and != BASE. | 694 | | jne ->vmeta_call // Ensure KBASE defined and != BASE. |
695 | | | 695 | | |
696 | |->vm_call_dispatch_f: | 696 | |->vm_call_dispatch_f: |
697 | | mov BASE, RA | 697 | | mov BASE, RA |
698 | | ins_call | 698 | | ins_call |
699 | | // BASE = new base, RD = nargs+1 | 699 | | // BASE = new base, RB = func, RD = nargs+1, PC = caller PC |
700 | | | 700 | | |
701 | |->vm_cpcall: // Setup protected C frame, call C. | 701 | |->vm_cpcall: // Setup protected C frame, call C. |
702 | | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | 702 | | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) |
@@ -760,10 +760,14 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
760 | | mov PC, [RB-12] // Restore PC from [cont|PC]. | 760 | | mov PC, [RB-12] // Restore PC from [cont|PC]. |
761 | |.if X64 | 761 | |.if X64 |
762 | | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. | 762 | | movsxd RAa, dword [RB-16] // May be negative on WIN64 with debug. |
763 | | test RA, RA | ||
764 | | jz >1 | ||
763 | | lea KBASEa, qword [=>0] | 765 | | lea KBASEa, qword [=>0] |
764 | | add RAa, KBASEa | 766 | | add RAa, KBASEa |
765 | |.else | 767 | |.else |
766 | | mov RA, dword [RB-16] | 768 | | mov RA, dword [RB-16] |
769 | | test RA, RA | ||
770 | | jz >1 | ||
767 | |.endif | 771 | |.endif |
768 | | mov LFUNC:KBASE, [BASE-8] | 772 | | mov LFUNC:KBASE, [BASE-8] |
769 | | mov KBASE, LFUNC:KBASE->pc | 773 | | mov KBASE, LFUNC:KBASE->pc |
@@ -771,6 +775,12 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
771 | | // BASE = base, RC = result, RB = meta base | 775 | | // BASE = base, RC = result, RB = meta base |
772 | | jmp RAa // Jump to continuation. | 776 | | jmp RAa // Jump to continuation. |
773 | | | 777 | | |
778 | |1: // Tail call from C function. | ||
779 | | sub RB, BASE | ||
780 | | shr RB, 3 | ||
781 | | lea RD, [RB-1] | ||
782 | | jmp ->vm_call_tail | ||
783 | | | ||
774 | |->cont_cat: // BASE = base, RC = result, RB = mbase | 784 | |->cont_cat: // BASE = base, RC = result, RB = mbase |
775 | | movzx RA, PC_RB | 785 | | movzx RA, PC_RB |
776 | | sub RB, 16 | 786 | | sub RB, 16 |
@@ -2735,10 +2745,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
2735 | | test RD, RD | 2745 | | test RD, RD |
2736 | | lea NARGS:RD, [RA+1] | 2746 | | lea NARGS:RD, [RA+1] |
2737 | | mov LFUNC:RB, [BASE-8] | 2747 | | mov LFUNC:RB, [BASE-8] |
2738 | | jne >2 // Returned -1? | 2748 | | jne ->vm_call_tail // Returned -1? |
2739 | | ins_callt // Returned 0: retry fast path. | 2749 | | ins_callt // Returned 0: retry fast path. |
2740 | | | 2750 | | |
2741 | |2: // Reconstruct previous base for vmeta_call during tailcall. | 2751 | |// Reconstruct previous base for vmeta_call during tailcall. |
2752 | |->vm_call_tail: | ||
2742 | | mov RA, BASE | 2753 | | mov RA, BASE |
2743 | | test PC, FRAME_TYPE | 2754 | | test PC, FRAME_TYPE |
2744 | | jnz >3 | 2755 | | jnz >3 |