platform/upstream/guile.git
5 years agoWording tweak to history.texi
Andy Wingo [Mon, 13 Jan 2020 20:35:15 +0000 (21:35 +0100)]
Wording tweak to history.texi

* doc/ref/history.texi (A Scheme of Many Maintainers): Fix wording.

5 years agoMention Mark Weaver in Guile history section
Andy Wingo [Mon, 13 Jan 2020 20:33:29 +0000 (21:33 +0100)]
Mention Mark Weaver in Guile history section

* doc/ref/history.texi (A Scheme of Many Maintainers): Credit to Mark
  for co-maintaining Guile for more than 5 years.  Thanks!!

5 years agoUpdate NEWS
Andy Wingo [Mon, 13 Jan 2020 19:30:00 +0000 (20:30 +0100)]
Update NEWS

* NEWS: Fold incremental alpha entries into a cumulative 3.0.0 entry.

5 years agoUpdate NEWS.
Ludovic Courtès [Mon, 13 Jan 2020 10:21:09 +0000 (11:21 +0100)]
Update NEWS.

* NEWS (Changes in alpha 2.9.x): Add (web client) news.

5 years agoweb: Update comment regarding the 'tls-wrap' port wrapper.
Ludovic Courtès [Fri, 3 Jan 2020 14:44:54 +0000 (15:44 +0100)]
web: Update comment regarding the 'tls-wrap' port wrapper.

* module/web/client.scm (tls-wrap): Update comment.

5 years agoweb: 'open-socket-for-uri' can verify the server's X.509 certificate.
Ludovic Courtès [Fri, 10 Jan 2020 14:13:40 +0000 (15:13 +0100)]
web: 'open-socket-for-uri' can verify the server's X.509 certificate.

This is largely based on Guix commit
bc3c41ce36349ed4ec758c70b48a7059e363043a and subsequent changes to that
code.

* module/web/client.scm (x509-certificate-directory): New variable.
(set-certificate-credentials-x509-trust-file!*)
(make-credendials-with-ca-trust-files, peer-certificate)
(assert-valid-server-certificate, print-tls-certificate-error): New
procedures.
<top level>: Add call to 'set-exception-printer!'.
(tls-wrap): Add #:verify-certificate? parameter.  When it is true, call
'make-credendials-with-ca-trust-files', pass it to
'set-session-credentials!', and call 'assert-valid-server-certificate'.
(open-socket-for-uri): Add #:verify-certificate? parameter and pass it
to 'tls-wrap'.
(http-request): Add #:verify-certificate? parameter and pass it to
'open-socket-for-uri'.
(define-http-verb): Add #:verify-certificate? parameter and pass it to
'http-request'.
* doc/ref/web.texi (Web Client): Update documentation of
'open-socket-for-uri' and 'http-request'.  Document
'x509-certificate-directory'.

5 years agoweb: Continue handshake upon TLS warning alerts.
Ludovic Courtès [Fri, 10 Jan 2020 11:11:45 +0000 (12:11 +0100)]
web: Continue handshake upon TLS warning alerts.

This is a backport of Guix commit 7b9ac883ea62a816afbfa747c1377dc273c15c20.

* module/web/client.scm (tls-wrap): Catch 'gnutls-error' around
'handshake'.  Upon ERROR/WARNING-ALERT-RECEIVED, print a message and
call 'handshake'.

5 years agoweb: Add 'current-https-proxy' and honor $https_proxy.
Ludovic Courtès [Fri, 10 Jan 2020 11:01:39 +0000 (12:01 +0100)]
web: Add 'current-https-proxy' and honor $https_proxy.

* module/web/client.scm (current-https-proxy): New variable.
(setup-http-tunnel): New procedure.
(open-socket-for-uri): Move 'http-proxy', 'uri', and 'addresses' inside
'open-socket'.  Remove 'with-https-proxy' macro.  Add call to
'setup-http-tunnel'.  Honor 'current-https-proxy' in 'open-socket'.
* doc/ref/web.texi (Web Client): Document 'current-https-proxy'.
* doc/ref/guile.texi: Update copyright years.

Based on Guix commit 9bc8175cfa6b23c31f6c43531377d266456e430e.

Co-authored-by: Sou Bunnbu (宋文武) <iyzsong@gmail.com>
5 years agoweb: Adjust (gnutls) loading to new module autoload semantics.
Ludovic Courtès [Fri, 10 Jan 2020 09:40:02 +0000 (10:40 +0100)]
web: Adjust (gnutls) loading to new module autoload semantics.

Prior to commit cb14fd214365e50b6b1655616ae74d0228933bbd (Guile 2.9.7),
autoloading a module would give you access to all its bindings.  In
future versions, autoloading a module gives access only to the listed
bindings, as per #:select (see <https://bugs.gnu.org/38895>).

This commit adjusts autoloads to the new semantics, fixing a regression
introduced in cb14fd214365e50b6b1655616ae74d0228933bbd.

* module/web/client.scm <top level>: Remove 'module-autoload!' call.
(gnutls-module, ensure-gnutls): Remove.
(load-gnutls): New procedure.
(tls-wrap): Call it instead of 'ensure-gnutls'.  Replace reference to
GNUTLS-MODULE by a call to 'resolve-interface'.

5 years agoBump manual year, and fix NEWS typo
Andy Wingo [Mon, 13 Jan 2020 08:52:01 +0000 (09:52 +0100)]
Bump manual year, and fix NEWS typo

* NEWS: Fix a typo.
* doc/ref/guile.texi: Bump copyright year.

5 years agoGNU Guile 2.9.9 (beta). v2.9.9
Andy Wingo [Mon, 13 Jan 2020 08:11:20 +0000 (09:11 +0100)]
GNU Guile 2.9.9 (beta).

* GUILE-VERSION (GUILE_MICRO_VERSION): Bump to 2.9.9.

5 years agoBump user-visible copyright years to 2020
Andy Wingo [Mon, 13 Jan 2020 07:36:23 +0000 (08:36 +0100)]
Bump user-visible copyright years to 2020

* module/ice-9/command-line.scm (version-etc):
* module/scripts/compile.scm (show-version): Bump to 2020.

5 years agoBump objcode minor version in preparation for new stable series
Andy Wingo [Mon, 13 Jan 2020 07:01:40 +0000 (08:01 +0100)]
Bump objcode minor version in preparation for new stable series

* libguile/loader.h (SCM_OBJCODE_MINIMUM_MINOR_VERSION):
  (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.

5 years agosrfi-11: Do not expose variables to later clauses
Tim Gesthuizen [Tue, 3 Dec 2019 17:50:37 +0000 (18:50 +0100)]
srfi-11: Do not expose variables to later clauses

The current implementation of srfi-11s let-values allows later clauses
to access and modify variables bound in earlier clauses when the clause
is not a proper list.

* module/srfi/srfi-11.scm (let-values): Fix switched variable names.
* test-suite/tests/srfi-11.test (let-values): Add test checking that the
  variable cannot be changed in later clauses.

5 years agoUpdate NEWS
Andy Wingo [Sun, 12 Jan 2020 21:08:49 +0000 (22:08 +0100)]
Update NEWS

* NEWS: Update.

5 years agoRespect thread local fluid defaults
Rob Browning [Sun, 8 Dec 2019 17:35:37 +0000 (11:35 -0600)]
Respect thread local fluid defaults

Previously (fluid-ref (make-thread-local-fluid #t)) would return #f via
scm_fluid_ref because the internal scm_hashq_ref would return #f when
the fluid had not been set, and that was interpreted as an actual value
for the fluid.

Instead, just pass the fluid default as the default for the hash table
lookups so that we don't need a second step to determine if the fluid
was set.

Thanks to Andrew Gierth for tracking down the problem.

5 years agoFix typos in previous commit.
Andy Wingo [Sun, 12 Jan 2020 21:01:54 +0000 (22:01 +0100)]
Fix typos in previous commit.

* module/ice-9/boot-9.scm (record-modifier):
* module/rnrs/records/procedural.scm (make-record-type-descriptor): Fix
  typos.

5 years agoOptionally allow duplicate field names in core records
Andy Wingo [Sun, 12 Jan 2020 20:50:08 +0000 (21:50 +0100)]
Optionally allow duplicate field names in core records

* NEWS: Update.
* doc/ref/api-data.texi (Records): Update docs.
* module/ice-9/boot-9.scm (make-record-type): Add
  #:allow-duplicate-field-names? keyword argument.
  (record-accessor, record-modifier): Allow passing indexes to identify
  fields.
* module/rnrs/records/procedural.scm (make-record-type-descriptor):
  Allow duplicate field names.  Fixes #38611.

5 years agoFix peval bug that ignored excess args
Andy Wingo [Sun, 12 Jan 2020 20:11:09 +0000 (21:11 +0100)]
Fix peval bug that ignored excess args

* module/language/tree-il/peval.scm (peval): Fix arity check for type
  confusion (empty value of "rest" in this context was (), not #f).  The
  effect was that we'd silently allow extra arguments to inlined calls.
  Thanks to Christopher Lam for the report!  Fixes #38617.
* test-suite/tests/peval.test ("partial evaluation"): Add a test.

5 years agoSupport R7RS define-library
Andy Wingo [Sun, 12 Jan 2020 19:14:30 +0000 (20:14 +0100)]
Support R7RS define-library

* module/Makefile.am (ice-9/boot-9.go, NOCOMP_SOURCES): Add
  r7rs-libraries.
* module/ice-9/boot-9.scm ("ice-9/r7rs-libraries"): Include file.
* module/ice-9/psyntax.scm (call-with-include-port): New definition.
  (include): Use call-with-include-port.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/r7rs-libraries.scm: New file.
* module/scheme/base.scm (r7:include, r7:include-ci): Fix mistaken use
  of core "include".  Use include-ci from core.
  (features): Remove features that are already part of core.
* NEWS: Update.

5 years agoAdd NEWS entries
Andy Wingo [Sat, 11 Jan 2020 10:51:38 +0000 (11:51 +0100)]
Add NEWS entries

* NEWS: Add a couple entries.

5 years agoFix bug in closure conversion
Andy Wingo [Sat, 11 Jan 2020 10:48:36 +0000 (11:48 +0100)]
Fix bug in closure conversion

* module/language/cps/closure-conversion.scm (convert-one):
  Strongly-connected components of letrec bindings that do not share a
  closure may include member functions that have a single free variable,
  or even no free variables as a result of free variable pruning.
  Handle this case instead of erroring out.  Thanks to Stefan Israelsson
  Tampe for the report.

5 years agoFix build on 32-bit systems with JIT support
Andy Wingo [Sat, 11 Jan 2020 09:28:36 +0000 (10:28 +0100)]
Fix build on 32-bit systems with JIT support

* libguile/intrinsics.h: Add s64->f64 intrinsic, for 32-bit targets.
* libguile/jit.c (compile_s64_to_f64): Call the intrinsic for 32-bit
  targets.

5 years agoUpdate NEWS with details on guard and autoloads.
Andy Wingo [Fri, 10 Jan 2020 21:09:17 +0000 (22:09 +0100)]
Update NEWS with details on guard and autoloads.

* NEWS: Update.

5 years agoRe-implement `guard'
Andy Wingo [Fri, 10 Jan 2020 20:42:26 +0000 (21:42 +0100)]
Re-implement `guard'

* module/ice-9/exceptions.scm (guard): Add guard definition that
  re-propagates from original continuation, runs consequents in tail
  position in guard continuation, and doesn't rewind the stack.
* module/srfi/srfi-34.scm:
* module/rnrs/exceptions.scm (guard): Re-export from (ice-9
  exceptions).

5 years agoMerge remote-tracking branch 'lightening/master'
Andy Wingo [Mon, 6 Jan 2020 21:00:53 +0000 (22:00 +0100)]
Merge remote-tracking branch 'lightening/master'

5 years agoFix mips32r6 bug
Andy Wingo [Mon, 6 Jan 2020 20:58:04 +0000 (21:58 +0100)]
Fix mips32r6 bug

See also:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925129
http://hades.mech.northwestern.edu/images/1/16/MIPS32_Architecture_Volume_II-A_Instruction_Set.pdf
https://lists.gnu.org/archive/html/lightning/2019-08/msg00010.html
https://lists.gnu.org/archive/html/guile-devel/2019-08/msg00030.html

* lightening/mips-cpu.c: Fix encoding of LR.  Thanks to Bruno Haible.

5 years agoMention WebAssembly in status section
Andy Wingo [Mon, 6 Jan 2020 20:51:02 +0000 (21:51 +0100)]
Mention WebAssembly in status section

* doc/ref/history.texi (Status): Add mention of WebAssembly.

5 years agoUpdate compiler.texi and history.texi
Andy Wingo [Mon, 6 Jan 2020 20:44:39 +0000 (21:44 +0100)]
Update compiler.texi and history.texi

* doc/ref/compiler.texi (Extending the Compiler):
* doc/ref/history.texi (A Timeline of Selected Guile Releases):
  (Status): Update.  Thanks to Mikael Djurfeldt for the bug report.

5 years agoNew function string-replace-substring in (ice-9 string-fun)
Daniel Llorens [Mon, 6 Jan 2020 08:44:01 +0000 (09:44 +0100)]
New function string-replace-substring in (ice-9 string-fun)

By A. Wingo in
https://lists.gnu.org/archive/html/guile-devel/2014-03/msg00058.html.

* module/ice-9/string-fun.scm (string-replace-substring): As stated.
* doc/ref/api-data.texi: Document the new function.
* test-suite/tests/strings.test: Test.

5 years agoExtend core vector-fill! to handle a range
Daniel Llorens [Wed, 18 Dec 2019 13:31:39 +0000 (14:31 +0100)]
Extend core vector-fill! to handle a range

With this patch, these two lines

  (vector-fill! vec fill)
  (vector-fill! vec fill 0 end)

run at the same speed; before, the second one was much slower.

This patch also makes it an error to call vector-fill! with a non-vector
array. The previous implementation did not work correctly in this case.

* libguile/vectors.c (SCM_VALIDATE_MUTABLE_VECTOR): Better error message.
  (vector-fill!): Handle optional arguments start, end. Do not attempt
    to handle non-vector arrays. Rename the C binding to
    scm_vector_fill_partial_x.
  (scm_vector_fill_x): Reuse scm_vector_fill_partial_x.
* module/srfi/srfi-43.scm (vector-fill!): Remove & re-export the core
  version instead.

5 years agoProvide SCM_DEFINE_STATIC
Daniel Llorens [Fri, 3 Jan 2020 10:59:03 +0000 (11:59 +0100)]
Provide SCM_DEFINE_STATIC

From guile-gnome:plain/glib/gnome/gobject/private.h.

* libguile/gsubr.h (SCM_DEFINE_STATIC): As stated.

5 years agoGNU Guile 2.9.8 (beta). v2.9.8
Andy Wingo [Thu, 2 Jan 2020 12:55:22 +0000 (13:55 +0100)]
GNU Guile 2.9.8 (beta).

* GUILE-VERSION (GUILE_MICRO_VERSION): Bump.

5 years agoUpdate NEWS
Andy Wingo [Thu, 2 Jan 2020 12:55:00 +0000 (13:55 +0100)]
Update NEWS

* NEWS: Update for 2.9.8.

5 years agoFix abort_to_prompt bug if dynwind leave thunk expands the stack
Andy Wingo [Thu, 2 Jan 2020 12:27:23 +0000 (13:27 +0100)]
Fix abort_to_prompt bug if dynwind leave thunk expands the stack

* libguile/vm.c (scm_i_vm_emergency_abort, abort_to_prompt): Unwinding
  the dynwind stack can run dynwind leave thunks, which may expand the
  stack, which may invalidate previously calculated SP / FP values.
  (Re)calculate SP/FP after unwinding, to avoid writing to unmapped
  memory.  Fixes compile errors seen on Ubuntu and some other ports.

5 years agosrfi-35: Generate a unique binding for the constructor.
Ludovic Courtès [Sat, 14 Dec 2019 22:56:12 +0000 (23:56 +0100)]
srfi-35: Generate a unique binding for the constructor.

Previously we'd get warnings like:

  t.scm:11:0: warning: shadows previous definition of `unused-constructor-51900bdce47d50c' at /tmp/t.scm:6:0

whenever 'define-condition-type' appeared more than once in a source
file.

* module/srfi/srfi-35.scm (define-condition-type): Rewrite as
'syntax-case' and generate UNUSED-CONSTRUCTOR as a function of TYPE.

5 years agosrfi-35: Replace '&error'.
Ludovic Courtès [Sat, 14 Dec 2019 17:37:43 +0000 (18:37 +0100)]
srfi-35: Replace '&error'.

* module/srfi/srfi-35.scm: Move '&error' to new #:re-export-and-replace
clause.

5 years agoGNU Guile 2.9.7. v2.9.7
Andy Wingo [Fri, 13 Dec 2019 12:57:04 +0000 (13:57 +0100)]
GNU Guile 2.9.7.

* GUILE-VERSION (GUILE_MICRO_VERSION): Bump.
* NEWS: Update.

5 years agoAvoid throwing exceptions during early boot if stdin is closed
Andy Wingo [Fri, 13 Dec 2019 12:52:58 +0000 (13:52 +0100)]
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.

5 years agoUpdate NEWS
Andy Wingo [Wed, 11 Dec 2019 21:01:57 +0000 (22:01 +0100)]
Update NEWS

* NEWS: Fold 2.9.6 NEWS into 3.0 NEWS.  Add NEWS for 2.9.7.

5 years agoDocument JIT environment variables
Andy Wingo [Wed, 11 Dec 2019 20:55:49 +0000 (21:55 +0100)]
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.

5 years agoMerge remote-tracking branch 'origin/stable-2.2'
Andy Wingo [Wed, 11 Dec 2019 20:26:54 +0000 (21:26 +0100)]
Merge remote-tracking branch 'origin/stable-2.2'

5 years agoMove less? slow path out of line
Andy Wingo [Tue, 10 Dec 2019 22:03:19 +0000 (23:03 +0100)]
Move less? slow path out of line

* libguile/jit.c (compile_less, compile_less_slow): Move slow path out
  of line.

5 years agoAdd fixnum fast-path for =
Andy Wingo [Tue, 10 Dec 2019 21:54:17 +0000 (22:54 +0100)]
Add fixnum fast-path for =

* libguile/jit.c (compile_numerically_equal): Add fixnum fast-path.
  (compile_numerically_equal_slow): New slow path.

5 years agoMove allocate-pointerless-words/immediate slow path out of line
Andy Wingo [Tue, 10 Dec 2019 21:38:45 +0000 (22:38 +0100)]
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.

5 years agoMove allocate-words/immediate slow path out of line
Andy Wingo [Tue, 10 Dec 2019 21:33:47 +0000 (22:33 +0100)]
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.

5 years agoMove assert-nargs-le slow path out of line
Andy Wingo [Tue, 10 Dec 2019 21:10:06 +0000 (22:10 +0100)]
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.

5 years agoAdd out-of-line slow path for abort
Andy Wingo [Tue, 10 Dec 2019 21:07:26 +0000 (22:07 +0100)]
Add out-of-line slow path for abort

* libguile/jit.c (compile_abort, compile_abort_slow): Move interpreter
  fallback to slow path.

5 years agoAdd out-of-line slow path for compose-continuation
Andy Wingo [Tue, 10 Dec 2019 21:05:43 +0000 (22:05 +0100)]
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.

5 years agoAdd subr-call out-of-line slow path
Andy Wingo [Tue, 10 Dec 2019 21:02:45 +0000 (22:02 +0100)]
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.

5 years agoMove alloc-frame slow path out of line
Andy Wingo [Sun, 8 Dec 2019 10:57:46 +0000 (11:57 +0100)]
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.

5 years agoMove assert-nargs-ge slow path out of line
Andy Wingo [Tue, 10 Dec 2019 16:11:41 +0000 (17:11 +0100)]
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.

5 years agoMove assert-nargs-ee slow path out of line
Andy Wingo [Sun, 8 Dec 2019 08:38:40 +0000 (09:38 +0100)]
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.

5 years agoMove receive-values slow path out of line
Andy Wingo [Sat, 7 Dec 2019 21:23:36 +0000 (22:23 +0100)]
Move receive-values slow path out of line

* libguile/jit.c (compile_receive_values, compile_receive_values_slow):
  Move slow path out of line.

5 years agoMove receive slow path out of line
Andy Wingo [Sat, 7 Dec 2019 21:20:08 +0000 (22:20 +0100)]
Move receive slow path out of line

* libguile/jit.c (compile_receive, compile_receive_slow): Move slow path
  out of line.

5 years agoMove handle-interrupts slow path out of line
Andy Wingo [Tue, 10 Dec 2019 16:08:22 +0000 (17:08 +0100)]
Move handle-interrupts slow path out of line

* libguile/jit.c (compile_handle_interrupts)
  (compile_handle_interrupts_slow): Move slow path out of line.

5 years agoMove add, sub slow paths out of line
Andy Wingo [Tue, 10 Dec 2019 16:08:05 +0000 (17:08 +0100)]
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.

5 years agoMove add/immediate, sub/immediate slow paths out of line
Andy Wingo [Fri, 6 Dec 2019 21:52:24 +0000 (22:52 +0100)]
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.

5 years agoAdd infrastructure for out-of-line JIT compilation of slow paths
Andy Wingo [Fri, 6 Dec 2019 15:49:22 +0000 (16:49 +0100)]
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.

5 years agoRemove vm->sp_min_since_gc
Andy Wingo [Sat, 7 Dec 2019 21:54:32 +0000 (22:54 +0100)]
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.

5 years agoReduce quo, rem, mod for power-of-two divisors
Andy Wingo [Mon, 9 Dec 2019 20:48:20 +0000 (21:48 +0100)]
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.

5 years agoAllow for inexact integers in quo, rem, and so on
Andy Wingo [Mon, 9 Dec 2019 20:08:43 +0000 (21:08 +0100)]
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.

5 years agoFix non-deterministic crash in 'finalization_thread_proc'.
Ludovic Courtès [Mon, 9 Dec 2019 13:44:59 +0000 (14:44 +0100)]
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.

5 years agoFix JIT tier-up from within loops for already-JIT-compiled functions
Andy Wingo [Sun, 8 Dec 2019 20:44:47 +0000 (21:44 +0100)]
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.

5 years agoFix resolve-r6rs-interface to propagate replacement flags
Andy Wingo [Fri, 6 Dec 2019 14:35:01 +0000 (15:35 +0100)]
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.

5 years agoSingle definition of (iota)
Daniel Llorens [Fri, 6 Dec 2019 13:14:30 +0000 (14:14 +0100)]
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.

5 years agoGNU Guile 2.9.6 (beta) v2.9.6
Andy Wingo [Fri, 6 Dec 2019 10:50:33 +0000 (11:50 +0100)]
GNU Guile 2.9.6 (beta)

* GUILE-VERSION (GUILE_MICRO_VERSION): Bump to 2.9.6.

5 years agoUpdate NEWS for Guile 2.9.6
Andy Wingo [Fri, 6 Dec 2019 10:29:15 +0000 (11:29 +0100)]
Update NEWS for Guile 2.9.6

* NEWS: Update, folding in old NEWS entries.

5 years agoEffects analysis treats the fixed parts of objects specially
Andy Wingo [Fri, 6 Dec 2019 09:19:44 +0000 (10:19 +0100)]
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.

5 years agoAllocations and raw mutating operations restrict to mutable types
Andy Wingo [Thu, 5 Dec 2019 16:04:43 +0000 (17:04 +0100)]
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.

5 years agoPropagate replacement flag for autoload interfaces
Andy Wingo [Thu, 5 Dec 2019 13:05:51 +0000 (14:05 +0100)]
Propagate replacement flag for autoload interfaces

* module/ice-9/boot-9.scm (make-autoload-interface): Propagate replaced
  binding flags to autoload interface.

5 years agoAdd --r6rs and --r7rs options to "guild compile"
Andy Wingo [Mon, 2 Dec 2019 16:29:32 +0000 (17:29 +0100)]
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.

5 years agoAdd guile-3, r6rs, r7rs cond-expand features
Andy Wingo [Mon, 2 Dec 2019 13:32:21 +0000 (14:32 +0100)]
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.

5 years agoAssociate #:replace info with modules, not variables
Andy Wingo [Fri, 29 Nov 2019 10:51:29 +0000 (11:51 +0100)]
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.

5 years agoFix range inference on division in unreachable code
Andy Wingo [Wed, 27 Nov 2019 15:00:43 +0000 (16:00 +0100)]
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.

5 years agoFix frame-call-representation for callees without closures
Andy Wingo [Wed, 27 Nov 2019 14:04:55 +0000 (15:04 +0100)]
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.

5 years agoFix range inference for right-shifts
Andy Wingo [Tue, 26 Nov 2019 10:03:24 +0000 (11:03 +0100)]
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.

5 years agoFix port-position documentation
Andy Wingo [Mon, 25 Nov 2019 08:47:04 +0000 (09:47 +0100)]
Fix port-position documentation

* doc/ref/r6rs.texi (rnrs io ports): Update the translation for
  port-position.

5 years agoFix stack overflow if printing a pre-boot error throws an error
Andy Wingo [Mon, 25 Nov 2019 08:46:13 +0000 (09:46 +0100)]
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.

5 years agoGNU Guile 2.9.5. v2.9.5
Andy Wingo [Fri, 22 Nov 2019 14:24:04 +0000 (15:24 +0100)]
GNU Guile 2.9.5.

* GUILE-VERSION: Bump to 2.9.5.

5 years agoFix texinfo in r7rs.texi
Andy Wingo [Fri, 22 Nov 2019 14:56:00 +0000 (15:56 +0100)]
Fix texinfo in r7rs.texi

* doc/ref/r7rs.texi (R7RS Standard Libraries): Fix syntax.

5 years agoInstall exception converters and printers from boot-9
Andy Wingo [Thu, 21 Nov 2019 15:48:35 +0000 (16:48 +0100)]
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).

5 years agoports: 'scm_port_poll' honors "w" flags.
Ludovic Courtès [Mon, 18 Nov 2019 14:14:56 +0000 (15:14 +0100)]
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.

5 years agoAdd NEWS for R7RS
Andy Wingo [Sun, 17 Nov 2019 14:48:43 +0000 (15:48 +0100)]
Add NEWS for R7RS

* NEWS: Support R7RS.

5 years agoAdd R7RS documentation and --r7rs command-line option
Andy Wingo [Sun, 17 Nov 2019 14:26:23 +0000 (15:26 +0100)]
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.

5 years agoAdd R7RS xfails due to a restriction in hungry-eol-escapes (#38239)
Andy Wingo [Sat, 16 Nov 2019 21:29:41 +0000 (22:29 +0100)]
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.

5 years agoAdd R7RS xfails due to Guile's ( . 42) syntax extension
Andy Wingo [Sat, 16 Nov 2019 21:19:30 +0000 (22:19 +0100)]
Add R7RS xfails due to Guile's ( . 42) syntax extension

* test-suite/tests/r7rs.test ("https://bugs.gnu.org/38238"): Add new
  xfails.

5 years agoAdd R7RS xfails due to https://bugs.gnu.org/38237 (i/o exn types)
Andy Wingo [Sat, 16 Nov 2019 21:12:57 +0000 (22:12 +0100)]
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.

5 years agoAdd R7RS XFAILs due to https://bugs.gnu.org/38236 (datum labels)
Andy Wingo [Sat, 16 Nov 2019 21:06:06 +0000 (22:06 +0100)]
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.

5 years agoAdd expected failure for R7RS test due to https://bugs.gnu.org/38235
Andy Wingo [Sat, 16 Nov 2019 20:43:34 +0000 (21:43 +0100)]
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.

5 years agoAdd r7rs test
Andy Wingo [Sat, 16 Nov 2019 13:33:51 +0000 (14:33 +0100)]
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.

5 years agoAdd install-r7rs!, like install-r6rs!
Andy Wingo [Sat, 16 Nov 2019 13:32:51 +0000 (14:32 +0100)]
Add install-r7rs!, like install-r6rs!

* module/ice-9/boot-9.scm (install-r7rs!): New function.

5 years agoAdd initial implementation of R7RS modules
Andy Wingo [Sat, 5 Oct 2019 19:30:33 +0000 (21:30 +0200)]
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.

5 years agoAllow equality between arrays of vu8 and u8
Andy Wingo [Sat, 16 Nov 2019 08:45:41 +0000 (09:45 +0100)]
Allow equality between arrays of vu8 and u8

* libguile/array-map.c (scm_array_equal_p): Treat vu8 and u8 arrays as
  equivalent.

5 years agoUpdate NEWS for records and exceptions work
Andy Wingo [Thu, 14 Nov 2019 20:37:00 +0000 (21:37 +0100)]
Update NEWS for records and exceptions work

* NEWS: Update.
* doc/ref/api-data.texi (Records): Fix a typo.

5 years agoSRFI-18 uses core exceptions
Andy Wingo [Thu, 14 Nov 2019 15:33:10 +0000 (16:33 +0100)]
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.

5 years agoUpdate documentation for with-exception-handler et al
Andy Wingo [Wed, 13 Nov 2019 21:26:31 +0000 (22:26 +0100)]
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.

5 years agoRebase throw/catch on top of raise-exception/with-exception-handler
Andy Wingo [Fri, 8 Nov 2019 14:31:00 +0000 (15:31 +0100)]
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.

5 years agoRemove boot "catch" definition.
Andy Wingo [Mon, 7 Oct 2019 12:22:54 +0000 (14:22 +0200)]
Remove boot "catch" definition.

* libguile/throw.c (scm_init_throw): Remove boot definition of "catch".

5 years agoMove exceptions with key and args to core
Andy Wingo [Thu, 7 Nov 2019 15:43:23 +0000 (16:43 +0100)]
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.