1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

20044 commits

Author SHA1 Message Date
Andy Wingo
dbc93d6195 Avoid throwing exceptions during early boot if stdin is closed
* 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.
2019-12-13 13:52:58 +01:00
Andy Wingo
cf693d862d Update NEWS
* NEWS: Fold 2.9.6 NEWS into 3.0 NEWS.  Add NEWS for 2.9.7.
2019-12-11 22:01:57 +01:00
Andy Wingo
c23fe0ec5a Document JIT environment variables
* 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.
2019-12-11 21:55:49 +01:00
Andy Wingo
bcb4f7dca8 Merge remote-tracking branch 'origin/stable-2.2' 2019-12-11 21:26:54 +01:00
Andy Wingo
114198d15f Move less? slow path out of line
* libguile/jit.c (compile_less, compile_less_slow): Move slow path out
  of line.
2019-12-10 23:03:19 +01:00
Andy Wingo
5e41d58ab9 Add fixnum fast-path for =
* libguile/jit.c (compile_numerically_equal): Add fixnum fast-path.
  (compile_numerically_equal_slow): New slow path.
2019-12-10 22:54:17 +01:00
Andy Wingo
6b335506ef Move allocate-pointerless-words/immediate slow path out of line
* libguile/jit.c (compile_allocate_pointerless_words_immediate)
  (compile_allocate_pointerless_words_immediate_slow): Move slow path
  out of line.
2019-12-10 22:38:45 +01:00
Andy Wingo
f1578c98b2 Move allocate-words/immediate slow path out of line
* libguile/jit.c (compile_allocate_words_immediate)
  (compile_allocate_words_immediate_slow): Move slow path out of line.
2019-12-10 22:33:47 +01:00
Andy Wingo
0c8a4d3426 Move assert-nargs-le slow path out of line
* libguile/jit.c (compile_assert_nargs_le)
  (compile_assert_nargs_le_slow): Move slow path out of line.
2019-12-10 22:20:53 +01:00
Andy Wingo
45b936a8e3 Add out-of-line slow path for abort
* libguile/jit.c (compile_abort, compile_abort_slow): Move interpreter
  fallback to slow path.
2019-12-10 22:20:51 +01:00
Andy Wingo
7a6fdd4fb5 Add out-of-line slow path for compose-continuation
* libguile/jit.c (compile_compose_continuation)
  (compile_compose_continuation_slow): Move interpreter fallback to slow
  path.
2019-12-10 22:17:24 +01:00
Andy Wingo
76b8f107ca Add subr-call out-of-line slow path
* libguile/jit.c (emit_branch_if_heap_object_has_tc7): New helper.
  (compile_subr_call, compile_subr_call_slow): Add a slow path for the
  values case.
2019-12-10 22:02:45 +01:00
Andy Wingo
c9d29e4b4c Move alloc-frame slow path out of line
* 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.
2019-12-10 17:12:35 +01:00
Andy Wingo
16c1a5d2cd Move assert-nargs-ge slow path out of line
* libguile/jit.c (compile_assert_nargs_ge)
  (compile_assert_nargs_ge_slow): Move slow path out of line.
2019-12-10 17:11:41 +01:00
Andy Wingo
7aad56105f Move assert-nargs-ee slow path out of line
* libguile/jit.c (compile_assert_nargs_ee)
  (compile_assert_nargs_ee_slow): Move slow path out of line.
2019-12-10 17:11:36 +01:00
Andy Wingo
8d8c52dde9 Move receive-values slow path out of line
* libguile/jit.c (compile_receive_values, compile_receive_values_slow):
  Move slow path out of line.
2019-12-10 17:09:59 +01:00
Andy Wingo
1152036333 Move receive slow path out of line
* libguile/jit.c (compile_receive, compile_receive_slow): Move slow path
  out of line.
2019-12-10 17:09:20 +01:00
Andy Wingo
a3be0b1e2d Move handle-interrupts slow path out of line
* libguile/jit.c (compile_handle_interrupts)
  (compile_handle_interrupts_slow): Move slow path out of line.
2019-12-10 17:08:22 +01:00
Andy Wingo
9c329776df Move add, sub slow paths out of line
* libguile/jit.c (compile_call_scm_from_scm_sc)
  (compile_call_scm_from_scm_scm_slow): Move non-fixnum path out of
  line.
2019-12-10 17:08:05 +01:00
Andy Wingo
fafa502875 Move add/immediate, sub/immediate slow paths out of line
* libguile/jit.c (compile_call_scm_from_scm_uimm)
  (compile_call_scm_from_scm_uimm_slow): Move non-fixnum path out of
  line.
2019-12-10 17:06:06 +01:00
Andy Wingo
d21c5a26da Add infrastructure for out-of-line JIT compilation of slow paths
* 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.
2019-12-10 17:05:03 +01:00
Andy Wingo
4a6a7e15d6 Remove vm->sp_min_since_gc
* 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.
2019-12-09 22:03:34 +01:00
Andy Wingo
70ad8a2e72 Reduce quo, rem, mod for power-of-two divisors
* module/language/cps/type-fold.scm (power-of-two?): New helper.
  (quo, rem, mod): New reducers for when the denominator is a power of
  two.
2019-12-09 21:48:20 +01:00
Andy Wingo
2178de4d38 Allow for inexact integers in quo, rem, and so on
* module/language/cps/types.scm (&integer): New helper definition.
  (quo, rem, mod): Fix to allow inexact integer results :(
  (even?): Allow inexact integer arguments.
2019-12-09 21:08:43 +01:00
Ludovic Courtès
edf5aea7ac Fix non-deterministic crash in 'finalization_thread_proc'.
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.
2019-12-09 14:44:59 +01:00
Andy Wingo
a1e88ebc12 Fix JIT tier-up from within loops for already-JIT-compiled functions
* 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.
2019-12-08 21:44:47 +01:00
Andy Wingo
d14e8fabb3 Fix resolve-r6rs-interface to propagate replacement flags
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): Fix to
  propagate module-replacements correctly for custom interfaces.
2019-12-06 15:38:08 +01:00
Daniel Llorens
2b6083865a Single definition of (iota)
* module/ice-9/boot-9.scm (iota): Fix to be SRFI-1 compatible.
* module/srfi/srfi-1.scm: Re-export iota.
2019-12-06 14:14:30 +01:00
Andy Wingo
c6a9a7e775 GNU Guile 2.9.6 (beta)
* GUILE-VERSION (GUILE_MICRO_VERSION): Bump to 2.9.6.
2019-12-06 11:50:33 +01:00
Andy Wingo
4a168cddcd Update NEWS for Guile 2.9.6
* NEWS: Update, folding in old NEWS entries.
2019-12-06 11:29:15 +01:00
Andy Wingo
6c6867d570 Effects analysis treats the fixed parts of objects specially
* 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.
2019-12-06 10:23:53 +01:00
Andy Wingo
e63e266105 Allocations and raw mutating operations restrict to mutable types
* module/language/cps/types.scm (annotation->mutable-type): New helper.
  (allocate-words, allocate-words/immediate): Define objects of mutable
  type.
  (scm-set!/tag, scm-set!, scm-set!/immediate, word-set!)
  (word-set!/immediate): Restrict to mutable types.
2019-12-05 17:04:43 +01:00
Andy Wingo
cb14fd2143 Propagate replacement flag for autoload interfaces
* module/ice-9/boot-9.scm (make-autoload-interface): Propagate replaced
  binding flags to autoload interface.
2019-12-05 14:05:51 +01:00
Andy Wingo
0f61d8d797 Add --r6rs and --r7rs options to "guild compile"
* module/scripts/compile.scm (%options, compile): Add --r6rs and --r7rs
  options.
* doc/ref/api-evaluation.texi (Compilation): Add docs.
2019-12-02 17:32:34 +01:00
Andy Wingo
82127b3ad9 Add guile-3, r6rs, r7rs cond-expand features
* module/ice-9/boot-9.scm (%cond-expand-features): Add new features.
* doc/ref/srfi-modules.texi (SRFI-0): Document new features.
2019-12-02 14:34:52 +01:00
Andy Wingo
cf08dbdc18 Associate #:replace info with modules, not variables
* 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.
2019-11-29 11:51:29 +01:00
Andy Wingo
8304b15807 Fix range inference on division in unreachable code
* 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.
2019-11-27 16:03:59 +01:00
Andy Wingo
7190905109 Fix frame-call-representation for callees without closures
* 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.
2019-11-27 15:04:55 +01:00
Andy Wingo
08bd2f0dcb Fix range inference for right-shifts
* module/language/cps/types.scm (compute-ash-range): Fix rsh range
  inference, broken during refactoring.  Fixes
  https://bugs.gnu.org/38369.
2019-11-26 11:03:24 +01:00
Andy Wingo
59febb4b2d Fix port-position documentation
* doc/ref/r6rs.texi (rnrs io ports): Update the translation for
  port-position.
2019-11-25 09:47:04 +01:00
Andy Wingo
2fbc38f0d0 Fix stack overflow if printing a pre-boot error throws an error
* libguile/throw.c (scm_throw): Fall back to fprintf if all is lost.
2019-11-25 09:46:58 +01:00
Andy Wingo
a12e862bec GNU Guile 2.9.5.
* GUILE-VERSION: Bump to 2.9.5.
2019-11-22 15:56:24 +01:00
Andy Wingo
cc3190ed95 Fix texinfo in r7rs.texi
* doc/ref/r7rs.texi (R7RS Standard Libraries): Fix syntax.
2019-11-22 15:56:24 +01:00
Andy Wingo
1907e59c09 Install exception converters and printers from boot-9
* doc/ref/intro.texi (Guile and Scheme): Fix a date.
* module/ice-9/boot-9.scm: Load (ice-9 exceptions).
2019-11-21 16:48:35 +01:00
Ludovic Courtès
659526d33b ports: 'scm_port_poll' honors "w" flags.
Fixes <https://bugs.gnu.org/36709>.
Reported by Mark H Weaver <mhw@netris.org>.

* libguile/ports.c (scm_port_poll): Replace second POLLIN by POLLOUT.
2019-11-18 15:14:56 +01:00
Andy Wingo
2346a540c0 Add NEWS for R7RS
* NEWS: Support R7RS.
2019-11-17 15:48:43 +01:00
Andy Wingo
b634071dd4 Add R7RS documentation and --r7rs command-line option
* doc/ref/Makefile.am: Add r7rs.texi.
* doc/ref/guile-invoke.texi (Command-line Options): Document --r7rs.
* doc/ref/guile.texi (Guile Modules): Link to R7RS.
* doc/ref/intro.texi (Guile and Scheme): Update for R7RS support.
* doc/ref/r7rs.texi: New file.
* doc/ref/scheme-intro.texi (Guile Scheme): Update for R7RS.
* module/ice-9/command-line.scm (*usage*, compile-shell-switches): Add
  --r7rs option.
2019-11-17 15:30:59 +01:00
Andy Wingo
72a2c742f6 Add R7RS xfails due to a restriction in hungry-eol-escapes (#38239)
* test-suite/tests/r7rs.test ("https://bugs.gnu.org/38239"): Add more
  xfails.
2019-11-16 22:29:41 +01:00
Andy Wingo
78ea5c51b5 Add R7RS xfails due to Guile's ( . 42) syntax extension
* test-suite/tests/r7rs.test ("https://bugs.gnu.org/38238"): Add new
  xfails.
2019-11-16 22:19:30 +01:00
Andy Wingo
609c386d89 Add R7RS xfails due to https://bugs.gnu.org/38237 (i/o exn types)
* test-suite/tests/r7rs.test ("https://bugs.gnu.org/38237"): Add more
  expected failures.
2019-11-16 22:12:57 +01:00