Andy Wingo
dffbf45559
Rework continuations to be relocatable
...
* libguile/continuations-internal.h:
* libguile/continuations.c (scm_i_make_continuation): Allow continuation
objects to be relocated.
2025-07-01 15:48:17 +02:00
Andy Wingo
18dac263a1
Pin bytevectors passed to bytevector->pointer
...
* libguile/foreign.c (scm_bytevector_to_pointer): Pin bv.
2025-07-01 15:38:33 +02:00
Andy Wingo
2e0c7c9696
Dynstack snapshot relocation
...
* libguile/dynstack.c (scm_trace_dynstack): Allow for snapshots to be
relocated.
2025-07-01 15:32:21 +02:00
Andy Wingo
c379fba9a9
Allow for contiguous bytevectors to be relocated
...
* libguile/trace.h (scm_trace_bytevector): Update contents pointer for
contiguous bytevectors.
* module/system/vm/assembler.scm (link-data): Make sure to set the
contiguous flag on serialized bytevectors.
2025-07-01 15:14:47 +02:00
Andy Wingo
77a6914c3a
Include new Whippet header files
...
* libguile/gc-internal.h: Add includes that were split out of gc-api.h,
to allow trace functions to use functions in gc-api.h.
2025-07-01 13:20:38 +02:00
Andy Wingo
bb65e18d68
Merge remote-tracking branch 'whippet/main' into wip-whippet
2025-07-01 13:19:38 +02:00
Andy Wingo
9de24bd429
Implement scm_trace_object
...
* libguile/trace.h: Make a precise object tracer.
2025-07-01 11:07:39 +02:00
Andy Wingo
a7801c750f
vm: BUILDING_LIBGUILE-guarded defs to internal headers
...
Also make "struct scm_vm" private, now that scm_thread is also private.
* libguile/vm-internal.h: New file.
* libguile/Makefile.am: Add new file.
* libguile/continuations.c:
* libguile/debug.c:
* libguile/frames.c:
* libguile/init.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/script.c:
* libguile/stacks.c:
* libguile/threads-internal.h:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c:
* libguile/vm.c: Include new file.
* libguile/vm.h: Remove private defs.
2025-07-01 11:04:57 +02:00
Andy Wingo
6a32628e18
frames, values: BUILDING_LIBGUILE-guarded defs to internal headers
...
I was writing the trace function, which is included by Whippet, which
doesn't have the BUILDING_LIBGUILE define. It is just as fine to put
these in private headers; better, even.
* libguile/frames-internal.h:
* libguile/values-internal.h: New files.
* libguile/Makefile.am (noinst_HEADERS): Add new files.
* libguile/backtrace.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/frames.h:
* libguile/gsubr.c:
* libguile/init.c:
* libguile/intrinsics.c:
* libguile/numbers.c:
* libguile/print.c:
* libguile/smob.c:
* libguile/smob.h:
* libguile/stacks.c:
* libguile/stacks.h:
* libguile/values.c:
* libguile/values.h:
* libguile/vm.c: Include new files.
2025-07-01 10:43:14 +02:00
Andy Wingo
65a265adea
Add filesys-internal.h
...
* libguile/Makefile.am: Add new file.
* libguile/filesys-internal.h: New file.
* libguile/filesys.c:
* libguile/filesys.h:
* libguile/fports.c:
* libguile/finalizers.c:
* libguile/init.c:
* libguile/print.c: Adapt.
2025-06-30 16:05:38 +02:00
Andy Wingo
823df42d0c
Move scm_cond, scm_mutex definitions to internal header
...
* libguile/threads.c
* libguile/threads-internal.h: As it says on the tin!
2025-06-30 16:03:25 +02:00
Andy Wingo
7c13e983b3
Add srfi-14-internal.h
...
* libguile/srfi-14-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add file.
* libguile/srfi-14.h: Remove internal definitions.
* libguile/init.c:
* libguile/srfi-14.c:
* libguile/eq.c:
* libguile/print.c: Use internal file.
2025-06-30 15:46:14 +02:00
Andy Wingo
c66668a87a
Move struct scm_regexp definition to internal header
...
* libguile/regex-posix.c:
* libguile/regex-posix.h (scm_is_regexp):
(scm_to_regexp):
(scm_from_regexp):
(SCM_REGEXP_P):
(SCM_VALIDATE_REGEXP): Move definitions to header.
2025-06-30 15:45:37 +02:00
Andy Wingo
cce7a04e55
Add macros-internal.h
...
* libguile/macros-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add file.
* libguile/macros.h: Remove internal definitions.
* libguile/init.c:
* libguile/macros.c:
* libguile/print.c: Use internal file.
2025-06-30 15:35:30 +02:00
Andy Wingo
db13048459
Add i18n-internal.h
...
* libguile/i18n-internal.h: New file.
* libguile/Makefile.am: Add file.
* libguile/i18n.c:
* libguile/finalizers.c:
* libguile/init.c: Use new file.
2025-06-30 15:30:43 +02:00
Andy Wingo
30ad63113a
Add bitvectors-internal.h
...
* libguile/bitvectors-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
* libguile/bitvectors.c: Adapt to add scm_ prefix to the is_bytevector,
bytevector_bits, etc helpers.
* libguile/bitvectors.h (scm_is_bitvector): Define inline. Remove
internal defines from the header.
* libguile/eq.c:
* libguile/init.c:
* libguile/print.c:
* libguile/array-handle.c: Adapt.
2025-06-30 15:26:14 +02:00
Andy Wingo
62b23a8dc4
Add smob-internal.h
...
* libguile/smob-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
* libguile/smob.c (scm_new_smob, scm_new_double_smob): Adapt.
2025-06-30 14:58:44 +02:00
Andy Wingo
8e6a06ca29
Name the field for string backing store
...
* libguile/strings.h (chars): Name the field.
* libguile/strings.c (string_stringbuf, string_aliased_string)
(make_string, scm_i_string_ensure_mutable_x, scm_i_substring_shared)
(scm_i_try_narrow_string, scm_i_string_set_x): Adapt.
2025-06-30 14:53:58 +02:00
Andy Wingo
38c22e77a0
Add new typed struct helpers to get size and unboxed fields
...
* libguile/struct.h (scm_i_vtable_size):
(scm_i_vtable_unboxed_fields): New helpers.
2025-06-30 14:49:35 +02:00
Andy Wingo
4f25a845cb
Dispatch gc_trace_object to scm_trace_object
...
* libguile/whippet-embedder.h (gc_trace_object): Call scm_trace_object.
* libguile/trace.h (scm_trace_object): Stub implementation.
2025-06-30 14:47:10 +02:00
Andy Wingo
974550e335
Move "struct scm_syntax" definition to internal header
...
* libguile/syntax.c:
* libguile/syntax.h (scm_is_syntax, scm_to_syntax, scm_from_syntax):
Move here.
2025-06-30 14:36:53 +02:00
Andy Wingo
c18e93ef04
Add scm_integer_size_z to internal integers.h
...
* libguile/integers.c (scm_integer_size_z):
* libguile/integers.h: Voilà.
2025-06-30 14:35:41 +02:00
Andy Wingo
1eedd208fb
Move "struct scm_ephemeron_table" to internal header
...
* libguile/ephemerons.c:
* libguile/ephemerons.h: Put definition here.
2025-06-30 14:35:06 +02:00
Andy Wingo
2b3b843f82
Dynstack uses inline functions instead of macros
...
* libguile/control.c:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/vm.c: Move SCM_DYNSTACK_TAG etc to be inline functions.
Adapt all callers.
2025-06-30 14:28:52 +02:00
Andy Wingo
985c1d16f2
Make dynstack interface completely internal
...
* libguile/Makefile.am (noinst_HEADERS, modinclude_HEADERS): Don't
install dynstack.h.
* libguile/dynwind.c (translate_frame_flags, scm_dynwind_begin)
(translate_winder_flags, scm_dynwind_unwind_handler):
* libguile/dynwind.h (scm_t_dynwind_flags, scm_t_wind_flags): Instead of
punning the dynwind.h flags to dynstack.h values, translate them.
* libguile/threads-internal.h:
* libguile/threads.h: Include dynstack.h in the private header.
2025-06-30 14:07:05 +02:00
Andy Wingo
8726b8789b
Replace alloca hack in vm.c:invoke_hook with alignas
...
* libguile/vm.c (invoke_hook): Stack-allocate the "struct scm_vm_frame"
by specifying an alignment on the type.
2025-06-30 09:57:53 +02:00
Andy Wingo
8b2b0d52d8
Remove "result" member from struct scm_thread
...
* libguile/threads-internal.h:
* libguile/threads.c (scm_trace_thread, guilify_self_1, really_launch):
Remove "result". Replaced by join_results.
2025-06-30 09:56:20 +02:00
Andy Wingo
9eb4d960cd
Pin struct unboxed_fields
...
* libguile/struct.c (set_vtable_access_fields): Pin unboxed_fields, so
that we can access it from within struct trace function.
2025-06-30 09:55:51 +02:00
Andy Wingo
fecd6c00e4
Pin bytevector parents
...
* libguile/bytevectors.c (make_bytevector_from_buffer): If there is a
parent GC-managed object for the buffer, pin that object so that the
buffer remains valid.
2025-06-30 09:55:50 +02:00
Andy Wingo
c79d5bd0f7
Change to be less sloppy as regards functions without prototypes
...
* libguile/gsubr.h (scm_t_subr_0, scm_t_subr_1, etc): New precise
typedefs.
(SCM_AS_SUBR): Use C11's _Generic to cast subrs to the generic subr
type, while also producing a warning/error if the function isn't
compatible.
(SCM_DEFINE_GSUBR, SCM_PRIMITIVE_GENERIC, SCM_DEFINE_PUBLIC)
(SCM_DEFINE_STATIC, SCM_PROC, SCM_REGISTER_PROC, SCM_GPROC): Use
SCM_AS_SUBR.
* libguile/gsubr-internal.h (scm_t_subr_with_thread_0)
(scm_t_subr_with_thread_1, etc): New precise typedefs.
(SCM_AS_SUBR_WITH_THREAD): Like SCM_AS_SUBR.
* libguile/gsubr.c (scm_apply_subr): Cast callee to the right type
before calling.
* libguile/hash.c (floor): Remove weird unused declaration.
* libguile/init.c (scm_boot_guile): Fix type of main_func in definition.
* libguile/jit.c: Fix type of enter_mcode.
* libguile/smob.c (apply_0, apply_1, apply_2, apply_3): Cast callee to
right type.
(scm_smob_trampoline): Use SCM_AS_SUBR.
* libguile/smob.h (SCM_SMOB_APPLY): Use SCM_AS_SUBR.
* libguile/backtrace.c:
* libguile/control.c:
* libguile/dynl.c:
* libguile/eval.c:
* libguile/exceptions.c:
* libguile/expand.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/gc.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/macros.c:
* libguile/memoize.c:
* libguile/pairs.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/rdelim.c:
* libguile/rw.c:
* libguile/vm.c: Adapt scm_c_make_gsubr / scm_c_define_gsubr callers to
use SCM_AS_SUBR.
2025-06-26 15:56:16 +02:00
Andy Wingo
a7d7ff5019
scm_gc_object_address pins its referent
...
* libguile/gc.h:
* libguile/gc.c (scm_gc_pin_object): New function.
(scm_gc_object_address): New function, to be used instead of SCM_UNPACK
when an object's address is exposed, for example via hashq.
* libguile/atomic.c:
* libguile/cache-internal.h:
* libguile/continuations.c:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/ephemerons.c:
* libguile/exceptions.c:
* libguile/finalizers.c:
* libguile/fluids-internal.h:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/frames.c:
* libguile/hash.c:
* libguile/hashtab.c:
* libguile/intrinsics.c:
* libguile/memoize.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/smob.c:
* libguile/struct.c:
* libguile/struct.h:
* libguile/variable.c:
* libguile/vm.c: Use the new functions everywhere that is needed.
Because they take a thread, sometimes we have to do some extra plumbing.
2025-06-26 15:00:22 +02:00
Andy Wingo
b0ce014801
Inline thread wakeup data into "struct scm_thread"
...
This way we don't allocate an untagged wake data, and we don't need a
type tag. On the other hand we have to roll a more complicated seqlock,
but that's fine.
Also switch to require C11 atomics.
* libguile/atomics-internal.h: Remove fallback for when we don't have
C11 atomics.
(scm_atomic_ref_uint32, scm_atomic_swap_uint32, scm_atomic_set_uint32):
New helpers.
* libguile/threads-internal.h:
* libguile/async.h:
* libguile/async.c: Inline the thread wake data. Happily, waking a
remote thread is still wait-free from both sides.
2025-06-25 16:00:07 +02:00
Andy Wingo
7d1eda149e
Manage pre-goops port type list using pairs
...
Avoids sloppy allocations.
* libguile/ports-internal.h (scm_is_port_type):
(scm_to_port_type, scm_from_port_type): New helpers.
* libguile/goops.c (scm_make_port_classes):
(create_port_classes): Use a list and be thread-safe.
2025-06-25 12:55:18 +02:00
Andy Wingo
9e9567b22a
Port type objects are tagged
...
* libguile/scm.h (scm_tc7_port_type):
* libguile/ports-internal.h (struct scm_t_port_type):
* libguile/ports.c (scm_make_port_type): These objects have been
allocated pointerless since 2011, but since 2016 at least they have had
SCM members. Oops!
2025-06-25 12:55:18 +02:00
Andy Wingo
1520a5e425
Convert thread launch data to be vector
...
Before, it was untagged, which is a problem for precise tracing.
* libguile/threads.c (make_launch_data, protect_launch_data)
(unprotect_launch_data, really_launch, launch_thread)
(scm_sys_call_with_new_thread): Use a vector for launch data.
2025-06-25 12:55:18 +02:00
Andy Wingo
5fe6bc9d66
Remove unused scm_make_cache
...
* libguile/cache-internal.h (scm_make_cache): Remove.
2025-06-25 12:55:18 +02:00
Andy Wingo
552960b3e2
Move struct scm_thread definition to private header
...
Allows us to inline the "struct scm_dynamic_state", avoiding an untagged
traced allocation.
* libguile/threads-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
Adapt all users, notably of SCM_I_CURRENT_THREAD and scm_i_misc_mutex.
2025-06-25 12:55:18 +02:00
Andy Wingo
a6b848dcba
Deprecate C hooks
...
* libguile/chooks.c:
* libguile/chooks.h: Remove.
* libguile/deprecated.h:
* libguile/deprecated.c: Add deprecated implementations.
* libguile/gc.c:
* libguile/gc.h: Arrange to call before/after C hooks if deprecated code
is enabled.
* libguile/Makefile.am:
* libguile.h: Remove chooks.[ch] references.
2025-06-25 12:55:18 +02:00
Andy Wingo
08296e6022
Remove last vestiges of ia64 support
...
* configure.ac:
* libguile/continuations-internal.h (struct scm_continuation):
* libguile/continuations.c (capture_auxiliary_stack)
(restore_auxiliary_stack, scm_i_make_continuation, copy_stack_and_call):
* libguile/gen-scmconfig.c (main):
* libguile/threads.h (struct scm_thread): Remove support for aux stacks.
2025-06-25 12:55:18 +02:00
Andy Wingo
4b2924730e
Excise scm_words from struct.c
...
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Update for unboxed-fields
representation change.
* libguile/struct.c (scm_i_alloc_struct, scm_make_struct_simple): Use
scm_allocate_tagged.
2025-06-25 12:55:18 +02:00
Andy Wingo
91ba12f444
Fix vtable base layout
...
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Update for unboxed-fields
representation change.
* module/oop/goops.scm (fold-class-slots): Likewise.
2025-06-25 12:55:12 +02:00
Andy Wingo
bd1e5ff688
Switch unboxed-fields bitmask to be a Scheme integer
...
Requires a full rebuild!!
* libguile/struct.h (SCM_VTABLE_UNBOXED_FIELDS):
(SCM_VTABLE_FIELD_IS_UNBOXED): Use logbit? to determine if a field is
unboxed.
* module/language/cps/guile-vm/lower-primcalls.scm
(vtable-has-unboxed-fields?): Just check against SCM_INUM0.
(vtable-field-boxed?): Likewise, the bitmask is an integer.
* libguile/struct.c (set_vtable_access_fields): Set UNBOXED_FIELDS
bitmask as integer.
2025-06-24 15:05:28 +02:00
Andy Wingo
1c092eb413
Give structs a "struct scm_struct"
...
* libguile/modules.h (SCM_MODULE_OBARRAY):
(SCM_MODULE_USES):
(SCM_MODULE_BINDER):
(SCM_MODULE_EVAL_CLOSURE):
(SCM_MODULE_TRANSFORMER):
(SCM_MODULE_DUPLICATE_HANDLERS):
(SCM_MODULE_IMPORT_OBARRAY): Use SCM_STRUCT_SLOT_REF instead of
SCM_STRUCT_SLOTS.
* libguile/struct.h (scm_is_struct):
(scm_to_struct):
(scm_from_struct):
(scm_i_struct_vtable):
(scm_i_struct_ref_scm):
(scm_i_struct_set_scm):
(scm_i_struct_ref_raw):
(scm_i_struct_set_raw): New helpers.
(SCM_STRUCTP):
(SCM_STRUCT_SLOT_REF):
(SCM_STRUCT_SLOT_SET):
(SCM_STRUCT_DATA_REF):
(SCM_STRUCT_DATA_SET): Use new helpers.
(SCM_STRUCT_DATA):
(SCM_STRUCT_SLOTS): Remove.
(SCM_SET_VTABLE_FLAGS): Fix for SCM_STRUCT_SLOT_REF not being lvalue.
2025-06-24 13:58:14 +02:00
Andy Wingo
c2f451bf57
Remove unused internal inline allocation functions
...
* libguile/gc-inline.h (scm_inline_cell, scm_inline_double_cell)
(scm_inline_words, scm_inline_gc_malloc_pointerless, scm_inline_gc_malloc)
(scm_inline_gc_malloc_words, scm_inline_gc_malloc_pointerless_words):
Remove.
2025-06-24 11:41:49 +02:00
Andy Wingo
5d9d84b68e
Remove internal scm_inline_cons
...
* libguile/gc-inline.h (scm_inline_cons): Remove.
* libguile/vm.c (cons): Inline use.
2025-06-24 11:37:50 +02:00
Andy Wingo
a478665ab6
Move vectors off scm_words
...
Also move most internal vector representation into a private header
file.
* libguile/vectors-internal.h: New file.
* libguile/vectors.h (SCM_I_IS_MUTABLE_VECTOR, SCM_I_VECTOR_WELTS)
(SCM_I_VECTOR_ELTS, SCM_I_VECTOR_LENGTH): Remove these internal
definitions.
* libguile/vectors.c: Adapt to use new data types.
* libguile/eval.c: Include internal file.
* libguile/init.c: Include internal file.
* libguile/array-handle.c (scm_array_get_handle): Use new functions.
2025-06-24 11:20:38 +02:00
Andy Wingo
7dfbb8bc4b
Inline scm_is_vector
...
* libguile/vectors.h (scm_is_vector): Define inline.
(SCM_I_IS_VECTOR): Remove.
* libguile/eval.c (env_tail): Use scm_is_vector.
* libguile/vectors.c (scm_is_vector): Remove.
2025-06-24 10:54:22 +02:00
Andy Wingo
05e868892b
Deprecate SCM_SIMPLE_VECTOR_REF et al
...
* libguile/vectors.h:
* libguile/deprecated.c:
* libguile/deprecated.h (SCM_SIMPLE_VECTOR_LENGTH):
(SCM_SIMPLE_VECTOR_REF):
(SCM_SIMPLE_VECTOR_SET): Deprecate.
2025-06-24 10:52:31 +02:00
Andy Wingo
da51198ce8
Fix a couple SCM_SIMPLE_VECTOR stragglers
...
* libguile/filesys.c (retrieve_select_type):
* libguile/hashtab.c (rehash):
* libguile/posix.c (scm_uname):
* libguile/vectors.c (scm_c_vector_set_x):
(scm_c_make_vector): Fix some SCM_SIMPLE_VECTOR users.
2025-06-24 10:52:27 +02:00
Andy Wingo
617344f822
Switch all users of SCM_SIMPLE_VECTOR_SET to scm_c_vector_set_x
...
* libguile/eval.c:
* libguile/filesys.c:
* libguile/hashtab.c:
* libguile/memoize.c:
* libguile/net_db.c:
* libguile/ports-internal.h:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/regex-posix.c:
* libguile/scmsigs.c:
* libguile/socket.c:
* libguile/stime.c:
* libguile/strports.c: Use C function instead of macro.
2025-06-24 10:40:40 +02:00