On Mon, Apr 29, 2002 at 01:41:56PM -0400, Mike Lambert wrote:
> - Make an array of buffer data, in order of insertion into the hashtable.
> set pmc_pointer and buffer_ptr and let the GC rip through it.
> - The hashtable itself just uses indices into this array. Each
> linked-list node would be a PMC header, that follows the logic mentioned
> above, where the linked-list node data would simply be an integer lookup
> into the array of buffer data.

A bucket needs at least:
  - key : STRING*
  - value : PMC* or maybe a discriminated union
  - next : integer index

If you use PMCs for buckets, then you really only have room for two of
those things (in ->data and ->cache). You could overload another PMC
field, choosing from:

  (gdb) ptype PMC
  type = struct PMC {
      VTABLE *vtable;
      INTVAL flags;
      DPOINTER *data;
      UnionVal cache;
      SYNC *synchronize;
      PMC *next_for_GC;
  }

and the only available option there is vtable (or synchronized? I'm
not sure how that is used/will be used.) And overloading vtable is not
only ugly, it's also dangerous -- you have to avoid setting the custom
mark bit in flags, or it'll be accessed, and who knows what else we'll
throw in next that might get called unexpectedly (stringify?).

This is why I was using a big raw Buffer for an array of all of the
buckets, and handling allocation/deallocation myself. Cleaner, more
space-efficient, and it doesn't slow down regular garbage collection.

Reply via email to