Branch: Tag:

1996-02-24

1996-02-24 02:42:05 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

Garbage collect finished

Rev: lib/simulate.lpc:1.9
Rev: src/ChangeLog:1.17
Rev: src/Makefile.in:1.9
Rev: src/array.c:1.7
Rev: src/array.h:1.4
Rev: src/backend.c:1.3
Rev: src/backend.h:1.3
Rev: src/builtin_efuns.c:1.10
Rev: src/call_out.c:1.3
Rev: src/config.h:1.3
Rev: src/debug.c:1.2(DEAD)
Rev: src/debug.h:1.2(DEAD)
Rev: src/global.h:1.2
Rev: src/mapping.c:1.3
Rev: src/mapping.h:1.2
Rev: src/modules/efuns.c:1.2(DEAD)
Rev: src/modules/files/Makefile.in:1.2
Rev: src/modules/regexp/Makefile.in:1.2
Rev: src/modules/sprintf/Makefile.in:1.2
Rev: src/object.c:1.6
Rev: src/object.h:1.4
Rev: src/program.c:1.7
Rev: src/program.h:1.3
Rev: src/stralloc.c:1.2
Rev: src/stralloc.h:1.2
Rev: src/svalue.c:1.6
Rev: src/svalue.h:1.4
Rev: src/test/create_testsuite:1.8

19:   #include "interpret.h"   #include "hashtable.h"   #include "main.h" + #include "gc.h"   #include <stdio.h>   #include <fcntl.h>   
156:    p->next->prev=p->prev;       free((char *)p); +  +  GC_FREE();   }      #ifdef DEBUG
214:   }      #ifdef DEBUG - void check_program(struct program *p, int pass) + void check_program(struct program *p)   {    INT32 size,e;    unsigned INT32 checksum;    -  if(pass) -  { -  if(checked((void *)p,0) != p->refs) -  fatal("Program has wrong number of references.\n"); -  -  return; -  } -  +     if(p->refs <=0)    fatal("Program has zero refs.\n");   
333:    {    if(p->inherits[e].storage_offset < 0)    fatal("Inherit->storage_offset is wrong.\n"); -  -  checked((void *)p->inherits[e].prog,1); +     } -  checked((void *)p,-1); /* One too many were added above */ +    }   #endif   
466:    first_program=prog;      #ifdef DEBUG -  check_program(prog,0); +  check_program(prog);    if(l_flag)    dump_program_desc(prog);   #endif
1196:    error("Couldn't open file '%s'.\n",file_name->str);       +  GC_ALLOC(); +  +    #define FILE_STATE   #define PUSH   #include "compilation.h"
1226:   #include "compilation.h"   #undef PUSH    +  GC_ALLOC(); +     start_new_string(prog->str,prog->len,name);    start_new_program();    compile();
1281:   }      #ifdef DEBUG - void check_all_programs(int pass) + void check_all_programs()   {    struct program *p;    for(p=first_program;p;p=p->next) -  check_program(p,pass); -  - #ifdef FIND_FUNCTION_HASHSIZE -  if(!pass) -  { -  int e; -  for(e=0;e<FIND_FUNCTION_HASHSIZE;e++) -  { -  if(cache[e].name) -  checked((void *)cache[e].name,1); +  check_program(p);   } -  } +    #endif - } - #endif +       void cleanup_program()   {
1315:    }   #endif   } +  + #ifdef GC2 +  + void gc_check_program(struct program *p) + { +  if(p==gc_ptr) gc_refs++; +  if(p->flags & GC_MARK) return; +  p->flags |= GC_MARK; +  gc_check_svalues(p->constants, p->num_constants); + } +  + void gc_check_all_programs() + { +  struct program *p, *next; +  for(p=first_program;p;p=next) +  { +  if(!(p->flags & GC_MARK)) +  { +  gc_ptr=p; +  gc_refs=0; +  +  gc_check_program(p); +  +  p->refs++; +  +  if(gc_refs == p->refs) +  free_svalues(p->constants, p->num_constants, -1); +  +  next=p->next; +  free_program(p); +  }else{ +  next=p->next; +  } +  } + } +  + void gc_clear_program_marks() + { +  struct program *p; +  +  for(p=first_program;p;p=p->next) p->flags &=~ GC_MARK; + } +  + #endif /* GC2 */