1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-02 23:50:47 +02:00

Allow precise tracing of dynstacks

Gosh this was a slog

* libguile/dynstack.c (dynstack_ensure_space): Use malloc and free.
Threads have off-heap dynstacks, with manual marking.
(scm_trace_dynstack): Implement tracing.
(trace_pinned_trampoline, scm_trace_dynstack_roots): Implement tracing
for active threads.
(scm_dynstack_capture): Tag dynstacks.
* libguile/dynstack.h (scm_t_dynstack): Add a tag.
(scm_t_dynstack_winder_flags): Add SCM_F_DYNSTACK_WINDER_MANAGED.
* libguile/dynwind.h (scm_t_wind_flags): Add SCM_F_WIND_MANAGED.
* libguile/dynwind.c (scm_dynwind_unwind_handler_with_scm)
(scm_dynwind_rewind_handler_with_scm): These values need to be traced by
GC.
* libguile/scm.h (scm_tc16_dynstack_slice): New typecode.  No need for
equality etc because it shouldn't escape to Scheme (currently).
* libguile/trace.h: Add trace decls.
* libguile/threads.c (scm_trace_thread_roots): Trace dynstacks
explicitly here, as they are off-heap.
This commit is contained in:
Andy Wingo 2025-06-19 16:32:56 +02:00
parent 923bfdc7ed
commit 278ba99027
7 changed files with 155 additions and 43 deletions

View file

@ -1,4 +1,4 @@
/* Copyright 1995-1996,1998-2001,2003-2004,2006,2008,2010-2012,2018
/* Copyright 1995-1996,1998-2001,2003-2004,2006,2008,2010-2012,2018,2025
Free Software Foundation, Inc.
This file is part of Guile.
@ -99,7 +99,8 @@ scm_dynwind_unwind_handler_with_scm (void (*proc) (SCM), SCM data,
scm_t_wind_flags flags)
{
/* FIXME: This is not a safe cast. */
scm_dynwind_unwind_handler ((scm_t_guard) proc, SCM2PTR (data), flags);
scm_dynwind_unwind_handler ((scm_t_guard) proc, SCM2PTR (data),
flags | SCM_F_WIND_MANAGED);
}
void
@ -107,7 +108,8 @@ scm_dynwind_rewind_handler_with_scm (void (*proc) (SCM), SCM data,
scm_t_wind_flags flags)
{
/* FIXME: This is not a safe cast. */
scm_dynwind_rewind_handler ((scm_t_guard) proc, SCM2PTR (data), flags);
scm_dynwind_rewind_handler ((scm_t_guard) proc, SCM2PTR (data),
flags | SCM_F_WIND_MANAGED);
}
void