diff options
-rw-r--r-- | lfunc.c | 10 | ||||
-rw-r--r-- | lgc.c | 16 | ||||
-rw-r--r-- | lgc.h | 4 | ||||
-rw-r--r-- | lstring.c | 6 | ||||
-rw-r--r-- | ltable.c | 4 | ||||
-rw-r--r-- | ltests.c | 4 |
6 files changed, 24 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.35 2013/08/26 12:41:10 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.36 2013/08/27 18:53:35 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 | */ |
@@ -21,16 +21,14 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | Closure *luaF_newCclosure (lua_State *L, int n) { | 23 | Closure *luaF_newCclosure (lua_State *L, int n) { |
24 | Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), | 24 | Closure *c = &luaC_newobj(L, LUA_TCCL, sizeCclosure(n), NULL, 0)->cl; |
25 | &G(L)->localgc, 0)->cl; | ||
26 | c->c.nupvalues = cast_byte(n); | 25 | c->c.nupvalues = cast_byte(n); |
27 | return c; | 26 | return c; |
28 | } | 27 | } |
29 | 28 | ||
30 | 29 | ||
31 | Closure *luaF_newLclosure (lua_State *L, int n) { | 30 | Closure *luaF_newLclosure (lua_State *L, int n) { |
32 | Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), | 31 | Closure *c = &luaC_newobj(L, LUA_TLCL, sizeLclosure(n), NULL, 0)->cl; |
33 | &G(L)->localgc, 0)->cl; | ||
34 | c->l.p = NULL; | 32 | c->l.p = NULL; |
35 | c->l.nupvalues = cast_byte(n); | 33 | c->l.nupvalues = cast_byte(n); |
36 | while (n--) c->l.upvals[n] = NULL; | 34 | while (n--) c->l.upvals[n] = NULL; |
@@ -87,7 +85,7 @@ void luaF_close (lua_State *L, StkId level) { | |||
87 | 85 | ||
88 | 86 | ||
89 | Proto *luaF_newproto (lua_State *L) { | 87 | Proto *luaF_newproto (lua_State *L) { |
90 | Proto *f = &luaC_newobj(L, LUA_TPROTO, sizeof(Proto), NULL, 0)->p; | 88 | Proto *f = &luaC_newobj(L, LUA_TPROTO, sizeof(Proto), &G(L)->allgc, 0)->p; |
91 | nolocal(obj2gco(f)); /* prototypes are never local */ | 89 | nolocal(obj2gco(f)); /* prototypes are never local */ |
92 | f->k = NULL; | 90 | f->k = NULL; |
93 | f->sizek = 0; | 91 | f->sizek = 0; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.152 2013/08/26 12:41:10 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.153 2013/08/27 18:53:35 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 | */ |
@@ -208,9 +208,11 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, | |||
208 | global_State *g = G(L); | 208 | global_State *g = G(L); |
209 | char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); | 209 | char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); |
210 | GCObject *o = obj2gco(raw + offset); | 210 | GCObject *o = obj2gco(raw + offset); |
211 | if (list == NULL) | ||
212 | list = &g->allgc; /* standard list for collectable objects */ | ||
213 | gch(o)->marked = luaC_white(g); | 211 | gch(o)->marked = luaC_white(g); |
212 | if (list == NULL) | ||
213 | list = &g->localgc; /* standard list for collectable objects */ | ||
214 | else | ||
215 | l_setbit(gch(o)->marked, LOCALMARK); /* mark object as not in 'localgc' */ | ||
214 | gch(o)->tt = tt; | 216 | gch(o)->tt = tt; |
215 | gch(o)->next = *list; | 217 | gch(o)->next = *list; |
216 | *list = o; | 218 | *list = o; |
@@ -894,7 +896,7 @@ static void localmarkthread (lua_State *l) { | |||
894 | return; /* stack not completely built yet */ | 896 | return; /* stack not completely built yet */ |
895 | for (; o < l->top; o++) { /* mark live elements in the stack */ | 897 | for (; o < l->top; o++) { /* mark live elements in the stack */ |
896 | if (iscollectable(o)) | 898 | if (iscollectable(o)) |
897 | l_setbit(gcvalue(o)->gch.marked, LOCALBLACK); | 899 | l_setbit(gcvalue(o)->gch.marked, LOCALMARK); |
898 | } | 900 | } |
899 | } | 901 | } |
900 | 902 | ||
@@ -918,10 +920,12 @@ static void localsweep (lua_State *L, global_State *g, GCObject **p) { | |||
918 | *p = curr->gch.next; /* remove 'curr' from list */ | 920 | *p = curr->gch.next; /* remove 'curr' from list */ |
919 | curr->gch.next = g->allgc; /* link 'curr' in 'allgc' list */ | 921 | curr->gch.next = g->allgc; /* link 'curr' in 'allgc' list */ |
920 | g->allgc = curr; | 922 | g->allgc = curr; |
923 | /* mark it as out of local list */ | ||
924 | l_setbit(curr->gch.marked, LOCALMARK); | ||
921 | } | 925 | } |
922 | else { /* still local */ | 926 | else { /* still local */ |
923 | if (testbit(curr->gch.marked, LOCALBLACK)) { /* locally alive? */ | 927 | if (testbit(curr->gch.marked, LOCALMARK)) { /* locally alive? */ |
924 | resetbit(curr->gch.marked, LOCALBLACK); | 928 | resetbit(curr->gch.marked, LOCALMARK); |
925 | p = &curr->gch.next; /* go to next element */ | 929 | p = &curr->gch.next; /* go to next element */ |
926 | } | 930 | } |
927 | else { /* object is dead */ | 931 | else { /* object is dead */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.66 2013/08/23 13:34:54 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.67 2013/08/27 18:53:35 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 | */ |
@@ -77,7 +77,7 @@ | |||
77 | #define BLACKBIT 2 /* object is black */ | 77 | #define BLACKBIT 2 /* object is black */ |
78 | #define FINALIZEDBIT 3 /* object has been marked for finalization */ | 78 | #define FINALIZEDBIT 3 /* object has been marked for finalization */ |
79 | #define LOCALBIT 4 /* object is not local */ | 79 | #define LOCALBIT 4 /* object is not local */ |
80 | #define LOCALBLACK 5 /* object is 'locally black' */ | 80 | #define LOCALMARK 5 /* object is 'locally marked' or out of local list */ |
81 | /* bit 7 is currently used by tests (luaL_checkmemory) */ | 81 | /* bit 7 is currently used by tests (luaL_checkmemory) */ |
82 | 82 | ||
83 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | 83 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.30 2013/08/22 15:21:48 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.31 2013/08/23 13:34:54 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -106,7 +106,7 @@ static TString *createstrobj (lua_State *L, const char *str, size_t l, | |||
106 | TString *ts; | 106 | TString *ts; |
107 | size_t totalsize; /* total size of TString object */ | 107 | size_t totalsize; /* total size of TString object */ |
108 | totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); | 108 | totalsize = sizeof(TString) + ((l + 1) * sizeof(char)); |
109 | ts = &luaC_newobj(L, tag, totalsize, &G(L)->localgc, 0)->ts; | 109 | ts = &luaC_newobj(L, tag, totalsize, NULL, 0)->ts; |
110 | ts->tsv.len = l; | 110 | ts->tsv.len = l; |
111 | ts->tsv.hash = h; | 111 | ts->tsv.hash = h; |
112 | ts->tsv.extra = 0; | 112 | ts->tsv.extra = 0; |
@@ -213,7 +213,7 @@ Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { | |||
213 | Udata *u; | 213 | Udata *u; |
214 | if (s > MAX_SIZE - sizeof(Udata)) | 214 | if (s > MAX_SIZE - sizeof(Udata)) |
215 | luaM_toobig(L); | 215 | luaM_toobig(L); |
216 | u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u; | 216 | u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, &G(L)->allgc, 0)->u; |
217 | u->uv.len = s; | 217 | u->uv.len = s; |
218 | u->uv.metatable = NULL; | 218 | u->uv.metatable = NULL; |
219 | u->uv.env = e; | 219 | u->uv.env = e; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.78 2013/06/20 15:02:49 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.79 2013/08/18 16:12:18 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -378,7 +378,7 @@ static void rehash (lua_State *L, Table *t, const TValue *ek) { | |||
378 | 378 | ||
379 | 379 | ||
380 | Table *luaH_new (lua_State *L) { | 380 | Table *luaH_new (lua_State *L) { |
381 | Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h; | 381 | Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), &G(L)->allgc, 0)->h; |
382 | t->metatable = NULL; | 382 | t->metatable = NULL; |
383 | t->flags = cast_byte(~0); | 383 | t->flags = cast_byte(~0); |
384 | t->array = NULL; | 384 | t->array = NULL; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.149 2013/08/26 12:41:10 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.150 2013/08/27 18:53:35 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -452,6 +452,7 @@ int lua_checkmemory (lua_State *L) { | |||
452 | else lua_assert(!isthread); /* ... and only threads */ | 452 | else lua_assert(!isthread); /* ... and only threads */ |
453 | checkobject(g, o, maybedead); | 453 | checkobject(g, o, maybedead); |
454 | lua_assert(!tofinalize(o)); | 454 | lua_assert(!tofinalize(o)); |
455 | lua_assert(testbit(o->gch.marked, LOCALMARK)); | ||
455 | } | 456 | } |
456 | /* check 'finobj' list */ | 457 | /* check 'finobj' list */ |
457 | checkgray(g, g->finobj); | 458 | checkgray(g, g->finobj); |
@@ -473,6 +474,7 @@ int lua_checkmemory (lua_State *L) { | |||
473 | checkgray(g, g->localgc); | 474 | checkgray(g, g->localgc); |
474 | for (o = g->localgc; o != NULL; o = gch(o)->next) { | 475 | for (o = g->localgc; o != NULL; o = gch(o)->next) { |
475 | checkobject(g, o, 1); | 476 | checkobject(g, o, 1); |
477 | lua_assert(!testbit(o->gch.marked, LOCALMARK)); | ||
476 | } | 478 | } |
477 | return 0; | 479 | return 0; |
478 | } | 480 | } |