aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/lgc.c b/lgc.c
index 933b035b..55101120 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.106 2010/12/20 18:17:46 roberto Exp roberto $ 2** $Id: lgc.c,v 2.107 2010/12/20 19:40:07 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*/
@@ -318,8 +318,7 @@ static void remarkupvals (global_State *g) {
318** mark root set and reset all gray lists, to start a new 318** mark root set and reset all gray lists, to start a new
319** incremental (or full) collection 319** incremental (or full) collection
320*/ 320*/
321static void markroot (lua_State *L) { 321static void markroot (global_State *g) {
322 global_State *g = G(L);
323 g->gray = g->grayagain = NULL; 322 g->gray = g->grayagain = NULL;
324 g->weak = g->allweak = g->ephemeron = NULL; 323 g->weak = g->allweak = g->ephemeron = NULL;
325 markobject(g, g->mainthread); 324 markobject(g, g->mainthread);
@@ -889,7 +888,7 @@ static l_mem singlestep (lua_State *L) {
889 switch (g->gcstate) { 888 switch (g->gcstate) {
890 case GCSpause: { 889 case GCSpause: {
891 if (!isgenerational(g)) 890 if (!isgenerational(g))
892 markroot(L); /* start a new collection */ 891 markroot(g); /* start a new collection */
893 /* in any case, root must be marked */ 892 /* in any case, root must be marked */
894 lua_assert(!iswhite(obj2gco(g->mainthread)) 893 lua_assert(!iswhite(obj2gco(g->mainthread))
895 && !iswhite(gcvalue(&g->l_registry))); 894 && !iswhite(gcvalue(&g->l_registry)));
@@ -986,15 +985,24 @@ static void step (lua_State *L) {
986} 985}
987 986
988 987
989void luaC_step (lua_State *L) { 988/*
989** performs a basic GC step even if the collector is stopped
990*/
991void luaC_forcestep (lua_State *L) {
990 global_State *g = G(L); 992 global_State *g = G(L);
991 if (g->gcrunning) { 993 int i;
992 int i; 994 if (isgenerational(g)) generationalcollection(L);
993 if (isgenerational(g)) generationalcollection(L); 995 else step(L);
994 else step(L); 996 for (i = 0; i < GCFINALIZENUM && g->tobefnz; i++)
995 for (i = 0; i < GCFINALIZENUM && g->tobefnz; i++) 997 GCTM(L, 1); /* Call a few pending finalizers */
996 GCTM(L, 1); /* Call a few pending finalizers */ 998}
997 } 999
1000
1001/*
1002** performs a basic GC step only if collector is running
1003*/
1004void luaC_step (lua_State *L) {
1005 if (G(L)->gcrunning) luaC_forcestep(L);
998} 1006}
999 1007
1000 1008