瀏覽代碼

PPC: Add dispatch target for call hook.

Mike Pall 15 年之前
父節點
當前提交
f635e3e5bb
共有 1 個文件被更改,包括 22 次插入2 次删除
  1. 22 2
      src/buildvm_ppc.dasc

+ 22 - 2
src/buildvm_ppc.dasc

@@ -1182,12 +1182,32 @@ static void build_subroutines(BuildCtx *ctx)
 #endif
   |
   |->vm_callhook:			// Dispatch target for call hooks.
-  |  NYI
+  |  mr CARG2, PC
+#if LJ_HASJIT
+  |  b >1
+#endif
   |
   |->vm_hotcall:			// Hot call counter underflow.
 #if LJ_HASJIT
-  |  NYI
+  |  ori CARG2, PC, 1
+  |1:
 #endif
+  |  add TMP0, BASE, RC
+  |   stw PC, SAVE_PC
+  |  mr CARG1, L
+  |   stw BASE, L->base
+  |  sub RA, RA, BASE
+  |   stw TMP0, L->top
+  |  bl extern lj_dispatch_call		// (lua_State *L, const BCIns *pc)
+  |  // Returns ASMFunction.
+  |  lwz BASE, L->base
+  |   lwz TMP0, L->top
+  |   stw ZERO, SAVE_PC			// Invalidate for subsequent line hook.
+  |  sub NARGS8:RC, TMP0, BASE
+  |  add RA, BASE, RA
+  |  lwz LFUNC:RB, FRAME_FUNC(BASE)
+  |  mtctr CRET1
+  |  bctr
   |
   |//-----------------------------------------------------------------------
   |//-- Trace exit handler -------------------------------------------------