1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-03 08:10:31 +02:00

scm_gc_object_address pins its referent

* libguile/gc.h:
* libguile/gc.c (scm_gc_pin_object): New function.
(scm_gc_object_address): New function, to be used instead of SCM_UNPACK
when an object's address is exposed, for example via hashq.
* libguile/atomic.c:
* libguile/cache-internal.h:
* libguile/continuations.c:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/ephemerons.c:
* libguile/exceptions.c:
* libguile/finalizers.c:
* libguile/fluids-internal.h:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/intrinsics.c:
* libguile/memoize.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/smob.c:
* libguile/struct.c:
* libguile/struct.h:
* libguile/variable.c:
* libguile/vm.c: Use the new functions everywhere that is needed.
Because they take a thread, sometimes we have to do some extra plumbing.
This commit is contained in:
Andy Wingo 2025-06-26 15:00:22 +02:00
parent b0ce014801
commit a7d7ff5019
25 changed files with 133 additions and 117 deletions

View file

@ -79,7 +79,7 @@ scm_cache_lookup (struct scm_cache *cache, SCM k)
}
static inline void
scm_cache_insert (struct scm_cache *cache, SCM k, SCM v,
scm_cache_insert (struct scm_thread *thr, struct scm_cache *cache, SCM k, SCM v,
struct scm_cache_entry *evicted)
{
struct scm_cache_entry *entry;
@ -95,7 +95,9 @@ scm_cache_insert (struct scm_cache *cache, SCM k, SCM v,
memmove (cache->entries,
cache->entries + 1,
(entry - cache->entries) * sizeof (*entry));
entry->key = SCM_UNPACK (k);
// FIXME: Perhaps we should just reorder after a GC in which a fluid
// is moved. For now, pin the key.
entry->key = scm_gc_object_address (thr, k);
entry->value = SCM_UNPACK (v);
}