diff options
| -rw-r--r-- | lgc.c | 12 |
1 files changed, 8 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.36 2005/08/24 17:06:36 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.37 2005/12/22 16:19:56 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 | */ |
| @@ -320,8 +320,10 @@ static l_mem propagatemark (global_State *g) { | |||
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | 322 | ||
| 323 | static void propagateall (global_State *g) { | 323 | static size_t propagateall (global_State *g) { |
| 324 | while (g->gray) propagatemark(g); | 324 | size_t m = 0; |
| 325 | while (g->gray) m += propagatemark(g); | ||
| 326 | return m; | ||
| 325 | } | 327 | } |
| 326 | 328 | ||
| 327 | 329 | ||
| @@ -540,7 +542,7 @@ static void atomic (lua_State *L) { | |||
| 540 | propagateall(g); | 542 | propagateall(g); |
| 541 | udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ | 543 | udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ |
| 542 | marktmu(g); /* mark `preserved' userdata */ | 544 | marktmu(g); /* mark `preserved' userdata */ |
| 543 | propagateall(g); /* remark, to propagate `preserveness' */ | 545 | udsize += propagateall(g); /* remark, to propagate `preserveness' */ |
| 544 | cleartable(g->weak); /* remove collected objects from weak tables */ | 546 | cleartable(g->weak); /* remove collected objects from weak tables */ |
| 545 | /* flip current white */ | 547 | /* flip current white */ |
| 546 | g->currentwhite = cast_byte(otherwhite(g)); | 548 | g->currentwhite = cast_byte(otherwhite(g)); |
| @@ -590,6 +592,8 @@ static l_mem singlestep (lua_State *L) { | |||
| 590 | case GCSfinalize: { | 592 | case GCSfinalize: { |
| 591 | if (g->tmudata) { | 593 | if (g->tmudata) { |
| 592 | GCTM(L); | 594 | GCTM(L); |
| 595 | if (g->estimate > GCFINALIZECOST) | ||
| 596 | g->estimate -= GCFINALIZECOST; | ||
| 593 | return GCFINALIZECOST; | 597 | return GCFINALIZECOST; |
| 594 | } | 598 | } |
| 595 | else { | 599 | else { |
