pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #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"   #include "svalue.h"   #include "array.h"   #include "pike_macros.h"   #include "error.h"   #include "pike_memory.h"   #include "dynamic_buffer.h"   #include "interpret.h"
pike.git/src/mapping.c:839:    INT32 e;    struct keypair *k, **prev;    TYPE_FIELD ind_types, val_types;    struct mapping_data *md=m->data;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    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       /* no is_eq -> no locking */       if(!md->size) return;       if((md->ind_types | md->val_types) & (BIT_OBJECT | BIT_FUNCTION))    {
pike.git/src/mapping.c:1903: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    fatal("Looks like check_mapping_for_destruct "    "didn't do its job properly.\n");   #endif    }    }    }    }   }    - 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");   #endif       if((m->data->ind_types | m->data->val_types) & BIT_COMPLEX)    {    INT32 e;    struct keypair *k;   
pike.git/src/mapping.c:1929:    {    if (gc_cycle_check_svalues(&k->ind, 1) ||    gc_cycle_check_svalues(&k->val, 1)) {   #ifdef PIKE_DEBUG    fatal("Looks like check_mapping_for_destruct "    "didn't do its job properly.\n");   #endif    }    }    } - } -  - 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;    struct keypair *k;       if((m->data->ind_types | m->data->val_types) & BIT_COMPLEX)    {    if(debug_gc_check(m->data, T_MAPPING, m)) return;       if (m->flags & MAPPING_FLAG_WEAK) {
pike.git/src/mapping.c:2042:    /* Done in gc_mark_mapping_as_referenced() otherwise (and it has    * to be done there). */    check_mapping_for_destruct(m);    }   }      void gc_cycle_check_all_mappings(void)   {    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;    gc_mark_mapping_pos = m->next;    gc_mark_mapping_as_referenced(m);    }    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))    {    /* Got an extra ref from gc_cycle_pop(). */    md = m->data;    /* Protect against unlink_mapping_data() recursing too far. */    m->data=&empty_data;    m->data->refs++;