1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-04 16:50:25 +02:00
Commit graph

22041 commits

Author SHA1 Message Date
Andy Wingo
0a6767b3b9 Fix a bug in after-gc Scheme hook
* libguile/gc.c (scm_gc_event_listener_restarting_mutators): Avoid
running hook before Guile is booted.
2025-05-22 16:24:16 +02:00
Andy Wingo
2db9cfa918 nofl: Limit sweeping if there are empty blocks 2025-05-22 16:23:04 +02:00
Andy Wingo
6d5e7c9b60 Fix bof returning blocks from the evacuation target list to empties 2025-05-22 16:15:31 +02:00
Andy Wingo
1d157a133d mmc: Add "headroom" for growable heaps that cannot defragment 2025-05-22 14:57:34 +02:00
Andy Wingo
eab463bd6c nofl: Include pending large object allocations in the live data size 2025-05-22 14:57:02 +02:00
Andy Wingo
47ddd3dd5a nofl: No evacuation reserve if evacuation is impossible 2025-05-22 14:56:43 +02:00
Andy Wingo
7b4f4427f8 Update for Whippet changes, VM stacks scanned partly-conservatively
* libguile/trace.h (scm_from_ref, scm_to_ref): Helpers moved here;
update all callers.
* libguile/loader.c (scm_trace_loader_roots):
* libguile/threads.c (scm_trace_thread_roots):
* libguile/vm.c (scm_trace_vm_roots): Update for new
pinned-roots prototype.
* libguile/whippet-embedder.h (gc_extern_space_visit): Update for
Whippet API changes.
2025-05-21 14:31:23 +02:00
Andy Wingo
fb5a99c752 Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-21 14:28:34 +02:00
Andy Wingo
41de2dfd91 Update conservative roots embedder interface 2025-05-21 14:27:17 +02:00
Andy Wingo
f12990bb64 Fix alignment for platform conservative roots visitor 2025-05-21 14:26:39 +02:00
Andy Wingo
eb5f9ff878 nofl: Add asserts when getting metadata for an object
The metadata byte should have a mark.
2025-05-21 14:20:53 +02:00
Andy Wingo
0277953efc gc_extern_space_visit doesn't take an edge
The whole extern space interface is a bit wonky but for now let's assume
that external objects can't move and therefore we don't need the edge.
2025-05-21 14:04:24 +02:00
Andy Wingo
8b9fe196a1 No need to clear allocation table during allocation
The mmc clears holes eagerly; there is no need to memset during
allocation.
2025-05-21 14:01:42 +02:00
Andy Wingo
72fbb05ee8 Fix Guile's whippet embedding for conservative roots tracing
* libguile/whippet-embedder.h (gc_extern_space_visit): Don't crash if
conservative tracing is enabled: these are already part of the root set.
2025-05-16 22:38:45 +02:00
Andy Wingo
0ffa6688aa Adapt to whippet change 2025-05-16 22:27:20 +02:00
Andy Wingo
a344c225c4 Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-16 22:22:56 +02:00
Andy Wingo
b794e46635 mmc: Grow the heap if collection fails to find space for large alloc
For a pending large allocation, we will try to page out blocks from the
nofl space.  However sometimes we are not able to do so, especially if
evacuation is unavailable, as in a heap-conservative configuration.  In
that case, if the heap is growable, grow the heap after GC if there are
still bytes pending to page out.
2025-05-16 22:01:55 +02:00
Andy Wingo
fbcdffdc62 Fix bogus assert in mmc.c:deactivate_mutator 2025-05-16 22:01:15 +02:00
Andy Wingo
2018a77f36 Fix bogus static debug check in mmc init 2025-05-16 22:00:48 +02:00
Andy Wingo
e59fde2edf Fix build issue with mmc in Guile
For some reason we need to include gc-api with GC_IMPL already defined,
otherwise the attrs don't get picked up.
2025-05-16 22:00:02 +02:00
Andy Wingo
7010b4fce0 Fix --with-gc-debug in whippet.m4 2025-05-16 21:59:40 +02:00
Andy Wingo
9512c8b806 Simplify mmc-attrs.h 2025-05-16 21:59:27 +02:00
Andy Wingo
8a157bc616 Add allocation counter to prepare_gc event
Adapt all users
2025-05-16 21:59:07 +02:00
Andy Wingo
b96a22d3ea primitive-load after boot uses read-syntax
* module/ice-9/boot-9.scm (primitive-load): Define a version in Scheme
that uses read-syntax.  This allows the expander to be able to access
source locations.
2025-05-15 22:36:41 +02:00
Andy Wingo
ddef73d03f Remove the last direct uses of BDW API
* configure.ac: Remove code to detect BDW, that is taken care of by the
whippet macros.  Remove support for ia64, for the moment at least,
perhaps for good.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS):
Remove BDW cflags.
(modinclude_HEADERS): Remove bdw-gc.h.
* libguile/bdw-gc.h: Remove.
* libguile/fluids.c:
* libguile/hashtab.c:
* libguile/numbers.c:
* libguile/smob.c:
* libguile/srfi-4.c:
* libguile/struct.c:
* libguile/vectors.c:
* libguile/vm.c: Remove bdw-gc.h includes.
* meta/guile-4.0-uninstalled.pc.in (Libs):
* meta/guile-4.0.pc.in (Libs): Remove direct dependency on BDW-GC, as it
is all encapsulated through Whippet, which is not publically exposed.
2025-05-15 16:13:18 +02:00
Andy Wingo
c9df342c9a Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 15:56:48 +02:00
Andy Wingo
f5edbc278b Add warn proc to bdw 2025-05-15 15:56:40 +02:00
Andy Wingo
f71775f396 Remove BDW usage from gc.c
* libguile/atomics-internal.h (scm_atomic_subtract_size): New helper.
* libguile/gc.c (scm_gc_register_allocation): Rework to use atomics.
(scm_gc_event_listener_restarting_mutators): Reset the
off_heap_allocation_countdown to the heap size after GC.
(scm_gc_disable, scm_gc_enable): Remove these.  Unclear what they mean
exactly!  Perhaps if there is a meaning we can look at it later.
(scm_i_gc):
(scm_storage_prehistory):
(scm_init_gc): Update.
2025-05-15 15:56:03 +02:00
Andy Wingo
d560676572 Wire loader DT_GUILE_GC_ROOT sections to Whippet API
* libguile/loader.c (add_roots):
(scm_trace_loader_conservative_roots):
(process_dynamic_segment): Use Whippet API to register roots.
* libguile/trace.h (struct gc_heap_roots): Define here.
* libguile/whippet-embedder.h (gc_trace_mutator_conservative_roots):
(gc_trace_heap_conservative_roots): Add definitions.
2025-05-15 15:15:28 +02:00
Andy Wingo
b97b12a19b Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 14:47:07 +02:00
Andy Wingo
08e6633f93 Add embedder API to provide heap and mutator conservative roots 2025-05-15 14:46:34 +02:00
Andy Wingo
f5a1d2ca33 Use Whippet API for signal handler thread
* libguile/scmsigs.c (signal_delivery_thread): Use Whippet API.
2025-05-15 12:05:52 +02:00
Andy Wingo
799901edc4 Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 12:00:17 +02:00
Andy Wingo
2f13187f62 Add gc_safepoint_signal_number() API 2025-05-15 11:59:51 +02:00
Andy Wingo
8b12d6f26c Excise BDW API use from threads.c
* libguile/threads.c (with_guile, scm_without_guile): Use gc_activate /
gc_deactivate API.  It's a noop on BDW, but all we lose is a bit of
precision.
(%call-with-new-thread): Remove GC_collect_a_little call, it was
useless.
2025-05-15 11:50:47 +02:00
Andy Wingo
173adcfe09 Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 11:39:48 +02:00
Andy Wingo
6a554e5dd7 Add gc_deactivate / gc_reactivate
Guile needs this.
2025-05-15 11:39:12 +02:00
Andy Wingo
8f7e3dde4a Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 11:27:08 +02:00
Andy Wingo
675d8d649a Rework gc_call_without_gc to allow reentrancy
Rename to gc_deactivate_for_call / gc_reactivate_for_call
2025-05-15 11:26:27 +02:00
Andy Wingo
0e8c6b6727 Remove SMOB mark functions
Oh yeah!  They are almost impossible to use correctly as-is, have mostly
disappeared in practice (I am aware of only two users), have the wrong
interface for moving collectors, and current usage has cemented smobs as
conservatively-marked objects.  In order to move forward with Whippet,
they have to go!

* libguile/deprecated.h (SCM_SMOB_MARK, SCM_GLOBAL_SMOB_MARK, scm_mark0)
(scm_markcdr, scm_free0, scm_set_smob_mark, scm_gc_mark): Remove these,
leaving defines to indicate that users should talk to guile-devel to
figure out what to do.
* libguile/smob.h: Remove interfaces relating to mark functions.
(scm_new_double_smob, scm_new_smob): Make not inline
* libguile/smob.c: Remove mark functions from here.
(scm_new_smob): Out-of-line-only definition.
(scm_smob_prehistory): Don't create a new GC kind for smobs.

* test-suite/standalone/test-smob-mark-race.c:
* test-suite/standalone/test-smob-mark.c: Remove.
* test-suite/standalone/Makefile.am: Update.
2025-05-15 10:46:01 +02:00
Andy Wingo
2bfc66554e Remove BDW alloc lock API in vm.c
* libguile/vm.c (vm_expand_stack_inner):
(vm_expand_stack):
(reinstate_continuation_x):
(compose_continuation): Use gc_inhibit_preemption /
gc_reallow_preemption.
2025-05-15 09:25:03 +02:00
Andy Wingo
1e3ce66224 Merge remote-tracking branch 'whippet/main' into wip-whippet 2025-05-15 09:02:31 +02:00
Andy Wingo
d58aa71281 Add API to inihibit pre-emption
This is really only for BDW.  It uses GC_alloc_lock() /
GC_alloc_unlock().
2025-05-15 09:01:28 +02:00
Mikael Djurfeldt
f948d414f8 Fixed documentation for make-guardian.
* module/ice-9/guardians.scm (make-guardian): Copy full documentation of
old C version.
2025-05-14 22:00:06 +02:00
Andy Wingo
1e06be2fa8 Remove weak sets
* libguile/weak-set.c:
* libguile/weak-set.h: Remove.
* libguile.h:
* libguile/Makefile.am: Adapt build and includes.
* libguile/scm.h: Remove weak set tc7.
* libguile/evalext.c:
* libguile/hash.c:
* libguile/ioext.c:
* libguile/ports.c:
* libguile/print.c: Remove weak-set includes and tc7 cases.
* libguile/init.c: No need to init weak sets.
* module/language/cps/compile-bytecode.scm:
* module/system/base/types.scm:
* module/system/base/types/internal.scm:
* module/system/vm/assembler.scm: Adapt to tc7 change.
2025-05-14 16:12:11 +02:00
Andy Wingo
4138d3c646 The symbol table is an ephemeron table
* libguile/symbols.c: Rework the symbol table to be an ephemeron table
instead of a weak set.  It is no longer resizeable; getting that to work
will involve some GC cooperation.
2025-05-14 16:12:11 +02:00
Andy Wingo
dbc384a6ba Remove weak set usage in ports.c
* libguile/ephemerons.h:
* libguile/ephemerons.c (scm_c_ephemeron_load, scm_c_ephemeron_push):
New routines.
* libguile/ioext.c (scm_fdes_to_ports): Rework in terms of
scm_c_port_for_each.
* libguile/ports-internal.h (struct scm_t_port): Add pointer to entry on
weak ports list, so that we can cancel it easily.
* libguile/ports.c (release_port): Mark weak ports list entry as dead.
(all_ports_needing_close, for_each_port_needing_close): Rework as
ephemeron chain.
(scm_c_make_port_with_encoding, close_port, scm_c_port_for_each): Adapt
API.
(scm_init_ports): No more weak set.
2025-05-14 16:12:11 +02:00
Mikael Djurfeldt
2a6f6ec354 Add documentation for make-guardian.
* module/ice-9/guardians.scm (make-guardian): Add documentation from old
C version.
2025-05-14 09:59:04 +02:00
Mikael Djurfeldt
c724f92c89 Enable building in separate directory.
* libguile/whippet/embed.am: Add -I$(top_builddir) to WHIPPET_CPPFLAGS.
2025-05-13 15:55:17 +02:00
Mikael Djurfeldt
0a5fedc11d Rename libguile-3.0-gdb.scm -> libguile-4.0-gdb.scm
* libguile/libguile-3.0-gdb.scm: Remove.
* libguile/libguile-4.0-gdb.scm: New.
2025-05-13 15:52:39 +02:00