summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-06 10:08:56 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-06 10:08:56 -0300
commit2331e1beec01babf78ca09fea8701b5bb3c78d4c (patch)
treed6d5a05daf5338b383e7c5681503272318a62958
parente4287da3a6b0b167da465fd449e5191b9ac9ef46 (diff)
downloadlua-2331e1beec01babf78ca09fea8701b5bb3c78d4c.tar.gz
lua-2331e1beec01babf78ca09fea8701b5bb3c78d4c.tar.bz2
lua-2331e1beec01babf78ca09fea8701b5bb3c78d4c.zip
small changes in 'luaC_upvalbarrier'
-rw-r--r--lapi.c10
-rw-r--r--lfunc.c9
-rw-r--r--lgc.c8
-rw-r--r--lgc.h8
-rw-r--r--lvm.c4
5 files changed, 19 insertions, 20 deletions
diff --git a/lapi.c b/lapi.c
index 494fce75..25ed81fd 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp roberto $ 2** $Id: lapi.c,v 2.260 2017/02/23 21:07:34 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1004,7 +1004,7 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
1004 const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); 1004 const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
1005 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ 1005 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
1006 setobj(L, f->upvals[0]->v, gt); 1006 setobj(L, f->upvals[0]->v, gt);
1007 luaC_upvalbarrier(L, f->upvals[0]); 1007 luaC_upvalbarrier(L, f->upvals[0], gt);
1008 } 1008 }
1009 } 1009 }
1010 lua_unlock(L); 1010 lua_unlock(L);
@@ -1253,8 +1253,8 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
1253 if (name) { 1253 if (name) {
1254 L->top--; 1254 L->top--;
1255 setobj(L, val, L->top); 1255 setobj(L, val, L->top);
1256 if (owner) { luaC_barrier(L, owner, L->top); } 1256 if (owner) { luaC_barrier(L, owner, val); }
1257 else if (uv) { luaC_upvalbarrier(L, uv); } 1257 else if (uv) { luaC_upvalbarrier(L, uv, val); }
1258 } 1258 }
1259 lua_unlock(L); 1259 lua_unlock(L);
1260 return name; 1260 return name;
@@ -1300,7 +1300,7 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
1300 *up1 = *up2; 1300 *up1 = *up2;
1301 (*up1)->refcount++; 1301 (*up1)->refcount++;
1302 if (upisopen(*up1)) (*up1)->u.open.touched = 1; 1302 if (upisopen(*up1)) (*up1)->u.open.touched = 1;
1303 luaC_upvalbarrier(L, *up1); 1303 luaC_upvalbarrier(L, *up1, (*up1)->v);
1304} 1304}
1305 1305
1306 1306
diff --git a/lfunc.c b/lfunc.c
index 4c10230e..0f839e7c 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 2.44 2014/10/25 11:50:46 roberto Exp roberto $ 2** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -88,9 +88,10 @@ void luaF_close (lua_State *L, StkId level) {
88 if (uv->refcount == 0) /* no references? */ 88 if (uv->refcount == 0) /* no references? */
89 luaM_free(L, uv); /* free upvalue */ 89 luaM_free(L, uv); /* free upvalue */
90 else { 90 else {
91 setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ 91 TValue *slot = &uv->u.value; /* new position for value */
92 uv->v = &uv->u.value; /* now current value lives here */ 92 setobj(L, slot, uv->v); /* move value to upvalue slot */
93 luaC_upvalbarrier(L, uv); 93 uv->v = slot; /* now current value lives here */
94 luaC_upvalbarrier(L, uv, slot);
94 } 95 }
95 } 96 }
96} 97}
diff --git a/lgc.c b/lgc.c
index 8d185cd7..73114300 100644
--- a/lgc.c
+++ b/lgc.c
@@ -186,13 +186,11 @@ void luaC_barrierback_ (lua_State *L, Table *t) {
186** closures pointing to it. So, we assume that the object being assigned 186** closures pointing to it. So, we assume that the object being assigned
187** must be marked. 187** must be marked.
188*/ 188*/
189void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) { 189void luaC_upvalbarrier_ (lua_State *L, GCObject *o) {
190 global_State *g = G(L); 190 global_State *g = G(L);
191 GCObject *o = gcvalue(uv->v); 191 if (keepinvariant(g) && !isold(o)) {
192 if (keepinvariant(g)) {
193 markobject(g, o); 192 markobject(g, o);
194 if (!isold(o)) 193 setage(o, G_OLD0);
195 setage(o, G_OLD0);
196 } 194 }
197} 195}
198 196
diff --git a/lgc.h b/lgc.h
index 158c0e38..c5dfcf2e 100644
--- a/lgc.h
+++ b/lgc.h
@@ -153,9 +153,9 @@
153 (isblack(p) && iswhite(o)) ? \ 153 (isblack(p) && iswhite(o)) ? \
154 luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) 154 luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
155 155
156#define luaC_upvalbarrier(L,uv) ( \ 156#define luaC_upvalbarrier(L,uv,x) ( \
157 (iscollectable((uv)->v) && !upisopen(uv)) ? \ 157 (iscollectable(x) && !upisopen(uv)) ? \
158 luaC_upvalbarrier_(L,uv) : cast_void(0)) 158 luaC_upvalbarrier_(L,gcvalue(x)) : cast_void(0))
159 159
160LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); 160LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
161LUAI_FUNC void luaC_freeallobjects (lua_State *L); 161LUAI_FUNC void luaC_freeallobjects (lua_State *L);
@@ -165,7 +165,7 @@ LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
165LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); 165LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz);
166LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); 166LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v);
167LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); 167LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o);
168LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); 168LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, GCObject *o);
169LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); 169LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt);
170LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv); 170LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
171LUAI_FUNC void luaC_changemode (lua_State *L, int newmode); 171LUAI_FUNC void luaC_changemode (lua_State *L, int newmode);
diff --git a/lvm.c b/lvm.c
index 3709d77a..81b2a481 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.267 2016/01/05 16:07:21 roberto Exp roberto $ 2** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -855,7 +855,7 @@ void luaV_execute (lua_State *L) {
855 vmcase(OP_SETUPVAL) { 855 vmcase(OP_SETUPVAL) {
856 UpVal *uv = cl->upvals[GETARG_B(i)]; 856 UpVal *uv = cl->upvals[GETARG_B(i)];
857 setobj(L, uv->v, ra); 857 setobj(L, uv->v, ra);
858 luaC_upvalbarrier(L, uv); 858 luaC_upvalbarrier(L, uv, ra);
859 vmbreak; 859 vmbreak;
860 } 860 }
861 vmcase(OP_SETTABLE) { 861 vmcase(OP_SETTABLE) {