diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-16 17:00:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-16 17:00:28 -0300 |
commit | ecc7769de2f3fb898235759cda9ae822a6168341 (patch) | |
tree | a03e317d323b32ab7282c3ff18419f6fbf77f578 | |
parent | da19c436cc361401563eeda2cca3d161a6ddeef7 (diff) | |
download | lua-ecc7769de2f3fb898235759cda9ae822a6168341.tar.gz lua-ecc7769de2f3fb898235759cda9ae822a6168341.tar.bz2 lua-ecc7769de2f3fb898235759cda9ae822a6168341.zip |
names...
-rw-r--r-- | lgc.c | 48 | ||||
-rw-r--r-- | lgc.h | 4 | ||||
-rw-r--r-- | lstate.c | 4 |
3 files changed, 28 insertions, 28 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.145 2002/08/06 17:06:56 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.146 2002/08/16 14:45:55 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 | */ |
@@ -58,7 +58,7 @@ static void reallymarkobject (GCState *st, TObject *o); | |||
58 | #define markobject(st,o) if (ismarkable(o)) reallymarkobject(st,o) | 58 | #define markobject(st,o) if (ismarkable(o)) reallymarkobject(st,o) |
59 | 59 | ||
60 | 60 | ||
61 | static void protomark (Proto *f) { | 61 | static void markproto (Proto *f) { |
62 | if (!f->marked) { | 62 | if (!f->marked) { |
63 | int i; | 63 | int i; |
64 | f->marked = 1; | 64 | f->marked = 1; |
@@ -68,7 +68,7 @@ static void protomark (Proto *f) { | |||
68 | strmark(tsvalue(f->k+i)); | 68 | strmark(tsvalue(f->k+i)); |
69 | } | 69 | } |
70 | for (i=0; i<f->sizep; i++) | 70 | for (i=0; i<f->sizep; i++) |
71 | protomark(f->p[i]); | 71 | markproto(f->p[i]); |
72 | for (i=0; i<f->sizelocvars; i++) /* mark local-variable names */ | 72 | for (i=0; i<f->sizelocvars; i++) /* mark local-variable names */ |
73 | strmark(f->locvars[i].varname); | 73 | strmark(f->locvars[i].varname); |
74 | } | 74 | } |
@@ -97,7 +97,7 @@ static void markclosure (GCState *st, Closure *cl) { | |||
97 | int i; | 97 | int i; |
98 | lua_assert(cl->l.nupvalues == cl->l.p->nupvalues); | 98 | lua_assert(cl->l.nupvalues == cl->l.p->nupvalues); |
99 | marktable(st, hvalue(&cl->l.g)); | 99 | marktable(st, hvalue(&cl->l.g)); |
100 | protomark(cl->l.p); | 100 | markproto(cl->l.p); |
101 | for (i=0; i<cl->l.nupvalues; i++) { /* mark its upvalues */ | 101 | for (i=0; i<cl->l.nupvalues; i++) { /* mark its upvalues */ |
102 | UpVal *u = cl->l.upvals[i]; | 102 | UpVal *u = cl->l.upvals[i]; |
103 | if (!u->marked) { | 103 | if (!u->marked) { |
@@ -147,7 +147,7 @@ static void checkstacksizes (lua_State *L, StkId max) { | |||
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | static void markstacks (GCState *st) { | 150 | static void traversestacks (GCState *st) { |
151 | lua_State *L1 = st->L; | 151 | lua_State *L1 = st->L; |
152 | do { /* for each thread */ | 152 | do { /* for each thread */ |
153 | StkId o, lim; | 153 | StkId o, lim; |
@@ -251,7 +251,7 @@ static void propagatemarks (GCState *st) { | |||
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | static int hasmark (const TObject *o) { | 254 | static int ismarked (const TObject *o) { |
255 | switch (ttype(o)) { | 255 | switch (ttype(o)) { |
256 | case LUA_TUSERDATA: | 256 | case LUA_TUSERDATA: |
257 | return isudmarked(uvalue(o)); | 257 | return isudmarked(uvalue(o)); |
@@ -279,7 +279,7 @@ static void cleartablekeys (GCState *st) { | |||
279 | int i = sizenode(h); | 279 | int i = sizenode(h); |
280 | while (i--) { | 280 | while (i--) { |
281 | Node *n = node(h, i); | 281 | Node *n = node(h, i); |
282 | if (!hasmark(key(n))) /* key was collected? */ | 282 | if (!ismarked(key(n))) /* key was collected? */ |
283 | removekey(n); /* remove entry from table */ | 283 | removekey(n); /* remove entry from table */ |
284 | } | 284 | } |
285 | } | 285 | } |
@@ -297,13 +297,13 @@ static void cleartablevalues (GCState *st) { | |||
297 | int i = sizearray(h); | 297 | int i = sizearray(h); |
298 | while (i--) { | 298 | while (i--) { |
299 | TObject *o = &h->array[i]; | 299 | TObject *o = &h->array[i]; |
300 | if (!hasmark(o)) /* value was collected? */ | 300 | if (!ismarked(o)) /* value was collected? */ |
301 | setnilvalue(o); /* remove value */ | 301 | setnilvalue(o); /* remove value */ |
302 | } | 302 | } |
303 | i = sizenode(h); | 303 | i = sizenode(h); |
304 | while (i--) { | 304 | while (i--) { |
305 | Node *n = node(h, i); | 305 | Node *n = node(h, i); |
306 | if (!hasmark(val(n))) /* value was collected? */ | 306 | if (!ismarked(val(n))) /* value was collected? */ |
307 | removekey(n); /* remove entry from table */ | 307 | removekey(n); /* remove entry from table */ |
308 | } | 308 | } |
309 | } | 309 | } |
@@ -311,7 +311,7 @@ static void cleartablevalues (GCState *st) { | |||
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | static void collectproto (lua_State *L) { | 314 | static void sweepproto (lua_State *L) { |
315 | Proto **p = &G(L)->rootproto; | 315 | Proto **p = &G(L)->rootproto; |
316 | Proto *curr; | 316 | Proto *curr; |
317 | while ((curr = *p) != NULL) { | 317 | while ((curr = *p) != NULL) { |
@@ -327,7 +327,7 @@ static void collectproto (lua_State *L) { | |||
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | static void collectclosures (lua_State *L) { | 330 | static void sweepclosures (lua_State *L) { |
331 | Closure **p = &G(L)->rootcl; | 331 | Closure **p = &G(L)->rootcl; |
332 | Closure *curr; | 332 | Closure *curr; |
333 | while ((curr = *p) != NULL) { | 333 | while ((curr = *p) != NULL) { |
@@ -343,7 +343,7 @@ static void collectclosures (lua_State *L) { | |||
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | static void collectupval (lua_State *L) { | 346 | static void sweepupval (lua_State *L) { |
347 | UpVal **v = &G(L)->rootupval; | 347 | UpVal **v = &G(L)->rootupval; |
348 | UpVal *curr; | 348 | UpVal *curr; |
349 | while ((curr = *v) != NULL) { | 349 | while ((curr = *v) != NULL) { |
@@ -359,7 +359,7 @@ static void collectupval (lua_State *L) { | |||
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | static void collecttable (lua_State *L) { | 362 | static void sweeptable (lua_State *L) { |
363 | Table **p = &G(L)->roottable; | 363 | Table **p = &G(L)->roottable; |
364 | Table *curr; | 364 | Table *curr; |
365 | while ((curr = *p) != NULL) { | 365 | while ((curr = *p) != NULL) { |
@@ -376,7 +376,7 @@ static void collecttable (lua_State *L) { | |||
376 | 376 | ||
377 | 377 | ||
378 | 378 | ||
379 | static void collectudata (lua_State *L) { | 379 | static void sweepudata (lua_State *L) { |
380 | Udata **p = &G(L)->rootudata; | 380 | Udata **p = &G(L)->rootudata; |
381 | Udata *curr; | 381 | Udata *curr; |
382 | while ((curr = *p) != NULL) { | 382 | while ((curr = *p) != NULL) { |
@@ -392,7 +392,7 @@ static void collectudata (lua_State *L) { | |||
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | static void collectstrings (lua_State *L, int all) { | 395 | static void sweepstrings (lua_State *L, int all) { |
396 | int i; | 396 | int i; |
397 | for (i=0; i<G(L)->strt.size; i++) { /* for each list */ | 397 | for (i=0; i<G(L)->strt.size; i++) { /* for each list */ |
398 | TString **p = &G(L)->strt.hash[i]; | 398 | TString **p = &G(L)->strt.hash[i]; |
@@ -462,13 +462,13 @@ void luaC_callallgcTM (lua_State *L) { | |||
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | void luaC_collect (lua_State *L, int all) { | 465 | void luaC_sweep (lua_State *L, int all) { |
466 | collectudata(L); | 466 | sweepudata(L); |
467 | collectstrings(L, all); | 467 | sweepstrings(L, all); |
468 | collecttable(L); | 468 | sweeptable(L); |
469 | collectproto(L); | 469 | sweepproto(L); |
470 | collectupval(L); | 470 | sweepupval(L); |
471 | collectclosures(L); | 471 | sweepclosures(L); |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
@@ -477,14 +477,14 @@ void luaC_collectgarbage (lua_State *L) { | |||
477 | st.L = L; | 477 | st.L = L; |
478 | st.tmark = NULL; | 478 | st.tmark = NULL; |
479 | st.toclear = NULL; | 479 | st.toclear = NULL; |
480 | markstacks(&st); /* mark all stacks */ | 480 | traversestacks(&st); /* mark all stacks */ |
481 | propagatemarks(&st); /* mark all reachable objects */ | 481 | propagatemarks(&st); /* mark all reachable objects */ |
482 | cleartablevalues(&st); | 482 | cleartablevalues(&st); |
483 | separateudata(L); /* separate userdata to be preserved */ | 483 | separateudata(L); /* separate userdata to be preserved */ |
484 | marktmu(&st); /* mark `preserved' userdata */ | 484 | marktmu(&st); /* mark `preserved' userdata */ |
485 | propagatemarks(&st); /* remark */ | 485 | propagatemarks(&st); /* remark */ |
486 | cleartablekeys(&st); | 486 | cleartablekeys(&st); |
487 | luaC_collect(L, 0); | 487 | luaC_sweep(L, 0); |
488 | checkMbuffer(L); | 488 | checkMbuffer(L); |
489 | G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ | 489 | G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */ |
490 | callGCTM(L); | 490 | callGCTM(L); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ | 2 | ** $Id: lgc.h,v 1.14 2001/12/10 22:11:23 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 | */ |
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | 17 | ||
18 | void luaC_callallgcTM (lua_State *L); | 18 | void luaC_callallgcTM (lua_State *L); |
19 | void luaC_collect (lua_State *L, int all); | 19 | void luaC_sweep (lua_State *L, int all); |
20 | void luaC_collectgarbage (lua_State *L); | 20 | void luaC_collectgarbage (lua_State *L); |
21 | 21 | ||
22 | 22 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.102 2002/08/06 15:32:22 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.103 2002/08/07 19:22:39 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -159,7 +159,7 @@ void luaE_closethread (lua_State *OL, lua_State *L) { | |||
159 | static void close_state (lua_State *L) { | 159 | static void close_state (lua_State *L) { |
160 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 160 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
161 | if (G(L)) { /* close global state */ | 161 | if (G(L)) { /* close global state */ |
162 | luaC_collect(L, 1); /* collect all elements */ | 162 | luaC_sweep(L, 1); /* collect all elements */ |
163 | lua_assert(G(L)->rootproto == NULL); | 163 | lua_assert(G(L)->rootproto == NULL); |
164 | lua_assert(G(L)->rootudata == NULL); | 164 | lua_assert(G(L)->rootudata == NULL); |
165 | lua_assert(G(L)->rootcl == NULL); | 165 | lua_assert(G(L)->rootcl == NULL); |