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.55 2000/04/19 21:59:37 mast Exp $"); + RCSID("$Id: gc.c,v 1.56 2000/04/22 13:20:39 mast 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:309:   {    int ret;    found_in=data;    found_in_type=t;    ret=gc_check(x);    found_in_type=T_UNKNOWN;    found_in=0;    return ret;   }    + int debug_gc_check_nongarbed(void *x, TYPE_T t, void *data) + { +  int ret; +  found_in=data; +  found_in_type=t; +  ret=gc_check_nongarbed(x); +  found_in_type=T_UNKNOWN; +  found_in=0; +  return ret; + } +    void low_describe_something(void *a, int t, int dm)   {    struct program *p=(struct program *)a;       switch(t)    {    case T_FUNCTION:    if(attempt_to_identify(a) != T_OBJECT)    {    fprintf(stderr,"**Builtin function!\n");
pike.git/src/gc.c:516: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG    if(check_for)    {    if(check_for == a)    {    gdb_gc_stop_here(a);    }    return 0;    } +  if (m->flags & GC_NONGARBED) +  fatal("Using gc_check() and gc_check_nongarbed() on the same object.\n");   #endif    m->flags |= GC_CHECKED;       return add_ref(m);   }    -  + INT32 real_gc_check_nongarbed(void *a) + { +  struct marker *m = get_marker(a); + #ifdef PIKE_DEBUG +  if (m->flags & GC_CHECKED) +  fatal("Using gc_check_nongarbed() and gc_check() on the same object.\n"); + #endif +  if (m->flags & GC_NONGARBED) +  return 1; +  else { +  m->flags |= GC_NONGARBED; +  return 0; +  } + } +    static void init_gc(void)   {   #if 0    INT32 tmp3;    /* init hash , hashsize will be a prime between num_objects/8 and    * num_objects/4, this will assure that no re-hashing is needed.    */    tmp3=my_log2(num_objects);       if(!d_flag) tmp3-=2;
pike.git/src/gc.c:707:   }   #endif      void do_gc(void)   {    double tmp;    INT32 tmp2;    double multiplier;       if(Pike_in_gc) return; +  +  init_gc();    Pike_in_gc=1;       /* Make sure there will be no callback to this while we're in the gc. */    destruct_objects_to_destruct();       if(gc_evaluator_callback)    {    remove_callback(gc_evaluator_callback);    gc_evaluator_callback=0;    }
pike.git/src/gc.c:739:    last_gc=TIME(0);       multiplier=pow(MULTIPLIER, (double) num_allocs / (double) alloc_threshold);    objects_alloced*=multiplier;    objects_alloced += (double) num_allocs;       objects_freed*=multiplier;    objects_freed += (double) num_objects;       -  init_gc(); -  +     /* First we count internal references */    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);       /* Next we mark anything with external references */    gc_mark_all_arrays();
pike.git/src/gc.c:772:    gc_mark_all_strings();       /* Now we free the unused stuff */    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();       exit_gc(); +  Pike_in_gc=0;       destruct_objects_to_destruct();       objects_freed -= (double) num_objects;       tmp=(double)num_objects;    tmp=tmp * GC_CONST/100.0 * (objects_alloced+1.0) / (objects_freed+1.0);       if((int)tmp < alloc_threshold + num_allocs)    {
pike.git/src/gc.c:804: Inside #if defined(PIKE_DEBUG)
   if(t_flag)    fprintf(stderr,"done (freed %ld of %ld objects).\n",    (long)(tmp2-num_objects),(long)tmp2);   #endif      #ifdef ALWAYS_GC    ADD_GC_CALLBACK();   #else    if(d_flag > 3) ADD_GC_CALLBACK();   #endif -  Pike_in_gc=0; +    }         void f__gc_status(INT32 args)   {    pop_n_elems(args);       push_constant_text("num_objects");    push_int(num_objects);