mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Initialize BDW-GC using Whippet API
* libguile/gc.c (scm_storage_prehistory): Use Whippet API instead of BDW-GC API.
This commit is contained in:
parent
2d5d9f6ba9
commit
57e8686cea
1 changed files with 21 additions and 25 deletions
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "gc-internal.h"
|
#include "gc-internal.h"
|
||||||
|
#include "gc-basic-stats.h"
|
||||||
|
|
||||||
|
|
||||||
/* For GC_set_start_callback. */
|
/* For GC_set_start_callback. */
|
||||||
|
@ -444,38 +445,33 @@ scm_gc_unregister_roots (SCM *b, unsigned long n)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
static struct gc_heap *the_gc_heap;
|
||||||
scm_storage_prehistory ()
|
static struct gc_basic_stats the_gc_stats;
|
||||||
{
|
|
||||||
GC_set_all_interior_pointers (0);
|
|
||||||
GC_set_finalize_on_demand (1);
|
|
||||||
|
|
||||||
#if (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 4 \
|
void
|
||||||
&& GC_VERSION_MICRO == 0)
|
scm_storage_prehistory (void)
|
||||||
/* BDW-GC 7.4.0 has a bug making it loop indefinitely when using more
|
{
|
||||||
than one marker thread: <https://github.com/ivmai/bdwgc/pull/30>.
|
struct gc_options *options = gc_allocate_options ();
|
||||||
Work around it by asking for one marker thread. */
|
gc_options_set_int(options, GC_OPTION_HEAP_SIZE_POLICY, GC_HEAP_SIZE_GROWABLE);
|
||||||
setenv ("GC_MARKERS", "1", 1);
|
gc_options_set_size(options, GC_OPTION_HEAP_SIZE, DEFAULT_INITIAL_HEAP_SIZE);
|
||||||
#endif
|
|
||||||
|
char *options_str = getenv ("GUILE_GC_OPTIONS");
|
||||||
|
if (options_str && !gc_options_parse_and_set_many (options, options_str))
|
||||||
|
fprintf (stderr, "warning: failed to set GC options from string: \"%s\"\n",
|
||||||
|
options_str);
|
||||||
|
|
||||||
#if SCM_I_GSC_USE_NULL_THREADS
|
#if SCM_I_GSC_USE_NULL_THREADS
|
||||||
/* If we have disabled threads in Guile, ensure that the GC doesn't
|
/* If we have disabled threads in Guile, ensure that the GC doesn't
|
||||||
spawn any marker threads. */
|
spawn any marker threads. */
|
||||||
setenv ("GC_MARKERS", "1", 1);
|
gc_options_set_int (options, GC_OPTION_PARALLELISM, 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GC_INIT ();
|
struct gc_mutator *mut;
|
||||||
|
if (!gc_init (options, NULL, &the_gc_heap, &mut,
|
||||||
size_t heap_size = GC_get_heap_size ();
|
GC_BASIC_STATS, &the_gc_stats)) {
|
||||||
if (heap_size < DEFAULT_INITIAL_HEAP_SIZE)
|
fprintf (stderr, "Failed to initialize GC\n");
|
||||||
GC_expand_hp (DEFAULT_INITIAL_HEAP_SIZE - heap_size);
|
abort ();
|
||||||
|
}
|
||||||
/* We only need to register a displacement for those types for which the
|
|
||||||
higher bits of the type tag are used to store a pointer (that is, a
|
|
||||||
pointer to an 8-octet aligned region). */
|
|
||||||
GC_REGISTER_DISPLACEMENT (scm_tc3_cons);
|
|
||||||
GC_REGISTER_DISPLACEMENT (scm_tc3_struct);
|
|
||||||
/* GC_REGISTER_DISPLACEMENT (scm_tc3_unused); */
|
|
||||||
|
|
||||||
/* Sanity check. */
|
/* Sanity check. */
|
||||||
if (!GC_is_visible (&scm_protects))
|
if (!GC_is_visible (&scm_protects))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue