mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 12:20:20 +02:00
Cleanup mark-during-GC debug checks.
* libguile/__scm.h (SCM_DEBUG): add SCM_DEBUG_MARKING_API * libguile/gc.h (SCM_SET_GC_MARK): depending on SCM_DEBUG_MARKING_API crash if someone is touching markbits outside regular hours. Rename ensure_marking() to scm_i_ensure_marking(). * libguile/inline.h (scm_double_cell, scm_cell): only set mark bits for debugging if SCM_DEBUG_MARKING_API is unset * libguile/gc-mark.c: Issue deprecation warning if we are marking outside of the GC mark phase.
This commit is contained in:
parent
a8db4a59c8
commit
7ddb9baf80
5 changed files with 35 additions and 9 deletions
|
@ -197,6 +197,14 @@
|
|||
#define SCM_DEBUG 0
|
||||
#endif
|
||||
|
||||
/* For debugging purposes: define this is to ensure nobody is using
|
||||
* the mark bits outside of the marking phase. This is meant for
|
||||
* debugging purposes only.
|
||||
*/
|
||||
#ifndef SCM_DEBUG_MARKING_API
|
||||
#define SCM_DEBUG_MARKING_API 0
|
||||
#endif
|
||||
|
||||
/* If SCM_DEBUG_CELL_ACCESSES is set to 1, cell accesses will perform
|
||||
* exhaustive parameter checking: It will be verified that cell parameters
|
||||
* actually point to a valid heap cell. Note: If this option is enabled,
|
||||
|
|
|
@ -165,12 +165,19 @@ scm_gc_mark (SCM ptr)
|
|||
if (SCM_GC_MARK_P (ptr))
|
||||
return;
|
||||
|
||||
if (!scm_i_marking)
|
||||
{
|
||||
static const char msg[]
|
||||
= "Should only call scm_gc_mark() during GC.";
|
||||
scm_c_issue_deprecation_warning (msg);
|
||||
}
|
||||
|
||||
SCM_SET_GC_MARK (ptr);
|
||||
scm_gc_mark_dependencies (ptr);
|
||||
}
|
||||
|
||||
void
|
||||
ensure_marking (void)
|
||||
scm_i_ensure_marking (void)
|
||||
{
|
||||
assert (scm_i_marking);
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ scm_assert_cell_valid (SCM cell)
|
|||
*/
|
||||
if (scm_expensive_debug_cell_accesses_p)
|
||||
scm_i_expensive_validation_check (cell);
|
||||
|
||||
#if (SCM_DEBUG_MARKING_API == 0)
|
||||
if (!SCM_GC_MARK_P (cell))
|
||||
{
|
||||
fprintf (stderr,
|
||||
|
@ -153,7 +153,8 @@ scm_assert_cell_valid (SCM cell)
|
|||
(unsigned long) SCM_UNPACK (cell));
|
||||
abort ();
|
||||
}
|
||||
|
||||
#endif /* SCM_DEBUG_MARKING_API */
|
||||
|
||||
scm_i_cell_validation_already_running = 0; /* re-enable */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,9 +156,16 @@ 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)
|
||||
SCM_INTERNAL void scm_i_ensure_marking(void);
|
||||
|
||||
#if (SCM_DEBUG_MARKING_API == 1)
|
||||
#define SCM_I_ENSURE_MARKING scm_i_ensure_marking(),
|
||||
#else
|
||||
#define SCM_I_ENSURE_MARKING
|
||||
#endif
|
||||
|
||||
#define SCM_SET_GC_MARK(x) SCM_I_ENSURE_MARKING SCM_GC_CELL_SET_BIT (x)
|
||||
#define SCM_CLEAR_GC_MARK(x) SCM_I_ENSURE_MARKING SCM_GC_CELL_CLEAR_BIT (x)
|
||||
|
||||
/* Low level cell data accessing macros. These macros should only be used
|
||||
* from within code related to garbage collection issues, since they will
|
||||
|
|
|
@ -134,12 +134,14 @@ scm_cell (scm_t_bits car, scm_t_bits cdr)
|
|||
}
|
||||
}
|
||||
|
||||
#if (SCM_DEBUG_MARKING_API == 0)
|
||||
/*
|
||||
Always set mark. Otherwise cells that are alloced before
|
||||
scm_debug_cell_accesses_p is toggled seem invalid.
|
||||
*/
|
||||
SCM_SET_GC_MARK (z);
|
||||
|
||||
#endif /* SCM_DEBUG_MARKING_API */
|
||||
|
||||
/*
|
||||
TODO: figure out if this use of mark bits is valid with
|
||||
threading. What if another thread is doing GC at this point
|
||||
|
@ -202,10 +204,11 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr,
|
|||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
#if (SCM_DEBUG_MARKING_API == 0)
|
||||
/* see above. */
|
||||
SCM_SET_GC_MARK (z);
|
||||
|
||||
#endif /* SCM_DEBUG_MARKING_API */
|
||||
|
||||
#endif
|
||||
|
||||
/* When this function is inlined, it's possible that the last
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue