mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 20:30:28 +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
|
#define SCM_DEBUG 0
|
||||||
#endif
|
#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
|
/* If SCM_DEBUG_CELL_ACCESSES is set to 1, cell accesses will perform
|
||||||
* exhaustive parameter checking: It will be verified that cell parameters
|
* exhaustive parameter checking: It will be verified that cell parameters
|
||||||
* actually point to a valid heap cell. Note: If this option is enabled,
|
* 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))
|
if (SCM_GC_MARK_P (ptr))
|
||||||
return;
|
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_SET_GC_MARK (ptr);
|
||||||
scm_gc_mark_dependencies (ptr);
|
scm_gc_mark_dependencies (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ensure_marking (void)
|
scm_i_ensure_marking (void)
|
||||||
{
|
{
|
||||||
assert (scm_i_marking);
|
assert (scm_i_marking);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ scm_assert_cell_valid (SCM cell)
|
||||||
*/
|
*/
|
||||||
if (scm_expensive_debug_cell_accesses_p)
|
if (scm_expensive_debug_cell_accesses_p)
|
||||||
scm_i_expensive_validation_check (cell);
|
scm_i_expensive_validation_check (cell);
|
||||||
|
#if (SCM_DEBUG_MARKING_API == 0)
|
||||||
if (!SCM_GC_MARK_P (cell))
|
if (!SCM_GC_MARK_P (cell))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
|
@ -153,7 +153,8 @@ scm_assert_cell_valid (SCM cell)
|
||||||
(unsigned long) SCM_UNPACK (cell));
|
(unsigned long) SCM_UNPACK (cell));
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
#endif /* SCM_DEBUG_MARKING_API */
|
||||||
|
|
||||||
scm_i_cell_validation_already_running = 0; /* re-enable */
|
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 */
|
/* 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);
|
SCM_INTERNAL void scm_i_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)
|
#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
|
/* Low level cell data accessing macros. These macros should only be used
|
||||||
* from within code related to garbage collection issues, since they will
|
* 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
|
Always set mark. Otherwise cells that are alloced before
|
||||||
scm_debug_cell_accesses_p is toggled seem invalid.
|
scm_debug_cell_accesses_p is toggled seem invalid.
|
||||||
*/
|
*/
|
||||||
SCM_SET_GC_MARK (z);
|
SCM_SET_GC_MARK (z);
|
||||||
|
#endif /* SCM_DEBUG_MARKING_API */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: figure out if this use of mark bits is valid with
|
TODO: figure out if this use of mark bits is valid with
|
||||||
threading. What if another thread is doing GC at this point
|
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();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if (SCM_DEBUG_MARKING_API == 0)
|
||||||
/* see above. */
|
/* see above. */
|
||||||
SCM_SET_GC_MARK (z);
|
SCM_SET_GC_MARK (z);
|
||||||
|
#endif /* SCM_DEBUG_MARKING_API */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* When this function is inlined, it's possible that the last
|
/* When this function is inlined, it's possible that the last
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue