Branch: Tag:

2000-07-18

2000-07-18 05:48:20 by Martin Stjernholm <mast@lysator.liu.se>

Fixed tricky gc problems by implementing a gc-tailored call stack that can
be rotated. That also made the whole thing quite a bit less hairy.

Rev: src/array.c:1.78
Rev: src/array.h:1.21
Rev: src/gc.c:1.107
Rev: src/gc.h:1.55
Rev: src/mapping.c:1.93
Rev: src/mapping.h:1.27
Rev: src/multiset.c:1.25
Rev: src/multiset.h:1.13
Rev: src/object.c:1.136
Rev: src/object.h:1.49
Rev: src/program.c:1.251
Rev: src/program.h:1.96
Rev: src/svalue.c:1.84
Rev: src/testsuite.in:1.314

5:   \*/   /**/   #include "global.h" - RCSID("$Id: mapping.c,v 1.92 2000/07/11 03:45:10 mast Exp $"); + RCSID("$Id: mapping.c,v 1.93 2000/07/18 05:48:20 mast Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"
846: Inside #if defined(PIKE_DEBUG)
   fatal("Zero refs in mapping->data\n");    if(d_flag>1) check_mapping(m);    debug_malloc_touch(m); -  if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_FREE && +  if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_ZAP_WEAK &&    Pike_in_gc != GC_PASS_MARK)    fatal("check_mapping_for_destruct called in wrong pass inside gc.\n");   #endif
1910:    }   }    - void low_gc_cycle_check_mapping(struct mapping *m) + void real_gc_cycle_check_mapping(struct mapping *m, int weak)   { -  +  GC_CYCLE_ENTER(m, weak) {   #ifdef PIKE_DEBUG    if(m->data->refs <=0)    fatal("Zero refs in mapping->data\n");
1936:    }    }    } - } -  - void real_gc_cycle_check_mapping(struct mapping *m) - { -  GC_CYCLE_ENTER(m, 0) { -  low_gc_cycle_check_mapping(m); +     } GC_CYCLE_LEAVE;   }    - void real_gc_cycle_check_mapping_weak(struct mapping *m) - { -  GC_CYCLE_ENTER(m, 1) { -  low_gc_cycle_check_mapping(m); -  } GC_CYCLE_LEAVE; - } -  +    static void gc_check_mapping(struct mapping *m)   {    INT32 e;
2049:   {    struct mapping *m;    for (m = gc_internal_mapping; m; m = m->next) { -  real_gc_cycle_check_mapping(m); -  run_lifo_queue(&gc_mark_queue); +  real_gc_cycle_check_mapping(m, 0); +  gc_cycle_run_queue();    }   }    - void gc_free_all_unreferenced_mappings(void) + void gc_zap_ext_weak_refs_in_mappings(void)   { -  INT32 e; -  struct keypair *k,**prev; -  struct mapping *m,*next; -  struct mapping_data *md; -  -  if (gc_ext_weak_refs) { -  /* Have to go through all marked things if we got external weak -  * references to otherwise unreferenced things, so the mark -  * functions can free those references. */ +     gc_mark_mapping_pos = first_mapping;    while (gc_mark_mapping_pos != gc_internal_mapping && gc_ext_weak_refs) {    struct mapping *m = gc_mark_mapping_pos;
2074:    discard_queue(&gc_mark_queue);    }    + void gc_free_all_unreferenced_mappings(void) + { +  INT32 e; +  struct keypair *k,**prev; +  struct mapping *m,*next; +  struct mapping_data *md; +     for(m=gc_internal_mapping;m;m=next)    {    if(gc_do_free(m))