pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: gc.c,v 1.252 2004/04/17 23:35:53 mast Exp $ + || $Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $   */      #include "global.h"      struct callback *gc_evaluator_callback=0;      #include "array.h"   #include "multiset.h"   #include "mapping.h"   #include "object.h"
pike.git/src/gc.c:26:   #include "interpret.h"   #include "bignum.h"   #include "pike_threadlib.h"      #include "gc.h"   #include "main.h"   #include <math.h>      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.252 2004/04/17 23:35:53 mast Exp $"); + RCSID("$Id: gc.c,v 1.253 2004/04/18 02:16:05 mast Exp $");      int gc_enabled = 1;      /* These defaults are only guesses and hardly tested at all. Please improve. */   double gc_garbage_ratio_low = 0.2;   double gc_time_ratio = 0.05;   double gc_garbage_ratio_high = 0.5;      /* This slowness factor approximately corresponds to the average over    * the last ten gc rounds. (0.9 == 1 - 1/10) */
pike.git/src/gc.c:314:       for(mu=first_multiset;mu;mu=mu->next)    if(mu==(struct multiset *)something)    return T_MULTISET;    else if (mu->msd == (struct multiset_data *) something)    return T_MULTISET_DATA;       if(safe_debug_findstring((struct pike_string *)something))    return T_STRING;    +  if (pike_type_hash)    for (i = 0; i < pike_type_hash_size; i++)    for (t = pike_type_hash[i]; t; t = t->next)    if (t == (struct pike_type *) something)    return T_TYPE;       for (c = first_callable; c; c = c->next)    if (c == (struct callable *) something)    return T_STRUCT_CALLABLE;       return PIKE_T_UNKNOWN;
pike.git/src/gc.c:1521:    add_ref(m);    if (m->refs == *(INT32 *) a)    m->flags |= GC_NOT_REFERENCED;    return ret;   }      static void cleanup_markers (void)   {   #ifdef DO_PIKE_CLEANUP    size_t e=0; -  struct marker *h; +  +  if (gc_keep_markers) { +  /* Carry over any GC_CLEANUP_FREED flags but reinitialize them +  * otherwise. */ +  for(e=0;e<marker_hash_table_size;e++) { +  struct marker *m; +  for (m = marker_hash_table[e]; m; m = m->next) { +  m->flags &= GC_CLEANUP_FREED; +  m->refs = m->weak_refs = m->xrefs = 0; +  m->saved_refs = -1; +  m->frame = 0; +  } +  } +  return; +  } +     for(e=0;e<marker_hash_table_size;e++)    while(marker_hash_table[e])    remove_marker(marker_hash_table[e]->data);   #endif    exit_marker_hash();   }    -  +    static void init_gc(void)   {   #ifdef PIKE_DEBUG    if (!gc_is_watching) {    /* The marker hash table is left around after a previous gc if    * gc_keep_markers is set. */    if (marker_hash_table) cleanup_markers(); -  +  if (!marker_hash_table)   #endif -  +     low_init_marker_hash(num_objects);    get_marker(rec_list.data); /* Used to simplify fencepost conditions. */   #ifdef PIKE_DEBUG    }   #endif   }    - static void exit_gc(void) + void exit_gc(void)   {    if (gc_evaluator_callback) {    remove_callback(gc_evaluator_callback);    gc_evaluator_callback = NULL;    }    if (!gc_keep_markers)    cleanup_markers();       free_all_gc_frame_blocks();   
pike.git/src/gc.c:1757: 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;   }    + #ifdef DO_PIKE_CLEANUP + void gc_check_zapped (void *a, TYPE_T type, const char *file, int line) + { +  struct marker *m = find_marker (a); +  if (m && (m->flags & GC_CLEANUP_FREED)) +  fprintf (stderr, "Free of leaked %s %p from %s:%d, %d refs remaining\n", +  get_name_of_type (type), a, file, line, *(INT32 *)a - 1); + } + #endif +    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 *)(ptrdiff_t) -1;    really_free_gc_frame(l);   #ifdef GC_VERBOSE    num_gc_frames--;   #endif