aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-11 19:31:14 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-12-11 19:31:14 -0200
commit8da245bfd2a767e1a738c2a85492d1f64d68f016 (patch)
tree9cb12a687b8051d9402d3c861c2c33d251bf7acd /lgc.c
parenta2a2abcba4b3a221780a4499880aa16bf76e8204 (diff)
downloadlua-8da245bfd2a767e1a738c2a85492d1f64d68f016.tar.gz
lua-8da245bfd2a767e1a738c2a85492d1f64d68f016.tar.bz2
lua-8da245bfd2a767e1a738c2a85492d1f64d68f016.zip
better to keep GC state numbers sequential, to optimize switch in
'singlestep'
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lgc.c b/lgc.c
index 2d042390..286b2213 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.63 2009/11/26 11:39:20 roberto Exp roberto $ 2** $Id: lgc.c,v 2.64 2009/12/11 19:14:59 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*/
@@ -786,12 +786,12 @@ void luaC_step (lua_State *L) {
786 786
787 787
788/* 788/*
789** advances the garbage collector until it reaches a "valid" state 789** advances the garbage collector until it reaches a state allowed
790** (defined by the caller) 790** by 'statemask'
791*/ 791*/
792void luaC_runtilstate (lua_State *L, int validstates) { 792void luaC_runtilstate (lua_State *L, int statesmask) {
793 global_State *g = G(L); 793 global_State *g = G(L);
794 while (!(g->gcstate & validstates)) 794 while (!testbit(statesmask, g->gcstate))
795 singlestep(L); 795 singlestep(L);
796} 796}
797 797
@@ -811,13 +811,13 @@ void luaC_fullgc (lua_State *L, int isemergency) {
811 g->gcstate = GCSsweepstring; 811 g->gcstate = GCSsweepstring;
812 } 812 }
813 /* finish any pending sweep phase */ 813 /* finish any pending sweep phase */
814 luaC_runtilstate(L, ~(GCSsweepstring | GCSsweep)); 814 luaC_runtilstate(L, ~bit2mask(GCSsweepstring, GCSsweep));
815 markroot(L); /* start a new collection */ 815 markroot(L); /* start a new collection */
816 /* run collector up to finalizers */ 816 /* run collector up to finalizers */
817 luaC_runtilstate(L, GCSfinalize); 817 luaC_runtilstate(L, bitmask(GCSfinalize));
818 g->gckind = KGC_NORMAL; 818 g->gckind = KGC_NORMAL;
819 if (!isemergency) /* do not run finalizers during emergency GC */ 819 if (!isemergency) /* do not run finalizers during emergency GC */
820 luaC_runtilstate(L, ~GCSfinalize); 820 luaC_runtilstate(L, ~bitmask(GCSfinalize));
821 g->GCthreshold = (g->totalbytes/100) * g->gcpause; 821 g->GCthreshold = (g->totalbytes/100) * g->gcpause;
822} 822}
823 823