* module/ice-9/binary-ports.scm (bytevector-concatenate-reverse):
(bytevector-copy*): New helpers.
(open-bytevector-output-port): New implementation.
* libguile/r6rs-ports.c (scm_open_bytevector_output_port):
(init_bytevector_port_vars): Arrange to proxy to Scheme.
* libguile/random.h (scm_t_rstate): Put a tag word in the beginning.
(scm_is_random_state, scm_to_random_state, scm_from_random_state): New
helpers.
(SCM_RSTATEP, SCM_RSTATE): Use the new helpers.
(scm_masktab): Make private.
* libguile/random.c: Adapt random states to not be a smob.
* libguile/eq.c:
* libguile/print.c:
* libguile/scm.h:
* module/oop/goops.scm: Add new random-state cases. Fix a number of
classes for other types that were recently changed to not be smobs.
The goal was that, as part of a print operation, all nested prints of
contained data would be able to use the same parameters (e.g. write or
not), and also detect cycles, highlight objects, etc. The mechanism was
a heap-allocated data structure. However, given that:
1. Nobody accessed print states from Scheme
2. `write` and `display` should move to Scheme anyway, in order to be
suspendable
3. The "fancyp" and "highlight" options were unused
4. A simple stack-allocated data structure with a per-thread key could
do the trick just as well, without needing the weird freelist
structure
5. Ports-with-print-states were a source of bugs
In the end we switch print states to be something completely internal to
print.c. There are no more SCM print-state objects, and no more
ports-with-print-state.
* libguile/print.h: Remove print state from API.
* libguile/print.c (struct scm_print_state): Move definition here.
(scm_print_opts): Remove "highlight-prefix" and "highlight-suffix"
options, as they were not used.
(ENTER_NESTED_DATA): Remove "fancyp" case.
(init_print_state_key, get_print_state, push_print_state)
(maybe_push_print_state, pop_print_state): New facility to manage stack
of active print states.
(scm_iprin1, print_vector): No more fancyp.
(iprin1): Access "writingp" member directly. Don't make ports with
print states.
(scm_prin1): Manage print state stack.
(scm_iprlist): No more fancyp.
(scm_valid_oport_value_p): Remove; valid outports are SCM_OPOUTPORTP.
* libguile/backtrace.c:
* libguile/filesys.c:
* libguile/fports.c:
* libguile/goops.c:
* libguile/ioext.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/promises.c:
* libguile/socket.c:
* libguile/struct.c: Remove cases that dealt with
ports-with-print-states.
* libguile/private-options.h: Remove highlight options.
* module/ice-9/ports.scm (inherit-print-state): Deprecate.
* libguile/deprecated.c:
* libguile/deprecated.h: Add deprecation shims for print states, as far
as that is possible.
* libguile/mallocs.c:
* libguile/mallocs.h: Delete files. These exposed a SMOB interface for
traced mallocs, which is not compatible with precise tracing, and was
unused and undocumented.
* libguile.h:
* libguile/Makefile.am:
* libguile/init.c: Remove mallocs.
* libguile/options.c:
* libguile/ports.c: Remove useless mallocs.h includes
* libguile/scm.h: Allocate a tc16 for syntax transformers.
* libguile/expand.c: Adapt to renamings.
* libguile/eq.c:
* libguile/goops.c:
* libguile/print.c: Add tc16 cases.
* libguile/macros.h:
* libguile/macros.c (scm_i_make_primitive_syntax_transformer):
(scm_i_primitive_syntax_transformer): Rename internal functions from
scm_i_make_primitive_macro, etc. Use new representation.
(scm_make_syntax_transformer): Update for new representation.
* libguile/gc.c:
(scm_gc_event_listener_restarting_mutators):
(after_gc_async_thunk):
(scm_init_gc): Instead of using a hook for after-gc callbacks, just use
a list of thunks. Will allow us to move hooks to Scheme.
(add-after-gc-callback!, remove-after-gc-callback!): New functions.
* libguile/gc.h (scm_after_gc_hook): Remove.
* libguile/scmsigs.c (signal_delivery_thread): Update comment.
* module/statprof.scm (gcprof):
* test-suite/tests/gc.test ("gc"): Update to use new functions.
* libguile/vm.c (vm_hook_compute_enabled):
(invoke_hook):
(scm_i_vm_prepare_stack):
(VM_ADD_HOOK):
(VM_REMOVE_HOOK): Since we don't actually expose the hook objects, we
can just use lists; it's clearer and will let us move hook objects to
Scheme.
* libguile/filesys.h:
* libguile/filesys.c (SCM_DIR_FLAG_OPEN):
(SCM_DIR_OPEN_P):
(SCM_DIRP):
(SCM_VALIDATE_DIR): Move here, from the header. I don't think people
use them.
* libguile/continuations.c (pin_conservative_roots): New helper.
(capture_auxiliary_stack):
(scm_i_make_continuation): Pin aux stack, jmpbuf, and stack items.
* libguile/continuations-internal.h: New file, for internal definitions.
* libguile/continuations.h: Move out internal definitions.
* libguile/Makefile.am: Add new file.
* libguile/continuations.c: Adapt to put the tag in the beginning of the
continuation (contregs) structure.
* libguile/eq.c:
* libguile/goops.c:
* libguile/init.c:
* libguile/print.c:
* libguile/scm.h:
* libguile/stacks.c:
* libguile/vm.c:
* module/oop/goops.scm: Adapt to contregs tc16 change.
* libguile/srfi-14.c:
* module/srfi/srfi-14.scm: Arrange to define bindings here instead of in
the default environment.
* libguile/init.c:
* libguile/srfi-14.h: Fix so that srfi-14 can register an extension to
be loaded later.
* libguile/unidata_to_charset.awk: Rename private cs_letter_plus_digit
to cs_letter_and_digit.
* module/ice-9/deprecated.scm: Add deprecation trampolines for srfi-14.
* module/ice-9/sandbox.scm:
* module/language/elisp/lexer.scm:
* module/language/scheme/decompile-tree-il.scm:
* module/rnrs/unicode.scm:
* module/sxml/simple.scm:
* module/system/base/syntax.scm:
* module/system/repl/server.scm:
* module/texinfo/serialize.scm:
* module/texinfo/string-utils.scm:
* module/web/http.scm:
* module/web/uri.scm:
* test-suite/tests/strings.test:
* test-suite/tests/tree-il.test: Adapt for srfi-14 being in a module.
This doesn't fundamentally change how charsets are represented, but it
will eventually allow us to migrate more functionality to scheme, as the
charsets have a Scheme-legible representation. Also, and this is really
the point, give charsets their own type code, so that they can be
traced precisely.
* libguile/eq.c:
* libguile/evalext.c:
* libguile/goops.c:
* libguile/print.c:
* module/oop/goops.scm: Adjust to new tc16.
* libguile/srfi-14.h: Make private things private.
* libguile/srfi-14.c: Change to use bytevectors for the ranges. No
functional change.
* libguile/eval.c: Instead of applicable smobs, boot closures are subrs.
This gives better JIT and no shuffling in the VM.
(is_boot_closure):
(boot_closure_code):
(boot_closure_env):
(boot_closure_body):
(boot_closure_num_required_args):
(boot_closure_is_fixed):
(boot_closure_has_rest_args):
(boot_closure_is_rest): Inline functions instead of macros.
(eval): Create boot closures as programs, not smobs.
(prepare_boot_closure_env_for_apply):
(prepare_boot_closure_env_for_eval): Adapt to lower-casing of boot
closure inline functions.
(apply_boot_closure): Rename from boot_closure_apply.
(boot_closure_print): Remove.
(scm_init_eval): Update.
* libguile/throw.c (call_catch_handler): Rework to expect closure to be
program.
(scm_i_make_catch_handler): Rework to make closures.
(scm_init_throw): Rework to allocate trampoline code.
* libguile/exceptions.c (call_thunk):
(call_exception_handler): Rework to expect closure to be program.
(scm_c_make_thunk):
(scm_c_make_exception_handler): Rework to make closures.
(scm_init_exceptions): Rework to allocate trampoline code.
* libguile/gsubr.c (scm_allocate_subr_code):
(scm_make_subr_from_code): New functions.
(create_subr): Refactor in terms of new functions.
(scm_c_make_gsubr):
(scm_c_define_gsubr):
(scm_c_make_gsubr_with_generic):
(scm_c_define_gsubr_with_generic): Adapt.
* libguile/gsubr.c: Arrange to store flags alongside array of subrs.
One flag indicates the thread should also be passed as the first
argument; another says that the closure should be passed. Should remove
the need for arg shuffling in get_callee_vcode eventually.
(record_subr_name): Make the names be a vector; will integrate better
with precise tracing.
(create_subr): Add flags arg. Adapt callers.
(scm_apply_subr): Allow for passing thread or closure.
* libguile/gsubr-internal.h: Add new interfaces to see whether to pass
closure or thread. Pass thread to scm_apply_subr.
* libguile/jit.c (compile_subr_call): Allow for passing thread or
closure.
* libguile/vm-engine.c (subr_call): Pass thread.
* libguile/bitvectors.h: Unit of bitvectors is scm_t_bits, not uint32_t.
* libguile/bitvectors.c: Adapt implementation.
(make_bitvector): Malloc pointerless instead, with inline bits.
* libguile/posix.c (scm_setaffinity):
* libguile/bytevectors.c (uniform-array->bytevector): Adapt to unit size
change.
* module/system/vm/assembler.scm (intern-constant, link-data): Adapt to
bitvector representation change.
As long as we have a tc7 for arrays, we should be able to access it with
a struct type instead of casting each word.
* libguile/arrays-internal.h: New file.
* libguile/arrays.h (scm_array_p): Take just one argument.
(SCM_I_ARRAYP):
(SCM_I_ARRAY_NDIM):
(SCM_I_ARRAY_V):
(SCM_I_ARRAY_BASE):
(SCM_I_ARRAY_DIMS):
(SCM_I_ARRAY_SET_V):
(SCM_I_ARRAY_SET_BASE): Remove.
(scm_i_raw_array, scm_i_make_array, scm_i_shap2ra, scm_init_arrays):
Remove internally-linked decls.
* libguile/init.c:
* libguile/print.c:
* libguile/array-handle.c: Use interfaces from new file.
* module/system/vm/assembler.scm: Update, as we now shift the dimension
count by only 16. Requires a rebuild!
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.