mirror of
https://github.com/lua/lua
synced 2024-11-22 21:01:26 +03:00
hook count is quadratic
This commit is contained in:
parent
39b2d58c39
commit
44752fc9ce
4
ldblib.c
4
ldblib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldblib.c,v 1.61 2002/06/25 19:16:44 roberto Exp roberto $
|
||||
** $Id: ldblib.c,v 1.62 2002/07/08 18:21:33 roberto Exp roberto $
|
||||
** Interface from Lua to its debug API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -132,7 +132,7 @@ static int makemask (const char *smask, int count) {
|
||||
if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
||||
if (strchr(smask, 'r')) mask |= LUA_MASKRET;
|
||||
if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
|
||||
return mask | lua_maskcount(count);
|
||||
return mask | LUA_MASKCOUNT(count);
|
||||
}
|
||||
|
||||
|
||||
|
4
ldebug.h
4
ldebug.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldebug.h,v 1.23 2002/06/24 15:07:21 roberto Exp roberto $
|
||||
** $Id: ldebug.h,v 1.24 2002/07/08 18:21:33 roberto Exp roberto $
|
||||
** Auxiliary functions from Debug Interface module
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
|
||||
|
||||
#define resethookcount(L) \
|
||||
(L->hookcount = (1 << lua_getmaskcount(L->hookmask)) >> 1)
|
||||
(L->hookcount = lua_getmaskcount(L->hookmask), L->hookcount *= L->hookcount)
|
||||
|
||||
#define setallowhook(L,cond) ((L->hookmask) = ((L->hookmask) & ~1) | (cond))
|
||||
#define allowhook(L) ((L->hookmask) & 1)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llimits.h,v 1.43 2002/04/23 14:59:35 roberto Exp roberto $
|
||||
** $Id: llimits.h,v 1.44 2002/06/13 13:45:31 roberto Exp roberto $
|
||||
** Limits, basic types, and some other `installation-dependent' definitions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -52,6 +52,10 @@ typedef unsigned long lu_mem;
|
||||
/* an integer big enough to count the number of strings in use */
|
||||
typedef long ls_nstr;
|
||||
|
||||
/* an integer big enough to count the number of steps when calling a
|
||||
** `count' hook */
|
||||
typedef long ls_count;
|
||||
|
||||
|
||||
/* chars used as small naturals (so that `char' is reserved for characteres) */
|
||||
typedef unsigned char lu_byte;
|
||||
|
4
lstate.h
4
lstate.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstate.h,v 1.86 2002/07/02 16:43:28 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 1.87 2002/07/08 18:21:33 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -131,7 +131,7 @@ struct lua_State {
|
||||
CallInfo *base_ci; /* array of CallInfo's */
|
||||
global_State *l_G;
|
||||
int hookmask;
|
||||
int hookcount;
|
||||
ls_count hookcount;
|
||||
lua_Hook hook;
|
||||
TObject globs[NUMGLOBS]; /* registry, table of globals, etc. */
|
||||
struct lua_longjmp *errorJmp; /* current error recover point */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: luadebug.h,v 1.28 2002/06/18 17:10:43 roberto Exp roberto $
|
||||
** $Id: luadebug.h,v 1.29 2002/07/08 18:21:33 roberto Exp roberto $
|
||||
** Debugging API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -19,9 +19,8 @@ typedef enum lua_Hookevent {
|
||||
#define LUA_MASKCALL (2 << LUA_HOOKCALL)
|
||||
#define LUA_MASKRET (2 << LUA_HOOKRET)
|
||||
#define LUA_MASKLINE (2 << LUA_HOOKLINE)
|
||||
#define lua_maskcount(count) ((count) << (LUA_HOOKCOUNT+1))
|
||||
#define LUA_MASKCOUNT(count) ((count) << (LUA_HOOKCOUNT+1))
|
||||
#define lua_getmaskcount(mask) ((mask) >> (LUA_HOOKCOUNT+1))
|
||||
#define LUA_MASKCOUNT (lua_maskcount(1))
|
||||
|
||||
typedef struct lua_Debug lua_Debug; /* activation record */
|
||||
|
||||
|
4
lvm.c
4
lvm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lvm.c,v 1.244 2002/07/05 18:27:39 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 1.245 2002/07/08 18:21:33 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -70,7 +70,7 @@ int luaV_tostring (lua_State *L, TObject *obj) {
|
||||
|
||||
static void traceexec (lua_State *L) {
|
||||
int mask = L->hookmask;
|
||||
if (mask >= LUA_MASKCOUNT) { /* instruction hook set? */
|
||||
if (mask > LUA_MASKLINE) { /* instruction hook set? */
|
||||
if (L->hookcount == 0) {
|
||||
luaD_callhook(L, LUA_HOOKCOUNT, -1);
|
||||
resethookcount(L);
|
||||
|
Loading…
Reference in New Issue
Block a user