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.116 2000/08/11 13:08:02 grubba Exp $"); + RCSID("$Id: gc.c,v 1.117 2000/08/11 13:17:13 grubba 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:86: Inside #if defined(GC_VERBOSE) && !defined(PIKE_DEBUG)
     #if defined(GC_VERBOSE) && !defined(PIKE_DEBUG)   #undef GC_VERBOSE   #endif   #ifdef GC_VERBOSE   #define GC_VERBOSE_DO(X) X   #else   #define GC_VERBOSE_DO(X)   #endif    + /* Kludge to avoid some loss of precision warnings. */ + #ifdef __ECL + static inline long CAST_TO_LONG(ptrdiff_t val) + { +  return DO_NOT_WARN((long)val); + } + #else /* !__ECL */ + #define CAST_TO_LONG(val) ((long)(val)) + #endif /* __ECL */ +    INT32 num_objects = 1; /* Account for empty_array. */   INT32 num_allocs =0; - INT32 alloc_threshold = MIN_ALLOC_THRESHOLD; + ptrdiff_t alloc_threshold = MIN_ALLOC_THRESHOLD;   PMOD_EXPORT int Pike_in_gc = 0;   struct pike_queue gc_mark_queue;   time_t last_gc;      struct gc_frame   {    struct gc_frame *back; /* Previous stack frame. */    void *data;    union {    struct { /* Pop frame. */
pike.git/src/gc.c:391:    sizeof(struct identifier);    fprintf(stderr,"%*s **In p->identifiers[%ld] (%s)\n",indent,"",    DO_NOT_WARN((long)e),    p->identifiers[e].name ? p->identifiers[e].name->str : "no name");    break;    }      #define FOO(NTYP,TYP,NAME) \    if(location == (void *)&p->NAME) fprintf(stderr,"%*s **In p->" #NAME "\n",indent,""); \    if(ptr >= (char *)p->NAME && ptr<(char*)(p->NAME+p->PIKE_CONCAT(num_,NAME))) \ -  fprintf(stderr,"%*s **In p->" #NAME "[%ld]\n",indent,"",((long)ptr - (long)(p->NAME)) / sizeof(TYP)); +  fprintf(stderr,"%*s **In p->" #NAME "[%ld]\n",indent,"", \ +  CAST_TO_LONG(((char *)ptr - (char *)(p->NAME)) / sizeof(TYP)));   #include "program_areas.h"       break;    }       case T_OBJECT:    {    struct object *o=(struct object *)memblock;    struct program *p;   
pike.git/src/gc.c:453:       }    }    break;    }       case T_ARRAY:    {    struct array *a=(struct array *)memblock;    struct svalue *s=(struct svalue *)location; -  fprintf(stderr,"%*s **In index %ld\n",indent,"",(long)(s-ITEM(a))); +  fprintf(stderr,"%*s **In index %ld\n",indent,"", +  DO_NOT_WARN((long)(s-ITEM(a))));    break;    }    }      #ifdef DEBUG_MALLOC    dmalloc_describe_location(memblock, location, indent);   #endif   }      static void describe_gc_frame(struct gc_frame *l)
pike.git/src/gc.c:713:    case T_MAPPING:    fprintf(stderr,"%*s**Describing mapping:\n",indent,"");    debug_dump_mapping((struct mapping *)a);    fprintf(stderr,"%*s**Describing mapping data block:\n",indent,"");    describe_something( ((struct mapping *)a)->data, -2, indent+2,depth-1,flags);    break;       case T_STRING:    {    struct pike_string *s=(struct pike_string *)a; -  fprintf(stderr,"%*s**String length is %d:\n",indent,"",s->len); +  fprintf(stderr, "%*s**String length is %ld:\n", indent, "", +  DO_NOT_WARN((long)s->len));    if(s->len>77)    {    fprintf(stderr,"%*s** \"%60s ...\"\n",indent,"",s->str);    }else{    fprintf(stderr,"%*s** \"%s\"\n",indent,"",s->str);    }    break;    }    }   }
pike.git/src/gc.c:747:    /* Disable debug, this may help reduce recursion bugs */    tmp=d_flag;    d_flag=0;      #ifdef DEBUG_MALLOC    if (((int)a) == 0x55555555) {    fprintf(stderr,"%*s**Location: %p Type: %s Zapped pointer\n",indent,"",a,    get_name_of_type(t));    } else   #endif /* DEBUG_MALLOC */ -  if (((int)a) & 3) { +  if (((ptrdiff_t)a) & 3) {    fprintf(stderr,"%*s**Location: %p Type: %s Misaligned address\n",indent,"",a,    get_name_of_type(t));    } else {    fprintf(stderr,"%*s**Location: %p Type: %s Refs: %d\n",indent,"",a,    get_name_of_type(t),    *(INT32 *)a);    }      #ifdef DEBUG_MALLOC    if(!(flags & DESCRIBE_NO_DMALLOC))
pike.git/src/gc.c:2127:    tmp=tmp * GC_CONST/100.0 * (objects_alloced+1.0) / (objects_freed+1.0);       if(alloc_threshold + num_allocs <= tmp)    tmp = (double)(alloc_threshold + num_allocs);       if(tmp < MIN_ALLOC_THRESHOLD)    tmp = (double)MIN_ALLOC_THRESHOLD;    if(tmp > MAX_ALLOC_THRESHOLD)    tmp = (double)MAX_ALLOC_THRESHOLD;    -  alloc_threshold = (int)tmp; +  alloc_threshold = (ptrdiff_t)tmp;       num_allocs=0;      #ifdef PIKE_DEBUG    if(GC_VERBOSE_DO(1 ||) t_flag)    {   #ifdef HAVE_GETHRTIME    fprintf(stderr,"done (freed %ld of %ld objects), %ld ms.\n",    (long)objs,(long)objs + num_objects,    (long)((gethrtime() - gcstarttime)/1000000));
pike.git/src/gc.c:2166:   {    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_int32(alloc_threshold);       push_constant_text("objects_alloced"); -  push_int(objects_alloced); +  push_int32(objects_alloced);       push_constant_text("objects_freed"); -  push_int(objects_freed); +  push_int32(objects_freed);       push_constant_text("last_gc"); -  push_int(last_gc); +  push_int32(last_gc);       push_constant_text("projected_garbage");    push_float(objects_freed * (double) num_allocs / (double) alloc_threshold);       f_aggregate_mapping(14);   }