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

20082 commits

Author SHA1 Message Date
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
Andy Wingo
fcbf0d15b2 Add R7RS XFAILs due to https://bugs.gnu.org/38236 (datum labels)
* test-suite/tests/r7rs.test (failing-test-with-exception): New form.
  ("https://bugs.gnu.org/38236"): Mark a couple more xfails.
2019-11-16 22:07:04 +01:00
Andy Wingo
ddc03c070e Add expected failure for R7RS test due to https://bugs.gnu.org/38235
* test-suite/tests/r7rs.test (failing-test): New form.
  ("https://bugs.gnu.org/38235"): New failing test.
2019-11-16 21:43:34 +01:00
Andy Wingo
b494a7f793 Add r7rs test
* test-suite/tests/r7rs.test: New file, based on tests from Chibi
  Scheme, by Alex Shinn.  There are a few failing tests that a followup
  will fix.
2019-11-16 21:09:51 +01:00
Andy Wingo
614f0ab75f Add install-r7rs!, like install-r6rs!
* module/ice-9/boot-9.scm (install-r7rs!): New function.
2019-11-16 21:09:51 +01:00
Andy Wingo
d914652c0a Add initial implementation of R7RS modules
* module/Makefile.am (SOURCES): Add new files.
* module/scheme/base.scm:
* module/scheme/case-lambda.scm:
* module/scheme/char.scm:
* module/scheme/complex.scm:
* module/scheme/cxr.scm:
* module/scheme/eval.scm:
* module/scheme/file.scm:
* module/scheme/inexact.scm:
* module/scheme/lazy.scm:
* module/scheme/load.scm:
* module/scheme/process-context.scm:
* module/scheme/r5rs.scm:
* module/scheme/read.scm:
* module/scheme/repl.scm:
* module/scheme/time.scm:
* module/scheme/write.scm: New files.  Thanks to Göran Weinholt for
  akku-scm and OKUMURA Yuki for yuni, off of which some of these files
  were based.
2019-11-16 21:09:46 +01:00
Andy Wingo
aabea7394a Allow equality between arrays of vu8 and u8
* libguile/array-map.c (scm_array_equal_p): Treat vu8 and u8 arrays as
  equivalent.
2019-11-16 14:34:53 +01:00
Andy Wingo
4b2c512b94 Update NEWS for records and exceptions work
* NEWS: Update.
* doc/ref/api-data.texi (Records): Fix a typo.
2019-11-14 21:37:00 +01:00
Andy Wingo
95efe14e44 SRFI-18 uses core exceptions
* module/ice-9/boot-9.scm (exception-kind, exception-args): Export.
* module/ice-9/exceptions.scm (exception-kind, exception-args):
  Re-export.
* module/srfi/srfi-18.scm: Rewrite exception support in terms of core
  exceptions, not SRFI-34/35.
* test-suite/tests/srfi-18.test: Since Guile doesn't expose the current
  exception handler as such, SRFI-18 captures it using delimited
  continuations.  This means that we can't compare the result
  of (current-exception-handler) with the installed handler using eq?,
  even though the procedures are indeed equivalent.  So, instead test
  handler behavior.
2019-11-14 16:33:10 +01:00
Andy Wingo
44ee8c5559 Update documentation for with-exception-handler et al
* doc/ref/api-control.texi (Prompt Primitives): Reference the newer
  exception facilities.
  (Exceptions): Rewrite to use the new exception primitives.
  (Exception Terminology): Remove superfluous section.
  (Exception Objects): New section.
  (Raising and Handling Exceptions): New section.
  (Throw and Catch): New section, coalescing the previous catch,
  with-throw-handler, and throw sections.
  (Exceptions and C): New section, for miscellaneous procedures.
  (Handling Errors): Mention the transitional period regarding exception
  handling.
* doc/ref/api-debug.texi (Catching Exceptions): Rewrite to use newer
  exception facilities.
  (Capturing Stacks): Remove, as it's not really recommendable any
  more.
  (Pre-Unwind Debugging): Rewrite to use the new primitives.
  (Standard Error Handling): Add note about transitional status.
  (Stack Overflow): Reference new exception section.
* doc/ref/api-scheduling.texi (Mutexes and Condition Variables):
  Reference new exception section.
* doc/ref/r6rs.texi (rnrs exceptions, rnrs conditions): Update to
  mention compatibility with SRFI-34/35 and to relate to core
  exceptions.
* doc/ref/srfi-modules.texi (SRFI-34): Document.
2019-11-13 22:33:09 +01:00
Andy Wingo
f4ca107f7f Rebase throw/catch on top of raise-exception/with-exception-handler
* libguile/exceptions.c:
* libguile/exceptions.h: New files.
* libguile.h: Add exceptions.h.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, modinclude_HEADERS): Add exceptions.c and
  exceptions.h.
* libguile/init.c (scm_i_init_guile): Initialize exceptions.
* libguile/threads.c (scm_spawn_thread): Use new names for
  scm_i_make_catch_handler and scm_c_make_thunk.
* libguile/throw.c: Rewrite to be implemented in terms of
  with-exception-handler / raise-exception.
* libguile/throw.h: Use data types from exceptions.h.  Move
  scm_report_stack_overflow and scm_report_out_of_memory to
  exceptions.[ch].
* module/ice-9/boot-9.scm (&error, &programming-error)
  (&non-continuable, make-exception-from-throw, raise-exception)
  (with-exception-handler): New top-level definitions.
  (throw, catch, with-throw-handler): Rewrite in terms of
  with-exception-handler and raise-exception.
: New top-level definitions.
* module/ice-9/exceptions.scm: Adapt to re-export &error,
  &programming-error, &non-continuable, raise-exception, and
  with-exception-handler from boot-9.
  (make-quit-exception, guile-quit-exception-converter): New exception
  converters.
  (make-exception-from-throw): Override core binding.
* test-suite/tests/eval.test ("inner trim with prompt tag"): Adapt to
  "with-exception-handler" being the procedure on the stack.
  ("outer trim with prompt tag"): Likewise.
* test-suite/tests/exceptions.test (throw-test): Use pass-if-equal.
* module/srfi/srfi-34.scm: Reimplement in terms of core exceptions, and
  make "guard" actually re-raise continuations with the original "raise"
  continuation.
2019-11-13 22:24:19 +01:00
Andy Wingo
f2c8ff5a52 Remove boot "catch" definition.
* libguile/throw.c (scm_init_throw): Remove boot definition of "catch".
2019-11-07 16:46:53 +01:00
Andy Wingo
3c73d77e2a Move exceptions with key and args to core
* module/ice-9/boot-9.scm (&exception-with-key-and-args)
  (&quit-exception): New definitions.
* module/ice-9/exceptions.scm (make-guile-exception):
  (guile-exception?, guile-exception-key, guile-exception-args): Update
  definitions.
2019-11-07 16:43:23 +01:00