diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-12-11 19:31:14 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-12-11 19:31:14 -0200 |
commit | 8da245bfd2a767e1a738c2a85492d1f64d68f016 (patch) | |
tree | 9cb12a687b8051d9402d3c861c2c33d251bf7acd /lgc.c | |
parent | a2a2abcba4b3a221780a4499880aa16bf76e8204 (diff) | |
download | lua-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.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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 | */ |
792 | void luaC_runtilstate (lua_State *L, int validstates) { | 792 | void 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 | ||