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.161 2001/06/30 21:28:35 mast Exp $"); + RCSID("$Id: gc.c,v 1.162 2001/07/01 18:17:30 mast 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:562:   {    struct marker *m;    int orig_gc_pass = Pike_in_gc;    va_list args;       va_start(args, fmt);       fprintf(stderr, "**");    (void) VFPRINTF(stderr, fmt, args);    +  if (a) {    /* Temporarily jumping out of gc to avoid being catched in debug    * checks in describe(). */    Pike_in_gc = 0;    describe(a);       if (flags & 1) locate_references(a);       m=find_marker(a);    if(m)    {    fprintf(stderr,"** Describing marker for this thing.\n");    describe(m);    }else{    fprintf(stderr,"** No marker found for this thing.\n");    }    Pike_in_gc = orig_gc_pass; -  +  } +     if (flags & 2)    fatal_after_gc = "Fatal in garbage collector.\n";    else    debug_fatal("Fatal in garbage collector.\n");   }      static void gdb_gc_stop_here(void *a, int weak)   {   #if 1    if (!found_in) fatal("found_in is zero.\n");
pike.git/src/gc.c:1164: Inside #if defined(PIKE_DEBUG)
   found_where=" in a mapping";    gc_check_all_mappings();       found_where=" in a program";    gc_check_all_programs();       found_where=" in an object";    gc_check_all_objects();      #ifdef PIKE_DEBUG -  if(master_object) { -  found_where = " as master_object"; -  gc_external_mark2(master_object,0," &master_object"); -  } +  if(master_object) +  gc_external_mark2(master_object,0," as master_object");    {    extern struct mapping *builtin_constants; -  if(builtin_constants) { -  found_where = " as builtin_constants"; -  gc_external_mark2(builtin_constants,0," &builtin_constants"); +  if(builtin_constants) +  gc_external_mark2(builtin_constants,0," as builtin_constants");    } -  } +    #endif       found_where=0;    call_callback(& gc_callbacks, (void *)0);       found_where=orig_found_where;    check_for=orig_check_for;      #ifdef DEBUG_MALLOC    {
pike.git/src/gc.c:1692:    /* Only recurse through things already handled; we'll get to the    * other later in the normal recursion. */   #ifdef PIKE_DEBUG    if (m->flags & GC_LIVE_RECURSE)    gc_fatal(x, 0, "Mark live recursion attempted twice into thing.\n");   #endif    goto live_recurse;    }    CYCLE_DEBUG_MSG(m, "gc_cycle_push, no live recurse");    } -  +     else { -  /* Nothing more to do. Unwind the live recursion. */ +  /* We'll get here eventually in the normal recursion. Pop off +  * the remaining live recurse frames for the last thing. */    int flags; -  CYCLE_DEBUG_MSG(m, "gc_cycle_push, live rec done"); -  do { +  CYCLE_DEBUG_MSG(m, "gc_cycle_push, no live recurse");    last->flags &= ~GC_LIVE_RECURSE; - #ifdef GC_CYCLE_DEBUG -  gc_cycle_indent -= 2; -  CYCLE_DEBUG_MSG(find_marker(gc_rec_last->data), -  "> gc_cycle_push, unwinding live"); - #endif +     while (1) {    struct gc_frame *l = gc_rec_top;   #ifdef PIKE_DEBUG    if (!gc_rec_top)    fatal("Expected a gc_cycle_pop entry in gc_rec_top.\n");   #endif    gc_rec_top = l->back;    if (l->frameflags & GC_POP_FRAME) {    gc_rec_last = PREV(l);    debug_really_free_gc_frame(l);    break;    }    debug_really_free_gc_frame(l);    } -  last = find_marker(gc_rec_last->data); -  } while (last->flags & GC_LIVE_RECURSE); + #ifdef GC_CYCLE_DEBUG +  gc_cycle_indent -= 2; +  CYCLE_DEBUG_MSG(m, "> gc_cycle_push, unwound live rec"); + #endif    }       return 0;    }      #ifdef PIKE_DEBUG    if (weak < 0 && gc_rec_last->frameflags & GC_FOLLOWED_NONSTRONG)    gc_fatal(x, 0, "Followed strong link too late.\n");    if (weak >= 0) gc_rec_last->frameflags |= GC_FOLLOWED_NONSTRONG;   #endif
pike.git/src/gc.c:1764:       else if (weak < 0) {    CYCLE_DEBUG_MSG(m, "gc_cycle_push, search strong");    for (p = NEXT(m->frame);; p = NEXT(p)) {    CHECK_POP_FRAME(p);    if (p->frameflags & GC_WEAK_REF) weak_ref = p;    if (!(p->frameflags & GC_STRONG_REF)) nonstrong_ref = p;    if (p == gc_rec_last) break;    }   #ifdef PIKE_DEBUG -  if (p == gc_rec_last && !nonstrong_ref) -  gc_fatal(x, 0, "Only strong links in cycle.\n"); +  if (p == gc_rec_last && !nonstrong_ref) { +  fprintf(stderr, "Only strong links in cycle:\n"); +  for (p = NEXT(m->frame);; p = NEXT(p)) { +  describe(p->data); +  locate_references(p->data); +  if (p == gc_rec_last) break; +  fprintf(stderr, "========= next =========\n"); +  } +  gc_fatal(0, 0, "Only strong links in cycle.\n"); +  }   #endif    }       else {    struct gc_frame *q;    CYCLE_DEBUG_MSG(m, "gc_cycle_push, search weak");    for (q = m->frame, p = NEXT(q);; q = p, p = NEXT(p)) {    CHECK_POP_FRAME(p);    if (!(p->frameflags & GC_WEAK_REF) && !nonstrong_ref)    nonstrong_ref = q;
pike.git/src/gc.c:2185:    gc_ext_weak_refs = 0;    /* First we count internal references */    gc_check_all_arrays();    gc_check_all_multisets();    gc_check_all_mappings();    gc_check_all_programs();    gc_check_all_objects();      #ifdef PIKE_DEBUG    if(master_object) -  gc_external_mark2(master_object,0," &master_object"); +  gc_external_mark2(master_object,0," as master_object");       {    extern struct mapping *builtin_constants;    if(builtin_constants) -  gc_external_mark2(builtin_constants,0," &builtin_constants"); +  gc_external_mark2(builtin_constants,0," as builtin_constants");    }   #endif       /* These callbacks are mainly for the check pass, but can also    * do things that are normally associated with the mark pass    */    call_callback(& gc_callbacks, (void *)0);       GC_VERBOSE_DO(fprintf(stderr, "| check: %u references checked, counted %lu weak refs\n",    checked, SIZE_T_TO_ULONG(gc_ext_weak_refs)));
pike.git/src/gc.c:2271: Inside #if defined(PIKE_DEBUG)
   if (gc_ext_weak_refs != orig_ext_weak_refs)    fatal("gc_ext_weak_refs changed from %lu to %lu in cycle check pass.\n",    SIZE_T_TO_ULONG(orig_ext_weak_refs), SIZE_T_TO_ULONG(gc_ext_weak_refs));   #endif       GC_VERBOSE_DO(fprintf(stderr,    "| cycle: %u internal things visited, %u cycle ids used,\n"    "| %u weak references freed, %d more things to free,\n"    "| space for %u gc frames used\n",    cycle_checked, last_cycle, weak_freed, -  obj_count - delayed_freed, max_gc_frames)); +  delayed_freed - obj_count, max_gc_frames));    }       if (gc_ext_weak_refs) {    size_t to_free = gc_ext_weak_refs;   #ifdef PIKE_DEBUG    obj_count = delayed_freed;   #endif    Pike_in_gc = GC_PASS_ZAP_WEAK;    /* Zap weak references from external to internal things. That    * doesn't occur very often; only when something have both
pike.git/src/gc.c:2294:    gc_zap_ext_weak_refs_in_mappings();    gc_zap_ext_weak_refs_in_arrays();    /* Multisets handled as arrays. */    gc_zap_ext_weak_refs_in_objects();    gc_zap_ext_weak_refs_in_programs();    GC_VERBOSE_DO(    fprintf(stderr,    "| zap weak: freed %ld external weak refs, %lu internal still around,\n"    "| %d more things to free\n",    PTRDIFF_T_TO_LONG(to_free - gc_ext_weak_refs), -  SIZE_T_TO_ULONG(gc_ext_weak_refs), obj_count - delayed_freed)); +  SIZE_T_TO_ULONG(gc_ext_weak_refs), delayed_freed - obj_count));    }      #ifdef PIKE_DEBUG    if (gc_debug) {    unsigned n;    size_t i;    struct marker *m;    Pike_in_gc=GC_PASS_MIDDLETOUCH;    n = gc_touch_all_arrays();    n += gc_touch_all_multisets();