summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
7 daysReimplement weak vectors in Scheme using ephemeronswip-whippetAndy Wingo15-422/+140
* module/ice-9/weak-vector.scm: New implementation, same interface. * doc/ref/api-memory.texi (Weak vectors): Default weak vector value was documented as empty list when it was actually unspecified, but #f is most useful, so we change documentation and code to match. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES): (DOT_DOC_FILES): (noinst_HEADERS): (modinclude_HEADERS): * libguile.h: * libguile/deprecated.c: * libguile/deprecated.h: * libguile/init.c: * libguile/weak-vector.c: * libguile/weak-vector.h: Remove C weak vector implementation, replaced with deprecation stubs that call out to Scheme. * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-list.h: Remove unused internal header. * libguile/eq.c: * libguile/evalext.c: * libguile/goops.c: * libguile/hash.c: * libguile/scm.h: * module/system/base/types.scm: * module/system/base/types/internal.scm: * module/system/vm/assembler.scm: Remove wvect tc7.
7 daysAdd ephemeron objectsAndy Wingo8-1/+205
* module/ice-9/ephemerons.scm: * libguile/ephemerons.c: * libguile/ephemerons.h: * test-suite/tests/ephemerons.test: New files. * am/bootstrap.am (SOURCES): * test-suite/Makefile.am (SCM_TESTS): * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Wire ephemerons into build. * libguile/scm.h (scm_tc7_ephemeron): New tc7. * module/oop/goops.scm (<ephemeron>): * module/system/base/types/internal.scm (heap-tags): * module/system/vm/assembler.scm (system): * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (scm_class_of): * libguile/init.c (scm_i_init_guile): * libguile/print.c (iprin1): Add cases for new tc7.
7 daysMerge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo1-1/+2
8 daysReimplement guardians in SchemeAndy Wingo7-423/+28
Also, shunt them off to a module, and deprecate the C interface. * module/ice-9/guardians.scm: New file. * am/bootstrap.am (SOURCES): Add new file. * libguile.h: Remove guardians.h include. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES): (DOT_DOC_FILES): (modinclude_HEADERS): Remove guardians.[ch] files. * libguile/init.c (scm_i_init_guile): Remove guardians. * libguile/deprecated.h: * libguile/deprecated.c (scm_make_guardian): Deprecate. * module/ice-9/deprecated.scm: Add make-guardian shim. * module/oop/goops.scm (<guardian>): Remove class; they no longer have a tc16. * module/ice-9/popen.scm: Add guardians module. * test-suite/tests/eval.test: * test-suite/tests/fluids.test: * test-suite/tests/gc.test: * test-suite/tests/guardians.test: * test-suite/tests/threads.test: * test-suite/tests/types.test: Use the guardians module.
8 daysSCM_GC_MALLOC avoids BDW APIAndy Wingo5-11/+8
* libguile/gc.h (SCM_GC_MALLOC, SCM_GC_MALLOC_POINTERLESS): Always redirect to scm_gc_malloc{,_pointerless}. Don't include bdw-gc.h. * libguile/gc-malloc.c (scm_realloc): Use Whippet gc_collect API. * libguile/loader.c: * libguile/scmsigs.c: * libguile/weak-vector.c: Include bdw-gc.
8 daysReimplement scm_is_mutable_pair using gc_heap_containsAndy Wingo2-25/+22
* libguile/pairs.c (scm_to_ref): Copy this stub around again; we should fix this... (scm_is_mutable_pair): Use gc_heap_contains.
8 daysMerge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo5-0/+29
8 daysMore refactors off BDW APIAndy Wingo2-4/+2
* libguile/gc.c (gc): Use Guile finalization API, not BDW. * libguile/threads.c (guilify_self_2): Don't finalize here.
8 daysDon't run finalizers until Guile is initializedAndy Wingo3-18/+17
Prevents a problem where with-exception-handler isn't defined yet by the time the first finalizer gets kicked off (it's a file port, probably one that is closed already...) * libguile/finalizers.h: * libguile/init.c (scm_i_init_guile): * libguile/finalizers.c (queue_finalizer_async): Mark maybe-unused. (scm_init_finalizers): Rework to only enable notification when Guile is finished initializing.
10 daysRework finalizers implementation to use Whippet APIAndy Wingo2-155/+140
* libguile/finalizers.c (ref_to_scm, scm_to_ref): New helpers. (add_finalizer): New helper; returns the finalizer object. (add_builtin_finalizer): New helper for structs, smobs, ports. (scm_i_add_struct_finalizer): (scm_i_add_smob_finalizer): (scm_i_add_port_finalizer): (scm_i_add_pointer_finalizer): (scm_i_add_finalizer): Use new helpers. (scm_i_add_guardian_finalizer): New helper. (run_finalizer, run_finalizers, scm_run_finalizers): Reimplement. (%add-finalizer!): Use new helpers. (queue_finalizer_async): (notify_finalizers_to_run): (start_finalization_thread): (spawn_finalizer_thread): (scm_i_finalizer_pre_fork): (scm_set_automatic_finalization_enabled): (scm_init_finalizers): (scm_init_finalizer_thread): Use Whippet API. * libguile/finalizers.h (scm_i_set_finalizer, scm_i_add_resuscitator): Remove.
10 daysRework pointer implementation to avoid weak tablesAndy Wingo1-83/+102
Instead of storing keep-alive edges in weak tables, just add extra fields on pointer objects. * libguile/foreign.c (make_pointer, pointer_extra_word_count) (set_pointer_extra_word, make_pointer_0, make_pointer_1, make_pointer_3) (attach_finalizer): New helpers. (scm_make_pointer): Never attach finalizers on the null pointer object. (scm_from_pointer): Likewise. (scm_bytevector_to_pointer, scm_procedure_to_pointer): Store keep-alive links in extra words. (scm_init_foreign, scm_register_foreign): Rework init for null, free, and ffi_closure_free pointers.
10 daysMove pointers to new finalization APIAndy Wingo4-10/+35
* libguile/finalizers.h: * libguile/finalizers.c (pointer_finalizer_trampoline) (scm_i_add_pointer_finalizer): New helpers. * libguile/foreign.c (scm_i_finalize_pointer, scm_from_pointer) (scm_set_pointer_finalizer_x): Use new API.
10 daysMove ports towards new finalization APIAndy Wingo4-18/+26
* libguile/finalizers.h: * libguile/finalizers.c (port_finalizer_trampoline): (scm_i_add_port_finalizer): New functions. * libguile/ports.c (scm_i_finalize_port): New helper. (scm_c_make_port_with_encoding): (prepare_iconv_descriptors): Call scm_i_add_port_finalizer.
10 daysAdd tc7 for finalizer objectsAndy Wingo6-1/+22
Whippet will need this. * libguile/scm.h (scm_tc7_finalizer): Reserve. * libguile/evalext.c (scm_self_evaluating_p): Add finalizer case. * libguile/print.c (iprin1): * libguile/finalizers.h: * libguile/finalizers.c (scm_i_print_finalizer): Arrange to print finalizers. * module/oop/goops.scm (<finalizer>): * libguile/goops.c (class_finalizer, scm_class_of) (scm_sys_goops_early_init): Wire up support for <finalizer>. * module/system/base/types/internal.scm (heap-tags): Add finalizers. * module/system/vm/assembler.scm (system): Add emit-finalizer?.
10 daysRefactor to how struct and smob finalization worksAndy Wingo4-15/+42
* libguile/finalizers.h: * libguile/finalizers.c (scm_i_add_struct_finalizer): (scm_i_add_smob_finalizer): New internal API. * libguile/smob.c (scm_i_new_smob): (scm_i_new_double_smob): * libguile/struct.c (scm_i_alloc_struct): Use it.
10 daysRemove scm_i_register_async_gc_callbackAndy Wingo2-48/+0
* libguile/finalizers.h: * libguile/finalizers.c (async_gc_finalizer): (scm_i_register_async_gc_callback): Remove.
10 daysAdd (system finalizers)Andy Wingo6-42/+59
This will replace an internal interface in (system foreign-objects). * module/system/finalizers.scm: New file. * am/bootstrap.am (SOURCES): Add new file. * libguile/foreign-object.h: * libguile/foreign-object.c (invoke_finalizer): (sys_add_finalizer_x): (scm_init_foreign_object): (scm_register_foreign_object): Remove. * libguile/init.c (scm_i_init_guile): Register finalizers instead of foreign-object. * module/system/foreign-object.scm (allocate-instance): Use finalizers module. * libguile/finalizers.c (invoke_finalizer): (scm_sys_add_finalizer): New helper.
10 daysWeak sets and tables no longer vacuum after GCAndy Wingo2-77/+2
These tables will be implemented differently after Whippet. * libguile/weak-set.c (do_vacuum_weak_set, vacuum_all_weak_sets): Remove. (scm_c_make_weak_set, scm_init_weak_set): Don't keep a table of all weak sets. * libguile/weak-table.c (do_vacuum_weak_table, vacuum_all_weak_tables): Remove. (scm_c_make_weak_table, scm_init_weak_table): No table of all tables.
10 daysPrepare structs for new finalization APIAndy Wingo2-4/+10
* libguile/struct.h: * libguile/struct.c (scm_i_finalize_struct): New helper. (struct_finalizer_trampoline): Implement as shim.
10 daysPrepare SMOBs for new finalization APIAndy Wingo3-28/+37
* libguile/atomics-internal.h (scm_atomic_set_bits): New routine. * libguile/smob.c (scm_i_finalize_smob): Use atomics to clear the first word instead of the GC alloc lock. (finalize_smob): Implement as shim.
10 daysRemove all deprecated interfacesAndy Wingo7-1192/+79
We're on a new version series, let's remove deprecated things. Also reduces the amount of work we need to do in adapting to a new GC, notably for bignums. * configure.ac (--disable-tmpnam): Remove flag, tmpnam is gone. * doc/ref/posix.texi (File System): Remove tmpnam docs. * libguile/bitvectors.c (scm_bitvector_to_list): Remove deprecated branch treating arrays as bitvectors. * libguile/deprecated.c: Remove all deprecated code. Whee! * libguile/deprecated.h: Remove deprecated decls. * libguile/posix.c (scm_tmpnam): Remove. * libguile/struct.c (scm_is_valid_vtable_layout): Remove support for 'r' fields. * libguile/vectors.c (scm_vector_copy_partial, scm_vector_to_list) (scm_vector_move_left_x, scm_vector_move_right_x): Remove generalized array cases. * test-suite/tests/vectors.test ("vector->list"): Remove shared array test
12 daysRemove scm_gc_reallocAndy Wingo2-9/+0
Whippet may add a shrink interface, if it is needed. * doc/ref/api-memory.texi (Memory Blocks): Remove some 1.8 references. Remove discussion of scm_gc_malloc. Remove discussion of scm_gc_free. * libguile/gc.h: * libguile/gc-malloc.c (scm_gc_malloc): Remove.
12 daysRemove GUILE_DEBUG_MALLOC configurationAndy Wingo6-313/+0
* configure.ac: Remove --enable-debug-malloc. * doc/ref/api-memory.texi (Memory Blocks): Remove malloc-stats mention. * libguile/debug-malloc.c: * libguile/debug-malloc.h: Remove. * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (modinclude_HEADERS): Remove debug-malloc mentions. * libguile/gc-malloc.c (scm_gc_register_collectable_memory): (scm_calloc): * libguile/init.c (scm_i_init_guile): Remove debug-malloc things.
12 daysMove scm_c_shrink_bytevector off reallocAndy Wingo1-24/+9
* libguile/bytevectors.c (scm_c_shrink_bytevector): Return buf as is if length is more than half of previous. Otherwise make a fresh buffer and copy.
12 daysRefactor srfi-14.c to use malloc instead of reallocAndy Wingo1-94/+45
* libguile/srfi-14.c (char_ranges_insert, char_ranges_delete): New helpers. (scm_i_charset_set, scm_i_charset_set_range, scm_i_charset_unset): Use the new helpers.
12 daysRemove accidental chars in srfi-14.hAndy Wingo1-2/+1
* libguile/srfi-14.h: Remove typo
12 daysMove r6rs-ports off scm_gc_reallocAndy Wingo1-7/+25
* libguile/r6rs-ports.c (grow_byte_buffer, shrink_byte_buffer): New helpers. * libguile/r6rs-ports.c (bytevector_output_port_buffer_grow): (bytevector_output_port_procedure): Use new helpers.
2025-04-23Use scm_inline_gc_malloc for scm_gc_mallocAndy Wingo1-18/+5
* libguile/gc-malloc.c (do_realloc, do_calloc): Remove. (scm_gc_malloc): Dispatch to scm_inline_gc_malloc. (scm_gc_calloc): Dispatch to scm_gc_malloc. (scm_gc_realloc): Mark for removal. The issue is that the realloc'd object should have the same kind. We could add Whippet API but it would be nice to not do that.
2025-04-23Adapt to Whippet inline allocation changesAndy Wingo1-4/+8
* libguile/jit.c (compile_allocate_words_immediate): (compile_allocate_words_immediate_slow): (compile_allocate_pointerless_words_immediate): (compile_allocate_pointerless_words_immediate_slow): Update for new API.
2025-04-23Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo7-63/+52
2025-04-23Move scm_gc_malloc_pointerless to use Whippet APIAndy Wingo1-25/+5
* libguile/gc-malloc.c: Trim set of includes. (do_gc_malloc_atomic): Remove. (scm_gc_malloc_pointerless): Call scm_inline_gc_malloc_pointerless. (scm_gc_strndup): Call scm_gc_malloc_pointerless.
2025-04-23Remove scm_gc_freeAndy Wingo2-14/+1
* libguile/gc.h: * libguile/gc-malloc.c (do_gc_free, scm_gc_free): Remove.
2025-04-23Vtables avoid zero-sized bitmap allocationAndy Wingo1-13/+16
* libguile/struct.c (set_vtable_access_fields): If there are no fields, we don't need to allocate an unboxed fields array.
2025-04-23Remove some uses of scm_gc_freeAndy Wingo4-23/+4
* libguile/i18n.c (scm_make_locale): * libguile/random.c (scm_c_random_bignum): * libguile/regex-posix.c (regex_free): (scm_make_regexp): * libguile/srfi-14.c (scm_i_charset_unset, charsets_intersection) (charsets_complement): Remove calls to scm_gc_free.
2025-04-23Hook up gc_heap_set_allocation_failure_handlerAndy Wingo5-10/+10
* 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.
2025-04-23Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo8-99/+204
2025-04-22Switch to use Whippet allocation fast pathsAndy Wingo7-184/+92
* 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.
2025-04-22Bump version to 3.9.xAndy Wingo1-4/+4
Headed towards a 4.0. The binary format will change slightly but incompatibly (e.g. renumbering of intrinsics). Having a new GC is enough of a change to warrant a minor version bump, and it's been 5 years so why not go major. * GUILE-VERSION (GUILE_EFFECTIVE_VERSION): Bump to 4.0. (GUILE_MICRO_VERSION, GUILE_MINOR_VERSION): Bump to 3.9.0. (LIBGUILE_INTERFACE_CURRENT, LIBGUILE_INTERFACE_AGE): Reset. * meta/guile-4.0.pc.in: * meta/guile-4.0-uninstalled.pc.in: Rename from guile-3.0. * .gitignore: Ignore pkg-config files with 4.0 effective version. * README: Update slightly. * doc/ref/api-evaluation.texi (Load Paths): * doc/ref/api-options.texi (Build Config): * doc/ref/guile-invoke.texi (Environment Variables): * doc/ref/history.texi (A Timeline of Selected Guile Releases): * doc/ref/libguile-parallel.texi (Parallel Installations): * doc/ref/srfi-modules.texi (SRFI-0): Update references to stable version in paths. * module/system/vm/assembler.scm (*bytecode-minor-version*): * libguile/loader.h (SCM_OBJCODE_MAJOR_VERSION): (SCM_OBJCODE_MINIMUM_MINOR_VERSION): (SCM_OBJCODE_MINOR_VERSION): Use the same major objcode version for now but bump the minor to 99. * meta/guile.m4 (GUILE_PKG, GUILE_PROGS): Check for Guile 4.0. * module/ice-9/boot-9.scm (%cond-expand-features): Add new cond-expand features.
2025-04-22Use Whippet API to boot threadsAndy Wingo20-209/+286
* libguile/scm.h (scm_tc7_thread): Give threads their own tc7. * libguile/threads.h (struct scm_thread): Add a tag, so that struct thread can be a SCM directly. Add a struct gc_mutator* member. (scm_thread_handle): New inline function. (SCM_I_IS_THREAD, SCM_I_THREAD_DATA, SCM_VALIDATE_THREAD): Update to use tc7 instead of SMOB tags. * libguile/continuations.c (scm_i_with_continuation_barrier) * libguile/finalizers.c (queue_finalizer_async) * libguile/jit.c (compile_current_thread) * libguile/threads.c (block_self, guilify_self_2) (lock_mutex, unlock_mutex, timed_wait scm_current_thread) (scm_all_threads) * libguile/vm-engine.c (current-thread): Use scm_thread_handle instead of thread->handle. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (class_thread, scm_class_of, scm_sys_goops_early_init) * libguile/print.c (iprin1) * module/language/cps/compile-bytecode.scm (compile-function) * module/oop/goops.scm (<thread>) * module/system/base/types.scm (cell->object) * module/system/base/types/internal.scm (heap-tags) * module/system/vm/assembler.scm: (emit-thread?): Adapt to scm_tc7_thread. * libguile/gc-internal.h: Move init functions that take "struct gc_stack_addr" here, so that internal Whippet uses don't cause Whippet to be added to public headers. * libguile/gc.c (scm_storage_prehistory): Take struct gc_stack_addr as arg, and pass to gc_init. Return a mutator pointer. * libguile/init.c (scm_i_init_guile): Pass mutator and stack base to GC and thread init routines. * libguile/threads.c (scm_trace_dynstack, scm_trace_thread) (scm_trace_thread_mutator_roots): New infra for marking threads in terms of Whippet API. * libguile/threads.c (guilify_self_1): Since we don't use a separate GC kind for threads any more, and thread marking is keyed off gc_mutator_set_roots, we can avoid some of the gnarly synchronization. (on_thread_exit): Arrange to gc_finish_for_thread. (scm_i_init_thread_for_guile): Use gc_init_for_thread. (init_main_thread, with_guile, scm_i_with_guile): Use Whippet API. (scm_threads_prehistory): Take main-thread mutator and the stack base as arguments. * libguile/vm.c (scm_trace_vm): Rework in terms of Whippet API. * libguile/whippet-embedder.h (gc_trace_mutator_roots): Arrange to trace the current mutator's SCM thread object. * libguile/trace.h: New file, to declare implementations of trace routines. * libguile/Makefile.am (noinst_HEADERS): Add trace.h.
2025-04-22Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo1-1/+1
2025-04-18Adapt to Whippet changesAndy Wingo1-1/+1
* libguile/gc.c (scm_storage_prehistory): Adapt to new gc_init prototype.
2025-04-18Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo13-48/+82
2025-04-17Switch statistics collection, GC hooks to use Whippet APIAndy Wingo1-139/+255
* libguile/gc.c: Define an event listener that collects basic statistics, runs C hooks, and arranges to run the Scheme hook if it is nonempty. (scm_gc_stats): Fetch statistics from the gathered event data. (scm_gc_dump): Use scm_basic_stats_print. (scm_storage_prehistory): Fix indentation. (scm_init_gc_protect_object): Remove dead code. (queue_after_gc_hook): Not really needed, as we have an after-GC C event to run the C hooks. Scheme hook activation is inlined into the event listener. (start_gc_timer, accumulate_gc_timer): No need any more. (scm_init_gc): Simplify hook registration.
2025-04-17Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo1-0/+2
2025-04-17Initialize BDW-GC using Whippet APIAndy Wingo1-23/+19
* libguile/gc.c (scm_storage_prehistory): Use Whippet API instead of BDW-GC API.
2025-04-16Update for changes to Whippet buildAndy Wingo3-4/+35
* libguile/Makefile.am (WHIPPET_EMBEDDER_H): Define this variable instead of using -include; otherwise we don't get the chance to set _LARGEFILE64_SOURCE before including Whippet files. (AM_CPPFLAGS): Simplify. (libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES): Explicitly add libwhippet.la as a dependency. (noinst_HEADERS): Add gc-internal.h * libguile/gc-internal.h: New file. * libguile/gc.c: Include gc-internal.h.
2025-04-16Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo9-127/+150
2025-04-16Link Whippet into GuileAndy Wingo1-1/+1
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_LIBADD): Add libwhippet.la.
2025-04-16Add Whippet to libguile/Makefile.amAndy Wingo2-3/+228
* configure.ac: Add subdir-objects Makefile.am option, to prevent accidental collision between object file names. * libguile/Makefile.am: Include whippet/embed.am, and add the appropriate hooks to the Makefile. * libguile/whippet-embedder.h: New file.
2025-04-16Merge remote-tracking branch 'whippet/main' into wip-whippetAndy Wingo1-1/+2