From 3452bfcf8cb2dc67819485c7b011e5c6a59310f8 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 15 Feb 2010 17:36:29 +0100 Subject: Add generic function handling for debug modules. Don't call record vmevent for non-Lua functions. --- src/lib_jit.c | 7 +++++-- src/lj_trace.c | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/lib_jit.c b/src/lib_jit.c index a5829dc3..0ee5ad0d 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -197,9 +197,12 @@ LJLIB_CF(jit_util_funcinfo) } else { GCfunc *fn = funcV(L->base); GCtab *t; - lua_createtable(L, 0, 2); /* Increment hash size if fields are added. */ + lua_createtable(L, 0, 4); /* Increment hash size if fields are added. */ t = tabV(L->top-1); - setintfield(L, t, "ffid", fn->c.ffid); + if (!iscfunc(fn)) + setintfield(L, t, "ffid", fn->c.ffid); + setnumV(lj_tab_setstr(L, t, lj_str_newlit(L, "addr")), + cast_num((intptr_t)fn->c.f)); setintfield(L, t, "upvalues", fn->c.nupvalues); } return 1; diff --git a/src/lj_trace.c b/src/lj_trace.c index b5946346..7b366d54 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -475,17 +475,18 @@ static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) case LJ_TRACE_RECORD: setvmstate(J2G(J), RECORD); - lj_vmevent_send(L, RECORD, - setintV(L->top++, J->curtrace); - setfuncV(L, L->top++, J->fn); - setintV(L->top++, proto_bcpos(J->pt, J->pc)); - setintV(L->top++, J->framedepth); - if (bcmode_mm(bc_op(*J->pc)) == MM_call) { - cTValue *o = &L->base[bc_a(*J->pc)]; - if (bc_op(*J->pc) == BC_ITERC) o -= 3; - copyTV(L, L->top++, o); - } - ); + if (J->pt) + lj_vmevent_send(L, RECORD, + setintV(L->top++, J->curtrace); + setfuncV(L, L->top++, J->fn); + setintV(L->top++, proto_bcpos(J->pt, J->pc)); + setintV(L->top++, J->framedepth); + if (bcmode_mm(bc_op(*J->pc)) == MM_call) { + cTValue *o = &L->base[bc_a(*J->pc)]; + if (bc_op(*J->pc) == BC_ITERC) o -= 3; + copyTV(L, L->top++, o); + } + ); lj_record_ins(J); break; @@ -537,7 +538,7 @@ void lj_trace_ins(jit_State *J, const BCIns *pc) /* Note: J->L must already be set. pc is the true bytecode PC here. */ J->pc = pc; J->fn = curr_func(J->L); - J->pt = funcproto(J->fn); + J->pt = isluafunc(J->fn) ? funcproto(J->fn) : NULL; while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) J->state = LJ_TRACE_ERR; } -- cgit v1.2.3-55-g6feb