1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Introduce scm_i_marking to detect when GC mark bits are touched

outside of marking stage.
This commit is contained in:
Han-Wen Nienhuys 2008-08-16 11:57:27 -03:00
parent e89b7b3625
commit d09752ffd1
3 changed files with 15 additions and 2 deletions

View file

@ -73,6 +73,7 @@ scm_mark_all (void)
long j; long j;
int loops; int loops;
scm_i_marking = 1;
scm_i_init_weak_vectors_for_gc (); scm_i_init_weak_vectors_for_gc ();
scm_i_init_guardians_for_gc (); scm_i_init_guardians_for_gc ();
@ -139,8 +140,6 @@ scm_mark_all (void)
break; break;
} }
/* fprintf (stderr, "%d loops\n", loops); */
/* Remove all unmarked entries from the weak vectors. /* Remove all unmarked entries from the weak vectors.
*/ */
scm_i_remove_weaks_from_weak_vectors (); scm_i_remove_weaks_from_weak_vectors ();
@ -148,6 +147,7 @@ scm_mark_all (void)
/* Bring hashtables upto date. /* Bring hashtables upto date.
*/ */
scm_i_scan_weak_hashtables (); scm_i_scan_weak_hashtables ();
scm_i_marking = 0;
} }
/* {Mark/Sweep} /* {Mark/Sweep}
@ -169,6 +169,12 @@ scm_gc_mark (SCM ptr)
scm_gc_mark_dependencies (ptr); scm_gc_mark_dependencies (ptr);
} }
void
ensure_marking (void)
{
assert (scm_i_marking);
}
/* /*
Mark the dependencies of an object. Mark the dependencies of an object.

View file

@ -155,6 +155,8 @@ typedef unsigned long scm_t_c_bvec_long;
/* testing and changing GC marks */ /* testing and changing GC marks */
#define SCM_GC_MARK_P(x) SCM_GC_CELL_GET_BIT (x) #define SCM_GC_MARK_P(x) SCM_GC_CELL_GET_BIT (x)
void ensure_marking(void);
#define SCM_SET_GC_MARK(x) SCM_GC_CELL_SET_BIT (x) #define SCM_SET_GC_MARK(x) SCM_GC_CELL_SET_BIT (x)
#define SCM_CLEAR_GC_MARK(x) SCM_GC_CELL_CLEAR_BIT (x) #define SCM_CLEAR_GC_MARK(x) SCM_GC_CELL_CLEAR_BIT (x)

View file

@ -191,6 +191,11 @@ int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist);
/* /*
gc-mark gc-mark
*/ */
/* this can be used to ensure that set/clear gc marks only happen when
allowed. */
int scm_i_marking;
void scm_mark_all (void); void scm_mark_all (void);
/* /*