issue #196 small cleanups

lua54-gc
Dibyendu Majumdar 4 years ago
parent 73cba9e376
commit 660591d2b5

@ -125,7 +125,6 @@ static GCObject **getgclist (GCObject *o) {
case LUA_TCCL: return &gco2ccl(o)->gclist;
case LUA_TTHREAD: return &gco2th(o)->gclist;
case LUA_TPROTO: return &gco2p(o)->gclist;
default: lua_assert(0); return 0;
}
}
@ -279,11 +278,11 @@ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
** must be marked.
*/
void luaC_upvalbarrier_(lua_State* L, GCObject* o) {
global_State* g = G(L);
if (keepinvariant(g) && !isold(o)) {
markobject(g, o);
setage(o, G_OLD0);
}
global_State* g = G(L);
if (keepinvariant(g) && !isold(o)) {
markobject(g, o);
setage(o, G_OLD0);
}
}
/*
@ -440,7 +439,6 @@ static int remarkupvals (global_State *g) {
thread->twups = thread; /* mark that it is out of list */
for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) {
work++;
if (uv->u.open.touched) {
markvalue(g, uv->v); /* remark upvalue's value */
uv->u.open.touched = 0;

@ -53,9 +53,8 @@ static int runC (lua_State *L, lua_State *L1, const char *pc);
static void setnameval (lua_State *L, const char *name, int val) {
lua_pushstring(L, name);
lua_pushinteger(L, val);
lua_settable(L, -3);
lua_setfield(L, -2, name);
}
@ -270,6 +269,15 @@ static void checktable (global_State *g, Table *h) {
}
static void checkudata (global_State *g, Udata *u) {
GCObject *hgc = obj2gco(u);
TValue uservalue;
Table *mt = u->metatable;
checkobjref(g, hgc, mt);
getuservalue(g->mainthread, u, &uservalue);
checkvalref(g, hgc, &uservalue);
}
/*
** All marks are conditional because a GC may happen while the
** prototype is still being created
@ -354,11 +362,7 @@ static void checkstack (global_State *g, lua_State *L1) {
static void checkrefs (global_State *g, GCObject *o) {
switch (o->tt) {
case LUA_TUSERDATA: {
TValue uservalue;
Table *mt = gco2u(o)->metatable;
checkobjref(g, o, mt);
getuservalue(g->mainthread, gco2u(o), &uservalue);
checkvalref(g, o, &uservalue);
checkudata(g, gco2u(o));
break;
}
case LUA_TTABLE: {
@ -659,7 +663,7 @@ static int mem_query (lua_State *L) {
return 1;
}
}
return luaL_error(L, "unkown type '%s'", t);
return luaL_error(L, "unknown type '%s'", t);
}
}
@ -1087,8 +1091,8 @@ static const char *const delimits = " \t\n,;";
static void skip (const char **pc) {
for (;;) {
if (**pc != '\0' && strchr(delimits, **pc)) (*pc)++;
else if (**pc == '#') {
while (**pc != '\n' && **pc != '\0') (*pc)++;
else if (**pc == '#') { /* comment? */
while (**pc != '\n' && **pc != '\0') (*pc)++; /* until end-of-line */
}
else break;
}

Loading…
Cancel
Save