1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 22:31:12 +02:00

Update for Whippet changes, VM stacks scanned partly-conservatively

* libguile/trace.h (scm_from_ref, scm_to_ref): Helpers moved here;
update all callers.
* libguile/loader.c (scm_trace_loader_roots):
* libguile/threads.c (scm_trace_thread_roots):
* libguile/vm.c (scm_trace_vm_roots): Update for new
pinned-roots prototype.
* libguile/whippet-embedder.h (gc_extern_space_visit): Update for
Whippet API changes.
This commit is contained in:
Andy Wingo 2025-05-21 14:31:23 +02:00
parent fb5a99c752
commit 7b4f4427f8
8 changed files with 143 additions and 131 deletions

View file

@ -707,11 +707,15 @@ enum slot_desc
};
void
scm_trace_vm (struct scm_vm *vp,
void (*trace_edge) (struct gc_edge edge,
struct gc_heap *heap,
void *trace_data),
struct gc_heap *heap, void *trace_data)
scm_trace_vm_roots (struct scm_vm *vp,
void (*trace_pinned) (struct gc_ref ref,
struct gc_heap *heap,
void *trace_data),
void (*trace_ambiguous) (uintptr_t lo, uintptr_t hi,
int possibly_interior,
struct gc_heap *heap,
void *trace_data),
struct gc_heap *heap, void *trace_data)
{
union scm_vm_stack_element *sp, *fp;
/* The first frame will be marked conservatively (without a slot map).
@ -730,29 +734,31 @@ scm_trace_vm (struct scm_vm *vp,
{
ptrdiff_t nlocals = SCM_FRAME_NUM_LOCALS (fp, sp);
size_t slot = nlocals - 1;
for (slot = nlocals - 1; sp < fp; sp++, slot--)
{
enum slot_desc desc = SLOT_DESC_LIVE_GC;
if (slot_map)
for (slot = nlocals - 1; sp < fp; sp++, slot--)
{
enum slot_desc desc =
(slot_map[slot / 4U] >> ((slot % 4U) * 2)) & 3U;
if (slot_map)
desc = (slot_map[slot / 4U] >> ((slot % 4U) * 2)) & 3U;
switch (desc)
{
case SLOT_DESC_LIVE_RAW:
case SLOT_DESC_UNUSED:
break;
case SLOT_DESC_LIVE_GC:
trace_pinned (scm_to_ref (sp->as_scm), heap, trace_data);
break;
case SLOT_DESC_DEAD:
/* This value may become dead as a result of GC,
so we can't just leave it on the stack. */
sp->as_scm = SCM_UNSPECIFIED;
break;
}
}
else
trace_ambiguous ((uintptr_t) sp, (uintptr_t) (sp + nlocals), 0,
heap, trace_data);
switch (desc)
{
case SLOT_DESC_LIVE_RAW:
break;
case SLOT_DESC_UNUSED:
case SLOT_DESC_LIVE_GC:
if (SCM_NIMP (sp->as_scm))
trace_edge (gc_edge (sp), heap, trace_data);
break;
case SLOT_DESC_DEAD:
/* This value may become dead as a result of GC,
so we can't just leave it on the stack. */
sp->as_scm = SCM_UNSPECIFIED;
break;
}
}
sp = SCM_FRAME_PREVIOUS_SP (fp);
/* Inner frames may have a dead slots map for precise marking.
Note that there may be other reasons to not have a dead slots