diff options
author | Andy Wingo <wingo@pobox.com> | 2025-04-23 14:04:23 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2025-04-23 14:04:23 +0200 |
commit | 23d204b5a02b6cc11e7e735dc3882dc25f7b7292 (patch) | |
tree | 94a2c671d7eb49c3c15483cc4d5b27252f29d0f0 | |
parent | 25db208603c86ed1f2c89f95ce3227b763d52679 (diff) | |
download | guile-23d204b5a02b6cc11e7e735dc3882dc25f7b7292.tar.gz |
Hook up gc_heap_set_allocation_failure_handler
* libguile/gc.h:
* libguile/gc.c (scm_gc_after_nonlocal_exit): Give it a scm_thread
argument, and cause GC with whippet API.
(scm_init_gc): Set alloc failure handler using Whippet API instead of
BDW.
(scm_oom_fn): Add heap argumnet.
* libguile/eval.c (eval):
* libguile/exceptions.c (scm_c_with_exception_handler):
* libguile/vm.c (scm_call_n): Adapt.
-rw-r--r-- | libguile/eval.c | 4 | ||||
-rw-r--r-- | libguile/exceptions.c | 4 | ||||
-rw-r--r-- | libguile/gc.c | 8 | ||||
-rw-r--r-- | libguile/gc.h | 2 | ||||
-rw-r--r-- | libguile/vm.c | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/libguile/eval.c b/libguile/eval.c index db6d3a5e9..de62613b3 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -1,4 +1,4 @@ -/* Copyright 1995-2019 +/* Copyright 1995-2019, 2025 Free Software Foundation, Inc. This file is part of Guile. @@ -463,7 +463,7 @@ eval (SCM x, SCM env) { /* The prompt exited nonlocally. */ t->vm.registers = prev_registers; - scm_gc_after_nonlocal_exit (); + scm_gc_after_nonlocal_exit (t); proc = handler; args = scm_i_prompt_pop_abort_args_x (&t->vm, saved_stack_depth); goto apply_proc; diff --git a/libguile/exceptions.c b/libguile/exceptions.c index 8b462955f..5c25ce6a9 100644 --- a/libguile/exceptions.c +++ b/libguile/exceptions.c @@ -1,4 +1,4 @@ -/* Copyright 1995-1998,2000-2001,2003-2004,2006,2008,2009-2014,2017-2019,2023 +/* Copyright 1995-1998,2000-2001,2003-2004,2006,2008,2009-2014,2017-2019,2023,2025 Free Software Foundation, Inc. This file is part of Guile. @@ -152,7 +152,7 @@ scm_c_with_exception_handler (SCM type, scm_t_exception_handler handler, SCM args; t->vm.registers = prev_registers; - scm_gc_after_nonlocal_exit (); + scm_gc_after_nonlocal_exit (t); /* FIXME: We know where the args will be on the stack; we could avoid consing them. */ diff --git a/libguile/gc.c b/libguile/gc.c index ec9002e42..9825cb27a 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -296,7 +296,7 @@ static int needs_gc_after_nonlocal_exit = 0; /* Arrange to throw an exception on failed allocations. */ static void* -scm_oom_fn (size_t nbytes) +scm_oom_fn (struct gc_heap *heap, size_t nbytes) { needs_gc_after_nonlocal_exit = 1; scm_report_out_of_memory (); @@ -313,12 +313,12 @@ scm_gc_warn_proc (char *fmt, GC_word arg) } void -scm_gc_after_nonlocal_exit (void) +scm_gc_after_nonlocal_exit (struct scm_thread *thread) { if (needs_gc_after_nonlocal_exit) { needs_gc_after_nonlocal_exit = 0; - GC_gcollect_and_unmap (); + gc_collect (thread->mutator, GC_COLLECTION_COMPACTING); } } @@ -732,7 +732,7 @@ scm_init_gc () after_gc_async_thunk), SCM_BOOL_F); - GC_set_oom_fn (scm_oom_fn); + gc_heap_set_allocation_failure_handler (the_gc_heap, scm_oom_fn); GC_set_warn_proc (scm_gc_warn_proc); #include "gc.x" diff --git a/libguile/gc.h b/libguile/gc.h index e9779a7a3..f2e243d26 100644 --- a/libguile/gc.h +++ b/libguile/gc.h @@ -282,7 +282,7 @@ SCM_API void scm_gc_register_root (SCM *p); SCM_API void scm_gc_unregister_root (SCM *p); SCM_API void scm_gc_register_roots (SCM *b, unsigned long n); SCM_API void scm_gc_unregister_roots (SCM *b, unsigned long n); -SCM_INTERNAL void scm_gc_after_nonlocal_exit (void); +SCM_INTERNAL void scm_gc_after_nonlocal_exit (struct scm_thread *); SCM_INTERNAL void scm_init_gc_protect_object (void); SCM_INTERNAL void scm_init_gc (void); diff --git a/libguile/vm.c b/libguile/vm.c index 1c6670967..a042e9535 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -1604,7 +1604,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs) if (SCM_UNLIKELY (resume)) { uint8_t *mcode = vp->mra_after_abort; - scm_gc_after_nonlocal_exit (); + scm_gc_after_nonlocal_exit (thread); /* Non-local return. */ if (vp->abort_hook_enabled) invoke_abort_hook (thread); |