summaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-02-16 16:09:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-02-16 16:09:52 -0300
commit2aaf7394ad17180565423ce360d5faffb60f4e4f (patch)
tree32caa2d7b0079b4bc9b0ac392d216c5094a6433d /lfunc.c
parentb3ce4505296253e6da1fa780c23e7ed012efc88e (diff)
downloadlua-2aaf7394ad17180565423ce360d5faffb60f4e4f.tar.gz
lua-2aaf7394ad17180565423ce360d5faffb60f4e4f.tar.bz2
lua-2aaf7394ad17180565423ce360d5faffb60f4e4f.zip
more and better tools (assertions & inspectors) to check incremental GC
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lfunc.c b/lfunc.c
index af27bf0d..36bf3f32 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.74 2003/12/09 16:56:11 roberto Exp roberto $ 2** $Id: lfunc.c,v 2.1 2003/12/10 12:13:36 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*/
@@ -57,7 +57,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
57 } 57 }
58 uv = luaM_new(L, UpVal); /* not found: create a new one */ 58 uv = luaM_new(L, UpVal); /* not found: create a new one */
59 uv->tt = LUA_TUPVAL; 59 uv->tt = LUA_TUPVAL;
60 uv->marked = bitmask(FIXEDBIT); /* open upvalues cannot be collected */ 60 uv->marked = luaC_white(G(L));
61 uv->v = level; /* current value lives in the stack */ 61 uv->v = level; /* current value lives in the stack */
62 uv->next = *pp; /* chain it in the proper position */ 62 uv->next = *pp; /* chain it in the proper position */
63 *pp = obj2gco(uv); 63 *pp = obj2gco(uv);
@@ -68,11 +68,16 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
68void luaF_close (lua_State *L, StkId level) { 68void luaF_close (lua_State *L, StkId level) {
69 UpVal *uv; 69 UpVal *uv;
70 while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { 70 while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
71 lu_byte mark = uv->marked;
72 lua_assert(!isblack(obj2gco(uv)));
71 setobj(L, &uv->value, uv->v); 73 setobj(L, &uv->value, uv->v);
72 luaC_barrier(L, uv, uv->v); 74 luaC_barrier(L, uv, uv->v);
73 uv->v = &uv->value; /* now current value lives here */ 75 uv->v = &uv->value; /* now current value lives here */
74 L->openupval = uv->next; /* remove from `open' list */ 76 L->openupval = uv->next; /* remove from `open' list */
75 luaC_link(L, obj2gco(uv), LUA_TUPVAL); 77 luaC_link(L, obj2gco(uv), LUA_TUPVAL);
78 if (G(L)->gcstate == GCSpropagate)
79 uv->marked = mark; /* preserve previous mark */
80 lua_assert(!isdead(G(L), obj2gco(uv)));
76 } 81 }
77} 82}
78 83