pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:14:   #include "object.h"   #include "program.h"   #include "stralloc.h"   #include "stuff.h"   #include "error.h"   #include "pike_memory.h"   #include "pike_macros.h"   #include "pike_types.h"   #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.45 2000/02/01 06:24:40 hubbe Exp $"); + RCSID("$Id: gc.c,v 1.46 2000/02/02 00:38:27 hubbe Exp $");      /* Run garbage collect approximate every time we have    * 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:52:      struct callback_list gc_callbacks;      struct callback *debug_add_gc_callback(callback_func call,    void *arg,    callback_func free_func)   {    return add_to_callback(&gc_callbacks, call, arg, free_func);   }    - #define GC_REFERENCED 1 - #define GC_XREFERENCED 2 +     - struct marker - { -  INT32 refs; - #ifdef PIKE_DEBUG -  INT32 xrefs; - #endif -  INT32 flags; -  struct marker *next; -  void *data; - }; -  +    #undef INIT_BLOCK   #ifdef PIKE_DEBUG   #define INIT_BLOCK(X) (X)->flags=(X)->refs=(X)->xrefs=0   #else   #define INIT_BLOCK(X) (X)->flags=(X)->refs=0   #endif      PTR_HASH_ALLOC(marker,MARKER_CHUNK_SIZE)      #ifdef PIKE_DEBUG
pike.git/src/gc.c:435: Inside #if 0
      if(!d_flag) tmp3-=2;    if(tmp3<0) tmp3=0;    if(tmp3>=(long)NELEM(hashprimes)) tmp3=NELEM(hashprimes)-1;    hashsize=hashprimes[tmp3];       hash=(struct marker **)xalloc(sizeof(struct marker **)*hashsize);    MEMSET((char *)hash,0,sizeof(struct marker **)*hashsize);    markers_left_in_chunk=0;   #else + /* init_marker_hash(num_objects*8); */    init_marker_hash();   #endif   }      static void exit_gc(void)   {   #if 0    struct marker_chunk *m;    /* Free hash table */    free((char *)hash);
pike.git/src/gc.c:498: Inside #if defined(PIKE_DEBUG)
   call_callback(& gc_callbacks, (void *)0);       found_where="";    check_for=0;       if(!in_gc)    exit_gc();   }   #endif    - int gc_is_referenced(void *a) + #ifdef PIKE_DEBUG +  + int debug_gc_is_referenced(void *a)   {    struct marker *m;    m=get_marker(a); - #ifdef PIKE_DEBUG +     if(m->refs + m->xrefs > *(INT32 *)a ||    (!(m->refs < *(INT32 *)a) && m->xrefs) )    {    INT32 refs=m->refs;    INT32 xrefs=m->xrefs;    TYPE_T t=attempt_to_identify(a);       fprintf(stderr,"**Something has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)refs,(long)xrefs);    describe_something(a, t, 1);       locate_references(a);       fatal("Ref counts are wrong (has %d, found %d + %d external)\n",    *(INT32 *)a,    refs,    xrefs);    } - #endif +     return m->refs < *(INT32 *)a;   } -  + #endif      #ifdef PIKE_DEBUG   int gc_external_mark(void *a)   {    struct marker *m;    if(check_for)    {    if(a==check_for)    {    char *tmp=found_where;
pike.git/src/gc.c:563:       if(m->flags & GC_REFERENCED)    {    return 0;    }else{    m->flags |= GC_REFERENCED;    return 1;    }   }    - int gc_do_free(void *a) + #ifdef PIKE_DEBUG + int debug_gc_do_free(void *a)   {    struct marker *m;    m=get_marker(a); - #ifdef PIKE_DEBUG +     if( !(m->flags & GC_REFERENCED) && m->flags & GC_XREFERENCED )    {    INT32 refs=m->refs;    INT32 xrefs=m->xrefs;    TYPE_T t=attempt_to_identify(a);       fprintf(stderr,"**gc_is_referenced failed, object has %ld references, while gc() found %ld + %ld external.\n",(long)*(INT32 *)a,(long)refs,(long)xrefs);    describe_something(a, t, 1);       locate_references(a);       fatal("GC failed object (has %d, found %d + %d external)\n",    *(INT32 *)a,    refs,    xrefs);    } - #endif +     return !(m->flags & GC_REFERENCED);   } -  + #endif      void do_gc(void)   {    double tmp;    INT32 tmp2;    double multiplier;       if(in_gc) return;    in_gc=1;   
pike.git/src/gc.c:692: Inside #if defined(ALWAYS_GC)
     #ifdef ALWAYS_GC    ADD_GC_CALLBACK();   #else    if(d_flag > 3) ADD_GC_CALLBACK();   #endif    in_gc=0;   }       + void f__gc_status(INT32 args) + { +  pop_n_elems(args); +  +  push_constant_text("num_objects"); +  push_int(num_objects); +  +  push_constant_text("num_allocs"); +  push_int(num_allocs); +  +  push_constant_text("alloc_threshold"); +  push_int(alloc_threshold); +  +  push_constant_text("objects_alloced"); +  push_int(objects_alloced); +  +  push_constant_text("objects_freed"); +  push_int(objects_freed); +  +  push_constant_text("last_gc"); +  push_int(last_gc); +  +  push_constant_text("projected_garbage"); +  push_float(objects_freed * (double) num_allocs / (double) alloc_threshold); +  +  f_aggregate_mapping(14); + } +