lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 9eff921f8fe689794308cdb3fa7bb214604f75d3
parent 8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 19 Aug 2013 11:18:18 -0300

"barrier" for link prototype->cache changed to be consistent with
GC behavior (link is cleared to preserve invariant)

Diffstat:
Mlgc.c | 24+-----------------------
Mlgc.h | 5+----
Mlvm.c | 12++++++------
3 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/lgc.c b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.145 2013/08/13 17:36:44 roberto Exp roberto $ +** $Id: lgc.c,v 2.146 2013/08/16 18:55:49 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -172,28 +172,6 @@ void luaC_barrierback_ (lua_State *L, GCObject *o) { /* -** barrier for prototypes. When creating first closure (cache is -** NULL), use a forward barrier; this may be the only closure of the -** prototype (if it is a "regular" function, with a single instance) -** and the prototype may be big, so it is better to avoid traversing -** it again. Otherwise, use a backward barrier, to avoid marking all -** possible instances. -*/ -LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) { - global_State *g = G(L); - lua_assert(isblack(obj2gco(p))); - if (p->cache == NULL) { /* first time? */ - luaC_objbarrier(L, p, c); - } - else { /* use a backward barrier */ - black2gray(obj2gco(p)); /* make prototype gray (again) */ - p->gclist = g->grayagain; - g->grayagain = obj2gco(p); - } -} - - -/* ** check color (and invariants) for an upvalue that is being closed, ** i.e., moved into the 'allgc' list */ diff --git a/lgc.h b/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.60 2013/08/13 17:36:44 roberto Exp roberto $ +** $Id: lgc.h,v 2.61 2013/08/16 18:55:49 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -128,9 +128,6 @@ { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ luaC_barrierback_(L,p); } -#define luaC_barrierproto(L,p,c) \ - { if (nolocal(obj2gco(c)), isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } - LUAI_FUNC void luaC_freeallobjects (lua_State *L); LUAI_FUNC void luaC_step (lua_State *L); LUAI_FUNC void luaC_forcestep (lua_State *L); diff --git a/lvm.c b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.176 2013/07/10 17:15:12 roberto Exp roberto $ +** $Id: lvm.c,v 2.177 2013/08/16 18:55:49 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -399,9 +399,9 @@ static Closure *getcached (Proto *p, UpVal **encup, StkId base) { /* ** create a new Lua closure, push it in the stack, and initialize -** its upvalues. Note that the call to 'luaC_barrierproto' must come -** before the assignment to 'p->cache', as the function needs the -** original value of that field. +** its upvalues. Note that the closure is not cached if prototype is +** already black (which means that 'cache' was already cleared by the +** GC). */ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra) { @@ -418,8 +418,8 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, ncl->l.upvals[i] = encup[uv[i].idx]; /* new closure is white and local, so we do not need a barrier here */ } - luaC_barrierproto(L, p, ncl); - p->cache = ncl; /* save it on cache for reuse */ + if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */ + p->cache = ncl; /* save it on cache for reuse */ }