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

20710 commits

Author SHA1 Message Date
Christine Lemmer-Webber
a6ba7afed4
Remove lower-cps call in compile-js.
Since ijp's work, lower-cps is run before it reaches this stage.

* module/language/cps/compile-js.scm (lower-cps): Remove import.
(compile-js): Remove call to lower-cps.
2021-10-11 20:59:39 -04:00
Christine Lemmer-Webber
6f112d501d
Compile cps to bytecode by default
* module/language/cps/spec.scm (choose-compiler): Compile cps to
  bytecode by default if js-il or javascript are not explicitly chosen.
2021-10-10 21:44:55 -04:00
Christine Lemmer-Webber
204cb98646
Merge branch 'main' into compile-to-js-merge 2021-10-10 20:59:04 -04:00
Andy Wingo
e60469c8b6 Add primitive alias analysis to CSE
* module/language/cps/effects-analysis.scm (compute-known-allocations):
(compute-clobber-map): Add "conts" parameter, and use it to compute
primcalls that access known allocations.  A write to a known allocation
only clobbers a read to a known allocation if they are the same.
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
Pass conts also to compute-clobber-map.
2021-10-03 21:39:46 +02:00
Andy Wingo
71e201d5c4 Use more logtest in cse.scm
* module/language/cps/effects-analysis.scm (causes-effect?):
(effect-clobbers?): Use logtest.
2021-10-03 21:09:41 +02:00
Andy Wingo
c9c16db694 Allow primcalls with multiple defs
* module/language/cps/types.scm (infer-types): Allow multiple defs.
2021-10-01 11:33:13 +02:00
Andy Wingo
c803566a17 Add ,optimize-cps REPL meta-command
* module/system/repl/command.scm (*command-table*): Add optimize-cps /
optx.
(optimize-cps): Define meta-command.
* module/system/repl/common.scm (optimize*): New helper.
(repl-optimize): Use helper.
(repl-optimize-cps): New public function.
2021-10-01 11:33:13 +02:00
Andy Wingo
426867ac7d Add CPS pretty-printer
* module/language/cps/dump.scm: New file.
* module/Makefile.am (SOURCES): Add to build.
2021-10-01 11:33:10 +02:00
Andy Wingo
c8c35c6987 Allow unchecked functions to have unboxed arguments
* module/language/cps/utils.scm (compute-var-representations): Use
'arg-representations from metadata for arg representations.
* module/language/tree-il/compile-cps.scm (sanitize-meta):
(convert): Make sure incoming terms have no arg representations.
2021-10-01 11:28:22 +02:00
Andy Wingo
8fab68f8b1 Move live variable computation routines to utils and graphs.
* module/language/cps/graphs.scm (rename-keys, rename-intset)
(rename-graph, compute-reverse-control-flow-order)
(compute-live-variables): Move here from slot-allocation.
* module/language/cps/utils.scm: Remove duplicate compute-idoms
definition.
(compute-defs-and-uses, compute-var-representations): Move here from
slot-allocation.
* module/language/cps/slot-allocation.scm: Move routines out to utils
and graphs.
2021-10-01 11:28:22 +02:00
Andy Wingo
745b67c04a Add frame-local-ref / frame-local-set! support for type 'ptr
* libguile/frames.c (enum stack_item_representation):
(scm_to_stack_item_representation):
(scm_frame_local_ref):
(scm_frame_local_set_x): Add support for "ptr" representations.
2021-10-01 11:28:22 +02:00
Andy Wingo
d4d4336ede Hotfix to unify (x ...) patterns in match
* module/ice-9/match.upstream.scm (match-gen-ellipsis): Instead of just
binding the identifier when matching (x ...), go through match-one so
that if the id is already bound, we unify instead.
* test-suite/tests/match.test ("unify in list patterns"): Add test.
* test-suite/tests/match.test.upstream: Add additional tests from
upstream.

See commit 05c546e38 in Chibi Scheme.  Thanks to Alex Shinn for help
here!
2021-09-30 15:47:41 +02:00
Ludovic Courtès
74abae04aa Baseline compiler no longer swaps rsh/lsh when transforming ash calls.
Reported by Marius Bakke <marius@gnu.org>
at <https://issues.guix.gnu.org/50696>.

Previously, the baseline compiler would incorrectly emit a right shift
when for, say, (ash x 2), and a left shift for (ash x -2).

* module/language/tree-il/compile-bytecode.scm (canonicalize): When Y is
negative, emit 'rsh', not 'lsh'.
* test-suite/tests/numbers.test ("ash at -O1"): New test.
2021-09-20 23:27:39 +02:00
Ludovic Courtès
330c6ea83f Fix 'ash' primcall match clause in baseline compiler.
Previously the pattern would only match when the two 'src' values were
the same, which is not the case for example when running on the
interpreter.

* module/language/tree-il/compile-bytecode.scm (canonicalize): In 'ash
primcall pattern, rename second 'src' to 'src*'.
2021-09-20 23:24:24 +02:00
Ludovic Courtès
136417990c doc: Fix wrong @uref argument order.
* doc/ref/sxml.texi (SXML): Fix @uref argument order.
2021-09-20 17:00:19 +02:00
Ludovic Courtès
e304773416 srfi-1: 'find-tail' passes 'check-arg' the right procedure name.
* module/srfi/srfi-1.scm (find-tail): Pass 'find-tail' as the 3rd
argument to 'check-arg'.
2021-09-20 17:00:19 +02:00
Ludovic Courtès
5a389ca728 (system repl command) autoloads the compiler, disassembler, and profiler.
* module/system/repl/command.scm: Autoload (system base compile),
(system vm disassembler), and (statprof).
2021-09-20 17:00:19 +02:00
Daniel Llorens
96e3686db1 Revert shift of ndim in array tag from 3df3ba1a2c
To avoid breaking ABI.

* libguile/arrays.h (SCM_I_ARRAY_DIM, scm_i_raw_array): As stated.
* module/system/vm/assembler.scm: As stated.
2021-09-17 11:20:24 +02:00
Daniel Llorens
af741e50e9 Fix typo in srfi-69 doc 2021-09-14 16:55:15 +02:00
Aleix Conchillo Flaqué
1f100a4f20 foreign-library: fix darwin detection
* module/system/foreign-library.scm (system-library-extensions): fix
darwin host detection. darwin host types have "-darwin" but not
"-darwin-".
2021-09-02 08:59:57 +02:00
Daniel Llorens
9a62f7caca Extend bytevector-fill! to handle a partial fill
* libguile/bytevectors.c (bytevector-fill!): As stated.
  (scm_bytevector_fill_x): Stub to avoid changing the C API.
* doc/ref/api-data.texi: Documentation.
* libguile/vectors.c (vector-fill!): Less confusing variable names.
* test-suite/tests/bytevectors.test: Test partial fill cases for
  bytevector-fill!.
2021-08-17 16:47:04 +02:00
Daniel Llorens
926f70f9b5 Refactor srfi-4 declarations 2021-08-17 14:11:11 +02:00
Daniel Llorens
3df3ba1a2c Remove array contp flag
This flag was set, but never used in Guile, and there was no documented
API to access it.

To check if an array is contiguous, use (array-contents <> #t).

* libguile/arrays.h (scm_i_raw_array): New function.
  SCM_I_ARRAY_CONTIGUOUS, SCM_SET_ARRAY_CONTIGUOUS_FLAG,
  SCM_CLR_ARRAY_CONTIGUOUS_FLAG, SCM_I_ARRAY_CONTP: Remove.
  scm_t_array_dim: Declare here, not in array-handle.h.
  SCM_I_ARRAY_NDIM: Shift by one bit since the contp flag isn't there
  anymore.
* module/syste/vm/assembler.scm: Match removal of contp flag.
* libguile/arrays.c (scm_i_make_array): Reuse scm_i_raw_array.
  (scm_i_ra_set_contp): Remove.
  (scm_transpose_array): Don't set or clear the contp flag.
  (scm_make_shared_array): Don't set or clear the contp flag.
  (scm_make_typed_array): Don't set the contp flag.
* libguile/array-map.c (scm_i_array_rebase): Reuse scm_i_raw_array.
2021-08-16 19:02:43 +02:00
Daniel Llorens
c60601332e Deprecate scm_from_contiguous_typed_array
This was never documented and it's not used in Guile itself, either.
2021-08-16 17:00:03 +02:00
Daniel Llorens
c2cf685b65 Remove the 'simple vector' concept
* Deprecate scm_is_simple_vector.
* libguile/vectors.c (scm_vector_elements,
  scm_vector_writable_elements): These functions take an array; reword
  to make this clear.
* libguile/print.h: Remove reference to 'simple vector'.
* doc/ref/api-data.texi: Remove documentation for scm_is_simple_vector.
  Remove references to 'simple vector'.
  Fix documentation for scm_vector_elements,
  scm_vector_writable_elements.
* test-suite/tests/arrays.test:
* test-suite/tests/vectors.test: Remove references to 'simple vector'.
2021-08-16 15:39:21 +02:00
Daniel Llorens
b4a80f4239 Update gnulib to 8f4538a53d64054ae2fc8b86c0f87c418c6176e6
Includes gnulib:0c907f7da13232908f05c415b8cec56024071906 to fix #49930
https://lists.gnu.org/archive/html/bug-guile/2021-08/msg00003.html.
2021-08-16 13:23:27 +02:00
Daniel Llorens
5df5555d12 Add function vector-copy! to core
This is up to 20%-30% faster than the previous versions in (scheme base) or
(srfi srfi-43) that used vector-move-left!/vector-move-right!.

* libguile/vectors.h:
* libguile/vectors.c: As stated.
* doc/ref/api-data.texi (vector-copy!): Document the new function.
  (vector-fill!): Document optional arguments.
  (vector-copy): Document optional arguments.
* module/scheme/base.scm: Reuse core vector-copy!.
* module/srfi/srfi-43.scm: Reuse core vector-copy!.
2021-08-06 17:13:21 +02:00
Daniel Llorens
091f5062cb Reuse core vector-fill! in (scheme base)
module/scheme/base.scm: As stated.
2021-08-06 13:06:51 +02:00
Daniel Llorens
a34c762de0 Extend core vector-copy to r7rs vector-copy
* libguile/vectors.h: Declare scm_vector_copy_partial.
* libguile/vectors.c (scm_vector_copy_partial): As stated.
  (scm_vector_copy): Reuse scm_vector_copy_partial.
* module/scheme/base.scm: Reuse core vector-copy.
* module/srfi/srfi-43: Reuse core vector-copy.
* test-suite/tests/vectors.test: Test vector-copy.
2021-08-06 13:06:51 +02:00
Daniel Llorens
bfda8d3972 Deprecate use of vector-move-left! and vector-move-right! on non-vector arrays
These functions weren't advertised to work on non-vector arrays. They
did try to, but only incorrectly. For example:

  (define a (vector 1 2 3 4 5))
  (define b (make-array 0 '(1 5)))
  (vector-move-right! a 0 2 b 2)
  b
  => #1@1(0 0 1 2 0)

instead of the correct result #1@1(0 1 2 0 0).

* libguile/vectors.c (vector-move-left!, vector-move-right!): As stated.
2021-08-06 13:06:51 +02:00
Daniel Llorens
81f12bf86e Deprecate using vector->list, vector-copy on arrays
* libguile/vectors.c (vector-copy, vector->list): As stated. Provide
  array free implementation for the supported case.
2021-08-05 12:33:34 +02:00
Daniel Llorens
bc7bd22267 Merge libguile/generalized-arrays.* into libguile/arrays.*
* libguile/arrays.h:
* libguile/arrays.c: As stated.
* libguile/init.c: Remove call to scm_init_generalized_arrays().

Elsewhere fix references to generalized-arrays.*.
2021-08-03 14:21:41 +02:00
Maxime Devos
c78c130b1d ice-9/read: Parse #{}}# properly.
This is a regression since Guile 3.0.2 and breaks compilation
of a Guile library.

* module/ice-9/read.scm
  (%read)[read-parenthesized]: When SAW-BRACE? is #t but CH isn't
  #\#, don't eat CH.
* test-suite/tests/reader.test
  ("#{}#): Add four test cases.
2021-08-02 12:15:59 +02:00
Rob Browning
d79a226359 Fix crash on #nil in syntaxes
In 3.0.7 (after 0cc7991855 "Ensure
that (syntax ()) results in ("), the use of #nil in syntax-rules
expansions like this:

  (define-syntax foo
    (syntax-rules ()
      ((_ x) (eq? #nil x))))

  (foo #t)

could cause a crash that looks like this:

  ice-9/psyntax.scm:2795:12: In procedure syntax-violation:
  Syntax error:
  unknown location: unexpected syntax in form ()

To fix it, add another special case (the commit mentioned above
special-cased the empty list) to preserve #nil

* module/ice-9/psyntax.scm (gen-syntax): Preserve #nil.
* test-suite/tests/syntax.test: Test #nil in syntax expansions.

Closes: 49305
2021-07-11 15:00:33 -05:00
Daniel Llorens
118ee0c50b Fix else in init_bouncing_parens() 2021-06-02 10:48:53 +02:00
Daniel Llorens
c1fd55d174 Fix null dereference in readline initialization
* guile-readline/readline.c (init_bouncing_parens): Check that the keymap is
  valid before using it.
2021-05-27 12:00:18 +02:00
Andy Wingo
17aab66e75 Fix bug in eq-constant? propagation in CSE if kf == kt
* module/language/cps/cse.scm (compute-out-edges): Only propagate
constant to successor if successor not kf.
* test-suite/tests/compiler.test ("cse auxiliary definitions"):
("closure conversion"): Refactor.
("constant propagation"): New test.

Fixes #48368.
2021-05-24 11:09:24 +02:00
Daniel Llorens
f499754bc8 Fix bug in nftw function
Fixes bug #44182. Thanks to Matija Obid for the report and RhodiumToad in
2021-05-21 14:19:49 +02:00
Luis Felipe
d1c6ae19f4 Fix typo in lambda documentation.
In the part about lambda formals, change "arguments will converted into"
to "arguments will BE converted into".

* doc/ref/api-procedures.texi (Lambda: Basic Procedure Creation):
  Fix typo.
2021-05-21 14:03:46 +02:00
jakub-w
f3a23edf9e Fixed style for 02439a124
* guile-readline/readline.c (scm_filename_completion_function)
2021-05-19 17:33:14 +02:00
Robin Green
f9f55b9ce7 Fix trace-calls-to-procedure
Fixes #43102 and duplicate #48412.
2021-05-19 16:41:30 +02:00
Jakub Wojciech
02439a1240 Fixed filename-completion-function for readline completion
* guile-readline/readline.c (scm_filename_completion_function):
  A completion function should return #f when there's no more
  candidates.  Since the result of readline's
  rl_filename_completion_function was never checked it was impossible
  for it to work as intended and instead of #f it threw an error from
  trying to convert NULL to an scm string.
2021-05-19 15:45:05 +02:00
Maxime Devos
221203b0df Add ‘expt’ to the list of effect-free primitives.
I find myself writing code like (- (expt 2 32) 1)
lately. Let's allow constant-folding that.

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*):
  Add 'expt'.
2021-05-18 13:42:34 +02:00
Andy Wingo
fd5cb457fb Implement cross-module inlining
* module/language/tree-il/optimize.scm (make-optimizer): Pass
cross-module-inlining? to peval.
* module/language/tree-il/peval.scm (peval): Add cross-module-inlining?
kwarg.  Try to inline public module-ref.
2021-05-11 21:39:07 +02:00
Andy Wingo
cbfad75fa6 Add support for recording inlinable module exports
* module/language/tree-il/inlinable-exports.scm: New module.
* am/bootstrap.am:
* module/Makefile.am:
* module/language/tree-il/optimize.scm (make-optimizer):
* module/system/base/optimize.scm (available-optimizations): Wire up new
module.
* module/ice-9/boot-9.scm (module): Add inlinable-exports field.
(define-module*): Add #:inlinable-exports kwarg.
2021-05-11 21:39:07 +02:00
Andy Wingo
a892791b43 Add pass to resolve free toplevel references in declarative modules
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES):
* module/language/tree-il/optimize.scm (make-optimizer): Wire up the new
pass.
* module/language/tree-il/resolve-free-vars.scm: New pass.
* module/system/base/optimize.scm (available-optimizations): Enable new
pass at -O1.
2021-05-11 21:39:07 +02:00
Andy Wingo
809b165128 Letrectify links module defs with uses
* module/language/tree-il/letrectify.scm (letrectify): Inline "let"
bindings inside residualized "letrec*" forms, to allow the dominator
relationship to be reflected in the scope tree.  Also, detect
"define-module*" invocations, and add these to the mod-vars set, so that
residualized "module-ensure-local-variable!" primcalls can clearly
denote their module without having to use "current-module".
2021-05-11 21:39:07 +02:00
Andy Wingo
afd268ac1d Bump objcode version
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, as
we're going to start adding inlinable exports.
2021-05-11 21:39:07 +02:00
Christopher Lemmer Webber
b03b359b5b
Switch use of $closure to $const-fun
Well, I think this is one of the necessary steps anyway.

* module/language/cps/compile-js.scm (compile-exp*): Switch use
of $closure to use the newer name, $const-fun.
2021-05-11 11:08:51 -04:00
Christopher Lemmer Webber
280312a9c3
Fix cps's choose-compiler to be able to compile javascript
* module/language/cps/spec.scm (choose-compiler): Fix to be able to
  recognize js-il and javascript as targets to compile to
2021-05-11 10:37:10 -04:00