summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Livshin <mlivshin@bigfoot.com>2000-12-29 22:18:06 +0000
committerMichael Livshin <mlivshin@bigfoot.com>2000-12-29 22:18:06 +0000
commitd9dcd93362ef2956d9d11a46024173c74e197f3c (patch)
treef97d66c4dcccb7d77ea455b7406517bf1911bc4f
parent174663302558e2eda063dfe185beef860b39deb2 (diff)
downloadguile-d9dcd93362ef2956d9d11a46024173c74e197f3c.tar.gz
* weaks.c (scm_scan_weak_vectors): move the calculation of the
`weak_keys' and `weak_values' flags out of the inner loop. * guardians.c: (greedily_guarded_prop): deleted. (greedily_guarded_whash): new variable. a doubly-weak hash table used to keep the "greedily hashed" object property. the previous implementation (via primitive object properties) was incorrect due to its only-the-key-is-weak semantics. (scm_guard, get_one_zombie, scm_init_guardians): use/init `greedily_guarded_whash'.
-rw-r--r--libguile/ChangeLog15
-rw-r--r--libguile/guardians.c27
-rw-r--r--libguile/weaks.c7
3 files changed, 30 insertions, 19 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 5961def8e..5ca3307c2 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,18 @@
+2000-12-30 Michael Livshin <mlivshin@bigfoot.com>
+
+ * weaks.c (scm_scan_weak_vectors): move the calculation of the
+ `weak_keys' and `weak_values' flags out of the inner loop.
+
+2000-12-29 Michael Livshin <mlivshin@bigfoot.com>
+
+ * guardians.c: (greedily_guarded_prop): deleted.
+ (greedily_guarded_whash): new variable. a doubly-weak hash table
+ used to keep the "greedily hashed" object property. the previous
+ implementation (via primitive object properties) was incorrect due
+ to its only-the-key-is-weak semantics.
+ (scm_guard, get_one_zombie, scm_init_guardians): use/init
+ `greedily_guarded_whash'.
+
2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (check_map_args), gh_data.c (gh_set_substr,
diff --git a/libguile/guardians.c b/libguile/guardians.c
index 130b3e1df..207567cd2 100644
--- a/libguile/guardians.c
+++ b/libguile/guardians.c
@@ -66,8 +66,9 @@
#include "libguile/print.h"
#include "libguile/smob.h"
#include "libguile/validate.h"
-#include "libguile/properties.h"
#include "libguile/root.h"
+#include "libguile/hashtab.h"
+#include "libguile/weaks.h"
#include "libguile/guardians.h"
@@ -126,9 +127,7 @@ typedef struct guardian_t
static guardian_t *greedy_guardians = NULL;
static guardian_t *sharing_guardians = NULL;
-/* greedily guarded objects have this property set, so that we can
- catch any attempt to greedily guard them again */
-static SCM greedily_guarded_prop = SCM_EOL;
+static SCM greedily_guarded_whash = SCM_EOL;
/* this is the list of guarded objects that are parts of cycles. we
don't know in which order to return them from guardians, so we just
@@ -219,13 +218,13 @@ scm_guard (SCM guardian, SCM obj)
if (GUARDIAN_GREEDY_P (guardian))
{
- if (SCM_NFALSEP (scm_primitive_property_ref
- (greedily_guarded_prop, obj)))
+ if (SCM_NFALSEP (scm_hashq_get_handle
+ (greedily_guarded_whash, obj)))
scm_misc_error ("guard",
"object is already greedily guarded", obj);
else
- scm_primitive_property_set_x (greedily_guarded_prop,
- obj, SCM_BOOL_T);
+ scm_hashq_create_handle_x (greedily_guarded_whash,
+ obj, guardian);
}
SCM_NEWCELL (z);
@@ -251,9 +250,9 @@ scm_get_one_zombie (SCM guardian)
if (SCM_NFALSEP (res)
&& GUARDIAN_GREEDY_P (guardian)
- && SCM_NFALSEP (scm_primitive_property_ref
- (greedily_guarded_prop, res)))
- scm_primitive_property_del_x (greedily_guarded_prop, res);
+ && SCM_NFALSEP (scm_hashq_get_handle
+ (greedily_guarded_whash, res)))
+ scm_hashq_remove_x (greedily_guarded_whash, res);
return res;
}
@@ -506,14 +505,14 @@ scm_init_guardians ()
scm_c_hook_add (&scm_before_mark_c_hook, guardian_gc_init, 0, 0);
scm_c_hook_add (&scm_before_sweep_c_hook, guardian_zombify, 0, 0);
- greedily_guarded_prop =
- scm_permanent_object (scm_primitive_make_property (SCM_BOOL_F));
-
self_centered_zombies =
scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL));
scm_c_hook_add (&scm_after_gc_c_hook,
whine_about_self_centered_zombies, 0, 0);
+ greedily_guarded_whash =
+ scm_permanent_object (scm_make_doubly_weak_hash_table (SCM_MAKINUM (31)));
+
#ifndef SCM_MAGIC_SNARFER
#include "libguile/guardians.x"
#endif
diff --git a/libguile/weaks.c b/libguile/weaks.c
index e6d47a376..f0b006a5a 100644
--- a/libguile/weaks.c
+++ b/libguile/weaks.c
@@ -273,6 +273,8 @@ scm_scan_weak_vectors (void *dummy1, void *dummy2, void *dummy3)
SCM obj = w;
register long n = SCM_VECTOR_LENGTH (w);
register long j;
+ int weak_keys = SCM_IS_WHVEC (obj) || SCM_IS_WHVEC_B (obj);
+ int weak_values = SCM_IS_WHVEC_V (obj) || SCM_IS_WHVEC_B (obj);
ptr = SCM_VELTS (w);
@@ -280,11 +282,6 @@ scm_scan_weak_vectors (void *dummy1, void *dummy2, void *dummy3)
{
SCM * fixup;
SCM alist;
- int weak_keys;
- int weak_values;
-
- weak_keys = SCM_IS_WHVEC (obj) || SCM_IS_WHVEC_B (obj);
- weak_values = SCM_IS_WHVEC_V (obj) || SCM_IS_WHVEC_B (obj);
fixup = ptr + j;
alist = *fixup;