control of garbage collection is done with Longs, as there can be

more than WORD objects to collect.
This commit is contained in:
Roberto Ierusalimschy
1995-01-12 12:19:04 -02:00
parent 53c0a0f43c
commit 8faf4d1de2
5 changed files with 16 additions and 14 deletions

6
hash.c
View File

@@ -3,7 +3,7 @@
** hash manager for lua ** hash manager for lua
*/ */
char *rcs_hash="$Id: hash.c,v 2.21 1994/12/16 15:55:04 roberto Exp roberto $"; char *rcs_hash="$Id: hash.c,v 2.22 1994/12/20 21:20:36 roberto Exp roberto $";
#include "mem.h" #include "mem.h"
#include "opcode.h" #include "opcode.h"
@@ -185,10 +185,10 @@ static void call_fallbacks (void)
** Garbage collection to arrays ** Garbage collection to arrays
** Delete all unmarked arrays. ** Delete all unmarked arrays.
*/ */
Word lua_hashcollector (void) Long lua_hashcollector (void)
{ {
Hash *curr_array = listhead, *prev = NULL; Hash *curr_array = listhead, *prev = NULL;
Word counter = 0; Long counter = 0;
call_fallbacks(); call_fallbacks();
while (curr_array != NULL) while (curr_array != NULL)
{ {

6
hash.h
View File

@@ -2,12 +2,14 @@
** hash.h ** hash.h
** hash manager for lua ** hash manager for lua
** Luiz Henrique de Figueiredo - 17 Aug 90 ** Luiz Henrique de Figueiredo - 17 Aug 90
** $Id: hash.h,v 2.6 1994/11/17 13:58:57 roberto Stab roberto $ ** $Id: hash.h,v 2.7 1994/12/20 21:20:36 roberto Exp roberto $
*/ */
#ifndef hash_h #ifndef hash_h
#define hash_h #define hash_h
#include "types.h"
typedef struct node typedef struct node
{ {
Object ref; Object ref;
@@ -27,7 +29,7 @@ typedef struct Hash
Bool lua_equalObj (Object *t1, Object *t2); Bool lua_equalObj (Object *t1, Object *t2);
Hash *lua_createarray (Word nhash); Hash *lua_createarray (Word nhash);
void lua_hashmark (Hash *h); void lua_hashmark (Hash *h);
Word lua_hashcollector (void); Long lua_hashcollector (void);
Object *lua_hashget (Hash *t, Object *ref); Object *lua_hashget (Hash *t, Object *ref);
Object *lua_hashdefine (Hash *t, Object *ref); Object *lua_hashdefine (Hash *t, Object *ref);
void lua_next (void); void lua_next (void);

View File

@@ -3,7 +3,7 @@
** Module to control static tables ** Module to control static tables
*/ */
char *rcs_table="$Id: table.c,v 2.24 1994/12/16 15:55:04 roberto Exp roberto $"; char *rcs_table="$Id: table.c,v 2.25 1994/12/20 21:20:36 roberto Exp roberto $";
#include <string.h> #include <string.h>
@@ -173,9 +173,9 @@ void lua_markobject (Object *o)
*/ */
void lua_pack (void) void lua_pack (void)
{ {
static Word block = GARBAGE_BLOCK; /* when garbage collector will be called */ static Long block = GARBAGE_BLOCK; /* when garbage collector will be called */
static Word nentity = 0; /* counter of new entities (strings and arrays) */ static Long nentity = 0; /* counter of new entities (strings and arrays) */
Word recovered = 0; Long recovered = 0;
if (nentity++ < block) return; if (nentity++ < block) return;
lua_travstack(lua_markobject); /* mark stack objects */ lua_travstack(lua_markobject); /* mark stack objects */
lua_travsymbol(lua_markobject); /* mark symbol table objects */ lua_travsymbol(lua_markobject); /* mark symbol table objects */

6
tree.c
View File

@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
*/ */
char *rcs_tree="$Id: tree.c,v 1.11 1994/11/25 19:27:03 roberto Exp roberto $"; char *rcs_tree="$Id: tree.c,v 1.12 1994/12/20 21:20:36 roberto Exp roberto $";
#include <string.h> #include <string.h>
@@ -78,10 +78,10 @@ TreeNode *lua_constcreate (char *str)
** Garbage collection function. ** Garbage collection function.
** This function traverse the string list freeing unindexed strings ** This function traverse the string list freeing unindexed strings
*/ */
Word lua_strcollector (void) Long lua_strcollector (void)
{ {
StringNode *curr = string_root, *prev = NULL; StringNode *curr = string_root, *prev = NULL;
Word counter = 0; Long counter = 0;
while (curr) while (curr)
{ {
StringNode *next = curr->next; StringNode *next = curr->next;

4
tree.h
View File

@@ -1,7 +1,7 @@
/* /*
** tree.h ** tree.h
** TecCGraf - PUC-Rio ** TecCGraf - PUC-Rio
** $Id: tree.h,v 1.7 1994/11/25 19:27:03 roberto Exp roberto $ ** $Id: tree.h,v 1.8 1994/12/20 21:20:36 roberto Exp roberto $
*/ */
#ifndef tree_h #ifndef tree_h
@@ -31,7 +31,7 @@ typedef struct TreeNode
TaggedString *lua_createstring (char *str); TaggedString *lua_createstring (char *str);
TreeNode *lua_constcreate (char *str); TreeNode *lua_constcreate (char *str);
Word lua_strcollector (void); Long lua_strcollector (void);
TreeNode *lua_varnext (char *n); TreeNode *lua_varnext (char *n);
#endif #endif