pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:8: Inside #if defined(GC2)
     #ifdef GC2      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"   #include "program.h" + #include "stralloc.h"      #include "gc.h"   #include "main.h"      /* Run garbage collect approximate every time we have    * 20 percent of all arrays, objects and programs is    * garbage.    */      #define GC_CONST 20
pike.git/src/gc.c:30:   #define MULTIPLIER 0.9   #define MARKER_CHUNK_SIZE 1023      INT32 num_objects;   INT32 num_allocs;   INT32 alloc_threshold = MIN_ALLOC_THRESHOLD;      static double objects_alloced;   static double objects_freed;    + struct callback_list gc_callbacks; +  + struct callback *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      struct marker   {    struct marker *next;    void *marked;    INT32 refs;    INT32 flags;   };   
pike.git/src/gc.c:97: Inside #if defined(DEBUG)
     #ifdef DEBUG   static void *check_for =0;      static void gdb_gc_stop_here(void *a)   {    fprintf(stderr,"One ref found.\n");   }   #endif    - void gc_check(void *a) + INT32 gc_check(void *a)   {   #ifdef DEBUG    if(check_for)    {    if(check_for == a)    {    gdb_gc_stop_here(a);    } -  return; +  return 0;    }   #endif -  getmark(a)->refs++; +  return getmark(a)->refs++;   }      int gc_is_referenced(void *a)   {    struct marker *m;    m=getmark(a);   #ifdef DEBUG    if(m->refs > *(INT32 *)a)    {    check_for=a;       gc_check_all_arrays();    gc_check_all_multisets();    gc_check_all_mappings();    gc_check_all_programs();    gc_check_all_objects(); -  +  call_callback(& gc_callbacks, (void *)0);       check_for=0;    fatal("Ref counts are totally wrong!!!\n");    }   #endif    return m->refs < *(INT32 *)a;   }      int gc_mark(void *a)   {
pike.git/src/gc.c:228:    objects_alloced += (double) num_allocs;       objects_freed*=MULTIPLIER;    objects_freed += (double) num_objects;          /* init hash , hashsize will be a prime between num_objects/8 and    * num_objects/4, this will assure that no re-hashing is needed.    */    hashsize=my_log2(num_objects); -  hashsize-=2; +  +  if(!d_flag) hashsize-=2; +     if(hashsize<0) hashsize=0;    hashsize=hashprimes[hashsize];    hash=(struct marker **)xalloc(sizeof(struct marker **)*hashsize);    MEMSET((char *)hash,0,sizeof(struct marker **)*hashsize);    markers_left_in_chunk=0;       gc_check_all_arrays();    gc_check_all_multisets();    gc_check_all_mappings();    gc_check_all_programs();    gc_check_all_objects(); -  +  call_callback(& gc_callbacks, (void *)0);       gc_mark_all_arrays();    gc_mark_all_multisets();    gc_mark_all_mappings();    gc_mark_all_programs();    gc_mark_all_objects();    -  +  if(d_flag) +  gc_mark_all_strings(); +     gc_free_all_unreferenced_arrays();    gc_free_all_unreferenced_multisets();    gc_free_all_unreferenced_mappings();    gc_free_all_unreferenced_programs();    gc_free_all_unreferenced_objects();          /* Free hash table */    free((char *)hash);    while(m=chunk)