pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:23:   #include "constants.h"   #include "interpret.h"   #include "bignum.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.131 2000/09/04 14:28:08 grubba Exp $"); + RCSID("$Id: gc.c,v 1.132 2000/09/04 23:08:33 grubba Exp $");      /* Run garbage collect approximately every time    * 20 percent of all arrays, objects and programs is    * garbage.    */      #define GC_CONST 20   #define MIN_ALLOC_THRESHOLD 1000   #define MAX_ALLOC_THRESHOLD 10000000   #define MULTIPLIER 0.9
pike.git/src/gc.c:1853: Inside #if defined(PIKE_DEBUG)
   }    if((m->flags & (GC_MARKED|GC_XREFERENCED)) == GC_XREFERENCED)    gc_fatal(a, 1, "Thing with external reference missed in gc mark pass.\n");    if ((m->flags & (GC_DO_FREE|GC_LIVE)) == GC_LIVE) live_ref++;    m->flags |= GC_DO_FREE;   #endif       return !(m->flags & GC_LIVE);   }    + static void free_obj_arr(void *oa) + { +  struct array *obj_arr = *((struct array **)oa); +  +  if (obj_arr) free_array(obj_arr); +  free(oa); + } +    static void warn_bad_cycles()   { -  JMP_BUF uwp; -  struct array *obj_arr = 0; +  /* The reason for the extra level of indirection, is that it might +  * be clobbered by the longjump() in SET_ONERROR otherwise. +  * (On some architectures longjump() might restore obj_arr's original +  * value (eg if obj_arr is in a register)). +  */ +  struct array **obj_arr_ = (struct array **)xalloc(sizeof(struct array *)); +  ONERROR tmp;    -  if (!SETJMP(uwp)) { +  *obj_arr_ = NULL; +  +  SET_ONERROR(tmp, free_obj_arr, obj_arr_); +  +  {    struct gc_frame *p;    unsigned cycle = 0; -  obj_arr = allocate_array(0); +  *obj_arr_ = allocate_array(0);       for (p = kill_list; p;) {    if ((cycle = CYCLE(p))) {    push_object((struct object *) p->data); -  obj_arr = append_array(obj_arr, --sp); +  *obj_arr_ = append_array(*obj_arr_, --sp);    }    p = NEXT(p);    if (p ? ((unsigned)(CYCLE(p) != cycle)) : cycle) { -  if (obj_arr->size >= 2) { +  if ((*obj_arr_)->size >= 2) {    push_constant_text("gc");    push_constant_text("bad_cycle"); -  push_array(obj_arr); -  obj_arr = 0; +  push_array(*obj_arr_); +  *obj_arr_ = 0;    SAFE_APPLY_MASTER("runtime_warning", 3);    pop_stack(); -  obj_arr = allocate_array(0); +  *obj_arr_ = allocate_array(0);    } -  else obj_arr = resize_array(obj_arr, 0); +  else *obj_arr_ = resize_array(*obj_arr_, 0);    }    if (!p) break;    }    }    -  UNSETJMP(uwp); -  if (obj_arr) free_array(obj_arr); +  CALL_AND_UNSET_ONERROR(tmp);   }      int do_gc(void)   {    double tmp;    int objs, pre_kill_objs;    double multiplier;    struct array *a;    struct multiset *l;    struct mapping *m;