diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 11:58:57 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-11-17 11:58:57 -0200 |
| commit | b234da1cc2053b8919a9b27af67291e48fdf9703 (patch) | |
| tree | b32559df54e0d9c79fe271260f69238244ae2fc7 /table.c | |
| parent | d6a1699e37257c0b3d4651a481ce0bf597bc4e45 (diff) | |
| download | lua-b234da1cc2053b8919a9b27af67291e48fdf9703.tar.gz lua-b234da1cc2053b8919a9b27af67291e48fdf9703.tar.bz2 lua-b234da1cc2053b8919a9b27af67291e48fdf9703.zip | |
changes in garbage collection control
Diffstat (limited to 'table.c')
| -rw-r--r-- | table.c | 36 |
1 files changed, 14 insertions, 22 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Module to control static tables | 3 | ** Module to control static tables |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_table="$Id: table.c,v 2.18 1994/11/16 16:03:48 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.19 1994/11/16 17:39:16 roberto Exp $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | 9 | ||
| @@ -33,12 +33,8 @@ static Long lua_maxconstant = 0; | |||
| 33 | char *lua_file[MAXFILE]; | 33 | char *lua_file[MAXFILE]; |
| 34 | int lua_nfile; | 34 | int lua_nfile; |
| 35 | 35 | ||
| 36 | /* Variables to controll garbage collection */ | ||
| 37 | #define GARBAGE_BLOCK 256 | 36 | #define GARBAGE_BLOCK 256 |
| 38 | Word lua_block=GARBAGE_BLOCK; /* when garbage collector will be called */ | 37 | #define MIN_GARBAGE_BLOCK 10 |
| 39 | Word lua_nentity; /* counter of new entities (strings and arrays) */ | ||
| 40 | Word lua_recovered; /* counter of recovered entities (strings and arrays) */ | ||
| 41 | |||
| 42 | 38 | ||
| 43 | static void lua_nextvar (void); | 39 | static void lua_nextvar (void); |
| 44 | 40 | ||
| @@ -168,22 +164,18 @@ void lua_markobject (Object *o) | |||
| 168 | */ | 164 | */ |
| 169 | void lua_pack (void) | 165 | void lua_pack (void) |
| 170 | { | 166 | { |
| 171 | /* mark stack objects */ | 167 | static int block = GARBAGE_BLOCK; /* when garbage collector will be called */ |
| 172 | lua_travstack(lua_markobject); | 168 | static int nentity = 0; /* counter of new entities (strings and arrays) */ |
| 173 | 169 | int recovered = 0; | |
| 174 | /* mark symbol table objects */ | 170 | if (nentity++ < block) return; |
| 175 | lua_travsymbol(lua_markobject); | 171 | lua_travstack(lua_markobject); /* mark stack objects */ |
| 176 | 172 | lua_travsymbol(lua_markobject); /* mark symbol table objects */ | |
| 177 | /* mark locked objects */ | 173 | luaI_travlock(lua_markobject); /* mark locked objects */ |
| 178 | luaI_travlock(lua_markobject); | 174 | recovered += lua_strcollector(); |
| 179 | 175 | recovered += lua_hashcollector(); | |
| 180 | lua_recovered=0; | 176 | nentity = 0; /* reset counter */ |
| 181 | 177 | block=2*block-3*recovered/2; /* adapt block size */ | |
| 182 | lua_strcollector(); | 178 | if (block < MIN_GARBAGE_BLOCK) block = MIN_GARBAGE_BLOCK; |
| 183 | lua_hashcollector(); | ||
| 184 | |||
| 185 | lua_nentity = 0; /* reset counter */ | ||
| 186 | lua_block=2*lua_block-3*lua_recovered/2U; /* adapt block size */ | ||
| 187 | } | 179 | } |
| 188 | 180 | ||
| 189 | 181 | ||
