'luaC_linkupval' embedded into call site

This commit is contained in:
Roberto Ierusalimschy 2010-04-29 14:34:35 -03:00
parent ee7478e884
commit 5a7a0c72d8

14
lfunc.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lfunc.c,v 2.20 2010/03/12 19:14:06 roberto Exp roberto $
** $Id: lfunc.c,v 2.21 2010/03/26 20:58:11 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@ -96,10 +96,16 @@ void luaF_close (lua_State *L, StkId level) {
if (isdead(g, o))
luaF_freeupval(L, uv); /* free upvalue */
else {
unlinkupval(uv);
setobj(L, &uv->u.value, uv->v);
unlinkupval(uv); /* remove upvalue from 'uvhead' list */
setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */
uv->v = &uv->u.value; /* now current value lives here */
luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */
g->allgc = o;
lua_assert(!isblack(o)); /* open upvalues are never black */
if (isgray(o)) { /* is it marked? */
gray2black(o); /* could not be black; now it can */
luaC_barrier(L, uv, uv->v);
}
}
}
}