pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:22:   #include "time_stuff.h"   #include "constants.h"   #include "interpret.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.108 2000/07/18 06:30:57 mast Exp $"); + RCSID("$Id: gc.c,v 1.109 2000/07/18 06:53:58 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:1101: Inside #if defined(PIKE_DEBUG)
   m=get_marker(a);    m->xrefs++;    m->flags|=GC_XREFERENCED;    if(Pike_in_gc == GC_PASS_CHECK &&    (m->refs + m->xrefs > *(INT32 *)a ||    (m->saved_refs != -1 && m->saved_refs != *(INT32 *)a)))    gc_fatal(a, 1, "Ref counts are wrong.\n");    return 0;   }    + void debug_really_free_gc_frame(struct gc_frame *l) + { +  if (l->frameflags & GC_LINK_FREED) +  gc_fatal(l->data, 0, "Freeing freed gc_frame.\n"); +  l->frameflags |= GC_LINK_FREED; +  l->back = PREV(l) = NEXT(l) = (struct gc_frame *) -1; +  really_free_gc_frame(l); + #ifdef GC_VERBOSE +  num_gc_frames--; + #endif + } +  + #else /* PIKE_DEBUG */ +  + #define debug_really_free_gc_frame(l) really_free_gc_frame(l) +  + #endif /* PIKE_DEBUG */ +    int gc_do_weak_free(void *a)   {    struct marker *m;    -  + #ifdef PIKE_DEBUG    if (!a) fatal("Got null pointer.\n");    if (Pike_in_gc != GC_PASS_MARK && Pike_in_gc != GC_PASS_CYCLE &&    Pike_in_gc != GC_PASS_ZAP_WEAK)    fatal("gc_do_weak_free() called in invalid gc pass.\n");    if (gc_debug) {    if (!(m = find_marker(a)))    gc_fatal(a, 0, "gc_do_weak_free() got unknown object.\n");    }    else m = get_marker(a);    debug_malloc_touch(a);       if (m->weak_refs > m->refs)    gc_fatal(a, 0, "More weak references than internal references.\n"); -  + #else +  m = get_marker(a); + #endif       if (Pike_in_gc != GC_PASS_ZAP_WEAK) {    if (m->weak_refs == -1) {    gc_ext_weak_refs--;    return 1;    }    }    else    if (!(m->flags & GC_MARKED)) { -  + #ifdef PIKE_DEBUG    if (m->weak_refs <= 0)    gc_fatal(a, 0, "Too many weak refs cleared to thing with external "    "weak refs.\n"); -  + #endif    m->weak_refs--;    gc_ext_weak_refs--;    return 1;    }    return 0;   }    - void debug_really_free_gc_frame(struct gc_frame *l) - { -  if (l->frameflags & GC_LINK_FREED) -  gc_fatal(l->data, 0, "Freeing freed gc_frame.\n"); -  l->frameflags |= GC_LINK_FREED; -  l->back = PREV(l) = NEXT(l) = (struct gc_frame *) -1; -  really_free_gc_frame(l); - #ifdef GC_VERBOSE -  num_gc_frames--; - #endif - } -  - #else /* PIKE_DEBUG */ -  - #define debug_really_free_gc_frame(l) really_free_gc_frame(l) -  - #endif /* PIKE_DEBUG */ -  +    int gc_mark(void *a)   {    struct marker *m = get_marker(debug_malloc_pass(a));      #ifdef PIKE_DEBUG    if (!a) fatal("Got null pointer.\n");    if (Pike_in_gc != GC_PASS_MARK && Pike_in_gc != GC_PASS_ZAP_WEAK)    fatal("gc mark attempted in invalid pass.\n");    if (!*(INT32 *) a)    gc_fatal(a, 0, "Marked a thing without refs.\n");
pike.git/src/gc.c:2060:    gc_fatal(o, 0, "GC destructed parent prematurely.\n");   #endif    GC_VERBOSE_DO(fprintf(stderr, "| Killing %p with %d refs\n",    o, o->refs));    destruct(o);    free_object(o);    gc_free_extra_ref(o);   #ifdef PIKE_DEBUG    destroy_count++;   #endif -  really_free_gc_frame(kill_list); +  debug_really_free_gc_frame(kill_list);    kill_list = next;    }       GC_VERBOSE_DO(fprintf(stderr, "| kill: %u objects killed, %d things really freed\n",    destroy_count, pre_kill_objs - num_objects));       Pike_in_gc=GC_PASS_DESTRUCT;    /* Destruct objects on the destruct queue. */    GC_VERBOSE_DO(obj_count = num_objects);    destruct_objects_to_destruct();