diff options
author | Michael Livshin <mlivshin@bigfoot.com> | 2000-12-29 22:18:06 +0000 |
---|---|---|
committer | Michael Livshin <mlivshin@bigfoot.com> | 2000-12-29 22:18:06 +0000 |
commit | d9dcd93362ef2956d9d11a46024173c74e197f3c (patch) | |
tree | f97d66c4dcccb7d77ea455b7406517bf1911bc4f /libguile/guardians.c | |
parent | 174663302558e2eda063dfe185beef860b39deb2 (diff) | |
download | guile-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'.
Diffstat (limited to 'libguile/guardians.c')
-rw-r--r-- | libguile/guardians.c | 27 |
1 files changed, 13 insertions, 14 deletions
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 |