'iswhite' and related macros now can work directly on any object

(no need to convert to 'GCObject')
This commit is contained in:
Roberto Ierusalimschy 2014-07-21 13:02:10 -03:00
parent 3c6d0aaa7d
commit 17ee57f8e0
3 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 2.140 2014/07/18 12:17:54 roberto Exp roberto $
** $Id: lparser.c,v 2.141 2014/07/18 13:36:14 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@ -164,7 +164,7 @@ static int registerlocalvar (LexState *ls, TString *varname) {
LocVar, SHRT_MAX, "local variables");
while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
f->locvars[fs->nlocvars].varname = varname;
luaC_objbarrier(ls->L, f, obj2gco(varname));
luaC_objbarrier(ls->L, f, varname);
return fs->nlocvars++;
}
@ -232,7 +232,7 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) {
f->upvalues[fs->nups].instack = (v->k == VLOCAL);
f->upvalues[fs->nups].idx = cast_byte(v->u.info);
f->upvalues[fs->nups].name = name;
luaC_objbarrier(fs->ls->L, f, obj2gco(name));
luaC_objbarrier(fs->ls->L, f, name);
return fs->nups++;
}
@ -1630,7 +1630,7 @@ LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
incr_top(L);
funcstate.f = cl->p = luaF_newproto(L);
funcstate.f->source = luaS_new(L, name); /* create and anchor TString */
luaC_objbarrier(L, funcstate.f, obj2gco(funcstate.f->source));
luaC_objbarrier(L, funcstate.f, funcstate.f->source);
lexstate.buff = buff;
lexstate.dyd = dyd;
dyd->actvar.n = dyd->gt.n = dyd->label.n = 0;

View File

@ -1,5 +1,5 @@
/*
** $Id: lstring.c,v 2.42 2014/07/18 13:36:14 roberto Exp roberto $
** $Id: lstring.c,v 2.43 2014/07/18 14:46:47 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@ -126,8 +126,8 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
if (l == ts->len &&
(memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
/* found! */
if (isdead(g, obj2gco(ts))) /* dead (but not collected yet)? */
changewhite(obj2gco(ts)); /* resurrect it */
if (isdead(g, ts)) /* dead (but not collected yet)? */
changewhite(ts); /* resurrect it */
return ts;
}
}

4
lvm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.218 2014/07/17 12:30:53 roberto Exp roberto $
** $Id: lvm.c,v 2.219 2014/07/18 13:36:14 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -549,7 +549,7 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
ncl->upvals[i]->refcount++;
/* new closure is white, so we do not need a barrier here */
}
if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */
if (!isblack(p)) /* cache will not break GC invariant? */
p->cache = ncl; /* save it on cache for reuse */
}