Also give bytevectors a private type (a struct).
* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Remove.
(SCM_BYTEVECTOR_LENGTH):
(SCM_BYTEVECTOR_CONTENTS): Proxy to the C accessors.
(SCM_BYTEVECTOR_PARENT): Remove from public API.
(SCM_BYTEVECTOR_P, SCM_VALIDATE_BYTEVECTOR): Make public.
(scm_c_bytevector_contents): New function.
* libguile/bytevectors-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
* libguile/bytevectors.c:
* libguile/array-handle.c:
* libguile/arrays.c:
* libguile/foreign.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/loader.c:
* libguile/print.c:
* libguile/r6rs-ports.c:
* libguile/srfi-4.c:
* libguile/strings.c: Adapt to use bytevectors-internal.h as needed, and
sometimes to use the internal bytevector type.
Previously, bytevectors that were serialized into binaries were actually
mutable by compiled bytevector-u8-set! et al.
* libguile/bytevectors.h (SCM_F_BYTEVECTOR_IMMUTABLE): Renumber to 0x80,
as for immutable vectors.
(SCM_BYTEVECTOR_CONTIGUOUS_P): Just use SCM_CELL_TYPE.
(SCM_BYTEVECTOR_FLAGS): Remove unused accessor.
* module/language/tree-il/compile-cps.scm (bytevector-set-converter):
Emit mutable-bytevector? instead of bytevector?.
* module/system/vm/assembler.scm (link-data): Update immutable flag.
* module/language/cps/compile-bytecode.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/system/base/types/internal.scm: Update for immutable-bytevector
predicates.
Before, they were always shifted by 7. Now the flags are just above
0x7f and just the element type is shifted, but by 16.
* libguile/bytevectors.h (SCM_BYTEVECTOR_FLAGS): Rework to not shift.
(SCM_SET_BYTEVECTOR_FLAGS): Remove.
(SCM_MUTABLE_BYTEVECTOR_P): Don't shift the immutable flag.
(SCM_BYTEVECTOR_ELEMENT_TYPE): Shift right by 16.
* libguile/bytevectors.c (SCM_BYTEVECTOR_SET_FLAG): Remove unused
helper.
(make_bytevector_tag): New helper.
(make_bytevector): Use new helper.
(make_bytevector_from_buffer): Add flags and parent args, and use new
helper.
(scm_c_take_gc_bytevector):
(scm_c_take_typed_bytevector):
(scm_bytevector_slice): Update callers.
* module/system/vm/assembler.scm (link-data): Don't shift the flag by 7;
instead shift the element type by 16.
* libguile/programs.h (scm_program_p, scm_program_code)
(scm_primitive_code_p, scm_primitive_code_name, scm_primitive_call_ip):
Don't expose these internal functions to C
ABI.
(scm_program_num_free_variables, scm_program_free_variable_ref,
scm_program_free_variable_set_x): Don't expose these previously-public
functions to C ABI.
(scm_is_program): New internal inline function.
* libguile/stacks.c (narrow_stack): Use new scm_is_program helper.
* libguile/programs.c: Adapt implementation to use SCM_DEFINE_STATIC.
This avoids an indirection and will make the tracer's job easier.
* libguile/frames.h (struct scm_vm_frame): New data type.
(scm_is_vm_frame):
(scm_vm_frame):
(scm_vm_frame_kind):
(scm_vm_frame_fp):
(scm_vm_frame_sp):
(scm_vm_frame_ip):
(scm_frame_init_from_vm_frame): New helpers.
* libguile/frames.c:
* libguile/stacks.c:
* libguile/stacks.h:
* libguile/vm.c: Update all users of SCM_VM_FRAME_* macros to use new
helpers.
* libguile/integers.c (struct scm_bignum): Now that SCM_I_BIG_MPZ is
gone with other deprecated code, we can simplify the bignum
representation. Adapt all users.
* libguile/vm.h (struct scm_vm_cont): Include the tag word, and put
flags there. Rename stack bottom to stack slice and make a flexible
array.
(scm_is_vm_cont):
(scm_to_vm_cont):
(scm_from_vm_cont):
(scm_vm_cont_is_partial):
(scm_vm_cont_is_rewindable): New build-time helpers.
* libguile/continuations.c (scm_i_make_continuation):
(scm_i_continuation_to_frame):
(copy_stack_and_call):
* libguile/continuations.h (scm_t_contregs):
* libguile/frames.c (frame_stack_top):
* libguile/stacks.c (scm_make_stack): Adapt to take struct scm_vm_cont*
instead of SCM for continuations.
* libguile/vm.c (capture_stack): Adapt to scm_vm_cont change. Use new
gc_resolve_conservative_ref API to pin conservative refs from the
captured stack.
(scm_i_vm_cont_to_frame):
(scm_i_capture_current_stack):
(reinstate_continuation_x):
(capture_continuation):
(compose_continuation):
(capture_delimited_continuation):
(abort_to_prompt): Adapt to type changes.
* libguile/Makefile.am (WHIPPET_IMPL_CFLAGS): Add GCC_CFLAGS, to ensure
the same compilation options (notably -fwrapv), to prevent mismatches at
LTO-time.
* 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.
* 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.
* 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.
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.
* 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.
* 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.
* libguile/goops.c (scm_i_define_class_for_vtable)
(create_struct_classes): Use ephemeron hash tables instead of the weak
table API. Add a FIXME about a race.