Fix from Ken Raeburn <raeburn@raeburn.org>:
authorJim Blandy <jimb@red-bean.com>
Tue, 15 Jun 1999 14:00:11 +0000 (14:00 +0000)
committerJim Blandy <jimb@red-bean.com>
Tue, 15 Jun 1999 14:00:11 +0000 (14:00 +0000)
* weaks.c (scm_make_weak_vector): Add another extra slot before
vector contents, to be used only during garbage collection.
* weaks.h (SCM_WVECT_GC_CHAIN): New macro to access it.
* gc.c (scm_weak_vectors): Now a SCM instead of a SCM*, and now
static.
(scm_weak_size, scm_n_weak): Deleted.
(scm_igc): Use SCM_WVECT_GC_CHAIN to build up a chain of weak
vectors without allocating new storage during GC, using
scm_weak_vectors as the head of the chain.
(scm_mark_weak_vector_spines): Walk SCM_WVECT_GC_CHAIN chain
instead of stepping through an array.
(scm_gc_sweep): Update offset used to find start of weak vector to
free it.
(scm_init_storage): Set scm_weak_vectors to EOL.

libguile/weaks.c
libguile/weaks.h

index b005acc..aaf246d 100644 (file)
@@ -58,11 +58,12 @@ scm_make_weak_vector (k, fill)
      SCM fill;
 {
   SCM v;
-  v = scm_make_vector (scm_sum (k, SCM_MAKINUM (1)), fill);
+  v = scm_make_vector (scm_sum (k, SCM_MAKINUM (2)), fill);
   SCM_DEFER_INTS;
   SCM_SETLENGTH(v, SCM_INUM (k), scm_tc7_wvect);
-  SCM_VELTS(v)[0] = (SCM)0;
-  SCM_SETVELTS(v, SCM_VELTS(v) + 1);
+  SCM_VELTS(v)[0] = SCM_EOL;
+  SCM_VELTS(v)[1] = (SCM)0;
+  SCM_SETVELTS(v, SCM_VELTS(v) + 2);
   SCM_ALLOW_INTS;
   return v;
 }
index f9130ae..cedfbc6 100644 (file)
@@ -54,6 +54,7 @@
 #define SCM_IS_WHVEC_V(X) (SCM_VELTS(X)[-1] == 2)
 #define SCM_IS_WHVEC_B(X) (SCM_VELTS(X)[-1] == 3)
 #define SCM_IS_WHVEC_ANY(X) (SCM_VELTS(X)[-1])
+#define SCM_WVECT_GC_CHAIN(X) (SCM_VELTS(X)[-2])
 
 \f