From cb1dd159e3b25e23cb8aa2ba9b6da76bb17398ec Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 24 Oct 2011 16:13:12 +0200 Subject: PPC: Add support for per-trace exit stubs. --- src/lib_jit.c | 14 +++++++++++++- src/lj_target.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib_jit.c b/src/lib_jit.c index bfafa724..d4277add 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -377,15 +377,27 @@ LJLIB_CF(jit_util_tracemc) return 0; } -/* local addr = jit.util.traceexitstub(idx) */ +/* local addr = jit.util.traceexitstub([tr,] exitno) */ LJLIB_CF(jit_util_traceexitstub) { +#ifdef EXITSTUBS_PER_GROUP ExitNo exitno = (ExitNo)lj_lib_checkint(L, 1); jit_State *J = L2J(L); if (exitno < EXITSTUBS_PER_GROUP*LJ_MAX_EXITSTUBGR) { setintptrV(L->top-1, (intptr_t)(void *)exitstub_addr(J, exitno)); return 1; } +#else + if (L->top > L->base+1) { /* Don't throw for one-argument variant. */ + GCtrace *T = jit_checktrace(L); + ExitNo exitno = (ExitNo)lj_lib_checkint(L, 2); + ExitNo maxexit = T->root ? T->nsnap+1 : T->nsnap; + if (T && T->mcode != NULL && exitno < maxexit) { + setintptrV(L->top-1, (intptr_t)(void *)exitstub_trace_addr(T, exitno)); + return 1; + } + } +#endif return 0; } diff --git a/src/lj_target.h b/src/lj_target.h index 410ad0a0..33feb17c 100644 --- a/src/lj_target.h +++ b/src/lj_target.h @@ -131,6 +131,7 @@ typedef uint32_t RegCost; #error "Missing include for target CPU" #endif +#ifdef EXITSTUBS_PER_GROUP /* Return the address of an exit stub. */ static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) { @@ -138,5 +139,6 @@ static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) return (MCode *)((char *)J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] + EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP)); } +#endif #endif -- cgit v1.2.3-55-g6feb