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

4452 commits

Author SHA1 Message Date
Ludovic Courtès
c7f76d94da popen: 'open-process' returns unbuffered ports.
* module/ice-9/popen.scm (open-process)[unbuffered, fdes-pair]: New
procedures.
Use them.  Return unbuffered ports.
* test-suite/tests/popen.test ("open-pipe*"): New test prefix.
2020-06-19 20:59:04 +02:00
Ludovic Courtès
a0b9d86638 Tree-IL-to-CPS compiler delays calls to 'target-most-positive-fixnum'.
Fixes a bug whereby, for example, "guild compile --target=i686-linux-gnu"
running on x86_64 would generate invalid code for 'bytevector-u32-native-set!'
because 'target-most-positive-fixnum' was called from the top-level
when (language tree-il compile-cps) was loaded.

Consequently, the .go files under prebuilt/ would be invalid, leading to
build failures on 32-bit platforms.

This issue became apparent with cb8cabe85f.

* module/language/tree-il/compile-cps.scm (bytevector-ref-converter)[tag]:
Turn into a lambda so that 'target-most-positive-fixnum' is called in
the right context.
(bytevector-set-converter)[integer-unboxer]: Likewise.
2020-06-19 16:00:29 +02:00
Ludovic Courtès
1ab2105339 web: Accept URI host names consisting only of hex digits.
Fixes <https://bugs.gnu.org/40582>.
Reported by Julien Lepiller <julien@lepiller.eu>.

Previously, a host part consisting of hex digits would be mistaken as an
IPv6 address and rejected by 'valid-host?'.

* module/web/uri.scm (ipv6-regexp): Add colon.
* test-suite/tests/web-uri.test ("string->uri")["xyz://abc/x/y/z"]: New
test.
* NEWS: Update.
2020-06-18 17:06:29 +02:00
Ludovic Courtès
a43aa1bc79 texinfo: Add basic support for @w{...}.
* module/texinfo.scm (texi-command-specs): Add 'w'.
(space-significant?): Add it.
* module/texinfo/html.scm (tag-replacements): Add 'w'.
* test-suite/tests/texinfo.test ("test-texinfo->stexinfo"): Add test.
2020-06-18 00:30:30 +02:00
Ludovic Courtès
a15acbb828 srfi-1: Rewrite 'assoc' in Scheme.
* libguile/srfi-1.c (scm_srfi1_assoc): Remove.
* libguile/srfi-1.h (scm_srfi1_assoc): Likewise.
* module/srfi/srfi-1.scm (assoc): New procedure.
2020-06-17 17:59:35 +02:00
Ludovic Courtès
cd4c747fb8 srfi-1: Rewrite 'find-tail' in Scheme.
* libguile/srfi-1.c (scm_srfi1_find_tail): Remove.
* libguile/srfi-1.h (scm_srfi1_find_tail): Likewise.
* module/srfi/srfi-1.scm (find-tail): New procedure.
2020-06-17 17:33:28 +02:00
Ludovic Courtès
0360843ace srfi-1: Rewrite 'find' in Scheme.
This halves the wall-clock time of:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find zero? lst)'

and yields an 18% speedup on:

  guile -c '(use-modules (srfi srfi-1)) (define lst (make-list 100000000 1)) (find (lambda (x) (= 2 x)) lst)'

* libguile/srfi-1.c (scm_srfi1_find): Remove.
* libguile/srfi-1.h (scm_srfi1_find): Likewise.
* module/srfi/srfi-1.scm (find): New procedure.
* doc/ref/srfi-modules.texi (SRFI-1 Searching): Adjust docstring.
2020-06-17 17:25:23 +02:00
Andy Wingo
fc139231a6 Make CSE more robust
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
  I think it's possible to get an orphan loop, with predecessors
  after successors in the original RPO.  Handle that here.
2020-06-12 15:58:54 +02:00
Andy Wingo
df22eb5956 Statprof reports primitive names
* module/statprof.scm (program-debug-info-printable): Remove unused
  function.
  (addr->printable): If the addr is a primitive, extract its name.
2020-06-04 11:46:34 +02:00
Andy Wingo
e2066d2e63 Change -O1 compiler to use baseline and also resolve primitives
* bootstrap/Makefile.am (GUILE_OPTIMIZATIONS): Change to just -O1.
* module/language/tree-il/spec.scm (choose-compiler): Use CPS for -O2
  and higher.
* module/system/base/optimize.scm (available-optimizations): CPS for -O2
  and higher, but -Oresolve-primitives now at -O1 also.
2020-06-01 21:15:39 +02:00
Andy Wingo
4c10ea0e57 Fix bug where private bindings would never be sealed
* module/language/tree-il/optimize.scm (make-optimizer): Fix plumbing of
-Oseal-private-bindings / -O3.
2020-05-31 22:05:41 +02:00
Andy Wingo
411954c961 Fix typo causing performance problems!!!
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
  Amazingly this typo causes Guile to be 10% slower or so.  Fixed!
2020-05-29 16:59:08 +02:00
Andy Wingo
4c59ff7e95 CSE forward-propagates changes to CFG
* module/language/cps/cse.scm (propagate-analysis): New helper.
  (eliminate-common-subexpressions-in-fun): Recompute avail and bool set
  in response to simplifications in predecessor CFG.  Allows much better
  compilation of pattern-matching idioms!
2020-05-29 16:33:48 +02:00
Andy Wingo
d9143c32c5 CSE forwards branch predecessors where the branch folds
* module/language/cps/cse.scm (forward-cont, forward-branch)
  (compute-avail-and-bool-edge): New helpers.
  (add-equivalent-expression!): Allow idempotent adds; can happen now
  when revisiting a cont after changes to its predecessors.
  (fold-branch): New helper.
  (eliminate-common-subexpressions-in-fun): Allow for reductions to
  branch predecessors.  In that case, revisit the branch, as the CFG
  will have changed.
2020-05-29 16:33:48 +02:00
Andy Wingo
4837e68315 CSE refactor
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
  Separate the paths for handling expressions and branches.
2020-05-29 16:33:48 +02:00
Andy Wingo
19ab4d6947 Use intmaps in CSE equivalent expression table
* module/language/cps/cse.scm (make-equivalent-expression-table)
  (intmap-select, add-equivalent-expression!)
  (lookup-equivalent-expressions): New helpers.
  (eliminate-common-subexpressions-in-fun): Adapt.
2020-05-29 16:33:48 +02:00
Andy Wingo
a92c623a66 Eager graph pruning in CSE
* module/language/cps/cse.scm (elide-predecessor, prune-branch)
  (prune-successors, term-successors): New helpers.
  (eliminate-common-subexpressions-in-fun): When we modify the CFG,
  update the analysis.  Also, thread the substs map through CSE so that
  closures in high-level CPS can take advantage of eliminated variables.
  (fold-renumbered-functions): Take multiple seeds.
  (eliminate-common-subexpressions): Thread var substs map through CSE.
2020-05-29 16:33:48 +02:00
Andy Wingo
1baed76349 Macro fix to CPS build-term
* module/language/cps.scm (build-term): Match on $branch and $throw as
  literals.
2020-05-29 16:33:48 +02:00
Andy Wingo
3c4d4acbd4 Thread flow analysis through CSE pass
* module/language/cps/cse.scm (<analysis>): New data type, grouping
  available expression analysis, predecessor map, etc.
  (eliminate-common-subexpressions-in-fun): Instead of having a static
  analysis, thread it through the CSE pass so that we can update the CFG
  as we go.
2020-05-29 16:33:48 +02:00
Andy Wingo
6fb0635358 CSE eliminates expressions at continuations
* module/language/cps/cse.scm (compute-available-expressions): Take a
  clobber map instead of an effects map.
  (compute-singly-referenced): Remove unused function.
  (eliminate-common-subexpressions-in-fun): Keep a preds map.  Use it
  add entries to the equiv-set and var-substs at expression
  continuations instead of at the expression terms themselves.
2020-05-29 16:33:48 +02:00
Andy Wingo
2318e7238f Refactor CSE to analyze and transform in a single pass
* module/language/cps/cse.scm (compute-truthy-expressions): Operate on a
  single function.
  (eliminate-common-subexpressions-in-fun): Instead of computing a set
  of labels to eliminate, go ahead and do the elimination as we go.
  (fold-renumbered-functions): Can just use a single seed now.
  (eliminate-common-subexpressions): Simplify to just fold over
  functions, building up renamed output as we go.
2020-05-29 16:33:48 +02:00
Andy Wingo
6e91173334 Refactor CSE to take advantage of RPO numbering
* module/language/cps/cse.scm (fold-renumbered-functions): New helper.
  (compute-equivalent-expressions): Use new helper.
  (compute-equivalent-expressions-in-fun): Lift to top-level.
  (eliminate-common-subexpressions): Adapt.
2020-05-29 16:33:48 +02:00
Andy Wingo
cf948e0f6f Renumber before CSE
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
  Assume renumbered program.
  (eliminate-common-subexpressions): Renumber.  Will allow optimizations
  later.
2020-05-29 16:33:48 +02:00
Andy Wingo
d36b9f0422 Slight optimization to invert-bijectiono
* module/language/cps/graphs.scm (invert-bijection): Use a transient
  intmap.
2020-05-28 10:58:09 +02:00
Andy Wingo
11878e1603 Fix truthy expression analysis in CSE
* module/language/cps/cse.scm (compute-truthy-expressions): The "meet"
  function here is union, not intersection.
2020-05-28 10:02:41 +02:00
Ludovic Courtès
a5421d2bb6 web: 'http-get' & co. now honor #:verify-certificate?.
Previously they would always assume #:verify-certificate? #t,
unless #:port was given.

Fixes <https://bugs.gnu.org/40486>.
Reported by Jan Synacek <jsynacek@redhat.com>.

* module/web/client.scm (define-http-verb): Pass #:verify-certificate?
to 'open-socket-for-uri'.
2020-05-27 23:28:14 +02:00
Christopher Baines
ac5df66f1c http: Support CONNECT and PATCH HTTP methods.
PATCH is described by RFC 5789 and CONNECT is described by RFC 7231.

* module/web/http.scm (parse-http-method): Support CONNECT and PATCH.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-05-18 09:44:00 +02:00
Andy Wingo
087bb683c8 Update match's no-matching-pattern code to use "throw"
* module/ice-9/match.upstream.scm (match-next): Use throw, so that CPS
  can see that there's no fallthrough.
* module/ice-9/match.scm: Add a note about what to do in 3.1 to remove
  the old "error" definition.
2020-05-17 22:26:17 +02:00
Rutger van Beusekom
786fbcd327 popen: Add 'pipeline' procedure.
* libguile/posix.c (scm_open_process): Remove.
(scm_piped_process): Add to replace open_process.
* module/ice-9/popen.scm (pipe->fdes): Add to convert pipe pair to fdes pair.
(open-process): Add open-process for backwards compatibility.
(pipeline): Add to implement a pipeline using piped-process.
* doc/ref/posix.texi (Pipes): Document it.
* test-suite/tests/popen.test ("open-process")
("piped-process", "piped-process: with output")
("pipeline"): New tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-05-16 22:36:19 +02:00
Andy Wingo
2c07a32ad8 Tree-IL lowerer only loads needed optimizations
* module/language/tree-il/optimize.scm (make-optimizer): New procedure,
  to compute an optimizer given options, lazily loading optimization
  modules.
  (optimize): Use make-optimizer.
  (make-lowerer): Use make-optimizer, so as to only load needed
  optimizations.  Speeds up bootstrap times.
2020-05-14 10:24:08 +02:00
Andy Wingo
033a67d575 Fix ,optimize to be independent of tree-il
* module/system/repl/common.scm (repl-default-options): Add
  optimization-level and warning-level REPL options.
  (repl-optimization-level, repl-warning-level): New accessors,
  defaulting to the default level parameters.
  (repl-expand): Take target language as keyword argument rather than
  hard-coding tree-il.
  (repl-optimize): Take target language as keyword argument.  Use REPL
  optimization and warning levels.  Use generic lowering interface.
2020-05-14 09:17:14 +02:00
Andy Wingo
7df3f3414b More robust reduction of equal? and eqv?
* module/language/tree-il/primitives.scm (expand-eq): Just expand out to
  binary comparisons.  Also expand eq?, which was missing.  Leave
  strength reduction to peval.
  (character-comparison-expander): Move down, as it depends on <, <=,
  and so on.
* module/language/tree-il/peval.scm (peval): Robustly reduce equal? and
  eqv?.
* test-suite/tests/peval.test ("partial evaluation"): Expect fixnum
  comparison to reduce to eq?.
  ("eqv?", "equal?"): A new battery of tests.
* test-suite/tests/tree-il.test ("primitives"): Remove reduction tests.
2020-05-13 15:51:58 +02:00
Andy Wingo
498428fbef Add with-lexicals helper; fix bug in (equal? #t (foo) #t)
* module/language/tree-il.scm (with-lexicals): New public helper.
* .dir-locals.el (with-lexicals): Add indentation rule.
* module/language/tree-il/compile-bytecode.scm (canonicalize): Use
  with-lexicals.
* module/language/tree-il/compile-cps.scm (canonicalize): Use
  with-lexicals from tree-il.
* module/language/tree-il/primitives.scm (chained-comparison-expander):
  Remove duplicate expander definitions for <, <=, and so on.
* module/language/tree-il/primitives.scm (maybe-simplify-to-eq): Avoid
  inadvertent code duplication by using with-lexicals.
  (expand-chained-comparisons): Likewise.
  (call-with-prompt): Simplify to use with-lexicals.
2020-05-13 14:51:56 +02:00
Andy Wingo
31bb0eea8c Another minor module compile order tweak
* module/Makefile.am (SOURCES): Put Tree-IL compiler early too, so that
  subsequent compilations can benefit from CPS speedups.
2020-05-13 09:39:41 +02:00
Andy Wingo
c6636ff312 Bump objcode minor version
* libguile/loader.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump, so
  that compiled files from Guile 3.0.3 will error when loaded on 3.0.2.
2020-05-13 09:37:54 +02:00
Andy Wingo
a165c49b29 Minor module/Makefile order tweak
* module/Makefile.am (ice-9/psyntax-pp.go): Add GUILE_OPTIMIZATIONS
  argument.
  (SOURCES): Reorder a bit for speed when bootstrapping.
2020-05-13 09:16:11 +02:00
Andy Wingo
c5da9d65a7 Fix optimizers after language lowerer refactor
* module/language/cps/optimize.scm (define-optimizer):
  (optimize-higher-order-cps, optimize-first-order-cps):
  (make-cps-lowerer):
* module/language/tree-il/optimize.scm (optimize, make-lowerer): In an
  embarrassing bug, after parsing optimization arguments, we were
  aconsing them instead of the expected cons*.  This meant the bootstrap
  was running all Tree-IL optimizations!  Change to have optimizers not
  have defaults and use alists after parsing.
2020-05-13 09:04:16 +02:00
Andy Wingo
32eef3dd14 Slight optimization to baseline compiler
* module/language/tree-il/compile-bytecode.scm (compile-closure):
  for-value-at and for-values-at take indexes instead of environments to
  denote destination.
2020-05-13 09:04:16 +02:00
Andy Wingo
9c4c6322f5 Whoops, fix bug in tree-il choose-compiler
* module/language/tree-il/spec.scm (choose-compiler): Fix spelling of
  "compile-cps" :)
2020-05-12 10:12:21 +02:00
Andy Wingo
cb8cabe85f Delay loading CPS unless CPS compiler used
* module/language/tree-il/spec.scm: Remove #:compilers declaration;
  instead rely on choose-compiler.
  (choose-compiler): Load compilers on demand.
* module/system/base/compile.scm (find-language-joint): Use next-pass
  instead of lookup-compilation-order, to avoid loading unused
  compilers.
  (read-and-compile): Adapt to find-language-joint change.
  (compute-compiler): Export.
* module/scripts/compile.scm (compile): Use compute-compiler to load
  compiler modules.
2020-05-12 09:54:19 +02:00
Andy Wingo
44ad8fbde5 Baseline FIXME's are done :)
* module/language/tree-il/compile-bytecode.scm: Remove FIXME comments.
2020-05-11 22:03:08 +02:00
Andy Wingo
b02a889659 Baseline compiler emits source locations
* module/language/tree-il/compile-bytecode.scm (compile-closure): Emit
  source annotations where we have them.
2020-05-11 16:53:23 +02:00
Andy Wingo
f66111a203 Baseline O(1) access to frame-base env
* module/language/tree-il/compile-bytecode.scm (compile-closure): No
  need to search for frame-base.
2020-05-11 16:43:08 +02:00
Andy Wingo
b35fd53664 Emit handle-interrupts in baseline compiler
* module/language/tree-il/compile-bytecode.scm (compile-closure): Handle
  interrupts before calls, returns, and tail calls.
2020-05-11 16:15:24 +02:00
Andy Wingo
b5108ccb2a Avoid having "guild compile" load optimizers
* module/language/cps/optimize.scm (cps-optimizations):
* module/language/tree-il/optimize.scm (tree-il-optimizations):
* module/system/base/optimize.scm (available-optimizations): Invert the
  dependency tree to hold the names and default optimization levels in a
  central place instead of in the optimizers.  It moves definitions
  farther from uses, but it avoids us having to load the CPS optimizer
  if we don't need it, which improves bootstrap times.
2020-05-11 15:42:20 +02:00
Andy Wingo
2ba3eb4cf2 Fix shuffling assembler for new primcalls
* module/system/vm/assembler.scm (encode-X8_S8_C8_S8-C32!/shuffle): New
  shuffling assembler.
2020-05-11 15:03:19 +02:00
Andy Wingo
7f4bbc3dba Improve tail recursion in compiler
* module/language/tree-il/compile-bytecode.scm (compile-closure): Make
  it so that for-tail is actually tail-recursive.  Likewise improve tail
  recursion for the other helpers.
2020-05-11 14:48:45 +02:00
Andy Wingo
73a23027f5 Fix module capture for closures in <fix>
* module/language/tree-il/compile-bytecode.scm (compile-closure):
  Capture closures for <fix> if needed.
2020-05-11 14:36:00 +02:00
Andy Wingo
4c3c35c536 Fix "cons" compilation in baseline compiler in some cases
* module/language/tree-il/compile-bytecode.scm (emit-cons): Fix for case
  where car is dst but cdr isn't.
2020-05-11 13:32:39 +02:00
Andy Wingo
3b6023d66d Baseline compiler: add pop-fluid primitive.
* module/language/tree-il/compile-bytecode.scm (pop-fluid): New
  primitive.
2020-05-11 13:32:19 +02:00