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.
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.
* libguile/hashtab.h (SCM_HASHTABLE_VECTOR):
(SCM_SET_HASHTABLE_VECTOR):
(SCM_HASHTABLE):
(SCM_HASHTABLE_N_ITEMS):
(SCM_SET_HASHTABLE_N_ITEMS):
(SCM_HASHTABLE_INCREMENT):
(SCM_HASHTABLE_DECREMENT):
(SCM_HASHTABLE_UPPER):
(SCM_HASHTABLE_LOWER):
(SCM_HASHTABLE_N_BUCKETS):
(SCM_HASHTABLE_BUCKET):
(SCM_SET_HASHTABLE_BUCKET): Remove these internal definitions from the
public interface.
(scm_t_hashtable): Add a tag, and add buckets.
(scm_is_hashtable):
(scm_to_hashtable):
(scm_from_hashtable): New helpers.
* libguile/modules.c (scm_module_reverse_lookup): Adapt to hash table
API change.
* libguile/hashtab.c: Rework to access hash table data through the typed
"struct scm_t_hashtable".
* libguile/foreign.h (SCM_IMMUTABLE_POINTER): Remove. This was part of
the implementation of static subrs, a long long time ago, but hasn't
been used since 2013 (27337b6373).
* libguile/numbers.h (scm_t_double, scm_t_complex): Change type and pad
to scm_t_bits.
(struct scm_fraction): New type.
(scm_is_fraction, scm_to_fraction, scm_from_fraction)
(scm_fraction_numerator, scm_fraction_denominator): New helpers.
(SCM_FRACTIONP, SCM_FRACTION_NUMERATOR, SCM_FRACTION_DENOMINATOR): Use
new helpers.
* libguile/numbers.c (scm_i_make_ratio_already_reduced): Allocate using
scm_allocate_tagged.
* libguile/keywords-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
* libguile/hash.c:
* libguile/init.c:
* libguile/keywords.c: Include new file.
(scm_symbol_to_keyword): Allocate via scm_allocate_tagged.
* libguile/gc.h:
* libguile/pairs.h (scm_pair_car_loc, scm_pair_cdr_loc): New helpers.
(SCM_CARLOC, SCM_CDRLOC): Move here from gc.h.
* libguile/list.c (scm_list_1, scm_list_2, scm_list_3): Just use
scm_cons.
* libguile/pairs.h: Remove inline scm_cons, scm_car, scm_cdr defnitions;
this is less important now with the VM. Add a "struct scm_pair", and
make all SCM_CAR / SCM_CDR checks use it. For now it does type checking
as well.
* libguile/pairs.c (scm_cons, scm_car, scm_cdr): Implement here.
* libguile/scm.h (SCM_DEBUG_PAIR_ACCESSES): No more macro!
* libguile/posix.c (free_string_pointers):
(free_string_pointers_on_unwind):
(allocate_string_pointers): Move here from string.c, and use malloc/free
instead of GC facilities. Adapt all users.
* libguile/strings.h:
* libguile/strings.c (scm_i_allocate_string_pointers): Remove.
* libguile/struct.c (scm_struct_init_1_default):
(scm_struct_init_1): New helpers.
(scm_struct_init_array): Use new helpers.
(scm_struct_init_list): New function.
(scm_make_struct_no_tail): Use scm_struct_init_list instead of mallocing.
Gosh this was a slog
* libguile/dynstack.c (dynstack_ensure_space): Use malloc and free.
Threads have off-heap dynstacks, with manual marking.
(scm_trace_dynstack): Implement tracing.
(trace_pinned_trampoline, scm_trace_dynstack_roots): Implement tracing
for active threads.
(scm_dynstack_capture): Tag dynstacks.
* libguile/dynstack.h (scm_t_dynstack): Add a tag.
(scm_t_dynstack_winder_flags): Add SCM_F_DYNSTACK_WINDER_MANAGED.
* libguile/dynwind.h (scm_t_wind_flags): Add SCM_F_WIND_MANAGED.
* libguile/dynwind.c (scm_dynwind_unwind_handler_with_scm)
(scm_dynwind_rewind_handler_with_scm): These values need to be traced by
GC.
* libguile/scm.h (scm_tc16_dynstack_slice): New typecode. No need for
equality etc because it shouldn't escape to Scheme (currently).
* libguile/trace.h: Add trace decls.
* libguile/threads.c (scm_trace_thread_roots): Trace dynstacks
explicitly here, as they are off-heap.
Instead of a 4-word object that has a tag, stream, pt, and ptob, just
add tag, stream, and ptob fields to pt. Also add a "stream mode",
indicating to the GC how the stream should be traced.
* libguile/custom-ports.c (scm_init_custom_ports): Indicate that streams
are managed.
* libguile/fports.c (scm_make_fptob): Streams are managed.
* libguile/ports-internal.h (scm_t_port_type): Add enum to indicate
stream management.
(scm_t_port): Add type-and-flags, stream, and ptob members.
* libguile/ports.c (scm_port_stream, scm_port_type): New helpers.
(scm_make_port_type): Init stream mode to CONSERVATIVE.
(scm_set_port_stream_mode): New API.
(scm_c_make_port_with_encoding): Adapt to new port representation.
(scm_init_ports): Void ports have unmanaged streams.
* libguile/ports.h (scm_is_port, scm_to_port, scm_from_port): New inline
functions.
(SCM_PORT, SCM_STREAM, SCM_PORT_TYPE): Rework in terms of new functions.
(SCM_SETSTREAM): Remove.
(enum scm_port_stream_mode): New.
(scm_set_port_stream_mode): New.
* libguile/smob.h:
* libguile/smob.c (scm_make_managed_smob_type): New API, to declare that
a SMOB has a certain number of fields, all of which will be traced by
the GC. 0 indicates "unknown", and will disable evacuation.
(scm_make_smob_type): Call scm_make_managed_smob_type with 0 nfields.
(scm_set_smob_field_is_unmanaged): New API to indicate that a field is
unmanaged (and should not be traced by GC).
* libguile/print.c (iprin1):
* libguile/eq.c (scm_equal_p): Add case for locales and also regexps
which we missed in the past.
* libguile/finalizers.h:
* libguile/finalizers.c (scm_i_add_locale_finalizer):
(run_finalizer): Add locale finalizers.
* libguile/scm.h (scm_tc16_locale): New tc16.
* module/oop/goops.scm:
* libguile/goops.c: Add locale class.
* libguile/i18n.c: Give locale objects their own tc16.
* libguile/i18n.c: Remove shim for pre-POSIX 2008, given that gnulib
does appear to have newlocale/uselocale implementations.
* libguile/posix.c: No USE_GNU_LOCALE_API define.
* libguile/r6rs-ports.c: Remove stray include.