small changes in 'luaC_upvalbarrier'

This commit is contained in:
Roberto Ierusalimschy 2017-04-06 10:08:56 -03:00
parent e4287da3a6
commit 2331e1beec
5 changed files with 19 additions and 20 deletions

10
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp roberto $
** $Id: lapi.c,v 2.260 2017/02/23 21:07:34 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -1004,7 +1004,7 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
/* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
setobj(L, f->upvals[0]->v, gt);
luaC_upvalbarrier(L, f->upvals[0]);
luaC_upvalbarrier(L, f->upvals[0], gt);
}
}
lua_unlock(L);
@ -1253,8 +1253,8 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
if (name) {
L->top--;
setobj(L, val, L->top);
if (owner) { luaC_barrier(L, owner, L->top); }
else if (uv) { luaC_upvalbarrier(L, uv); }
if (owner) { luaC_barrier(L, owner, val); }
else if (uv) { luaC_upvalbarrier(L, uv, val); }
}
lua_unlock(L);
return name;
@ -1300,7 +1300,7 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
*up1 = *up2;
(*up1)->refcount++;
if (upisopen(*up1)) (*up1)->u.open.touched = 1;
luaC_upvalbarrier(L, *up1);
luaC_upvalbarrier(L, *up1, (*up1)->v);
}

View File

@ -1,5 +1,5 @@
/*
** $Id: lfunc.c,v 2.44 2014/10/25 11:50:46 roberto Exp roberto $
** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@ -88,9 +88,10 @@ void luaF_close (lua_State *L, StkId level) {
if (uv->refcount == 0) /* no references? */
luaM_free(L, uv); /* free upvalue */
else {
setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */
uv->v = &uv->u.value; /* now current value lives here */
luaC_upvalbarrier(L, uv);
TValue *slot = &uv->u.value; /* new position for value */
setobj(L, slot, uv->v); /* move value to upvalue slot */
uv->v = slot; /* now current value lives here */
luaC_upvalbarrier(L, uv, slot);
}
}
}

8
lgc.c
View File

@ -186,13 +186,11 @@ void luaC_barrierback_ (lua_State *L, Table *t) {
** closures pointing to it. So, we assume that the object being assigned
** must be marked.
*/
void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) {
void luaC_upvalbarrier_ (lua_State *L, GCObject *o) {
global_State *g = G(L);
GCObject *o = gcvalue(uv->v);
if (keepinvariant(g)) {
if (keepinvariant(g) && !isold(o)) {
markobject(g, o);
if (!isold(o))
setage(o, G_OLD0);
setage(o, G_OLD0);
}
}

8
lgc.h
View File

@ -153,9 +153,9 @@
(isblack(p) && iswhite(o)) ? \
luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
#define luaC_upvalbarrier(L,uv) ( \
(iscollectable((uv)->v) && !upisopen(uv)) ? \
luaC_upvalbarrier_(L,uv) : cast_void(0))
#define luaC_upvalbarrier(L,uv,x) ( \
(iscollectable(x) && !upisopen(uv)) ? \
luaC_upvalbarrier_(L,gcvalue(x)) : cast_void(0))
LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
LUAI_FUNC void luaC_freeallobjects (lua_State *L);
@ -165,7 +165,7 @@ LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz);
LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v);
LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o);
LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv);
LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, GCObject *o);
LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt);
LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
LUAI_FUNC void luaC_changemode (lua_State *L, int newmode);

4
lvm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.267 2016/01/05 16:07:21 roberto Exp roberto $
** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -855,7 +855,7 @@ void luaV_execute (lua_State *L) {
vmcase(OP_SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, ra);
luaC_upvalbarrier(L, uv);
luaC_upvalbarrier(L, uv, ra);
vmbreak;
}
vmcase(OP_SETTABLE) {