mirror of https://github.com/rusefi/lua.git
small changes in 'luaC_upvalbarrier'
This commit is contained in:
parent
e4287da3a6
commit
2331e1beec
10
lapi.c
10
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
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** 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);
|
const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
|
||||||
/* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
|
/* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
|
||||||
setobj(L, f->upvals[0]->v, gt);
|
setobj(L, f->upvals[0]->v, gt);
|
||||||
luaC_upvalbarrier(L, f->upvals[0]);
|
luaC_upvalbarrier(L, f->upvals[0], gt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
|
@ -1253,8 +1253,8 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
|
||||||
if (name) {
|
if (name) {
|
||||||
L->top--;
|
L->top--;
|
||||||
setobj(L, val, L->top);
|
setobj(L, val, L->top);
|
||||||
if (owner) { luaC_barrier(L, owner, L->top); }
|
if (owner) { luaC_barrier(L, owner, val); }
|
||||||
else if (uv) { luaC_upvalbarrier(L, uv); }
|
else if (uv) { luaC_upvalbarrier(L, uv, val); }
|
||||||
}
|
}
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
return name;
|
return name;
|
||||||
|
@ -1300,7 +1300,7 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
|
||||||
*up1 = *up2;
|
*up1 = *up2;
|
||||||
(*up1)->refcount++;
|
(*up1)->refcount++;
|
||||||
if (upisopen(*up1)) (*up1)->u.open.touched = 1;
|
if (upisopen(*up1)) (*up1)->u.open.touched = 1;
|
||||||
luaC_upvalbarrier(L, *up1);
|
luaC_upvalbarrier(L, *up1, (*up1)->v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
9
lfunc.c
9
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
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -88,9 +88,10 @@ void luaF_close (lua_State *L, StkId level) {
|
||||||
if (uv->refcount == 0) /* no references? */
|
if (uv->refcount == 0) /* no references? */
|
||||||
luaM_free(L, uv); /* free upvalue */
|
luaM_free(L, uv); /* free upvalue */
|
||||||
else {
|
else {
|
||||||
setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */
|
TValue *slot = &uv->u.value; /* new position for value */
|
||||||
uv->v = &uv->u.value; /* now current value lives here */
|
setobj(L, slot, uv->v); /* move value to upvalue slot */
|
||||||
luaC_upvalbarrier(L, uv);
|
uv->v = slot; /* now current value lives here */
|
||||||
|
luaC_upvalbarrier(L, uv, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
lgc.c
8
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
|
** closures pointing to it. So, we assume that the object being assigned
|
||||||
** must be marked.
|
** must be marked.
|
||||||
*/
|
*/
|
||||||
void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) {
|
void luaC_upvalbarrier_ (lua_State *L, GCObject *o) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
GCObject *o = gcvalue(uv->v);
|
if (keepinvariant(g) && !isold(o)) {
|
||||||
if (keepinvariant(g)) {
|
|
||||||
markobject(g, o);
|
markobject(g, o);
|
||||||
if (!isold(o))
|
setage(o, G_OLD0);
|
||||||
setage(o, G_OLD0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
lgc.h
8
lgc.h
|
@ -153,9 +153,9 @@
|
||||||
(isblack(p) && iswhite(o)) ? \
|
(isblack(p) && iswhite(o)) ? \
|
||||||
luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
|
luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
|
||||||
|
|
||||||
#define luaC_upvalbarrier(L,uv) ( \
|
#define luaC_upvalbarrier(L,uv,x) ( \
|
||||||
(iscollectable((uv)->v) && !upisopen(uv)) ? \
|
(iscollectable(x) && !upisopen(uv)) ? \
|
||||||
luaC_upvalbarrier_(L,uv) : cast_void(0))
|
luaC_upvalbarrier_(L,gcvalue(x)) : cast_void(0))
|
||||||
|
|
||||||
LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
|
LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
|
||||||
LUAI_FUNC void luaC_freeallobjects (lua_State *L);
|
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 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_barrier_ (lua_State *L, GCObject *o, GCObject *v);
|
||||||
LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o);
|
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_checkfinalizer (lua_State *L, GCObject *o, Table *mt);
|
||||||
LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
|
LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv);
|
||||||
LUAI_FUNC void luaC_changemode (lua_State *L, int newmode);
|
LUAI_FUNC void luaC_changemode (lua_State *L, int newmode);
|
||||||
|
|
4
lvm.c
4
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
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -855,7 +855,7 @@ void luaV_execute (lua_State *L) {
|
||||||
vmcase(OP_SETUPVAL) {
|
vmcase(OP_SETUPVAL) {
|
||||||
UpVal *uv = cl->upvals[GETARG_B(i)];
|
UpVal *uv = cl->upvals[GETARG_B(i)];
|
||||||
setobj(L, uv->v, ra);
|
setobj(L, uv->v, ra);
|
||||||
luaC_upvalbarrier(L, uv);
|
luaC_upvalbarrier(L, uv, ra);
|
||||||
vmbreak;
|
vmbreak;
|
||||||
}
|
}
|
||||||
vmcase(OP_SETTABLE) {
|
vmcase(OP_SETTABLE) {
|
||||||
|
|
Loading…
Reference in New Issue