bpt/guile.git
12 years agodoc: Update (ice-9 match) reference.
Ludovic Courtès [Tue, 27 Sep 2011 11:46:35 +0000 (13:46 +0200)]
doc: Update (ice-9 match) reference.

* doc/ref/match.texi (Pattern Matching): Document `***', `..1', and
  `__1'; remove `..k' and `__k'.  Reported by Chris K. Jester-Young.

12 years agodoc: Fix typesetting of function definitions in "Accessing Modules from C".
Ludovic Courtès [Tue, 27 Sep 2011 11:41:21 +0000 (13:41 +0200)]
doc: Fix typesetting of function definitions in "Accessing Modules from C".

* doc/ref/api-modules.texi (Accessing Modules from C): Use the phrase "C
  Function" instead of "C Procedure".  Enclose multiple-word type names
  in braces.  Reported by Dale P. Smith.

12 years agopeval: more strict accounting
Andy Wingo [Mon, 26 Sep 2011 22:21:16 +0000 (00:21 +0200)]
peval: more strict accounting

* module/language/tree-il/optimize.scm (transfer!, make-nested-counter):
  (make-recursive-counter, peval): Limit the algorithm's time to be
  strictly O(N) by transferring effort and size counters of recursive
  inlining attempts from containing counters.

* test-suite/tests/tree-il.test ("partial evaluation"): Update
  expectations for the ((lambda (x) (x x)) (lambda (x) (x x))) case, as
  the new accounting policy will cause the entire inlining attempt to
  abort.

12 years agopeval: fix inlining of lambda* with #:optional
Andy Wingo [Mon, 26 Sep 2011 20:32:45 +0000 (22:32 +0200)]
peval: fix inlining of lambda* with #:optional

* module/language/tree-il/optimize.scm (peval): Fix calculation of how
  many init expressions to drop when inlining lambdas.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests.

12 years agoremove unused peval helpers
Andy Wingo [Mon, 26 Sep 2011 20:24:00 +0000 (22:24 +0200)]
remove unused peval helpers

* module/language/tree-il/optimize.scm (peval): Remove a couple unused
  helpers.

12 years agopeval: simpler and more precise treatment of mutability
Andy Wingo [Fri, 23 Sep 2011 10:43:04 +0000 (12:43 +0200)]
peval: simpler and more precise treatment of mutability

* module/language/tree-il/optimize.scm (peval): The old approach of
  optimistically producing constants and then de-constifying them at
  their uses was not only cumbersome but incorrect: it both failed to
  preserve identity in some cases and failed to retain immutable
  constant values.  Instead, now we only produce constants if they
  really are constant and immutable.  The constant folder has to have a
  few more algebraic cases to be as effective as it was, to destructure
  (car (cons _ _)) appropriately.  On the plus side, now constructors
  and deconstructors can handle impure cases more generally.

* test-suite/tests/tree-il.test ("partial evaluation"): Add constructor
  and destructuring tests.  Adapt other tests to new expectations.

12 years agopeval: add a bunch of missing maybe-unconst calls
Andy Wingo [Sun, 25 Sep 2011 00:54:34 +0000 (02:54 +0200)]
peval: add a bunch of missing maybe-unconst calls

* module/language/tree-il/optimize.scm (peval): Add missing
  maybe-unconst calls.  Things are getting ugly.  They will get better
  in the next commit though.

12 years agopeval uses effort counters, propagates lambdas more effectively
Andy Wingo [Thu, 22 Sep 2011 22:29:14 +0000 (00:29 +0200)]
peval uses effort counters, propagates lambdas more effectively

* module/language/tree-il/optimize.scm (code-contains-calls?): Remove
  this helper, we will deal with recursion when it happens, not after
  the fact.
  (peval): Add keyword args for various size and effort limits.  Instead
  of keeping a call stack, keep a chain of <counter> records, each with
  an abort continuation.  If ever an inlining attempt is taking too
  long, measured in terms of number of trips through the main loop, the
  counter will abort.  Add new contexts, `operator' and `operand'.  They
  have different default size limits.  In the future we should actually
  use the size counter, instead of these heuristics.

  The <lexical-ref> case is smarter now, and tries to avoid propagating
  too much data.  Perhaps it should be dumber though, and use a
  counter.  That would require changes to the environment structure.

  Inline <lambda> applications to <let>, so that we allow residual
  lexical references to have bindings.  Add a `for-operand' helper, and
  use it for the RHS of `let' expressions.  A `let' is an inlined
  `lambda'.

  `Let' and company no longer elide bindings if the result is a
  constant, as the arguments could have effects.  Peval will still do as
  much as it can, though.

* test-suite/tests/tree-il.test ("partial evaluation"): Update the tests
  for the new expectations.  They are uniformly awesomer, with the
  exception of two cases in which pure but not constant data is not
  propagated.

12 years agoprune unused letrec bindings
Andy Wingo [Thu, 22 Sep 2011 22:21:46 +0000 (00:21 +0200)]
prune unused letrec bindings

* module/language/tree-il/optimize.scm (peval): Prune unused `letrec'
  bindings.

12 years agomore peval refactoring
Andy Wingo [Thu, 22 Sep 2011 22:18:13 +0000 (00:18 +0200)]
more peval refactoring

* module/language/tree-il/optimize.scm (peval): Rename `var-table' to
  `store', as we're going to put some more things in it.  Rename
  `record-lexical-bindings' to `record-source-expression', which also
  takes the original, pre-renaming expression.  Keep a mapping from new
  expressions to original expressions, available using the
  `source-expression' helper.

12 years agoadd helpers for effort counters
Andy Wingo [Thu, 22 Sep 2011 22:12:21 +0000 (00:12 +0200)]
add helpers for effort counters

* module/language/tree-il/optimize.scm (<counter>, abort-counter)
  (record-effort!, record-size!, find-counter, make-top-counter)
  (make-nested-counter, make-recursive-counter): New helpers, as yet
  unused, but which will implement fixed effort bounds on the inlining
  algorithm.

12 years agopeval refactor
Andy Wingo [Thu, 22 Sep 2011 22:05:27 +0000 (00:05 +0200)]
peval refactor

* module/language/tree-il/optimize.scm (peval): Add for-value, for-test,
  for-effect, and for-tail helpers.  Use them.

12 years agoattempt to prune unreferenced bindings
Andy Wingo [Thu, 22 Sep 2011 13:56:22 +0000 (15:56 +0200)]
attempt to prune unreferenced bindings

* module/language/tree-il/optimize.scm (peval): Rename `record-lexicals'
  to `record-lexical-bindings'.  Record residualized lexical
  references.  Record lexical references in maybe-unlambda.
  Unfortunately this has the disadvantage that the speculative mapping
  of lambda expressions to lexical references records that reference,
  even if we are not going to residualize it.  After processing a `let',
  prune pure unreferenced bindings.  (We can do better than this in the
  future: we can simply process them for effect.)

* test-suite/tests/tree-il.test (pass-if-peval): More debugging.
  ("partial evaluation"): Update to reflect the fact that the `y'
  binding won't be emitted.

12 years agopeval handles lexical-set
Andy Wingo [Thu, 22 Sep 2011 11:16:36 +0000 (13:16 +0200)]
peval handles lexical-set

* module/language/tree-il/optimize.scm (alpha-rename, peval): Add
  support for lexical-set, while avoiding copy propagation and pruning
  of assigned variables.

12 years agopeval: pre-analyze mutated or reffed-once lexicals
Andy Wingo [Wed, 21 Sep 2011 21:59:02 +0000 (23:59 +0200)]
peval: pre-analyze mutated or reffed-once lexicals

* module/language/tree-il/optimize.scm (<var>, build-var-table, peval):
  Before going into peval, build a table indicating refcounts and a set?
  flag for all lexicals.  Add to the table when introducing new bindings
  (via alpha-renaming).

12 years agopeval: don't propagate expressions that access memory
Andy Wingo [Sat, 24 Sep 2011 16:57:59 +0000 (18:57 +0200)]
peval: don't propagate expressions that access memory

* module/language/tree-il/optimize.scm (peval): Rename
  `pure-expression?' to `constant-expression?', in the sense of GCC's
  `pure' and `const'.  A <toplevel-ref> is not constant, because it can
  be mutated.  A <dynref> isn't constant either, for the same reason.

* test-suite/tests/tree-il.test ("partial evaluation"): Add a test, and
  update existing tests that assumed that toplevel-ref would propagate.

12 years agocontext-specific folding for peval in test and effect contexts
Andy Wingo [Thu, 22 Sep 2011 10:06:21 +0000 (12:06 +0200)]
context-specific folding for peval in test and effect contexts

* module/language/tree-il/optimize.scm (peval): Add a "test" context,
  which folds statically decidable values to <const>.  Fold pure
  expressions to <void> in "effect" contexts.  Adapt the <conditional>
  and <sequence> tests to simply look for <const> or <void> expressions,
  respectively.

12 years agothread a context through peval
Andy Wingo [Thu, 22 Sep 2011 09:23:06 +0000 (11:23 +0200)]
thread a context through peval

* module/language/tree-il/optimize.scm (peval): Thread a "context"
  through the evaluator.

12 years agopaper around `match' bug
Andy Wingo [Sat, 24 Sep 2011 15:05:30 +0000 (17:05 +0200)]
paper around `match' bug

* module/ice-9/match.scm (match): Always introduce a lexical binding, to
  avoid http://debbugs.gnu.org/9567.  Real fix ongoing.  Patch and
  original report by Stefan Israelsson Tampe.

* test-suite/tests/match.test: Add test.

12 years agopeval: various bugfixes
Andy Wingo [Sat, 24 Sep 2011 15:15:32 +0000 (17:15 +0200)]
peval: various bugfixes

* module/language/tree-il/optimize.scm (alpha-rename): Rename the
  init
  expressions of a <lambda-case>.
  (peval): Coalesce the <let-values> clauses.
  Fix pure-expression? matching of <lambda> clauses.
  Loop over and maybe-unconst the inits of a <lambda-case>.

12 years agotree-il-any bugfix
Andy Wingo [Thu, 22 Sep 2011 12:14:02 +0000 (14:14 +0200)]
tree-il-any bugfix

* module/language/tree-il/optimize.scm (tree-il-any): Fix to be called
  on all values, including leaves.  It didn't matter for the use case,
  though.

12 years agominor peval style tweak
Andy Wingo [Thu, 22 Sep 2011 10:26:02 +0000 (12:26 +0200)]
minor peval style tweak

* module/language/tree-il/optimize.scm (peval): Minor refactor to
  <lexical-ref> copy propagation.

12 years agofix alpha-rename for kwargs
Andy Wingo [Thu, 22 Sep 2011 15:43:36 +0000 (17:43 +0200)]
fix alpha-rename for kwargs

* module/language/tree-il/optimize.scm (alpha-rename): Fix
  alpha-renaming of keyword arguments.

12 years agopeval: Add test for multiple-value returns.
Ludovic Courtès [Wed, 21 Sep 2011 20:56:45 +0000 (22:56 +0200)]
peval: Add test for multiple-value returns.

* test-suite/tests/tree-il.test (pass-if-peval): Support the
  `resolve-primitives' keyword.
  ("partial evaluation"): Add test for `call-with-values'.

12 years agopeval: Rectify style.
Ludovic Courtès [Wed, 21 Sep 2011 13:17:56 +0000 (15:17 +0200)]
peval: Rectify style.

* module/language/tree-il/optimize.scm (peval): Rename `src' to
  `lv-src', and `src2' to `src'; pass `make-let-values' the right source
  locations.  Reindent `let*'.

12 years agoprevent propagation for memory-dependent operations like `car'
Andy Wingo [Fri, 23 Sep 2011 16:02:05 +0000 (18:02 +0200)]
prevent propagation for memory-dependent operations like `car'

* module/language/tree-il/primitives.scm (*primitive-constructors*):
  Record car, cdr, vector-ref, and struct-ref as "constructors".
  Comment to come later.
  (*effect-free-primitives*): Update.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests.

12 years agopeval comment & reindentation
Andy Wingo [Wed, 21 Sep 2011 06:50:45 +0000 (08:50 +0200)]
peval comment & reindentation

* module/language/tree-il/optimize.scm (peval): Add a comment regarding
  failure modes, and reindent one clause.

12 years agofix comment regarding alpha-renaming
Andy Wingo [Wed, 21 Sep 2011 06:49:36 +0000 (08:49 +0200)]
fix comment regarding alpha-renaming

* module/language/tree-il/optimize.scm (peval): Fix comment regarding
  alpha-renaming: it's not simply the allocator that needs unique names;
  rather, all transformations depend on it.

12 years agobetter pure-expression?
Andy Wingo [Wed, 21 Sep 2011 06:46:44 +0000 (08:46 +0200)]
better pure-expression?

* module/language/tree-il/optimize.scm (peval): Allow dynref, fix, and
  let-values to be pure expressions.

12 years agomore alpha-rename robustness
Andy Wingo [Wed, 21 Sep 2011 06:46:03 +0000 (08:46 +0200)]
more alpha-rename robustness

* module/language/tree-il/optimize.scm (alpha-rename): Handle all kinds
  of tree-il, with the current exceptions of lexical set!, prompt, and
  abort.

12 years agomore robust alpha-renaming
Andy Wingo [Wed, 21 Sep 2011 06:44:19 +0000 (08:44 +0200)]
more robust alpha-renaming

* module/language/tree-il/optimize.scm (fresh-gensyms): New helper.
  (alpha-rename): Name the new gensyms using the old names as templates,
  not the old gensyms.  This prevents accidental collisions between
  gensyms, if #{x 1}# becomes #{x 12}# instead of #{x 2}#.

12 years agopeval: inlining of let-values
Andy Wingo [Wed, 21 Sep 2011 06:58:09 +0000 (08:58 +0200)]
peval: inlining of let-values

* module/language/tree-il/optimize.scm (peval): Add support for
  let-values.  Try to inline the consumer into the body of the producer,
  if there is only one return point, and we can figure out how many
  values are being returned, and that number is compatible with the
  consumer.

12 years agopeval support for more forms
Andy Wingo [Wed, 21 Sep 2011 06:56:09 +0000 (08:56 +0200)]
peval support for more forms

* module/language/tree-il/optimize.scm (peval): Add support for fix,
  dynwind, dynlet, dynref, module-set, and toplevel-set.  (Mutating a
  variable directly is similar to calling a function that does so behind
  our backs, so this presents no additional problem.)

12 years agoadd singly-valued-primitive?
Andy Wingo [Wed, 21 Sep 2011 06:53:06 +0000 (08:53 +0200)]
add singly-valued-primitive?

* module/language/tree-il/primitives.scm (singly-valued-primitive?): New
  predicate, for primitives that return exactly one value.

12 years agomore optimize.scm factoring
Andy Wingo [Tue, 20 Sep 2011 00:59:53 +0000 (20:59 -0400)]
more optimize.scm factoring

* module/language/tree-il/optimize.scm (vlist-any): New helper.
  (peval): Use it here.

12 years agooptimize.scm refactor
Andy Wingo [Tue, 20 Sep 2011 00:49:50 +0000 (20:49 -0400)]
optimize.scm refactor

* module/language/tree-il/optimize.scm (let/ec, tree-il-any): New
  helpers.
  (code-contains-calls?): Use them here.

12 years agoFix compilation of untyped arrays of rank not 1
Daniel Llorens [Mon, 5 Sep 2011 09:09:08 +0000 (11:09 +0200)]
Fix compilation of untyped arrays of rank not 1

* module/language/glil/compile-assembly.scm: vector-fold2 expects vector.

12 years agoRemove extraneous semicolon from `SCM_STATIC_SUBR_OBJVECT' to prevent ISO C90 warning.
Julian Graham [Sun, 18 Sep 2011 20:58:47 +0000 (16:58 -0400)]
Remove extraneous semicolon from `SCM_STATIC_SUBR_OBJVECT' to prevent ISO C90 warning.

* snarf.h (SCM_STATIC_SUBR_OBJVECT): Remove semicolon at end of macro
  definition.

12 years agopeval: Abort inlining when the residual code contains recursive calls.
Ludovic Courtès [Sun, 18 Sep 2011 21:01:51 +0000 (23:01 +0200)]
peval: Abort inlining when the residual code contains recursive calls.

* module/language/tree-il/optimize.scm (code-contains-calls?): New
  procedure.
  (peval): Use it and abort inlining if the residual code of a procedure
  application contains recursive calls.  Suggested by Wingo, Waddell,
  and Dybvig.  Fixes <http://debbugs.gnu.org/9542>.

* test-suite/tests/tree-il.test ("partial evaluation"): Update 2 tests
  that relied on the previous behavior.  Add 1 another test.

12 years agopeval: Improve alpha-renaming test.
Ludovic Courtès [Sun, 18 Sep 2011 20:34:40 +0000 (22:34 +0200)]
peval: Improve alpha-renaming test.

* test-suite/tests/tree-il.test ("partial evaluation")["inlined lambdas
  are alpha-renamed"]: Rewrite.

12 years agoArrange so that stack-cleaning loops in GC tests are not optimized out.
Ludovic Courtès [Sun, 18 Sep 2011 19:41:25 +0000 (21:41 +0200)]
Arrange so that stack-cleaning loops in GC tests are not optimized out.

* test-suite/tests/gc.test (stack-cleanup): New procedure.
  ("Unused modules are removed"): Use it.

* test-suite/tests/threads.test (stack-cleanup): Likewise.
  ("mutex with owner not retained (bug #27450)"): Use it.

12 years agopeval: Typo.
Ludovic Courtès [Sat, 17 Sep 2011 14:53:23 +0000 (16:53 +0200)]
peval: Typo.

* module/language/tree-il/optimize.scm (peval)[maybe-unlambda]: Fix
  typo in comment.

12 years agopeval: Alpha-rename anonymous lambdas that are duplicated.
Ludovic Courtès [Sat, 17 Sep 2011 14:49:41 +0000 (16:49 +0200)]
peval: Alpha-rename anonymous lambdas that are duplicated.

* module/language/tree-il/optimize.scm (alpha-rename): New procedure.
  (peval)[maybe-unlambda]: Use it.

* test-suite/tests/tree-il.test ("partial evaluation"): Add two test
  cases for <https://lists.gnu.org/archive/html/bug-guile/2011-09/msg00019.html>.

12 years agopeval: Use `resolve-primitives!'.
Ludovic Courtès [Tue, 13 Sep 2011 21:34:07 +0000 (23:34 +0200)]
peval: Use `resolve-primitives!'.

* module/language/tree-il/optimize.scm (peval): Add `cenv' optional
  argument; caller updated.
  Use `resolve-primitives!' to resolve <primitive-ref> expressions.

12 years agopeval: Clarify `pure-expression?'.
Ludovic Courtès [Tue, 13 Sep 2011 21:30:22 +0000 (23:30 +0200)]
peval: Clarify `pure-expression?'.

* module/language/tree-il/optimize.scm (peval)[pure-expression?]:
  Clarify the comment.

12 years agopeval: Inline thunks.
Ludovic Courtès [Tue, 13 Sep 2011 16:54:01 +0000 (18:54 +0200)]
peval: Inline thunks.

* module/language/tree-il/optimize.scm (peval): Inline thunks.

* test-suite/tests/tree-il.test ("partial evaluation"): Add test.

12 years agopeval: Use the right scope when replacing a lambda by a lexical-ref.
Ludovic Courtès [Tue, 13 Sep 2011 16:25:09 +0000 (18:25 +0200)]
peval: Use the right scope when replacing a lambda by a lexical-ref.

* module/language/tree-il/optimize.scm (peval)[maybe-unlambda]: New
  procedures.
  Use it to de-duplicate named lambdas.  This fixes the scoping bug
  described at <https://lists.gnu.org/archive/html/bug-guile/2011-09/msg00019.html>.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests to
  reproduce the bug.

12 years agopeval: Add tests for inlining with both static & dynamic arguments.
Ludovic Courtès [Tue, 13 Sep 2011 12:31:18 +0000 (14:31 +0200)]
peval: Add tests for inlining with both static & dynamic arguments.

* module/language/tree-il/optimize.scm (peval): Improve comment on the
  inlining heuristics.

* test-suite/tests/tree-il.test ("partial evaluation"): Add two tests.

12 years agopeval: Propagate only pure expressions to lambdas.
Ludovic Courtès [Sat, 10 Sep 2011 22:41:23 +0000 (00:41 +0200)]
peval: Propagate only pure expressions to lambdas.

* module/language/tree-il/optimize.scm (peval): Propagate ARGS to BODY
  only when all of ARGS are pure.  Change APP to use `maybe-unconst' for
  its arguments.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests for
  mutability preservation and non-propagation of non-constant arguments
  to lambdas.

12 years agopeval: Try hard to preserve mutability.
Ludovic Courtès [Sat, 10 Sep 2011 22:00:39 +0000 (00:00 +0200)]
peval: Try hard to preserve mutability.

* module/language/tree-il/optimize.scm (peval)[make-values]: Distinguish
  between 1 or another number of values.
  [mutable?, make-value-construction, maybe-unconst]: New procedures.
  Use it in <let>, <letrec>, <toplevel-define>, and <lambda-case>.

* test-suite/tests/tree-il.test ("partial evaluation"): Add tests
  for mutability preservation.

12 years agodoc: Fix typo regarding vhashes.
Ludovic Courtès [Sat, 10 Sep 2011 13:31:55 +0000 (15:31 +0200)]
doc: Fix typo regarding vhashes.

* doc/ref/api-compound.texi (VHashes): s/vlist-/alist-/.

12 years agofix scm_to_latin1_stringn for substrings
Andy Wingo [Sat, 10 Sep 2011 18:38:25 +0000 (11:38 -0700)]
fix scm_to_latin1_stringn for substrings

* libguile/strings.c (scm_to_latin1_stringn): Fix for substrings.

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-scm-to-latin1-string.c: Add test case.

  Thanks to David Hansen for the bug report and test case, and Stefan
  Israelsson Tampe for the fix.

12 years agoRFC 822 allows single digit days of the month
Ian Price [Fri, 9 Sep 2011 19:02:34 +0000 (20:02 +0100)]
RFC 822 allows single digit days of the month

* module/web/http.scm (parse-rfc-822-date): Add single digit day
  conditional.
* test-suite/tests/web-http.test("general headers"): Add test.

12 years agoFix --listen option to allow other ports
Ian Price [Sat, 10 Sep 2011 02:02:32 +0000 (03:02 +0100)]
Fix --listen option to allow other ports

* module/ice-9/command-line.scm (compile-shell-switches): Fix
  off-by-one error in 'substring', and swap branches of conditional.

12 years agoUnoptimize the busy loop of `statprof.test'.
Ludovic Courtès [Fri, 9 Sep 2011 07:06:30 +0000 (09:06 +0200)]
Unoptimize the busy loop of `statprof.test'.

This is a followup to f9c1b8278dbf1992d83f91f91391ee39e714d364 ("Tweak
`statprof.test' for faster machines.").

* test-suite/tests/statprof.test ("statistical sample counts within
  expected range"): Compile with `#:partial-eval? #f'.

12 years agoRemove unused macro in `tree-il.test'.
Ludovic Courtès [Thu, 8 Sep 2011 22:41:48 +0000 (00:41 +0200)]
Remove unused macro in `tree-il.test'.

* test-suite/tests/tree-il.test (assert-scheme->glil): Remove.

12 years agodoc: Use fashionable terminology for macros.
Ludovic Courtès [Thu, 8 Sep 2011 22:02:47 +0000 (00:02 +0200)]
doc: Use fashionable terminology for macros.

* doc/ref/api-macros.texi (Macros): Mention EDSLs.

12 years agoClarify `--debug' vs. `--no-debug'.
Ludovic Courtès [Thu, 8 Sep 2011 22:02:17 +0000 (00:02 +0200)]
Clarify `--debug' vs. `--no-debug'.

* module/ice-9/command-line.scm (*usage*): Attempt to suggest that
  `--no-debug' doesn't inhibit debugging support.

* doc/ref/guile-invoke.texi (Command-line Options): Make it clear that
  `--no-debug' doesn't inhibit debugging support.  Reported by Manuel
  Serrano.

12 years agoTweak `statprof.test' for faster machines.
Ludovic Courtès [Thu, 8 Sep 2011 21:53:31 +0000 (23:53 +0200)]
Tweak `statprof.test' for faster machines.

* test-suite/tests/statprof.test ("statistical sample counts within
  expected range"): Increase NUM-CALLS and the frequency so that they
  are at least a few samples on my new 2.6 GHz laptop.

12 years agoAdd a partial evaluator for use in the compiler.
Ludovic Courtès [Thu, 8 Sep 2011 22:05:34 +0000 (00:05 +0200)]
Add a partial evaluator for use in the compiler.

Thanks to William R. Cook for his excellent tutorial,
<http://softlang.uni-koblenz.de/dsl11/>.

* module/language/tree-il/optimize.scm (optimize!): Call `peval' unless
  the #:partial-eval? option asks otherwise.
  (peval): New procedure.

* module/language/tree-il/inline.scm: Add comment.

* module/language/tree-il/primitives.scm (*primitive-constructors*): New
  variable.
  (*effect-free-primitives*): Use it.
  (constructor-primitive?): New primitive.

* test-suite/tests/tree-il.test (assert-tree-il->glil): Extend to
  support `with-partial-evaluation', `without-partial-evaluation', and
  `with-options'.
  (peval): New binding.
  (pass-if-peval): New macro.
  ("lexical refs"): Run tests without partial evaluation.
  ("letrec"): Likewise.
  ("the or hack"): Likewise.
  ("conditional"): Likewise, for some tests.
  ("sequence"): Adjust to new generated code.
  ("partial evaluation"): New test prefix.

12 years agoUse (ice-9 match) instead of `record-case' where it improves readability.
Ludovic Courtès [Mon, 5 Sep 2011 22:18:36 +0000 (00:18 +0200)]
Use (ice-9 match) instead of `record-case' where it improves readability.

* module/language/tree-il/analyze.scm (goops-toplevel-definition, const-fmt):
  Replace `record-case' by `match'.
  (format-analysis): Likewise, partially.

12 years agoFix misdiagnoses of deprecated `+nan.[^0]' forms.
Ludovic Courtès [Sat, 3 Sep 2011 20:53:36 +0000 (22:53 +0200)]
Fix misdiagnoses of deprecated `+nan.[^0]' forms.

* libguile/numbers.c (mem2ureal): Check the result of `mem2uinteger'
  against `SCM_INUM0', not 0.
  (mem2uinteger): Add comment.

12 years agodoc: Augment "Pattern Matching" section.
Ludovic Courtès [Sat, 3 Sep 2011 20:16:54 +0000 (22:16 +0200)]
doc: Augment "Pattern Matching" section.

* doc/ref/match.texi (Pattern Matching): Mention records.  Add an
  example showing record matching and the `=' pattern.  Point users to
  `match.upstream.scm'.

12 years agoUpdate (ice-9 match) from Chibi-Scheme.
Ludovic Courtès [Sat, 3 Sep 2011 19:39:51 +0000 (21:39 +0200)]
Update (ice-9 match) from Chibi-Scheme.

* module/ice-9/match.scm (slot-ref, slot-set!, is-a?): New macros.

* module/ice-9/match.upstream.scm: Update from Chibi-Scheme.

* test-suite/Makefile.am (SCM_TESTS): Add `tests/match.test.upstream'.

* test-suite/tests/match.test (rtd-2-slots, rtd-3-slots): New record
  types.
  ("matches")["records"]: New test prefix.
  ("doesn't match")["records"]: New test prefix.
  Include `match.test.upstream'.

* test-suite/vm/t-match.scm (matches?): Fix `$' example.

12 years agoRemove Front-Cover and Back-Cover text from the manual.
Ludovic Courtès [Sat, 3 Sep 2011 19:36:49 +0000 (21:36 +0200)]
Remove Front-Cover and Back-Cover text from the manual.

* doc/ref/guile.texi: Remove Front-Cover and Back-Cover text.

12 years agodeprecate +nan.1
Andy Wingo [Sat, 3 Sep 2011 16:37:51 +0000 (18:37 +0200)]
deprecate +nan.1

* libguile/numbers.c (mem2ureal): Deprecate nan values that are not
  "+nan.0".

12 years agofix srfi-67 compilation
Andy Wingo [Fri, 2 Sep 2011 17:49:26 +0000 (19:49 +0200)]
fix srfi-67 compilation

* module/srfi/srfi-67/compare.scm: Fix define-syntax-rule conversion.

12 years agofix some cache consistency issues with goops and extended generics
Andy Wingo [Fri, 2 Sep 2011 11:17:19 +0000 (13:17 +0200)]
fix some cache consistency issues with goops and extended generics

* module/oop/goops.scm (extended-by!, not-extended-by!)
  (upgrade-accessor, merge-generics): Invalidate the method cache after
  munging "extends" or "methods" fields.
  (invalidate-method-cache!): A new wrapper around
  %invalidate-method-cache!, that will also invalidate the caches of
  "extended-by" generics.
  (internal-add-method!, remove-class-accessors!): Use the new
  invalidate-method-cache!.

12 years agodocument define-syntax-rule
Andy Wingo [Fri, 2 Sep 2011 09:42:44 +0000 (11:42 +0200)]
document define-syntax-rule

* doc/ref/api-macros.texi (Syntax Rules): Add define-syntax-rule.

12 years agomore define-syntax-rule usage
Andy Wingo [Fri, 2 Sep 2011 09:36:14 +0000 (11:36 +0200)]
more define-syntax-rule usage

* module/ice-9/boot-9.scm:
* module/ice-9/control.scm:
* module/ice-9/futures.scm:
* module/ice-9/optargs.scm:
* module/ice-9/poll.scm:
* module/ice-9/receive.scm:
* module/ice-9/threads.scm:
* module/ice-9/vlist.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/tree-il.scm:
* module/oop/goops.scm:
* module/oop/goops/simple.scm:
* module/oop/goops/stklos.scm:
* module/srfi/srfi-1.scm:
* module/srfi/srfi-35.scm:
* module/srfi/srfi-39.scm:
* module/srfi/srfi-45.scm:
* module/srfi/srfi-67/compare.scm:
* module/sxml/match.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/repl.scm:
* module/system/vm/inspect.scm:
* module/texinfo.scm:
* module/web/server.scm: Use define-syntax-rule, where it makes sense.

12 years agopsyntax uses define-syntax-rule
Andy Wingo [Fri, 2 Sep 2011 09:34:00 +0000 (11:34 +0200)]
psyntax uses define-syntax-rule

* module/ice-9/psyntax.scm: Use define-syntax-rule.

* module/ice-9/psyntax-pp.scm: Regenerate.

12 years agoadd define-syntax-rule
Andy Wingo [Fri, 2 Sep 2011 09:28:11 +0000 (11:28 +0200)]
add define-syntax-rule

* module/ice-9/psyntax.scm (define-syntax-rule): Add this new helper
  macro, to define a syntax-rules macro with one clause.

* module/ice-9/psyntax-pp.scm: Regenerate.

12 years agofix scm_gc_strdup invocation
Andy Wingo [Mon, 29 Aug 2011 20:20:39 +0000 (22:20 +0200)]
fix scm_gc_strdup invocation

* libguile/i18n.c (get_current_locale): Fix scm_gc_strdup invocation.

12 years agotexinfo: add paragraphindent
Andy Wingo [Mon, 29 Aug 2011 20:20:19 +0000 (22:20 +0200)]
texinfo: add paragraphindent

* module/texinfo.scm (texi-command-specs): Add paragraphindent.

12 years agomodule-stexi-documentation #:docs-resolver keyword arg
Andy Wingo [Tue, 23 Aug 2011 16:00:02 +0000 (18:00 +0200)]
module-stexi-documentation #:docs-resolver keyword arg

* module/texinfo/reflection.scm (module-stexi-documentation): Make
  #:docs-resolver a keyword argument.  Provide back compat with
  docs-resolver as an optional argument, though.

12 years agotexinfo: alias `url' to `uref'.
Andy Wingo [Tue, 23 Aug 2011 10:47:51 +0000 (12:47 +0200)]
texinfo: alias `url' to `uref'.

* module/texinfo.scm (texi-command-specs, complete-start-command):
  Upstream texinfo has aliased `url' to `uref'.  Let's do the same.

* test-suite/tests/texinfo.test ("test-texinfo->stexinfo"): Add a test.

12 years agobetter guild help FOO
Andy Wingo [Fri, 19 Aug 2011 10:04:46 +0000 (12:04 +0200)]
better guild help FOO

* module/scripts/help.scm (show-help, show-summary, show-usage): Grovel
  for %synopsis and %help variables as well, and show them
  appropriately.  Export these routines for other script modules to
  use.  Needs documentation.

12 years agofix order of importing modules and resolving duplicates handlers
Andy Wingo [Thu, 18 Aug 2011 10:56:14 +0000 (12:56 +0200)]
fix order of importing modules and resolving duplicates handlers

* module/ice-9/boot-9.scm (define-module*): Resolve duplicates handlers
  only after importing modules.  Fixes a bug in which a module with
  #:use-module (oop goops) but whose merge-generics handler got resolved
  to noop instead of the real merge-generics handler.  I can't think of
  an easy way to test this, though.

  Thanks to David Pirotte for the report!

12 years agofix a couple of leaks
Andy Wingo [Thu, 18 Aug 2011 09:54:20 +0000 (11:54 +0200)]
fix a couple of leaks

* libguile/bytevectors.h:
* libguile/bytevectors.c (scm_c_take_gc_bytevector): Rename this
  internal function, from scm_c_take_bytevector.  This indicates that
  unlike the other scm_take_* functions, this one takes GC-managed
  memory.

* libguile/objcodes.c (scm_objcode_to_bytecode):
* libguile/vm.c (really_make_boot_program): Use
  scm_gc_malloc_pointerless, not scm_malloc.  Thanks to Stefan
  Israelsson Tampe!

* libguile/r6rs-ports.c:
* libguile/strings.c: Adapt to renames.

12 years agoreword open-file docs
Andy Wingo [Thu, 18 Aug 2011 09:13:34 +0000 (11:13 +0200)]
reword open-file docs

* doc/ref/api-io.texi (File Ports): Refactor open-file docs.  Thanks to
  Bake Timmons for the report.

12 years agofix scm_tmpfile leak
Andy Wingo [Wed, 17 Aug 2011 21:54:58 +0000 (23:54 +0200)]
fix scm_tmpfile leak

* libguile/posix.c (scm_tmpfile): Fix to actually close the new
  tmpfile, causing its deletion, while keeping an fd to the file open.
  Fixes a leak both in memory and disk space on POSIX systems; MINGW
  systems will leak however.  A FIXME for later.

12 years agofix r6rs `map'
Andy Wingo [Wed, 17 Aug 2011 21:24:20 +0000 (23:24 +0200)]
fix r6rs `map'

* module/rnrs/base.scm (map): Define a version of map that is safe for
  multiple returns, though slower.

12 years agocheck that srfi-1 procedure arguments are procedures
Andy Wingo [Wed, 17 Aug 2011 21:09:39 +0000 (23:09 +0200)]
check that srfi-1 procedure arguments are procedures

* module/srfi/srfi-1.scm (check-arg, wrong-type-arg): Refactor arg type
  checkers to be macros, and do the minimal amount of work in the
  functions themselves.  Use these checkers consistently for all
  procedure arguments in this module.  This catches user errors early;
  see bug 33628.

12 years agofix recursive define-inlinable expansions
Andy Wingo [Wed, 17 Aug 2011 20:35:24 +0000 (22:35 +0200)]
fix recursive define-inlinable expansions

* module/ice-9/boot-9.scm (define-inlinable): Prevent expansion from
  diverging by using fluid-let-syntax, as Dybvig suggests.

12 years agosrfi-9 record compatibility with boot-9 records
Andy Wingo [Wed, 17 Aug 2011 08:47:04 +0000 (10:47 +0200)]
srfi-9 record compatibility with boot-9 records

* module/srfi/srfi-9.scm (define-record-type): Instead of defining the
  RTD using make-vtable, use make-struct with the record-type-vtable,
  and record the type name and fields names in the vtable.  This way
  SRFI-9 records are compatible with boot-9 records.  Also we use a
  generic printer, instead of generating one anew.

12 years agofix leak in get_current_locale()
Andy Wingo [Tue, 16 Aug 2011 11:16:21 +0000 (13:16 +0200)]
fix leak in get_current_locale()

* libguile/i18n.c (get_current_locale): Hold the locale name in a
  GC-managed string, not a mallocated string.  Thanks to Stefan
  Israelsson Tampe for the report.

12 years agofix take-right and drop-right for improper lists
Andy Wingo [Fri, 12 Aug 2011 21:26:15 +0000 (23:26 +0200)]
fix take-right and drop-right for improper lists

* libguile/srfi-1.h:
* libguile/srfi-1.c (scm_srfi1_drop_right, scm_srfi1_take_right): Remove
  these internal functions, replacing with Scheme implementations.

* module/srfi/srfi-1.scm (take-right, drop-right): Add these impls from
  the reference code.  They do the right thing for improper lists,
  according to the spec, but they diverge for circular lists.  Oh well.

* test-suite/tests/srfi-1.test ("drop-right", "take-right"): Add more
  tests.

12 years agofix tree-il->scheme test
Andy Wingo [Thu, 4 Aug 2011 17:23:49 +0000 (19:23 +0200)]
fix tree-il->scheme test

* module/language/tree-il.scm (tree-il->scheme): Fix incorporation of
  `lambda' in a `case-lambda'.

* test-suite/tests/tree-il.test ("tree-il->scheme"): Add a test.

12 years ago(web http): locale-independent parsing and serialization of dates
Andy Wingo [Thu, 4 Aug 2011 13:07:27 +0000 (15:07 +0200)]
(web http): locale-independent parsing and serialization of dates

* module/web/http.scm (parse-month, parse-rfc-822-date):
  (parse-rfc-850-date, parse-asctime-date, parse-date):
  (write-date): Parse and write dates without regard to the current
  locale, using a custom parser.  Also permits parsing of the deprecated
  RFC 850 and asctime() date formats.

12 years agosrfi-19 refactor
Andy Wingo [Thu, 4 Aug 2011 10:53:07 +0000 (12:53 +0200)]
srfi-19 refactor

* module/srfi/srfi-19.scm (priv:locale-number-separator, priv:locale-am)
  (priv:locale-am): Inline definitions.

  Strip priv: prefix from module vars, as it's unnecessary, except for
  in a couple cases.

12 years agoavoid duplicate stats when searching for files in a path
Andy Wingo [Wed, 3 Aug 2011 10:36:55 +0000 (12:36 +0200)]
avoid duplicate stats when searching for files in a path

* libguile/load.c (search_path): Extract from scm_search_path, to
  give the caller the stat buffer of the found path.
  (scm_search_path, scm_sys_search_load_path): Adapt accordingly.
  (compiled_is_fresh): Take the stat buffers directly.
  (scm_primitive_load_path, scm_init_eval_in_scheme): Adapt to
  search_path / compiled_is_fresh changes to avoid duplicate states in
  search-path.

12 years agofix unnecessary call to canonicalize_path in load-path fast case
Andy Wingo [Wed, 3 Aug 2011 09:46:56 +0000 (11:46 +0200)]
fix unnecessary call to canonicalize_path in load-path fast case

* libguile/load.c (scm_primitive_load_path): Don't canonicalize the
  filename unless we need to look in the fallback path.  Fixes a stat
  explosion; see http://savannah.gnu.org/bugs/?33815.

12 years agosimplify narrow_stack.
Andy Wingo [Fri, 29 Jul 2011 07:17:47 +0000 (09:17 +0200)]
simplify narrow_stack.

* libguile/stacks.c (narrow_stack): Simplify outer narrowing by a number
  of frames.  Thanks to
  http://article.gmane.org/gmane.lisp.guile.devel/12685.

12 years agostyle fix in read.c
Andy Wingo [Fri, 29 Jul 2011 07:14:04 +0000 (09:14 +0200)]
style fix in read.c

* libguile/read.c (scm_read_sexp): No need to assign to tmp here.

12 years agominor style fix in bytevectors.c
Andy Wingo [Fri, 29 Jul 2011 07:11:24 +0000 (09:11 +0200)]
minor style fix in bytevectors.c

* libguile/bytevectors.c (SCM_BYTEVECTOR_HEADER_BYTES): Use sizeof
  scm_t_bits, not sizeof SCM.  It's the same, but it seems like the
  right thing.

12 years agofix a leak on startup from script.c
Andy Wingo [Thu, 28 Jul 2011 17:12:07 +0000 (19:12 +0200)]
fix a leak on startup from script.c

* libguile/script.c (scm_get_meta_args): Free nargv.  Thanks to
  http://article.gmane.org/gmane.lisp.guile.devel/12685.  We leak narg
  though.

12 years agofix read beyond end of hashtable size array in hashtab.c
Andy Wingo [Thu, 28 Jul 2011 17:07:53 +0000 (19:07 +0200)]
fix read beyond end of hashtable size array in hashtab.c

* libguile/hashtab.c (make_hash_table): Fix read beyond end of
  hashtable_size array.  Thanks to
  http://article.gmane.org/gmane.lisp.guile.devel/12685.

12 years agofix write beyond array end in arrays.c
Andy Wingo [Thu, 28 Jul 2011 17:04:38 +0000 (19:04 +0200)]
fix write beyond array end in arrays.c

* libguile/arrays.c (scm_i_read_array): Fix write past end of array
  while reading array type tag.  Fix non-ascii type tag elements.
  Thanks to http://article.gmane.org/gmane.lisp.guile.devel/12685.

12 years agofix list validation bug in @abort
Andy Wingo [Thu, 28 Jul 2011 16:17:45 +0000 (18:17 +0200)]
fix list validation bug in @abort

* libguile/control.c (scm_at_abort): Fix to ensure that we store the
  return of scm_ilength in a signed integer, even if later we copy it to
  an unsigned.  See
  http://article.gmane.org/gmane.lisp.guile.devel/12685.

12 years agoremove dead code in scm_ceiling_quotient
Andy Wingo [Thu, 28 Jul 2011 15:59:56 +0000 (17:59 +0200)]
remove dead code in scm_ceiling_quotient

* libguile/numbers.c (scm_ceiling_quotient): Remove dead code.  See
  http://article.gmane.org/gmane.lisp.guile.devel/12685.