commit a73930228aada18cb9300f53dbcc6fafcb75caf9
parent a76fa251998ea83679cfad24542cf4c1aa3d6131
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 11 Feb 2008 13:45:07 -0200
more options for 'kinds' of Garbage Collection
Diffstat:
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/lstate.c b/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 2.41 2007/10/29 16:51:20 roberto Exp roberto $
+** $Id: lstate.c,v 2.42 2007/10/31 15:41:19 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -160,7 +160,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
L->tt = LUA_TTHREAD;
g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
L->marked = luaC_white(g);
- g->emergencygc = 0;
+ g->gckind = KGC_NORMAL;
g->nCcalls = 0;
set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
preinit_state(L, g);
diff --git a/lstate.h b/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.29 2007/10/29 16:51:20 roberto Exp roberto $
+** $Id: lstate.h,v 2.30 2007/10/31 15:41:19 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -34,6 +34,11 @@ struct lua_longjmp; /* defined in ldo.c */
#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
+/* kinds of Garbage Collection */
+#define KGC_NORMAL 0
+#define KGC_FORCED 1 /* gc was forced by the program */
+#define KGC_EMERGENCY 2 /* gc was forced by an allocation failure */
+
typedef struct stringtable {
GCObject **hash;
@@ -72,7 +77,7 @@ typedef struct global_State {
unsigned short nCcalls; /* number of nested C calls */
lu_byte currentwhite;
lu_byte gcstate; /* state of garbage collector */
- lu_byte emergencygc; /* true when collect was trigged by alloc error */
+ lu_byte gckind; /* kind of GC running */
int sweepstrgc; /* position of sweep in `strt' */
GCObject *rootgc; /* list of all collectable objects */
GCObject **sweepgc; /* position of sweep in `rootgc' */