pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:44:   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 + #define GC_XREFERENCED 2      struct marker   { -  struct marker *next; -  void *marked; +     INT32 refs; -  + #ifdef DEBUG +  INT32 xrefs; + #endif    INT32 flags; -  +  struct marker *next; +  void *marked;   };      struct marker_chunk   {    struct marker_chunk *next;    struct marker markers[MARKER_CHUNK_SIZE];   };      static struct marker_chunk *chunk=0;   static int markers_left_in_chunk=0;
pike.git/src/gc.c:94:       hashval=((long)a)%hashsize;       for(m=hash[hashval];m;m=m->next)    if(m->marked == a)    return m;       m=new_marker();    m->marked=a;    m->refs=0; + #ifdef DEBUG +  m->xrefs=0; + #endif    m->flags=0;    m->next=hash[hashval];    hash[hashval]=m;       return m;   }      #ifdef DEBUG   static void *check_for =0;   
pike.git/src/gc.c:130:    }   #endif    return getmark(a)->refs++;   }      int gc_is_referenced(void *a)   {    struct marker *m;    m=getmark(a);   #ifdef DEBUG -  if(m->refs > *(INT32 *)a) +  if(m->refs + m->xrefs > *(INT32 *)a)    {    check_for=a; -  +  fatal("Ref counts are wrong (has %d, found %d + %d external)\n", +  *(INT32 *)a, +  m->refs, +  m->xrefs);       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;   }    -  + #ifdef DEBUG + int gc_external_mark(void *a) + { +  struct marker *m; +  if(check_for) +  { +  if(a==check_for) +  { +  gdb_gc_stop_here(a); +  fprintf(stderr,"--External\n"); +  +  return 1; +  } +  return 0; +  } +  m=getmark(a); +  m->xrefs++; +  m->flags|=GC_XREFERENCED; +  gc_is_referenced(a); +  return 0; + } + #endif +    int gc_mark(void *a)   {    struct marker *m;    m=getmark(a);       if(m->flags & GC_REFERENCED)    {    return 0;    }else{    m->flags |= GC_REFERENCED;