diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2008-08-16 11:57:27 -0300 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2008-08-16 13:21:42 -0300 |
commit | d09752ffd17688b33a1e828cf4c11f66b86c3c3c (patch) | |
tree | 1eb7f19ed5592222011506ac97fb758144e5de18 | |
parent | e89b7b36259edb20f60efc0e3e11fa83e5b35b89 (diff) | |
download | guile-d09752ffd17688b33a1e828cf4c11f66b86c3c3c.tar.gz |
Introduce scm_i_marking to detect when GC mark bits are touched
outside of marking stage.
-rw-r--r-- | libguile/gc-mark.c | 10 | ||||
-rw-r--r-- | libguile/gc.h | 2 | ||||
-rw-r--r-- | libguile/private-gc.h | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/libguile/gc-mark.c b/libguile/gc-mark.c index 77f3ec2af..9fcf205ad 100644 --- a/libguile/gc-mark.c +++ b/libguile/gc-mark.c @@ -73,6 +73,7 @@ scm_mark_all (void) long j; int loops; + scm_i_marking = 1; scm_i_init_weak_vectors_for_gc (); scm_i_init_guardians_for_gc (); @@ -139,8 +140,6 @@ scm_mark_all (void) break; } - /* fprintf (stderr, "%d loops\n", loops); */ - /* Remove all unmarked entries from the weak vectors. */ scm_i_remove_weaks_from_weak_vectors (); @@ -148,6 +147,7 @@ scm_mark_all (void) /* Bring hashtables upto date. */ scm_i_scan_weak_hashtables (); + scm_i_marking = 0; } /* {Mark/Sweep} @@ -169,6 +169,12 @@ scm_gc_mark (SCM ptr) scm_gc_mark_dependencies (ptr); } +void +ensure_marking (void) +{ + assert (scm_i_marking); +} + /* Mark the dependencies of an object. diff --git a/libguile/gc.h b/libguile/gc.h index 05412bccf..939f80071 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -155,6 +155,8 @@ typedef unsigned long scm_t_c_bvec_long; /* testing and changing GC marks */ #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_CLEAR_GC_MARK(x) SCM_GC_CELL_CLEAR_BIT (x) diff --git a/libguile/private-gc.h b/libguile/private-gc.h index 7180f2b0b..26e980cb2 100644 --- a/libguile/private-gc.h +++ b/libguile/private-gc.h @@ -191,6 +191,11 @@ int scm_i_gc_grow_heap_p (scm_t_cell_type_statistics * freelist); /* 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); /* |