aboutsummaryrefslogtreecommitdiff
path: root/src/buildvm_x86.dasc
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-14 17:47:03 +0100
committerMike Pall <mike>2010-02-14 17:47:03 +0100
commit8e38231f9ea0bd1185c0b9688e71cef52f96bb31 (patch)
tree36711cbf1769c62de80cbd338c7011a7c35ef062 /src/buildvm_x86.dasc
parentc93138b59e8f28b3d412cd7ec0c6631fd27e3e1b (diff)
downloadluajit-8e38231f9ea0bd1185c0b9688e71cef52f96bb31.tar.gz
luajit-8e38231f9ea0bd1185c0b9688e71cef52f96bb31.tar.bz2
luajit-8e38231f9ea0bd1185c0b9688e71cef52f96bb31.zip
Implement call hooks (zero-cost if disabled).
Diffstat (limited to 'src/buildvm_x86.dasc')
-rw-r--r--src/buildvm_x86.dasc31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index b970278e..b9036273 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -2504,36 +2504,43 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2504 | mov L:RB->top, RD 2504 | mov L:RB->top, RD
2505 | mov FCARG2, PC 2505 | mov FCARG2, PC
2506 | lea FCARG1, [DISPATCH+GG_DISP2J] 2506 | lea FCARG1, [DISPATCH+GG_DISP2J]
2507 | mov [DISPATCH+DISPATCH_J(L)], L:RB 2507 | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa
2508 | mov SAVE_PC, PC 2508 | mov SAVE_PC, PC
2509 | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) 2509 | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc)
2510 | jmp <3 2510 | jmp <3
2511 |.endif 2511 |.endif
2512#endif 2512#endif
2513 | 2513 |
2514 |->vm_callhook: // Dispatch target for call hooks.
2515#if LJ_HASJIT
2516 | mov aword [DISPATCH+DISPATCH_J(L)], 0 // Marker for call hook.
2517 | jmp >1
2518#endif
2519 |
2514 |->vm_hotcall: // Hot call counter underflow. 2520 |->vm_hotcall: // Hot call counter underflow.
2515#if LJ_HASJIT 2521#if LJ_HASJIT
2516 |.if X64 2522 | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa
2517 | int3 // NYI 2523 |1:
2518 |.else 2524#endif
2519 | lea RD, [BASE+NARGS:RD*8-8] 2525 | lea RD, [BASE+NARGS:RD*8-8]
2520 | mov L:RB, SAVE_L 2526 | mov L:RB, SAVE_L
2521 | mov L:RB->base, BASE 2527 | mov L:RB->base, BASE
2522 | mov L:RB->top, RD 2528 | mov L:RB->top, RD
2523 | mov FCARG2, PC 2529 | mov FCARG2, PC
2524 | lea FCARG1, [DISPATCH+GG_DISP2J] 2530 | mov FCARG1, L:RB
2525 | mov [DISPATCH+DISPATCH_J(L)], L:RB
2526 | mov SAVE_PC, PC 2531 | mov SAVE_PC, PC
2527 | call extern lj_trace_hot@8 // (jit_State *J, const BCIns *pc) 2532 | call extern lj_dispatch_call@8 // (lua_State *L, const BCIns *pc)
2533 | // ASMFunction returned in eax/rax (RDa).
2534 | mov SAVE_PC, 0 // Invalidate for subsequent line hook.
2528 | mov BASE, L:RB->base 2535 | mov BASE, L:RB->base
2536 | mov RAa, RDa
2529 | mov RD, L:RB->top 2537 | mov RD, L:RB->top
2530 | sub RD, BASE 2538 | sub RD, BASE
2539 | mov RBa, RAa
2540 | movzx RA, PC_RA
2531 | shr RD, 3 2541 | shr RD, 3
2532 | add NARGS:RD, 1 2542 | add NARGS:RD, 1
2533 | mov LFUNC:RB, [BASE-8] 2543 | jmp RBa
2534 | ins_callt
2535 |.endif
2536#endif
2537 | 2544 |
2538 |//----------------------------------------------------------------------- 2545 |//-----------------------------------------------------------------------
2539 |//-- Trace exit handler ------------------------------------------------- 2546 |//-- Trace exit handler -------------------------------------------------
@@ -2570,7 +2577,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
2570 | // Caveat: RB is ebp. 2577 | // Caveat: RB is ebp.
2571 | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)] 2578 | mov L:RB, [DISPATCH+DISPATCH_GL(jit_L)]
2572 | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)] 2579 | mov BASE, [DISPATCH+DISPATCH_GL(jit_base)]
2573 | mov [DISPATCH+DISPATCH_J(L)], L:RB 2580 | mov aword [DISPATCH+DISPATCH_J(L)], L:RBa
2574 | mov L:RB->base, BASE 2581 | mov L:RB->base, BASE
2575 | lea FCARG2, [esp+16] 2582 | lea FCARG2, [esp+16]
2576 | lea FCARG1, [DISPATCH+GG_DISP2J] 2583 | lea FCARG1, [DISPATCH+GG_DISP2J]