* libguile/fports.c (scm_i_fdes_is_valid): New internal helper.
(scm_i_fdes_to_port): Use new helper.
* libguile/fports.h: Declare new helper.
* libguile/init.c (scm_standard_stream_to_port): Refactor to use
scm_i_fdes_is_valid.
* doc/ref/guile-invoke.texi (Environment Variables): Remove
GUILE_STACK_SIZE which is no longer needed, and document some JIT
debugging environment variables.
* doc/ref/vm.texi (Why a VM?, Just-In-Time Native Code): Update and link
to environment variables documentation.
* libguile/jit.c (compile_alloc_frame, compile_alloc_frame_slow): Move
slow path out of line.
(emit_alloc_frame_for_sp_fast, emit_alloc_frame_for_sp_slow): New
helpers.
(emit_alloc_frame): Refactor to use the new helpers.
(compile_push, compile_push_slow): Use the new helpers.
(compile_assert_nargs_ee_locals, compile_assert_nargs_ee_locals_slow):
Split off a slow path.
* libguile/jit.c (struct pending_reloc): Rename target_vcode_offset
field to target_label_offset.
(inline_label_offset, slow_label_offset): New helpers.
(emit_direct_tail_call): Use inline_label_offset helper.
(add_pending_reloc): Factor out of add_inter_instruction_patch.
(add_inter_instruction_patch): Use inline_label_offset helper.
(add_slow_path_patch): New helper.
(continue_after_slow_path): New helper.
Add slow path compilers for all instructions.
(compile_slow_path): New helper.
(compile): Compile slow paths after main code.
(compute_mcode): Allocate twice as many labels.
* libguile/jit.c (emit_alloc_frame_for_sp):
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
* libguile/vm.c (vm_increase_sp, scm_i_vm_prepare_stack):
(return_unused_stack_to_os, vm_expand_stack, alloc_frame):
(scm_call_with_stack_overflow_handler):
* libguile/vm.h (struct scm_vm): Remove sp_min_since_gc handling. It
was a very minor optimization when it was centralized in vm.c, but now
with JIT it's causing too much duplicate code generation.
Fixes <https://bugs.gnu.org/37757>.
Reported by Jesse Gibbons <jgibbons2357@gmail.com>.
* libguile/finalizers.c (finalization_thread_proc): Do not enter the
"switch (data.byte)" condition when data.n <= 0.
* libguile/jit.c (scm_jit_compute_mcode): If a caller wants mcode for a
loop but the function already has mcode, instead of punting, just
compile again.
* module/language/cps/effects-analysis.scm (&header): New memory kind,
for the fixed parts of objects. Distinguishing init-only memory
allows us to determine that vector-set! doesn't stomple
vector-length.
(annotation->memory-kind*): New helper, mapping references to fixed
offsets to &header. Use for scm-ref/immediate et al.
* doc/ref/api-modules.texi (Creating Guile Modules): Document
#:re-export-and-replace.
* module/ice-9/boot-9.scm (module-replacements): New module field.
(make-module, make-autoload-interface): Initialize replacements to an
empty hash table.
(resolve-interface): Propagate replacement info when making custom
interfaces.
(define-module): Parse a #:re-export-and-replace keyword arg.
(define-module*): Handle #:re-export-and-replace.
(module-export!, module-re-export!): Add a keyword arg to indicate
whether to replace or not.
(module-replace!): Call module-export! with #:replace? #t.
(duplicate-handlers): Update replace duplicate handler to look for
replacement info on the interfaces.
* module/srfi/srfi-18.scm (srfi):
* module/srfi/srfi-34.scm (srfi): Update to #:re-export-and-replace
raise-continuable as raise.
* module/language/cps/types.scm (div-result-range): It is possible for a
max value to be less than a minimum. In this bug from zig:
(define (benchmark x)
(let loop ((count 0)
(sum 0))
(if (= count 10)
(exact->inexact (/ sum 10)))
(loop (+ count 1) x)))
Here the first iteration gets peeled, and thus the first "if" can't be
true, because "count" is zero. However on the true branch of the if,
range inference produces bogus ranges -- notably, the variable bound
to 10 is inferred to have a min of 10 and a max of 0. This is fine,
because it's unreachable; but that then infects the division, because
the same variable bound to 10 is used there, resulting in division by
zero.
* module/system/vm/assembler.scm (<arity>): Add new "has-closure?"
flag.
(begin-kw-arity, pack-arity-flags, write-arities): Write
"elided-closure?" flag into binary. A negative flag for compat
reasons.
* module/system/vm/debug.scm (elided-closure?, arity-has-closure?): Add
arity-has-closure? accessor.
* module/system/vm/frame.scm (frame-call-representation): Count from 0
for callees with elided closures.