bpt/guile.git
9 years agoMerge commit '5af307de43e4b65eec7f235b48a8908f2a00f134'
Andy Wingo [Thu, 22 Jan 2015 11:50:18 +0000 (12:50 +0100)]
Merge commit '5af307de43e4b65eec7f235b48a8908f2a00f134'

Conflicts:
test-suite/tests/reader.test

9 years agoMerge commit 'b1451ad859183ae48c624d19ec144306bd2d3e3a'
Andy Wingo [Thu, 22 Jan 2015 11:46:11 +0000 (12:46 +0100)]
Merge commit 'b1451ad859183ae48c624d19ec144306bd2d3e3a'

9 years agoAssembler: Cope with non-string port filenames.
Mark H Weaver [Sun, 14 Dec 2014 15:24:00 +0000 (10:24 -0500)]
Assembler: Cope with non-string port filenames.

Fixes <http://bugs.gnu.org/19354>.
Reported by Linas Vepstas <linasvepstas@gmail.com>.

* module/system/vm/assembler.scm (write-sources): Intern the filename
  only if it's a string.  (For sockets, the filename is a symbol).

9 years agoConvert primitive-eval to "compile" its expressions to linked closures
Andy Wingo [Wed, 10 Dec 2014 13:34:44 +0000 (14:34 +0100)]
Convert primitive-eval to "compile" its expressions to linked closures

* libguile/memoize.c (memoize): Fix meta on subsequent case-lambda
  clauses.

* module/ice-9/eval.scm (primitive-eval): Rewrite to compile expressions
  to thunks, to avoid runtime dispatch cost.

9 years agoFix syntax.test
Andy Wingo [Wed, 10 Dec 2014 15:25:19 +0000 (16:25 +0100)]
Fix syntax.test

* test-suite/tests/syntax.test (exception:variable-ref): Change expected
  error.

9 years agoMinor evaluator tweaks
Andy Wingo [Sun, 7 Dec 2014 18:03:19 +0000 (19:03 +0100)]
Minor evaluator tweaks

* libguile/eval.c (eval): Remove unused variable.
* libguile/memoize.c (unmemoize): Fix unmemoization.
* module/ice-9/eval.scm: Attempt to speed up common box-ref cases.

9 years agoSimplify variable resolution in the evaluator
Andy Wingo [Sun, 7 Dec 2014 14:52:34 +0000 (15:52 +0100)]
Simplify variable resolution in the evaluator

* libguile/expand.c (convert_assignment): Handle creation of the default
  lambda-case body here.

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval):

* libguile/memoize.h:
* libguile/memoize.c (MAKMEMO_BOX_REF, MAKMEMO_BOX_SET):
  (MAKMEMO_TOP_BOX, MAKMEMO_MOD_BOX): Refactor all global var resolution
  to go through "resolve".  Add "box-ref" and "box-set!".  Rename
  memoize-variable-access! to %resolve-variable, and don't be
  destructive.

9 years agoClosure conversion in evaluator
Andy Wingo [Sun, 7 Dec 2014 08:34:22 +0000 (09:34 +0100)]
Closure conversion in evaluator

* libguile/memoize.c (MAKMEMO_CAPTURE_ENV, push_nested_link)
  (push_flat_link, env_link_is_flat, env_link_vars)
  (env_link_add_flat_var, lookup, capture_flat_env, memoize): Capture
  flat environments around closures.

9 years agoAdd capture-env to evaluator
Andy Wingo [Sat, 6 Dec 2014 18:43:24 +0000 (19:43 +0100)]
Add capture-env to evaluator

* libguile/eval.c (eval):
* libguile/memoize.c (memoized_tags, unmemoize):
* libguile/memoize.h (SCM_M_CAPTURE_ENV):
* module/ice-9/eval.scm (primitive-eval): Add capture-env memoized
  expression type.

9 years agoSimplify the interpreter for trivial inits and no letrec
Andy Wingo [Fri, 5 Dec 2014 15:54:35 +0000 (16:54 +0100)]
Simplify the interpreter for trivial inits and no letrec

* libguile/memoize.c (FULL_ARITY): Serialize "ninits" and the unbound
  value instead of the init list.
  (memoize): Adapt to FULL_ARITY changes.  Remove LETREC case.
  (unmemoize): Adapt to memoized code change.

* libguile/eval.c (BOOT_CLOSURE_PARSE_FULL): Adapt to parse ninits and
  unbound instead of inits.
  (eval): Lexical-ref can no longer raise an error.
  (prepare_boot_closure_env_for_apply): Adapt to inits change.

* module/ice-9/eval.scm (primitive-eval): Adapt to ninits/unbound
  change.

* libguile/expand.c (expand_named_let): Fix lambda-case creation to make
  lists for opt and inits.

9 years agoAssignment conversion in the interpreter
Andy Wingo [Thu, 4 Dec 2014 14:07:01 +0000 (15:07 +0100)]
Assignment conversion in the interpreter

* libguile/expand.c (compute_assigned, convert_assignment)
  (scm_convert_assignment): New functions.

* libguile/expand.h: Declare scm_convert_assignment.

* libguile/memoize.c (scm_memoize_expression): Do assignment conversion
  before memoization.

* test-suite/tests/syntax.test ("letrec"): Detection of unbound letrec
  variables now works.

9 years agotexinfo: fix @url{@@} parsing
Andy Wingo [Sun, 9 Nov 2014 15:56:33 +0000 (15:56 +0000)]
texinfo: fix @url{@@} parsing

* module/texinfo.scm (texi-command-specs): The body of @url{} can have
  texinfo commands.

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

9 years agoweb: Location header is URI-reference; better URI-reference support
Andy Wingo [Wed, 15 Oct 2014 09:49:41 +0000 (11:49 +0200)]
web: Location header is URI-reference; better URI-reference support

* module/web/uri.scm (validate-uri): Add reference? keyword argument,
  for validating references.
  (build-uri): Clarify comments to indicate that the result is an
  absolute URI.
  (build-uri-reference): New interface, to build URI-references.
  (string->uri-reference): Rename from string->uri*.  Fix fragment
  parsing to not include the #.
  (string->uri): Adapt to string->uri-reference name change.

* module/web/request.scm (request-absolute-uri): Add default-scheme
  optional argument.  Use it if the request-uri has no scheme, or
  error.

* module/web/http.scm (write-uri): Reflow to use "when".  Fix writing of
  URI-reference instances.
  (declare-uri-reference-header!): Rename from
  declare-relative-uri-header!.  Use string->uri-reference.
  ("Location"): Declare as a URI-reference header, as per RFC 7231.

* module/web/client.scm (open-socket-for-uri): Handle the case in which
  there is no URI scheme.

* test-suite/tests/web-http.test:
* test-suite/tests/web-uri.test: Add tests.

9 years agoMerge branch 'lloda-array-support'
Daniel Llorens [Thu, 30 Oct 2014 10:42:05 +0000 (11:42 +0100)]
Merge branch 'lloda-array-support'

9 years agoread: Accept "\(" in string literals.
Mark H Weaver [Thu, 2 Oct 2014 00:45:41 +0000 (20:45 -0400)]
read: Accept "\(" in string literals.

Suggested by David Kastrup <dak@gnu.org> in <http://bugs.gnu.org/13644>.

* libguile/read.c (scm_read_string_like_syntax): Accept "\(" as
  equivalent to "(".
* doc/ref/api-data.texi (String Syntax): Document it.
* test-suite/tests/reader.test ("reading"): Add test.

9 years agodocs: Fix documented return type of 'scm_c_export'.
Mark H Weaver [Wed, 1 Oct 2014 22:57:44 +0000 (18:57 -0400)]
docs: Fix documented return type of 'scm_c_export'.

Fixes <http://bugs.gnu.org/17869>.
Reported and fixed by Alexei Matveev <alexei.matveev@gmail.com>.

* doc/ref/api-modules.texi (Accessing Modules from C): Change documented
  return type of 'scm_c_export' to 'void' to reflect reality.
* THANKS: Add Alexei Matveev to the fixes section.

9 years agoIntern general arrays
Daniel Llorens [Fri, 19 Sep 2014 12:48:59 +0000 (14:48 +0200)]
Intern general arrays

* module/system/vm/assembler.scm (intern-constant, link-data): handle
  the array case.

9 years agoPack array dimensions in array object
Daniel Llorens [Fri, 19 Sep 2014 12:48:22 +0000 (14:48 +0200)]
Pack array dimensions in array object

* libguile/arrays.c (scm_i_make_array): redo object layout.

* libguile/arrays.h (SCM_I_ARRAY_V, SCM_ARRAY_BASE, SCM_I_ARRAY_DIMS):
  to match new layout.

  (SCM_I_ARRAY_SET_V, SCM_ARRAY_SET_BASE): new setters.

  (SCM_I_ARRAY_MEM, scm_i_t_array): unused, remove.

  (scm_i_shap2ra, scm_make_typed_array, scm_from_contiguous_typed_array,
  scm_from_contiguous_array, scm_make_shared_array, scm_transpose_array,
  scm_array_contents): fix uses of SCM_I_ARRAY_V, SCM_ARRAY_BASE as
  lvalues.

* libguile/array-map.c (make1array, scm_ramapc): fix uses of
  SCM_I_ARRAY_V, SCM_ARRAY_BASE as lvalues.

9 years agoRun some of arrays.test under both compiler & interpreter
Daniel Llorens [Fri, 19 Sep 2014 12:47:40 +0000 (14:47 +0200)]
Run some of arrays.test under both compiler & interpreter

* test-suite/test-suite/lib.scm (c&e): accept (pass-if exp) clause.

* test-suite/tests/arrays.test: use with-prefix/c&e instead of
  with-prefix where possible.

9 years agoMerge branch 'stable-2.0'
Mark H Weaver [Tue, 30 Sep 2014 07:50:47 +0000 (03:50 -0400)]
Merge branch 'stable-2.0'

Conflicts:
benchmark-suite/benchmarks/ports.bm
libguile/async.h
libguile/bytevectors.c
libguile/foreign.c
libguile/gsubr.c
libguile/srfi-1.c
libguile/vm-engine.h
libguile/vm-i-scheme.c
module/Makefile.am
module/language/tree-il/analyze.scm
module/language/tree-il/peval.scm
module/scripts/compile.scm
module/scripts/disassemble.scm
test-suite/tests/asm-to-bytecode.test
test-suite/tests/peval.test
test-suite/tests/rdelim.test

9 years agoAdd (ice-9 unicode) module
Andy Wingo [Fri, 12 Sep 2014 15:00:59 +0000 (17:00 +0200)]
Add (ice-9 unicode) module

* libguile/unicode.c:
* libguile/unicode.h:
* test-suite/tests/unicode.test:
* module/ice-9/unicode.scm: New files.

* module/Makefile.am:
* libguile/Makefile.am:
* test-suite/Makefile.am:
* libguile/init.c: Wire new files into the build.

* doc/ref/api-data.texi: Add docs.

9 years agopeval: Handle optional argument inits that refer to previous arguments.
Mark H Weaver [Sun, 28 Sep 2014 16:51:11 +0000 (12:51 -0400)]
peval: Handle optional argument inits that refer to previous arguments.

Fixes <http://bugs.gnu.org/17634>.
Reported by Josep Portella Florit <jpf@primfilat.com>.

* module/language/tree-il/peval.scm (inlined-application): When inlining
  an application whose operator is a lambda expression with optional
  arguments that rely on default initializers, expand into a series of
  nested let expressions, to ensure that previous arguments are in scope
  when the default initializers are evaluated.

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

9 years agodoc: Improve description of vector-unfold and vector-unfold-right.
Mark H Weaver [Thu, 25 Sep 2014 02:03:58 +0000 (22:03 -0400)]
doc: Improve description of vector-unfold and vector-unfold-right.

* doc/ref/srfi-modules.texi (SRFI-43 Constructors)[vector-unfold]:
  Improve description.
* module/srfi/srfi-43.scm (vector-unfold, vector-unfold-right):
  Improve docstrings.

9 years agoFix ungetc for characters 0x80 <= c < 0xf0 in UTF-8.
David Kastrup [Wed, 24 Sep 2014 01:39:29 +0000 (21:39 -0400)]
Fix ungetc for characters 0x80 <= c < 0xf0 in UTF-8.

Fixes <http://bugs.gnu.org/18536>.

* libguile/ports.c (scm_ungetc_unlocked): Fix bad UTF-8 reencoding,
  introduced in commit be7ecef05c1eea66f30360f658c610710c5cb22e.

Signed-off-by: David Kastrup <dak@gnu.org>
9 years agoAdd 'EXIT_SUCCESS' and 'EXIT_FAILURE'.
Ludovic Courtès [Mon, 22 Sep 2014 20:51:23 +0000 (22:51 +0200)]
Add 'EXIT_SUCCESS' and 'EXIT_FAILURE'.

Suggested by Frank Terbeck <ft@bewatermyfriend.org>.

* libguile/posix.c (scm_init_posix): Define 'EXIT_SUCCESS' and
  'EXIT_FAILURE'.
* doc/ref/posix.texi (Processes): Document them.

9 years agoguile-readline: Use the current directory if HOME is unset.
David Michael [Mon, 22 Sep 2014 03:21:25 +0000 (23:21 -0400)]
guile-readline: Use the current directory if HOME is unset.

* guile-readline/ice-9/readline.scm (history-file): When the HOME
  environment variable is unset, use the current directory instead.

9 years agobuild: Use 'libtoolize' in autogen.sh.
Ludovic Courtès [Sat, 20 Sep 2014 12:36:09 +0000 (14:36 +0200)]
build: Use 'libtoolize' in autogen.sh.

Fixes <http://bugs.gnu.org/18470>.
Reported by Rob Browning <rlb@defaultvalue.org>.

* autogen.sh: Invoke 'libtoolize' instead of 'libtool'.

9 years agoFix SCM_SMOB_OBJECT{_,_0_,_1_,_2_,_3_}LOC.
David Kastrup [Sat, 20 Sep 2014 09:17:54 +0000 (05:17 -0400)]
Fix SCM_SMOB_OBJECT{_,_0_,_1_,_2_,_3_}LOC.

Fixes <http://bugs.gnu.org/18495>.

* libguile/smob.h (SCM_SMOB_OBJECT_LOC, SCM_SMOB_OBJECT_0_LOC)
  (SCM_SMOB_OBJECT_1_LOC, SCM_SMOB_OBJECT_2_LOC)
  (SCM_SMOB_OBJECT_3_LOC): These elementary API macros have been broken
  by commit 56164dc47f6616b359f0ad23be208f01a77b55fa in 2009.

Signed-off-by: David Kastrup <dak@gnu.org>
9 years agoguild disassemble: Use #:prefix instead of #:renamer.
Mark H Weaver [Sat, 20 Sep 2014 08:51:02 +0000 (04:51 -0400)]
guild disassemble: Use #:prefix instead of #:renamer.

* module/scripts/disassemble.scm: Use #:prefix instead of #:renamer
  in #:use-module clause.

9 years agoDocument #:prefix option in use-module clauses.
Mark H Weaver [Sat, 20 Sep 2014 08:42:49 +0000 (04:42 -0400)]
Document #:prefix option in use-module clauses.

* doc/ref/api-modules.texi (Using Guile Modules): Document #:prefix
  option.

9 years agoSRFI-43: vector-concatenate: Fix error message.
Mark H Weaver [Sat, 20 Sep 2014 08:09:14 +0000 (04:09 -0400)]
SRFI-43: vector-concatenate: Fix error message.

* module/srfi/srfi-43.scm (vector-concatenate): Fix the 'who' of an
  error message.

9 years agoVM: Use register "a3" for IP_REG on m68k.
Mark H Weaver [Sat, 20 Sep 2014 08:05:43 +0000 (04:05 -0400)]
VM: Use register "a3" for IP_REG on m68k.

Subset of a patch by Andreas Schwab <schwab@linux-m68k.org>.
Reported by Rob Browning <rlb@defaultvalue.org>.

* libguile/vm-engine.h (IP_REG)[__mc68000__]: Use register "a3".

9 years agoVM: Allow the C compiler to choose FP_REG on ARM.
Mark H Weaver [Sat, 20 Sep 2014 07:59:51 +0000 (03:59 -0400)]
VM: Allow the C compiler to choose FP_REG on ARM.

Reported by Rob Browning <rlb@defaultvalue.org>.

* libguile/vm-engine.h (IP_REG)[__arm__]: Remove explicit register
  choice ("r7") for FP_REG, which was reported to cause compilation
  failures on ARM.

9 years agoDo not assume that 64-bit integers will be 64-bit aligned.
Mark H Weaver [Sat, 20 Sep 2014 07:49:46 +0000 (03:49 -0400)]
Do not assume that 64-bit integers will be 64-bit aligned.

* libguile/foreign.c (raw_bytecode, objcode_cells):
* libguile/gsubr.c (raw_bytecode, objcode_cells): Use SCM_ALIGNED to
  ensure 64-bit alignment.

9 years agoVM: ASM_MUL for ARM: Add earlyclobber constraint to the SMULL outputs.
Mark H Weaver [Sat, 20 Sep 2014 01:18:09 +0000 (21:18 -0400)]
VM: ASM_MUL for ARM: Add earlyclobber constraint to the SMULL outputs.

Reported by Rob Browning <rlb@defaultvalue.org>.

* libguile/vm-i-scheme.c (ASM_MUL)[ARM]: Add earlyclobber (&) constraint
  to the SMULL output registers.

9 years agotests: Link test against Gnulib.
Ludovic Courtès [Wed, 17 Sep 2014 11:43:55 +0000 (13:43 +0200)]
tests: Link test against Gnulib.

Reported by Eli Zaretskii <eliz@gnu.org>.

* test-suite/standalone/Makefile.am (test_scm_take_locale_symbol_LDADD):
  Add libgnu.la, for the 'strdup' replacement.

9 years agoAdd (ice-9 unicode) module
Andy Wingo [Fri, 12 Sep 2014 15:00:59 +0000 (17:00 +0200)]
Add (ice-9 unicode) module

* libguile/unicode.c:
* libguile/unicode.h:
* test-suite/tests/unicode.test:
* module/ice-9/unicode.scm: New files.

* module/Makefile.am:
* libguile/Makefile.am:
* test-suite/Makefile.am:
* libguile/init.c: Wire new files into the build.

* doc/ref/api-data.texi: Add docs.

9 years agoThank Franck.
Ludovic Courtès [Tue, 26 Aug 2014 21:41:14 +0000 (23:41 +0200)]
Thank Franck.

9 years agoHandle ~p in 'format' warnings.
Ludovic Courtès [Tue, 26 Aug 2014 21:40:22 +0000 (23:40 +0200)]
Handle ~p in 'format' warnings.

Fixes <http://bugs.gnu.org/18299>.
Reported by Frank Terbeck <ft@bewatermyfriend.org>.

* module/language/tree-il/analyze.scm (format-string-argument-count):
  Add case for ~p.
* test-suite/tests/tree-il.test ("warnings")["format"]("~p", "~p, too
  few arguments", "~:p", "~:@p, too many arguments", "~:@p, too few
  arguments"): New tests.

9 years agoSeparate &boolean type into &true and &false
Andy Wingo [Sun, 24 Aug 2014 15:07:49 +0000 (17:07 +0200)]
Separate &boolean type into &true and &false

* module/language/cps/types.scm (&all-types): Represent true and false
  as separate bits, so that #f can be removed from types on true
  branches.  Adapt all users.

* module/language/cps/type-fold.scm (&scalar-types):
  (fold-and-reduce): Adapt to boolean type representation change.

9 years agoOn MS-Windows, don't return file names with backslashes from search-path.
Eli Zaretskii [Fri, 15 Aug 2014 06:47:52 +0000 (09:47 +0300)]
On MS-Windows, don't return file names with backslashes from search-path.

* libguile/load.c (search_path): On MS-Windows, convert all
  backslashes to forward slashes if the file was found on PATH.

9 years agoCopy the result from 'nl_langinfo' before it can be overwritten.
Mark H Weaver [Thu, 14 Aug 2014 02:47:32 +0000 (22:47 -0400)]
Copy the result from 'nl_langinfo' before it can be overwritten.

Based on a patch by Eli Zaretskii <eliz@gnu.org>.

* libguile/i18n.c (copy_string_or_null): New static function.
  (scm_nl_langinfo): Use 'copy_string_or_null' to copy the result from
  'nl_langinfo' and 'nl_langinfo_l' before the next call and before
  releasing the locale mutex.

9 years agoMake temporary file in coding.test work on MS-Windows.
Eli Zaretskii [Wed, 13 Aug 2014 15:41:15 +0000 (18:41 +0300)]
Make temporary file in coding.test work on MS-Windows.

* test-suite/tests/coding.test (with-temp-file): Instead of
  hard-coding "/tmp" as the temporary directory, use $TMPDIR or
  $TEMP from the environment, and fall back on "/tmp" if none of
  those 2 is defined.

9 years agodoc: "!#" does not need to appear on a line of its own.
Ludovic Courtès [Tue, 12 Aug 2014 20:23:07 +0000 (22:23 +0200)]
doc: "!#" does not need to appear on a line of its own.

* doc/ref/api-evaluation.texi (Block Comments): Remove "which must appear on a
  line of their own".  Reported by David Michael <fedora.dm0@gmail.com>.

9 years agoClarify that object-properties cannot be reliably applied to numbers.
David Kastrup [Mon, 11 Aug 2014 02:50:08 +0000 (22:50 -0400)]
Clarify that object-properties cannot be reliably applied to numbers.

* doc/ref/api-utility.texi (Object Properties)[make-object-property]:
  Clarify that object-properties cannot be reliably applied to numbers.

Signed-off-by: David Kastrup <dak@gnu.org>
9 years agoProvide curried version of define*-public.
Ian Price [Thu, 31 Jul 2014 15:05:58 +0000 (16:05 +0100)]
Provide curried version of define*-public.

* module/ice-9/curried-definitions.scm (define*-public): New macro.

9 years agoPrevent add-to-load-path from adding duplicate entries
Ian Price [Wed, 30 Jul 2014 17:58:16 +0000 (18:58 +0100)]
Prevent add-to-load-path from adding duplicate entries

* module/ice-9/boot-9.scm (add-to-load-path): Remove argument from
  %load-path (if it exists) before pushing. This also means that the
  `elt' will always be at the front of %load-path.

9 years agoBetter simplification of literal constants that continue to branches
Andy Wingo [Sun, 20 Jul 2014 18:52:06 +0000 (20:52 +0200)]
Better simplification of literal constants that continue to branches

* module/language/cps/simplify.scm (eta-reduce): Constants that continue
  to branches eta-reduce to the true or false branch.

9 years agoCPS will not see "not" primcalls
Andy Wingo [Sun, 20 Jul 2014 18:19:01 +0000 (20:19 +0200)]
CPS will not see "not" primcalls

* module/language/tree-il/compile-cps.scm (convert): Remove "not"
  primcalls.

* module/language/cps/effects-analysis.scm (values):
* module/language/cps/types.scm: Remove special cases for the "not"
  primcall.

9 years agoSimplify pass rewrite scope tree to reflect dominator tree
Andy Wingo [Sun, 6 Jul 2014 10:38:26 +0000 (12:38 +0200)]
Simplify pass rewrite scope tree to reflect dominator tree

* module/language/cps/simplify.scm (redominate): Add micropass to
  rewrite the scope tree to reflect the dominator tree.  Will enable
  better eta reduction.

9 years agoRemove dead case in CSE
Andy Wingo [Sun, 6 Jul 2014 10:17:58 +0000 (12:17 +0200)]
Remove dead case in CSE

* module/language/cps/cse.scm (apply-cse): Remove a case that couldn't
  occur.

9 years agoCSE allocate-struct fix
Andy Wingo [Mon, 21 Jul 2014 15:30:16 +0000 (17:30 +0200)]
CSE allocate-struct fix

* module/language/cps/cse.scm (compute-equivalent-subexpressions):
  Fix handling of allocate-struct in tail position.

9 years agoFix typo in arities.scm
Andy Wingo [Mon, 21 Jul 2014 15:03:51 +0000 (17:03 +0200)]
Fix typo in arities.scm

* module/language/cps/arities.scm (fix-arities*): Fix typo.

9 years agoStabilize renumber.scm:sort-conts.
Andy Wingo [Mon, 21 Jul 2014 10:19:33 +0000 (12:19 +0200)]
Stabilize renumber.scm:sort-conts.

* module/language/cps/renumber.scm (sort-conts): Prevent spurious
  continuation reordering.

9 years agomaybe_annotate_source does not annotate negative positions
Andy Wingo [Mon, 21 Jul 2014 19:37:20 +0000 (21:37 +0200)]
maybe_annotate_source does not annotate negative positions

* libguile/read.c (maybe_annotate_source): Don't annotate with negative
  lines or columns.

9 years agoSoft port fill-input doesn't alter line or column
Andy Wingo [Mon, 21 Jul 2014 19:36:30 +0000 (21:36 +0200)]
Soft port fill-input doesn't alter line or column

* libguile/vports.c (sf_fill_input): Save and restore the line/column
  info around the ungetc.

9 years agoscm_ungetc_unlocked should not result in negative columns
Andy Wingo [Mon, 21 Jul 2014 19:35:49 +0000 (21:35 +0200)]
scm_ungetc_unlocked should not result in negative columns

* libguile/ports.c (scm_ungetc_unlocked): Use DECCOL in all cases, to
  avoid negative columns.

9 years agoFix allocate-slots for $kreceive with multiple predecessors
Andy Wingo [Mon, 21 Jul 2014 09:47:43 +0000 (11:47 +0200)]
Fix allocate-slots for $kreceive with multiple predecessors

* module/language/cps/slot-allocation.scm (allocate-slots): For
  continuations of $call, $callk, and $values with multiple
  predecessors, recalculate the set of live slots.  Fixes miscompilation
  of ice-9/futures.scm:process-future!, broken since the previous patch,
  now that $kreceive continuations can have multiple predecessors.

9 years agoBlock sorting to keep loop bodies together
Andy Wingo [Sat, 5 Jul 2014 13:46:48 +0000 (15:46 +0200)]
Block sorting to keep loop bodies together

* module/language/cps/renumber.scm (compute-new-labels-and-vars):
  (compute-tail-path-lengths, sort-conts): Arrange to visit successors
  in such a way that if branches are unsorted, the longest path length
  will appear first.  This keeps loop bodies together.

9 years agoRecognize more ARM targets.
Ludovic Courtès [Fri, 4 Jul 2014 15:26:41 +0000 (17:26 +0200)]
Recognize more ARM targets.

Suggested by Dale P. Smith.

* module/system/base/target.scm (cpu-endianness): Add cases for
  "arm.*eb", "^aarch64.*be", and "aarch64".  Change "arm" case to
  "arm.*".
  (triplet-pointer-size): Allow underscore as in 'aarch64_be'.
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["armeb-unknown-linux-gnu",
  "aarch64-linux-gnu", "aarch64_be-linux-gnu"]: New tests.

9 years agoFix bit-count* bug
Andy Wingo [Sat, 28 Jun 2014 13:24:29 +0000 (15:24 +0200)]
Fix bit-count* bug

* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
  2005 refactor (!) in which the second arg was erroneously taken from
  the first arg.

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

* doc/ref/api-compound.texi: Fix doc example for u32vector selector.

9 years agobuild: Support pthread builds without 'pthread_cancel' support (Android).
Ludovic Courtès [Fri, 4 Jul 2014 13:52:15 +0000 (15:52 +0200)]
build: Support pthread builds without 'pthread_cancel' support (Android).

Reported by Sylvain Beucler <beuc@beuc.net>.

* configure.ac: Check for 'pthread_cancel'.
* libguile/threads.c (scm_cancel_thread): Conditionalize on
  !SCM_USE_PTHREAD_THREADS || defined HAVE_PTHREAD_CANCEL.
* test-suite/tests/threads.test (require-cancel-thread): New procedure.
  ("timed joining fails if timeout exceeded", "join-thread returns
  timeoutval on timeout", "cancel succeeds", "handler result passed to
  join", "can cancel self"): Use it.

9 years agobuild: Use 'LT_LIB_M' to determine whether -lm is needed.
Ludovic Courtès [Fri, 4 Jul 2014 13:37:38 +0000 (15:37 +0200)]
build: Use 'LT_LIB_M' to determine whether -lm is needed.

* configure.ac: Use 'LT_LIB_M' instead of 'AC_CHECK_LIB(m, cos)'.
  Suggested by Sylvain Beucler <beuc@beuc.net>.

9 years agoRecognize arm-* target triplets.
Ludovic Courtès [Fri, 4 Jul 2014 13:35:06 +0000 (15:35 +0200)]
Recognize arm-* target triplets.

Reported by Sylvain Beucler <beuc@beuc.net>.

* module/system/base/target.scm (cpu-endianness): Add case where CPU is
  "arm".
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["arm-unknown-linux-androideabi"]:
  New test.

9 years agologbit? strength reduction
Andy Wingo [Fri, 4 Jul 2014 10:05:31 +0000 (12:05 +0200)]
logbit? strength reduction

* module/language/cps/type-fold.scm (fold-and-reduce): Don't require
  types to check out; it could be that the reduced expression can
  exhibit the same type-check effects.  Reduce for all continuations,
  even $kreceive.  Pass dfg to reducer.
  (mul): Check types.
  (logbit?): New reducer.

9 years agoFix logand range analysis.
Andy Wingo [Fri, 4 Jul 2014 09:54:03 +0000 (11:54 +0200)]
Fix logand range analysis.

* module/language/cps/types.scm (logand): Fix range analysis.

9 years agoFix range analysis for mul and div
Andy Wingo [Fri, 4 Jul 2014 09:14:16 +0000 (11:14 +0200)]
Fix range analysis for mul and div

* module/language/cps/types.scm (mul): Avoid producing nans in the
  resulting range.
  (div): Fix range analysis.

9 years agoType-driven strength reduction
Andy Wingo [Fri, 4 Jul 2014 08:46:31 +0000 (10:46 +0200)]
Type-driven strength reduction

* module/language/cps/type-fold.scm (*primcall-reducers*):
  (define-primcall-reducer, define-unary-primcall-reducer):
  (define-binary-primcall-reducer, mul): Beginnings of strength
  reduction.
  (fold-and-reduce): Rename from compute-folded.
  (fold-constants*): Adapt.

9 years agoSmall type-fold cleanup
Andy Wingo [Fri, 4 Jul 2014 07:18:36 +0000 (09:18 +0200)]
Small type-fold cleanup

* module/language/cps/type-fold.scm (fold-constants*): Remove stale
  branches that were there when we only type folded on limited-size
  branches.

9 years agoRemove trailing whitespace from ports.test.
Eli Zaretskii [Thu, 3 Jul 2014 18:05:49 +0000 (21:05 +0300)]
Remove trailing whitespace from ports.test.

9 years agoUntabify some test files.
Eli Zaretskii [Thu, 3 Jul 2014 18:02:23 +0000 (21:02 +0300)]
Untabify some test files.

* test-suite/tests/ports.test: Untabify.
* test-suite/tests/posix.test: Untabify.
* test-suite/tests/r6rs-files.test: Untabify.

9 years agoFix problems with Windows file names that use backslashes.
Eli Zaretskii [Thu, 3 Jul 2014 17:58:19 +0000 (20:58 +0300)]
Fix problems with Windows file names that use backslashes.

* libguile/load.c (scm_i_mirror_backslashes): New function.
  (scm_init_load_path): Call it to produce MS-Windows file names
  with forward slashes.
  (FILE_NAME_SEPARATOR_STRING): Define as "/" on all platforms.

* libguile/load.h (scm_i_mirror_backslashes): Add prototype.

* libguile/init.c (scm_boot_guile): Call scm_i_mirror_backslashes
  on argv[0].

* libguile/filesys.c (scm_getcwd): Call scm_i_mirror_backslashes
  on the directory name returned by getcwd.

* test-suite/tests/ports.test ("file name separators"): New test.

9 years agoFix calculation of CPU set size for getaffinity.
Eli Zaretskii [Thu, 3 Jul 2014 16:30:02 +0000 (19:30 +0300)]
Fix calculation of CPU set size for getaffinity.

* libguile/posix.c (cpu_set_to_bitvector): Use CPU_SETSIZE, not
  sizeof, to compute the size of the CPU set.

9 years agoProvide a more reasonable default value for stack limit on MS-Windows.
Eli Zaretskii [Thu, 3 Jul 2014 16:26:21 +0000 (19:26 +0300)]
Provide a more reasonable default value for stack limit on MS-Windows.

* libguile/debug.c (init_stack_limit) [__MINGW32__]: Use
  VirtualQuery to compute the stack limit on MS-Windows.

9 years agoUnconditionally build and test the ice-9/popen module.
Eli Zaretskii [Thu, 3 Jul 2014 16:20:00 +0000 (19:20 +0300)]
Unconditionally build and test the ice-9/popen module.

* module/Makefile.am (ICE_9_SOURCES): Add ice-9/popen.scm.
  (ICE_9_SOURCES) [BUILD_ICE_9_POPEN]: Remove conditional addition
  of ice-9/popen.scm.
  (SCRIPTS_SOURCES): Add scripts/autofrisk.scm and
  scripts/scan-api.scm unconditionally.
  (SCRIPTS_SOURCES) [BUILD_ICE_9_POPEN]: Remove conditional addition
  of scripts/autofrisk.scm and scripts/scan-api.scm.

* configure.ac: Remove the BUILD_ICE_9_POPEN condition.

* test-suite/tests/popen.test (if-supported): Don't test for 'fork
 feature being supported.

9 years agoCompiler emits br-if-logtest
Andy Wingo [Thu, 3 Jul 2014 13:03:40 +0000 (15:03 +0200)]
Compiler emits br-if-logtest

* module/language/cps/compile-bytecode.scm (compile-fun):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (logtest):
* module/language/cps/types.scm (logtest):
* module/system/vm/assembler.scm (system):
* module/system/vm/disassembler.scm (compute-labels): Add backend
  support for the logtest instruction.

9 years agoAdd br-if-logtest opcode
Andy Wingo [Thu, 3 Jul 2014 12:50:50 +0000 (14:50 +0200)]
Add br-if-logtest opcode

* libguile/vm-engine.c (br-if-logtest): New opcode.
* module/system/vm/disassembler.scm (code-annotation): Add branch
  annotation support.

9 years agoOptimizer support for logtest and logbit?
Andy Wingo [Thu, 3 Jul 2014 12:45:12 +0000 (14:45 +0200)]
Optimizer support for logtest and logbit?

* module/language/cps/effects-analysis.scm: Add entries for logtest and
  logbit?.
* module/language/cps/types.scm (logtest, logbit?): New checkers and
  inferrers.
* module/language/tree-il/peval.scm (peval): Convert (zero? (logand a
  b)) to (logtest a b), in anticipation of opcode support for logtest.
*
  module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  (*effect-free-primitives*): Add logtest and logbit?.

9 years agoConvert slot allocation to use intsets
Andy Wingo [Thu, 3 Jul 2014 09:24:37 +0000 (11:24 +0200)]
Convert slot allocation to use intsets

* module/language/cps/dfg.scm (compute-live-variables): Convert to use
  intsets, and fold in compute-maximum-fixed-point.
  (print-dfa): Update.

* module/language/cps/slot-allocation.scm (dead-after-def?)
  (dead-after-use?, allocate-slots): Convert to use intsets.

9 years agoAdd bitvector->intset.
Andy Wingo [Thu, 3 Jul 2014 08:37:20 +0000 (10:37 +0200)]
Add bitvector->intset.

* module/language/cps/intset.scm (bitvector->intset): New interface.

9 years agoRestrict intsets and maps to non-negative integers
Andy Wingo [Thu, 3 Jul 2014 07:37:30 +0000 (09:37 +0200)]
Restrict intsets and maps to non-negative integers

* module/language/cps/intmap.scm (intmap-add):
* module/language/cps/intset.scm (intset-add): Restrict to only hold
  non-negative integers.

9 years agoAdapt visit-prompt-control-flow to use intsets.
Andy Wingo [Thu, 3 Jul 2014 07:20:11 +0000 (09:20 +0200)]
Adapt visit-prompt-control-flow to use intsets.

* module/language/cps/dfg.scm (compute-reachable): Use intsets.
  (compute-interval): Adapt.
  (visit-prompt-control-flow): Adapt.

9 years agoCSE comments
Andy Wingo [Thu, 3 Jul 2014 07:03:45 +0000 (09:03 +0200)]
CSE comments

* module/language/cps/cse.scm (compute-available-expressions): Add
  clarifying comment.

9 years agoAdd intset-subtract.
Andy Wingo [Thu, 3 Jul 2014 07:02:31 +0000 (09:02 +0200)]
Add intset-subtract.

* module/language/cps/intset.scm (intset-subtract): New interface.

9 years ago More fixes for deleting files whose ports are not closed.
Eli Zaretskii [Wed, 2 Jul 2014 18:21:52 +0000 (21:21 +0300)]
More fixes for deleting files whose ports are not closed.

* test-suite/tests/r6rs-files.test: Close the port after
using it.

* test-suite/tests/posix.test ("mkstemp!"): Close the port after
using it.

9 years ago Make 'system*' available on MS-Windows.
Eli Zaretskii [Wed, 2 Jul 2014 15:38:28 +0000 (18:38 +0300)]
Make 'system*' available on MS-Windows.

* libguile/simpos.c (scm_system_star) [!HAVE_FORK]: An
implementation of 'system*' for MS-Windows, which doesn't have
'fork', but can use 'spawnvp' in this case.

9 years ago Fix deletion of ports.test test file on MS-Windows.
Eli Zaretskii [Wed, 2 Jul 2014 15:28:06 +0000 (18:28 +0300)]
Fix deletion of ports.test test file on MS-Windows.

* test-suite/tests/ports.test ("fdes->port", "seek")
("truncate-file"): Close every file and port we open, to avoid
failure to delete the test file on MS-Windows when the test is
completed.

9 years agoFix intset on 32-bit machines
Andy Wingo [Tue, 1 Jul 2014 09:30:29 +0000 (11:30 +0200)]
Fix intset on 32-bit machines

* module/language/cps/intset.scm (*leaf-bits*): Define to 4 on 32-bit
  machines, to stay in fixnum range.

9 years agoRemove size limit in elide-type-checks
Andy Wingo [Mon, 30 Jun 2014 13:30:39 +0000 (15:30 +0200)]
Remove size limit in elide-type-checks

* module/language/cps/dce.scm (elide-type-checks!): Remove limit on
  label-count, now that complexity is under control.

9 years agoFix intmap-intersect corner case
Andy Wingo [Sun, 29 Jun 2014 17:49:41 +0000 (19:49 +0200)]
Fix intmap-intersect corner case

* module/language/cps/intmap.scm (intmap-intersect): Fix a corner case,
  as was recently fixed for intsets.

9 years agoCSE truth inference pass uses intsets
Andy Wingo [Sun, 29 Jun 2014 17:25:54 +0000 (19:25 +0200)]
CSE truth inference pass uses intsets

* module/language/cps/cse.scm (compute-truthy-expressions): Rewrite to
  use intsets instead of bitvectors.
  (apply-cse): Adapt.

9 years agoResult of intsect-intersect will share structure with A if it can
Andy Wingo [Sun, 29 Jun 2014 17:47:25 +0000 (19:47 +0200)]
Result of intsect-intersect will share structure with A if it can

* module/language/cps/intset.scm (intset-intersect): Ensure that the
  result shares structure with A if possible, as intmaps do.

9 years agoFix an intset-intersect corner case
Andy Wingo [Sun, 29 Jun 2014 17:40:43 +0000 (19:40 +0200)]
Fix an intset-intersect corner case

* module/language/cps/intset.scm (intset-intersect): Avoid creating
  invalid intsets when lowering an intset with a higher shift.

9 years agoFix intset pruning for empty intsets
Andy Wingo [Sun, 29 Jun 2014 17:31:27 +0000 (19:31 +0200)]
Fix intset pruning for empty intsets

* module/language/cps/intset.scm (make-intset/prune): Fix empty intset
  case.

9 years agoRemove namesets.
Andy Wingo [Sun, 29 Jun 2014 12:29:20 +0000 (14:29 +0200)]
Remove namesets.

This was a failed experiment.  It had good space complexity but terrible
time complexity.

* module/Makefile.am: Update.
* module/language/cps/nameset.scm: Remove.

9 years agoRewrite type inference to use intmaps
Andy Wingo [Sun, 29 Jun 2014 12:20:52 +0000 (14:20 +0200)]
Rewrite type inference to use intmaps

* module/language/cps/types.scm: Rewrite to use intmaps instead of
  namesets.

9 years agoNew module (language cps intmap)
Andy Wingo [Sun, 29 Jun 2014 08:41:57 +0000 (10:41 +0200)]
New module (language cps intmap)

* module/language/cps/intmap.scm: New file.
* module/Makefile.am: Add to build.

9 years agoRewrite CSE to use intsets.
Andy Wingo [Sun, 29 Jun 2014 12:20:26 +0000 (14:20 +0200)]
Rewrite CSE to use intsets.

* module/language/cps/cse.scm: Rewrite using intsets.

9 years agoNew module: (language cps intset)
Andy Wingo [Sun, 29 Jun 2014 12:09:04 +0000 (14:09 +0200)]
New module: (language cps intset)

* module/Makefile.am: Add to build.
* module/language/cps/intset.scm: New file.

9 years agoFix bit-count* bug
Andy Wingo [Sat, 28 Jun 2014 13:24:29 +0000 (15:24 +0200)]
Fix bit-count* bug

* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
  2005 refactor (!) in which the second arg was erroneously taken from
  the first arg.

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

* doc/ref/api-compound.texi: Fix doc example for u32vector selector.