1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Use word_2 to store mark bits for freeing structs and vtables in the

correct order.

This ensures that we only use GC Marks during the actual GC Mark.
This commit is contained in:
Han-Wen Nienhuys 2008-08-16 02:58:17 -03:00
parent b61b5d0ebe
commit 569aa529d5
2 changed files with 14 additions and 5 deletions

View file

@ -364,7 +364,7 @@ scm_free_structs (void *dummy1 SCM_UNUSED,
{
SCM vtable = SCM_STRUCT_VTABLE (chain);
if (SCM_STRUCT_GC_CHAIN (vtable) != 0 && vtable != chain)
SCM_SET_GC_MARK (vtable);
SCM_SET_STRUCT_MARK (vtable);
chain = SCM_STRUCT_GC_CHAIN (chain);
}
/* Free unmarked structs. */
@ -374,9 +374,9 @@ scm_free_structs (void *dummy1 SCM_UNUSED,
{
SCM obj = chain;
chain = SCM_STRUCT_GC_CHAIN (chain);
if (SCM_GC_MARK_P (obj))
if (SCM_STRUCT_MARK_P (obj))
{
SCM_CLEAR_GC_MARK (obj);
SCM_CLEAR_STRUCT_MARK (obj);
SCM_SET_STRUCT_GC_CHAIN (obj, newchain);
newchain = obj;
}
@ -897,8 +897,8 @@ scm_struct_prehistory ()
{
scm_i_structs_to_free = SCM_EOL;
scm_c_hook_add (&scm_before_sweep_c_hook, scm_struct_gc_init, 0, 0);
/* With the new lazy sweep GC, the point at which the entire heap is
swept is just before the mark phase. */
/* With lazy sweep GC, the point at which the entire heap is swept
is just before the mark phase. */
scm_c_hook_add (&scm_before_mark_c_hook, scm_free_structs, 0, 0);
}

View file

@ -79,6 +79,15 @@ SCM_API SCM scm_struct_table;
#define SCM_STRUCT_GC_CHAIN(X) SCM_CELL_OBJECT_3 (X)
#define SCM_SET_STRUCT_GC_CHAIN(X, Y) SCM_SET_CELL_OBJECT_3 (X, Y)
/* For clearing structs. We can't use the regular GC mark bits, as
meddling with them at random times would mess up the invariants of
the garbage collector.
*/
#define SCM_STRUCT_MARK_P(X) SCM_CELL_WORD_2 (X)
#define SCM_SET_STRUCT_MARK(X) SCM_SET_CELL_WORD_2 (X, 0x1)
#define SCM_CLEAR_STRUCT_MARK(X) SCM_SET_CELL_WORD_2 (X, 0x0)
SCM_INTERNAL SCM scm_i_structs_to_free;