mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
Switch to use Whippet allocation fast paths
* libguile/Makefile.am (noinst_HEADERS, modinclude_HEADERS): Move gc-inline.h to be a private header. * libguile/gc-inline.h (scm_inline_gc_malloc_pointerless): (scm_inline_gc_malloc): Use gc_allocate. * libguile/intrinsics.c (allocate_words_with_freelist): (allocate_pointerless_words_with_freelist): Remove these intrinsics. Renumbers the intrinsics. (scm_bootstrap_intrinsics): * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Adapt to intrinsics change. * libguile/jit.c (emit_update_alloc_table): (emit_allocate_bytes_fast_freelist): (emit_allocate_words_slow): New helpers. (compile_allocate_words): (compile_allocate_words_immediate): (compile_allocate_words_immediate_slow): (compile_allocate_pointerless_words): (compile_allocate_pointerless_words_immediate): (compile_allocate_pointerless_words_immediate_slow): Use new helpers. * libguile/threads.c (scm_trace_thread_mutator_roots): (on_thread_exit): * libguile/threads.h: Remove Guile-managed thread-local freelists.
This commit is contained in:
parent
7696344634
commit
0532602cd3
7 changed files with 93 additions and 185 deletions
|
@ -1,7 +1,7 @@
|
|||
#ifndef SCM_GC_INLINE_H
|
||||
#define SCM_GC_INLINE_H
|
||||
|
||||
/* Copyright 1995-1996,1998-2004,2006-2014,2018-2019
|
||||
/* Copyright 1995-1996,1998-2004,2006-2014,2018-2019,2025
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Guile.
|
||||
|
@ -40,75 +40,22 @@
|
|||
|
||||
|
||||
#include "libguile/gc.h"
|
||||
#include "libguile/bdw-gc.h"
|
||||
#include "libguile/gc-internal.h"
|
||||
#include "libguile/threads.h"
|
||||
|
||||
#include <gc/gc_inline.h> /* GC_generic_malloc_many */
|
||||
|
||||
|
||||
|
||||
static inline size_t
|
||||
scm_inline_gc_bytes_to_freelist_index (size_t bytes)
|
||||
{
|
||||
return (bytes - 1U) / SCM_INLINE_GC_GRANULE_BYTES;
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
scm_inline_gc_freelist_object_size (size_t idx)
|
||||
{
|
||||
return (idx + 1U) * SCM_INLINE_GC_GRANULE_BYTES;
|
||||
}
|
||||
|
||||
/* The values of these must match the internal POINTERLESS and NORMAL
|
||||
definitions in libgc, for which unfortunately there are no external
|
||||
definitions. Alack. */
|
||||
typedef enum scm_inline_gc_kind
|
||||
{
|
||||
SCM_INLINE_GC_KIND_POINTERLESS,
|
||||
SCM_INLINE_GC_KIND_NORMAL
|
||||
} scm_inline_gc_kind;
|
||||
|
||||
static inline void *
|
||||
scm_inline_gc_alloc (void **freelist, size_t idx, scm_inline_gc_kind kind)
|
||||
{
|
||||
void *head = *freelist;
|
||||
|
||||
if (SCM_UNLIKELY (!head))
|
||||
{
|
||||
size_t bytes = scm_inline_gc_freelist_object_size (idx);
|
||||
GC_generic_malloc_many (bytes, kind, freelist);
|
||||
head = *freelist;
|
||||
if (SCM_UNLIKELY (!head))
|
||||
return (*GC_get_oom_fn ()) (bytes);
|
||||
}
|
||||
|
||||
*freelist = *(void **)(head);
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
scm_inline_gc_malloc_pointerless (scm_thread *thread, size_t bytes)
|
||||
{
|
||||
size_t idx = scm_inline_gc_bytes_to_freelist_index (bytes);
|
||||
|
||||
if (SCM_UNLIKELY (idx >= SCM_INLINE_GC_FREELIST_COUNT))
|
||||
return GC_malloc_atomic (bytes);
|
||||
|
||||
return scm_inline_gc_alloc
|
||||
(&thread->pointerless_freelists[idx], idx, SCM_INLINE_GC_KIND_POINTERLESS);
|
||||
return gc_allocate (thread->mutator, bytes,
|
||||
GC_ALLOCATION_UNTAGGED_POINTERLESS);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
scm_inline_gc_malloc (scm_thread *thread, size_t bytes)
|
||||
{
|
||||
size_t idx = scm_inline_gc_bytes_to_freelist_index (bytes);
|
||||
|
||||
if (SCM_UNLIKELY (idx >= SCM_INLINE_GC_FREELIST_COUNT))
|
||||
return GC_malloc (bytes);
|
||||
|
||||
return scm_inline_gc_alloc
|
||||
(&thread->freelists[idx], idx, SCM_INLINE_GC_KIND_NORMAL);
|
||||
return gc_allocate (thread->mutator, bytes, GC_ALLOCATION_TAGGED);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue