commit 2331e1beec01babf78ca09fea8701b5bb3c78d4c
parent e4287da3a6b0b167da465fd449e5191b9ac9ef46
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 6 Apr 2017 10:08:29 -0300
small changes in 'luaC_upvalbarrier'
Diffstat:
5 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -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);
}
diff --git a/lfunc.c b/lfunc.c
@@ -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);
}
}
}
diff --git a/lgc.c b/lgc.c
@@ -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);
}
}
diff --git a/lgc.h b/lgc.h
@@ -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);
diff --git a/lvm.c b/lvm.c
@@ -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) {