summaryrefslogtreecommitdiff
path: root/src/buildvm_x86.dasc
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildvm_x86.dasc')
-rw-r--r--src/buildvm_x86.dasc50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index 1e7331d2..7758cd15 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -2510,9 +2510,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2510 | 2510 |
2511 |->vm_hotloop: // Hot loop counter underflow. 2511 |->vm_hotloop: // Hot loop counter underflow.
2512#if LJ_HASJIT 2512#if LJ_HASJIT
2513 |.if X64
2514 | int3 // NYI
2515 |.else
2516 | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L). 2513 | mov LFUNC:RB, [BASE-8] // Same as curr_topL(L).
2517 | mov RB, LFUNC:RB->pc 2514 | mov RB, LFUNC:RB->pc
2518 | movzx RD, byte [RB+PC2PROTO(framesize)] 2515 | movzx RD, byte [RB+PC2PROTO(framesize)]
@@ -2526,7 +2523,6 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2526 | mov SAVE_PC, PC 2523 | mov SAVE_PC, PC
2527 | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) 2524 | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc)
2528 | jmp <3 2525 | jmp <3
2529 |.endif
2530#endif 2526#endif
2531 | 2527 |
2532 |->vm_callhook: // Dispatch target for call hooks. 2528 |->vm_callhook: // Dispatch target for call hooks.
@@ -2572,46 +2568,74 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2572 |->vm_exit_handler: 2568 |->vm_exit_handler:
2573#if LJ_HASJIT 2569#if LJ_HASJIT
2574 |.if X64 2570 |.if X64
2575 | int3 // NYI 2571 | push r13; push r12
2572 | push r11; push r10; push r9; push r8
2573 | push rdi; push rsi; push rbp; lea rbp, [rsp+88]; push rbp
2574 | push rbx; push rdx; push rcx; push rax
2575 | movzx RC, byte [rbp-8] // Reconstruct exit number.
2576 | mov RCH, byte [rbp-16]
2577 | mov [rbp-8], r15; mov [rbp-16], r14
2576 |.else 2578 |.else
2577 | push ebp; lea ebp, [esp+12]; push ebp 2579 | push ebp; lea ebp, [esp+12]; push ebp
2578 | push ebx; push edx; push ecx; push eax 2580 | push ebx; push edx; push ecx; push eax
2579 | movzx RC, byte [ebp-4] // Reconstruct exit number. 2581 | movzx RC, byte [ebp-4] // Reconstruct exit number.
2580 | mov RCH, byte [ebp-8] 2582 | mov RCH, byte [ebp-8]
2581 | mov [ebp-4], edi; mov [ebp-8], esi 2583 | mov [ebp-4], edi; mov [ebp-8], esi
2584 |.endif
2582 | // Caveat: DISPATCH is ebx. 2585 | // Caveat: DISPATCH is ebx.
2583 | mov DISPATCH, [ebp] 2586 | mov DISPATCH, [ebp]
2584 | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number. 2587 | mov RA, [DISPATCH+DISPATCH_GL(vmstate)] // Get trace number.
2585 | set_vmstate EXIT 2588 | set_vmstate EXIT
2586 | mov [DISPATCH+DISPATCH_J(exitno)], RC 2589 | mov [DISPATCH+DISPATCH_J(exitno)], RC
2587 | mov [DISPATCH+DISPATCH_J(parent)], RA 2590 | mov [DISPATCH+DISPATCH_J(parent)], RA
2591 |.if X64
2592 |.if X64WIN
2593 | sub rsp, 16*8+4*8 // Room for SSE regs + save area.
2594 |.else
2595 | sub rsp, 16*8 // Room for SSE regs.
2596 |.endif
2597 | add rbp, -128
2598 | movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14
2599 | movsd qword [rbp-24], xmm13; movsd qword [rbp-32], xmm12
2600 | movsd qword [rbp-40], xmm11; movsd qword [rbp-48], xmm10
2601 | movsd qword [rbp-56], xmm9; movsd qword [rbp-64], xmm8
2602 | movsd qword [rbp-72], xmm7; movsd qword [rbp-80], xmm6
2603 | movsd qword [rbp-88], xmm5; movsd qword [rbp-96], xmm4
2604 | movsd qword [rbp-104], xmm3; movsd qword [rbp-112], xmm2
2605 | movsd qword [rbp-120], xmm1; movsd qword [rbp-128], xmm0
2606 |.else
2588 | sub esp, 8*8+16 // Room for SSE regs + args. 2607 | sub esp, 8*8+16 // Room for SSE regs + args.
2589 |
2590 | // Must not access SSE regs if SSE2 is not present.
2591 | test dword [DISPATCH+DISPATCH_J(flags)], JIT_F_SSE2
2592 | jz >1
2593 | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6 2608 | movsd qword [ebp-40], xmm7; movsd qword [ebp-48], xmm6
2594 | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4 2609 | movsd qword [ebp-56], xmm5; movsd qword [ebp-64], xmm4
2595 | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2 2610 | movsd qword [ebp-72], xmm3; movsd qword [ebp-80], xmm2
2596 | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0 2611 | movsd qword [ebp-88], xmm1; movsd qword [ebp-96], xmm0
2597 |1: 2612 |.endif
2598 | // Caveat: RB is ebp. 2613 | // Caveat: RB is ebp.
2599 | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] 2614 | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)]
2600 | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] 2615 | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)]
2601 | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa 2616 | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa
2602 | mov L:RB->base, BASE 2617 | mov L:RB->base, BASE
2618 |.if X64WIN
2619 | lea CARG2, [rsp+4*8]
2620 |.elif X64
2621 | mov CARG2, rsp
2622 |.else
2603 | lea FCARG2, [esp+16] 2623 | lea FCARG2, [esp+16]
2624 |.endif
2604 | lea FCARG1, [DISPATCH+GG_DISP2J] 2625 | lea FCARG1, [DISPATCH+GG_DISP2J]
2605 | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex) 2626 | call extern lj_trace_exit@8 // (jit_State *J, ExitState *ex)
2606 | // Error code returned in eax (RD). 2627 | // Error code returned in eax (RD).
2607 | mov RAa, L:RB->cframe 2628 | mov RAa, L:RB->cframe
2608 | and RAa, CFRAME_RAWMASK 2629 | and RAa, CFRAME_RAWMASK
2630 |.if X64
2631 | mov rsp, RAa // Reposition stack to C frame.
2632 |.else
2609 | mov esp, RAa // Reposition stack to C frame. 2633 | mov esp, RAa // Reposition stack to C frame.
2634 |.endif
2610 | mov SAVE_L, L:RB // Needed for on-trace resume/yield. 2635 | mov SAVE_L, L:RB // Needed for on-trace resume/yield.
2611 | test RD, RD; jnz >1 // Check for error from exit. 2636 | test RD, RD; jnz >1 // Check for error from exit.
2612 | mov BASE, L:RB->base 2637 | mov BASE, L:RB->base
2613 | mov PC, SAVE_PC 2638 | mov PC, SAVE_PC
2614 |.endif
2615#endif 2639#endif
2616 |->vm_exit_interp: 2640 |->vm_exit_interp:
2617#if LJ_HASJIT 2641#if LJ_HASJIT
@@ -4681,7 +4705,11 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
4681#if LJ_HASJIT 4705#if LJ_HASJIT
4682 | ins_AD // RA = base (ignored), RD = traceno 4706 | ins_AD // RA = base (ignored), RD = traceno
4683 | mov RA, [DISPATCH+DISPATCH_J(trace)] 4707 | mov RA, [DISPATCH+DISPATCH_J(trace)]
4708 |.if X64
4709 | mov TRACE:RD, [RA+RD*8]
4710 |.else
4684 | mov TRACE:RD, [RA+RD*4] 4711 | mov TRACE:RD, [RA+RD*4]
4712 |.endif
4685 | mov RDa, TRACE:RD->mcode 4713 | mov RDa, TRACE:RD->mcode
4686 | mov L:RB, SAVE_L 4714 | mov L:RB, SAVE_L
4687 | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE 4715 | mov [DISPATCH+DISPATCH_GL(jit_base)], BASE