1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-06 17:40:29 +02:00

Separate tagged and untagged pointerless allocations

Tagged allocations can move; untagged allocations cannot.

* libguile/gc-inline.h:
* libguile/gc-malloc.c:
* libguile/gc.h: Split scm_allocate_pointerless into tagged and untagged
variants.
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/integers.c:
* libguile/intrinsics.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/numbers.c:
* libguile/programs.h:
* libguile/random.c:
* libguile/read.c:
* libguile/regex-posix.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/vm.c: Use the new functions.
This commit is contained in:
Andy Wingo 2025-07-03 10:10:20 +02:00
parent e21aa9c513
commit 8623e252bf
19 changed files with 85 additions and 72 deletions

View file

@ -149,13 +149,6 @@ scm_gc_unregister_collectable_memory (void *mem, size_t size, const char *what)
{
}
void *
scm_allocate_pointerless (struct scm_thread *thr, size_t size)
{
if (!size) abort();
return scm_inline_allocate_pointerless (thr, size);
}
void *
scm_allocate_tagged (struct scm_thread *thr, size_t size)
{
@ -163,6 +156,20 @@ scm_allocate_tagged (struct scm_thread *thr, size_t size)
return scm_inline_allocate_tagged (thr, size);
}
void *
scm_allocate_tagged_pointerless (struct scm_thread *thr, size_t size)
{
if (!size) abort();
return scm_inline_allocate_tagged_pointerless (thr, size);
}
void *
scm_allocate_untagged_pointerless (struct scm_thread *thr, size_t size)
{
if (!size) abort();
return scm_inline_allocate_untagged_pointerless (thr, size);
}
void *
scm_allocate_sloppy (struct scm_thread *thr, size_t size)
{
@ -171,13 +178,12 @@ scm_allocate_sloppy (struct scm_thread *thr, size_t size)
}
/* Allocate SIZE bytes of memory whose contents should not be scanned
for pointers (useful, e.g., for strings). Note though that this
memory is *not* cleared; be sure to initialize it to prevent
information leaks. */
for pointers (useful, e.g., for strings). The memory is cleared. */
void *
scm_gc_malloc_pointerless (size_t size, const char *what)
{
return scm_allocate_pointerless (SCM_I_CURRENT_THREAD, size ? size : 1);
return scm_allocate_untagged_pointerless (SCM_I_CURRENT_THREAD,
size ? size : 1);
}
void *