Branch: Tag:

2001-12-10

2001-12-10 02:08:17 by Martin Stjernholm <mast@lysator.liu.se>

Multiset implementation using rbtree. --with-new-multisets required to
enable it. There's still no glue to use most of the new features, except
that the iterator (and foreach) works without locking the multiset index,
and that multiset data blocks use copy-on-write (just like mappings).

Rev: src/acconfig.h:1.94
Rev: src/builtin.cmod:1.71
Rev: src/builtin_functions.c:1.416
Rev: src/configure.in:1.562
Rev: src/docode.c:1.137
Rev: src/encode.c:1.133
Rev: src/gc.c:1.178
Rev: src/interpret.c:1.253
Rev: src/iterators.cmod:1.15
Rev: src/main.c:1.138
Rev: src/multiset.c:1.40
Rev: src/multiset.h:1.20
Rev: src/opcodes.c:1.117
Rev: src/operators.c:1.143
Rev: src/pike_types.c:1.183

30:      #include "block_alloc.h"    - RCSID("$Id: gc.c,v 1.177 2001/09/24 14:36:51 grubba Exp $"); + RCSID("$Id: gc.c,v 1.178 2001/12/10 02:08:14 mast Exp $");      /* Run garbage collect approximately every time    * 20 percent of all arrays, objects and programs is
302:    for(mu=first_multiset;mu;mu=mu->next)    if(mu==(struct multiset *)something)    return T_MULTISET; + #ifdef PIKE_NEW_MULTISETS +  else if (mu->msd == (struct multiset_data *) something) +  return T_MULTISET_DATA; + #endif       if(safe_debug_findstring((struct pike_string *)something))    return T_STRING;
502:    fprintf(stderr, "%*s **In storage of object\n", indent, "");    break;    + #ifdef PIKE_NEW_MULTISETS    case T_MULTISET: -  +  descblock = ((struct multiset *) memblock)->msd; +  /* FALL THROUGH */ +  +  case T_MULTISET_DATA: { +  struct multiset_data *msd = (struct multiset_data *) descblock; +  union msnode *node = low_multiset_first (msd); +  struct svalue ind; +  int indval = msd->flags & MULTISET_INDVAL; +  for (; node; node = low_multiset_next (node)) { +  if (&node->i.ind == (struct svalue *) location) { +  fprintf (stderr, "%*s **In index ", indent, ""); +  print_svalue (stderr, low_use_multiset_index (node, ind)); +  fputc ('\n', stderr); +  break; +  } +  else if (indval && &node->iv.val == (struct svalue *) location) { +  fprintf(stderr, "%*s **In value with index ", indent, ""); +  print_svalue(stderr, low_use_multiset_index (node, ind)); +  fputc('\n', stderr); +  break; +  } +  } +  break; +  } +  + #else /* PIKE_NEW_MULTISETS */ +  case T_MULTISET:    descblock = ((struct multiset *) memblock)->ind;    /* FALL THROUGH */ -  + #endif +     case T_ARRAY:    {    struct array *a=(struct array *)descblock;
874:    break;    }    + #ifdef PIKE_NEW_MULTISETS +  case T_MULTISET_DATA: { +  struct multiset *l; +  for (l = first_multiset; l; l = l->next) { +  if (l->msd == (struct multiset_data *) a) { +  fprintf(stderr, "%*s**Describing multiset for this data block:\n", indent, ""); +  debug_dump_multiset(l); +  } +  } +  break; +  } +     case T_MULTISET: -  +  fprintf(stderr, "%*s**Describing multiset:\n", indent, ""); +  debug_dump_multiset((struct multiset *) a); +  fprintf(stderr, "%*s**Describing multiset data block:\n", indent, ""); +  describe_something(((struct multiset *) a)->msd, T_MULTISET_DATA, +  indent + 2, -1, flags, 0); +  break; +  + #else /* PIKE_NEW_MULTISETS */ +  case T_MULTISET:    fprintf(stderr,"%*s**Describing array of multiset:\n",indent,"");    debug_dump_array(((struct multiset *)a)->ind);    break; -  + #endif       case T_ARRAY:    fprintf(stderr,"%*s**Describing array:\n",indent,"");
2529:    * things. */    gc_zap_ext_weak_refs_in_mappings();    gc_zap_ext_weak_refs_in_arrays(); + #ifdef PIKE_NEW_MULTISETS +  gc_zap_ext_weak_refs_in_multisets(); + #else    /* Multisets handled as arrays. */ -  + #endif    gc_zap_ext_weak_refs_in_objects();    gc_zap_ext_weak_refs_in_programs();    GC_VERBOSE_DO(