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.240 2004/03/15 19:03:48 mast Exp $ + || $Id: gc.c,v 1.241 2004/03/15 22:23:14 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.240 2004/03/15 19:03:48 mast Exp $"); + RCSID("$Id: gc.c,v 1.241 2004/03/15 22:23:14 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:277:    struct array *a;    struct object *o;    struct program *p;    struct mapping *m;    struct multiset *mu;    struct pike_type *t;    struct callable *c;       if (inblock) *inblock = 0;    -  a=&empty_array; -  do -  { +  for (a = first_array; a; a = a->next) {    if(a==(struct array *)something) return T_ARRAY; -  a=a->next; -  }while(a!=&empty_array); +  }       for(o=first_object;o;o=o->next) {    if(o==(struct object *)something)    return T_OBJECT;    if (o->storage && o->prog &&    (char *) something >= o->storage &&    (char *) something < o->storage + o->prog->storage_needed) {    if (inblock) *inblock = (void *) o;    return T_STORAGE;    }
pike.git/src/gc.c:2189: Inside #if defined(PIKE_DEBUG)
   gc_fatal(x, 1, "Doing cycle check in externally referenced thing "    "missed in mark pass.\n");    if (weak && gc_rec_last == &rec_list)    gc_fatal(x, 1, "weak is %d when on top of stack.\n", weak);    if (gc_debug > 1) {    struct array *a;    struct object *o;    struct program *p;    struct mapping *m;    struct multiset *l; -  for(a = gc_internal_array; a != &empty_array; a = a->next) +  for(a = gc_internal_array; a; a = a->next)    if(a == (struct array *) x) goto on_gc_internal_lists;    for(o = gc_internal_object; o; o = o->next)    if(o == (struct object *) x) goto on_gc_internal_lists;    for(p = gc_internal_program; p; p = p->next)    if(p == (struct program *) x) goto on_gc_internal_lists;    for(m = gc_internal_mapping; m; m = m->next)    if(m == (struct mapping *) x) goto on_gc_internal_lists;    for(l = gc_internal_multiset; l; l = l->next)    if(l == (struct multiset *) x) goto on_gc_internal_lists;    gc_fatal(x, 0, "gc_cycle_check() called for thing not on gc_internal lists.\n");
pike.git/src/gc.c:2787:       GC_VERBOSE_DO(fprintf(stderr, "| check: %u references in %d things, "    "counted %"PRINTSIZET"u weak refs\n",    checked, num_objects, gc_ext_weak_refs));       Pike_in_gc=GC_PASS_MARK;       /* Anything after and including gc_internal_* in the linked lists    * are considered to lack external references. The mark pass move    * externally referenced things in front of these pointers. */ -  gc_internal_array = empty_array.next; +  gc_internal_array = first_array;    gc_internal_multiset = first_multiset;    gc_internal_mapping = first_mapping;    gc_internal_program = first_program;    gc_internal_object = first_object;       /* Next we mark anything with external references. Note that we can    * follow the same reference several times, e.g. with shared mapping    * data blocks. */    ACCEPT_UNFINISHED_TYPE_FIELDS {    gc_mark_all_arrays();
pike.git/src/gc.c:2939: Inside #if defined(PIKE_DEBUG)
   Pike_in_gc=GC_PASS_FREE;   #ifdef PIKE_DEBUG    weak_freed = 0;    obj_count = num_objects;   #endif       /* Now we free the unused stuff. The extra refs to gc_internal_*    * added above are removed just before the calls so we'll get the    * correct relative positions in them. */    unreferenced = 0; -  if (gc_internal_array != &weak_empty_array) +  if (gc_internal_array)    unreferenced += gc_free_all_unreferenced_arrays();    if (gc_internal_multiset)    unreferenced += gc_free_all_unreferenced_multisets();    if (gc_internal_mapping)    unreferenced += gc_free_all_unreferenced_mappings();    if (gc_internal_object)    unreferenced += gc_free_all_unreferenced_objects();    /* Note: gc_free_all_unreferenced_objects needs to have the programs    * around to handle the free (even when they aren't live). So it's    * necessary to free the objects before the programs. */