aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-08-19 11:18:43 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-08-19 11:18:43 -0300
commit9eff921f8fe689794308cdb3fa7bb214604f75d3 (patch)
tree1aeb916a4d2f6599cd1631c7be232379bbff16c1
parent8e6b7ef9ab226b9184d300ad1b14c3812a6e86d8 (diff)
downloadlua-9eff921f8fe689794308cdb3fa7bb214604f75d3.tar.gz
lua-9eff921f8fe689794308cdb3fa7bb214604f75d3.tar.bz2
lua-9eff921f8fe689794308cdb3fa7bb214604f75d3.zip
"barrier" for link prototype->cache changed to be consistent with
GC behavior (link is cleared to preserve invariant)
-rw-r--r--lgc.c24
-rw-r--r--lgc.h5
-rw-r--r--lvm.c12
3 files changed, 8 insertions, 33 deletions
diff --git a/lgc.c b/lgc.c
index e4d6b6c1..b7d564c4 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.145 2013/08/13 17:36:44 roberto Exp roberto $ 2** $Id: lgc.c,v 2.146 2013/08/16 18:55:49 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -172,28 +172,6 @@ void luaC_barrierback_ (lua_State *L, GCObject *o) {
172 172
173 173
174/* 174/*
175** barrier for prototypes. When creating first closure (cache is
176** NULL), use a forward barrier; this may be the only closure of the
177** prototype (if it is a "regular" function, with a single instance)
178** and the prototype may be big, so it is better to avoid traversing
179** it again. Otherwise, use a backward barrier, to avoid marking all
180** possible instances.
181*/
182LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) {
183 global_State *g = G(L);
184 lua_assert(isblack(obj2gco(p)));
185 if (p->cache == NULL) { /* first time? */
186 luaC_objbarrier(L, p, c);
187 }
188 else { /* use a backward barrier */
189 black2gray(obj2gco(p)); /* make prototype gray (again) */
190 p->gclist = g->grayagain;
191 g->grayagain = obj2gco(p);
192 }
193}
194
195
196/*
197** check color (and invariants) for an upvalue that is being closed, 175** check color (and invariants) for an upvalue that is being closed,
198** i.e., moved into the 'allgc' list 176** i.e., moved into the 'allgc' list
199*/ 177*/
diff --git a/lgc.h b/lgc.h
index 846d40d8..135c7f49 100644
--- a/lgc.h
+++ b/lgc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.h,v 2.60 2013/08/13 17:36:44 roberto Exp roberto $ 2** $Id: lgc.h,v 2.61 2013/08/16 18:55:49 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -128,9 +128,6 @@
128 { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ 128 { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \
129 luaC_barrierback_(L,p); } 129 luaC_barrierback_(L,p); }
130 130
131#define luaC_barrierproto(L,p,c) \
132 { if (nolocal(obj2gco(c)), isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); }
133
134LUAI_FUNC void luaC_freeallobjects (lua_State *L); 131LUAI_FUNC void luaC_freeallobjects (lua_State *L);
135LUAI_FUNC void luaC_step (lua_State *L); 132LUAI_FUNC void luaC_step (lua_State *L);
136LUAI_FUNC void luaC_forcestep (lua_State *L); 133LUAI_FUNC void luaC_forcestep (lua_State *L);
diff --git a/lvm.c b/lvm.c
index 7f86a16c..d29c0118 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.176 2013/07/10 17:15:12 roberto Exp roberto $ 2** $Id: lvm.c,v 2.177 2013/08/16 18:55:49 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*/
@@ -399,9 +399,9 @@ static Closure *getcached (Proto *p, UpVal **encup, StkId base) {
399 399
400/* 400/*
401** create a new Lua closure, push it in the stack, and initialize 401** create a new Lua closure, push it in the stack, and initialize
402** its upvalues. Note that the call to 'luaC_barrierproto' must come 402** its upvalues. Note that the closure is not cached if prototype is
403** before the assignment to 'p->cache', as the function needs the 403** already black (which means that 'cache' was already cleared by the
404** original value of that field. 404** GC).
405*/ 405*/
406static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, 406static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
407 StkId ra) { 407 StkId ra) {
@@ -418,8 +418,8 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
418 ncl->l.upvals[i] = encup[uv[i].idx]; 418 ncl->l.upvals[i] = encup[uv[i].idx];
419 /* new closure is white and local, so we do not need a barrier here */ 419 /* new closure is white and local, so we do not need a barrier here */
420 } 420 }
421 luaC_barrierproto(L, p, ncl); 421 if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */
422 p->cache = ncl; /* save it on cache for reuse */ 422 p->cache = ncl; /* save it on cache for reuse */
423} 423}
424 424
425 425