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.153 2001/06/11 19:58:28 mast Exp $"); + RCSID("$Id: gc.c,v 1.154 2001/06/26 21:03:49 hubbe 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:92:   #ifdef GC_VERBOSE   #define GC_VERBOSE_DO(X) X   #else   #define GC_VERBOSE_DO(X)   #endif      INT32 num_objects = 3; /* Account for *_empty_array. */   INT32 num_allocs =0;   ptrdiff_t alloc_threshold = MIN_ALLOC_THRESHOLD;   PMOD_EXPORT int Pike_in_gc = 0; + int gc_generation = 0;   struct pike_queue gc_mark_queue;   time_t last_gc;      struct gc_frame   {    struct gc_frame *back; /* Previous stack frame. */    void *data;    union {    struct { /* Pop frame. */    struct gc_frame *prev; /* Previous frame in rec_list. */
pike.git/src/gc.c:759:    case T_MULTISET:    fprintf(stderr,"%*s**Describing array of multiset:\n",indent,"");    debug_dump_array(((struct multiset *)a)->ind);    break;       case T_ARRAY:    fprintf(stderr,"%*s**Describing array:\n",indent,"");    debug_dump_array((struct array *)a);    break;    +  case T_MAPPING_DATA: +  { +  struct mapping *m; +  for(m=first_mapping;m;m=m->next) +  { +  if(m->data == (struct mapping_data *)a) +  { +  fprintf(stderr,"%*s**Describing mapping:\n",indent,""); +  debug_dump_mapping((struct mapping *)m); +  describe_something( m, T_MAPPING, indent+2,depth-1,flags); +  } +  } +  break; +  } +     case T_MAPPING:    fprintf(stderr,"%*s**Describing mapping:\n",indent,"");    debug_dump_mapping((struct mapping *)a);    fprintf(stderr,"%*s**Describing mapping data block:\n",indent,"");    describe_something( ((struct mapping *)a)->data, -2, indent+2,depth-1,flags);    break;       case T_STRING:    {    struct pike_string *s=(struct pike_string *)a;
pike.git/src/gc.c:1109: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG      void debug_gc_add_extra_ref(void *a)   {    struct marker *m = get_marker(a);    if (m->flags & GC_GOT_EXTRA_REF)    gc_fatal(a, 0, "Thing already got an extra gc ref.\n");    m->flags |= GC_GOT_EXTRA_REF;    gc_extra_refs++; -  ++*(INT32 *) a; +  add_ref( (struct ref_dummy *)a);   }      void debug_gc_free_extra_ref(void *a)   {    struct marker *m = get_marker(a);    if (!(m->flags & GC_GOT_EXTRA_REF))    gc_fatal(a, 0, "Thing haven't got an extra gc ref.\n");    m->flags &= ~GC_GOT_EXTRA_REF;    gc_extra_refs--;   }
pike.git/src/gc.c:1514: Inside #if defined(GC_STACK_DEBUG)
   fputc('\n', stderr);    }   #endif   }      int gc_cycle_push(void *x, struct marker *m, int weak)   {    struct marker *last = find_marker(gc_rec_last->data);      #ifdef PIKE_DEBUG +  +  debug_malloc_touch(x); +     if (!x) fatal("Got null pointer.\n");    if (m->data != x) fatal("Got wrong marker.\n");    if (Pike_in_gc != GC_PASS_CYCLE)    fatal("GC cycle push attempted in invalid pass.\n");    if (gc_debug && !(m->flags & GC_PRETOUCHED))    gc_fatal(x, 0, "gc_cycle_push() called for untouched thing.\n");    if ((!(m->flags & GC_NOT_REFERENCED) || m->flags & GC_MARKED) &&    *(INT32 *) x)    gc_fatal(x, 1, "Got a referenced marker to gc_cycle_push.\n");    if (m->flags & GC_XREFERENCED)
pike.git/src/gc.c:1717: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    cycle_checked++;    if (m->frame)    gc_fatal(x, 0, "Marker already got a frame.\n");    if (NEXT(gc_rec_last))    gc_fatal(gc_rec_last->data, 0, "Not at end of list.\n");   #endif       NEXT(gc_rec_last) = m->frame = l = gc_cycle_enqueue_pop(x);    m->flags |= GC_CYCLE_CHECKED | (last->flags & GC_LIVE); +  debug_malloc_touch(x);    if (weak) {    if (weak > 0) l->frameflags |= GC_WEAK_REF;    else l->frameflags |= GC_STRONG_REF;    }      #ifdef GC_CYCLE_DEBUG    if (weak > 0) CYCLE_DEBUG_MSG(m, "gc_cycle_push, recurse weak");    else if (weak < 0) CYCLE_DEBUG_MSG(m, "gc_cycle_push, recurse strong");    else CYCLE_DEBUG_MSG(m, "gc_cycle_push, recurse");    gc_cycle_indent += 2;
pike.git/src/gc.c:1745:    CYCLE_DEBUG_MSG(m, "gc_cycle_push, no recurse");    return 0;    }      live_recurse:   #ifdef PIKE_DEBUG    if (m->flags & GC_LIVE)    fatal("Shouldn't live recurse when there's nothing to do.\n");   #endif    m->flags |= GC_LIVE|GC_LIVE_RECURSE; +  debug_malloc_touch(x);       if (m->flags & GC_GOT_DEAD_REF) {    /* A thing previously popped as dead is now being marked live.    * Have to remove the extra ref added by gc_cycle_pop(). */    gc_free_extra_ref(x);    if (!--*(INT32 *) x) {   #ifdef PIKE_DEBUG    gc_fatal(x, 0, "Thing got zero refs after removing the dead gc ref.\n");   #endif    }
pike.git/src/gc.c:1984: Inside #if defined(PIKE_DEBUG) and #if defined(HAVE_GETHRTIME)
  #ifdef PIKE_DEBUG   #ifdef HAVE_GETHRTIME    hrtime_t gcstarttime = 0;   #endif    unsigned destroy_count, obj_count;    ONERROR uwp;   #endif       if(Pike_in_gc) return 0;    init_gc(); +  gc_generation++;    Pike_in_gc=GC_PASS_PREPARE;   #ifdef PIKE_DEBUG    gc_debug = d_flag;    SET_ONERROR(uwp, fatal_on_error, "Shouldn't get an exception inside the gc.\n");   #endif       destruct_objects_to_destruct();       if(gc_evaluator_callback)    {