diff options
author | Mike Pall <mike> | 2009-12-30 02:37:57 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-30 02:37:57 +0100 |
commit | 9de0f53a8db3a4d3fa1951ff08aaab392dc7a584 (patch) | |
tree | ce510093fe7d09073c90afbf18f8d5e3577c3cf3 /src/buildvm_x86.dasc | |
parent | 52eb88773e88464cb5cc69b485d742468f66f2a2 (diff) | |
download | luajit-9de0f53a8db3a4d3fa1951ff08aaab392dc7a584.tar.gz luajit-9de0f53a8db3a4d3fa1951ff08aaab392dc7a584.tar.bz2 luajit-9de0f53a8db3a4d3fa1951ff08aaab392dc7a584.zip |
Implement yield from C hooks.
Get number of multiple results from C frame.
Add lj_cont_hook: restores multres and dispatch to static ins.
Can use fastcall for lj_dispatch_ins() now.
Diffstat (limited to 'src/buildvm_x86.dasc')
-rw-r--r-- | src/buildvm_x86.dasc | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 5ff76a55..952fc9d6 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -618,13 +618,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
618 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | 618 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. |
619 | | // (void *cframe, int errcode) | 619 | | // (void *cframe, int errcode) |
620 | |.if X64 | 620 | |.if X64 |
621 | | and CARG1, CFRAME_RAWMASK | ||
622 | | mov eax, CARG2d // Error return status for vm_pcall. | 621 | | mov eax, CARG2d // Error return status for vm_pcall. |
623 | | mov rsp, CARG1 | 622 | | mov rsp, CARG1 |
624 | |.else | 623 | |.else |
625 | | mov ecx, [esp+4] | 624 | | mov ecx, [esp+4] |
626 | | mov eax, [esp+8] // Error return status for vm_pcall. | 625 | | mov eax, [esp+8] // Error return status for vm_pcall. |
627 | | and ecx, CFRAME_RAWMASK | ||
628 | | mov esp, ecx | 626 | | mov esp, ecx |
629 | |.endif | 627 | |.endif |
630 | | mov L:RB, SAVE_L | 628 | | mov L:RB, SAVE_L |
@@ -2618,24 +2616,15 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
2618 | | test RDL, LUA_MASKLINE | 2616 | | test RDL, LUA_MASKLINE |
2619 | | jz >5 | 2617 | | jz >5 |
2620 | |1: | 2618 | |1: |
2621 | |.if X64 | ||
2622 | | mov L:RB, SAVE_L | ||
2623 | | mov L:RB->base, BASE // Caveat: CARG2d/CARG3d may be BASE. | ||
2624 | | mov CARG3d, NRESULTS // Dynamic top for *M instructions. | ||
2625 | | mov CARG2d, PC | ||
2626 | | mov CARG1d, L:RB | ||
2627 | |.else | ||
2628 | | mov L:RB, SAVE_L | 2619 | | mov L:RB, SAVE_L |
2629 | | mov RD, NRESULTS // Dynamic top for *M instructions. | ||
2630 | | mov ARG3, RD | ||
2631 | | mov L:RB->base, BASE | 2620 | | mov L:RB->base, BASE |
2632 | | mov ARG2, PC | 2621 | | mov FCARG2, PC // Caveat: FCARG2 == BASE |
2633 | | mov ARG1, L:RB | 2622 | | mov FCARG1, L:RB |
2634 | |.endif | ||
2635 | | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. | 2623 | | // SAVE_PC must hold the _previous_ PC. The callee updates it with PC. |
2636 | | call extern lj_dispatch_ins // (lua_State *L, BCIns *pc, int nres) | 2624 | | call extern lj_dispatch_ins@8 // (lua_State *L, BCIns *pc) |
2637 | |4: | 2625 | |3: |
2638 | | mov BASE, L:RB->base | 2626 | | mov BASE, L:RB->base |
2627 | |4: | ||
2639 | | movzx RA, PC_RA | 2628 | | movzx RA, PC_RA |
2640 | |5: | 2629 | |5: |
2641 | | movzx OP, PC_OP | 2630 | | movzx OP, PC_OP |
@@ -2646,6 +2635,12 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
2646 | | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins. | 2635 | | jmp aword [DISPATCH+OP*4+GG_DISP_STATIC*4] // Re-dispatch to static ins. |
2647 | |.endif | 2636 | |.endif |
2648 | | | 2637 | | |
2638 | |->cont_hook: // Continue from hook yield. | ||
2639 | | add PC, 4 | ||
2640 | | mov RA, [RB-24] | ||
2641 | | mov NRESULTS, RA // Restore NRESULTS for *M ins. | ||
2642 | | jmp <4 | ||
2643 | | | ||
2649 | |->vm_hotloop: // Hot loop counter underflow. | 2644 | |->vm_hotloop: // Hot loop counter underflow. |
2650 | #if LJ_HASJIT | 2645 | #if LJ_HASJIT |
2651 | |.if X64 | 2646 | |.if X64 |
@@ -2658,7 +2653,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse) | |||
2658 | | mov [DISPATCH+DISPATCH_J(L)], L:RB | 2653 | | mov [DISPATCH+DISPATCH_J(L)], L:RB |
2659 | | mov SAVE_PC, PC | 2654 | | mov SAVE_PC, PC |
2660 | | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) | 2655 | | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) |
2661 | | jmp <4 | 2656 | | jmp <3 |
2662 | |.endif | 2657 | |.endif |
2663 | #endif | 2658 | #endif |
2664 | | | 2659 | | |