mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-30 00:40:20 +02:00
* 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'.
This commit is contained in:
parent
1746633025
commit
d9dcd93362
3 changed files with 30 additions and 19 deletions
|
@ -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>
|
2000-12-28 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
* eval.c (check_map_args), gh_data.c (gh_set_substr,
|
* eval.c (check_map_args), gh_data.c (gh_set_substr,
|
||||||
|
|
|
@ -66,8 +66,9 @@
|
||||||
#include "libguile/print.h"
|
#include "libguile/print.h"
|
||||||
#include "libguile/smob.h"
|
#include "libguile/smob.h"
|
||||||
#include "libguile/validate.h"
|
#include "libguile/validate.h"
|
||||||
#include "libguile/properties.h"
|
|
||||||
#include "libguile/root.h"
|
#include "libguile/root.h"
|
||||||
|
#include "libguile/hashtab.h"
|
||||||
|
#include "libguile/weaks.h"
|
||||||
|
|
||||||
#include "libguile/guardians.h"
|
#include "libguile/guardians.h"
|
||||||
|
|
||||||
|
@ -126,9 +127,7 @@ typedef struct guardian_t
|
||||||
static guardian_t *greedy_guardians = NULL;
|
static guardian_t *greedy_guardians = NULL;
|
||||||
static guardian_t *sharing_guardians = NULL;
|
static guardian_t *sharing_guardians = NULL;
|
||||||
|
|
||||||
/* greedily guarded objects have this property set, so that we can
|
static SCM greedily_guarded_whash = SCM_EOL;
|
||||||
catch any attempt to greedily guard them again */
|
|
||||||
static SCM greedily_guarded_prop = SCM_EOL;
|
|
||||||
|
|
||||||
/* this is the list of guarded objects that are parts of cycles. we
|
/* 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
|
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 (GUARDIAN_GREEDY_P (guardian))
|
||||||
{
|
{
|
||||||
if (SCM_NFALSEP (scm_primitive_property_ref
|
if (SCM_NFALSEP (scm_hashq_get_handle
|
||||||
(greedily_guarded_prop, obj)))
|
(greedily_guarded_whash, obj)))
|
||||||
scm_misc_error ("guard",
|
scm_misc_error ("guard",
|
||||||
"object is already greedily guarded", obj);
|
"object is already greedily guarded", obj);
|
||||||
else
|
else
|
||||||
scm_primitive_property_set_x (greedily_guarded_prop,
|
scm_hashq_create_handle_x (greedily_guarded_whash,
|
||||||
obj, SCM_BOOL_T);
|
obj, guardian);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_NEWCELL (z);
|
SCM_NEWCELL (z);
|
||||||
|
@ -251,9 +250,9 @@ scm_get_one_zombie (SCM guardian)
|
||||||
|
|
||||||
if (SCM_NFALSEP (res)
|
if (SCM_NFALSEP (res)
|
||||||
&& GUARDIAN_GREEDY_P (guardian)
|
&& GUARDIAN_GREEDY_P (guardian)
|
||||||
&& SCM_NFALSEP (scm_primitive_property_ref
|
&& SCM_NFALSEP (scm_hashq_get_handle
|
||||||
(greedily_guarded_prop, res)))
|
(greedily_guarded_whash, res)))
|
||||||
scm_primitive_property_del_x (greedily_guarded_prop, res);
|
scm_hashq_remove_x (greedily_guarded_whash, res);
|
||||||
|
|
||||||
return 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_mark_c_hook, guardian_gc_init, 0, 0);
|
||||||
scm_c_hook_add (&scm_before_sweep_c_hook, guardian_zombify, 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 =
|
self_centered_zombies =
|
||||||
scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL));
|
scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL));
|
||||||
scm_c_hook_add (&scm_after_gc_c_hook,
|
scm_c_hook_add (&scm_after_gc_c_hook,
|
||||||
whine_about_self_centered_zombies, 0, 0);
|
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
|
#ifndef SCM_MAGIC_SNARFER
|
||||||
#include "libguile/guardians.x"
|
#include "libguile/guardians.x"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -273,6 +273,8 @@ scm_scan_weak_vectors (void *dummy1, void *dummy2, void *dummy3)
|
||||||
SCM obj = w;
|
SCM obj = w;
|
||||||
register long n = SCM_VECTOR_LENGTH (w);
|
register long n = SCM_VECTOR_LENGTH (w);
|
||||||
register long j;
|
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);
|
ptr = SCM_VELTS (w);
|
||||||
|
|
||||||
|
@ -280,11 +282,6 @@ scm_scan_weak_vectors (void *dummy1, void *dummy2, void *dummy3)
|
||||||
{
|
{
|
||||||
SCM * fixup;
|
SCM * fixup;
|
||||||
SCM alist;
|
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;
|
fixup = ptr + j;
|
||||||
alist = *fixup;
|
alist = *fixup;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue