bpt/guile.git
10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Thu, 3 Oct 2013 19:35:21 +0000 (21:35 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/deprecated.h
libguile/programs.c
libguile/programs.h

10 years agoDeprecate scm_c_program_source, as it has no internal users.
Andy Wingo [Thu, 3 Oct 2013 17:45:41 +0000 (19:45 +0200)]
Deprecate scm_c_program_source, as it has no internal users.

* libguile/programs.c:
* libguile/programs.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_c_program_source): Deprecate.

10 years agoFix edge case in 'ash'.
Mark H Weaver [Thu, 3 Oct 2013 18:25:51 +0000 (14:25 -0400)]
Fix edge case in 'ash'.

* libguile/numbers.c (scm_ash): Fix (ash -1 SCM_I_FIXNUM_BIT-1) to
  return a fixnum instead of a bignum.

* test-suite/tests/numbers.test (ash): Add tests.

10 years agoAdd source location test
Andy Wingo [Thu, 3 Oct 2013 14:13:56 +0000 (16:13 +0200)]
Add source location test

* test-suite/tests/dwarf.test: New test, testing that source location
  information survives the round-trip through the compiler, back out to
  the (system vm debug) interfaces.

10 years agoAdd (system vm debug) interface to source location information
Andy Wingo [Thu, 3 Oct 2013 12:44:30 +0000 (14:44 +0200)]
Add (system vm debug) interface to source location information

* module/system/vm/debug.scm (<source>, source-pre-pc)
  (source-post-pc, source-file, source-line, source-column)
  (source-line-for-user): New data type for source location
  information.
  (find-source-for-addr, find-program-sources): New procedures to get
  source location information for a particular address.

10 years agoAdd interface to read .debug_line data
Andy Wingo [Thu, 3 Oct 2013 12:42:49 +0000 (14:42 +0200)]
Add interface to read .debug_line data

* module/system/vm/dwarf.scm (die-line-prog):
  (line-prog-advance, line-prog-scan-to-pc): New public interfaces,
  allowing clients to interpret the "statement programs" from
  .debug_line DWARF sections.
  (<meta>, elf->dwarf-context): Record the bounds of the .debug_line
  section.

10 years agoSerialize source positions into .debug_line
Andy Wingo [Wed, 2 Oct 2013 19:34:38 +0000 (21:34 +0200)]
Serialize source positions into .debug_line

* module/system/vm/assembler.scm (link-debug): Generate a correct DWARF2
  line program.  Tests come next.

10 years agoEmit a placeholder .debug_line section.
Andy Wingo [Mon, 30 Sep 2013 19:49:12 +0000 (21:49 +0200)]
Emit a placeholder .debug_line section.

* module/system/vm/assembler.scm (link-debug): Emit a .debug_line
  section also.
  (link-objects): Expect .debug_line.

10 years agoAdd new "source" macro instruction; compile-rtl emits it.
Andy Wingo [Mon, 30 Sep 2013 19:48:07 +0000 (21:48 +0200)]
Add new "source" macro instruction; compile-rtl emits it.

* module/system/vm/assembler.scm (<asm>): Add "sources" field.
  (make-assembler): Adapt to make-asm change.
  (source): New macro assembler.

* module/language/cps/compile-rtl.scm (emit-rtl-sequence):
  (compile-fun): Emit source instructions as appropriate.

10 years agoFix minor mistakes in documentation.
Mark H Weaver [Mon, 30 Sep 2013 16:46:01 +0000 (12:46 -0400)]
Fix minor mistakes in documentation.

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

* doc/ref/api-i18n.texi (i18n Introduction, Text Collation,
  Internationalization, Internationalization):
  LC_MESSAGE --> LC_MESSAGES.

* doc/ref/api-procedures.texi (Compiled Procedures):
  program-lambda-alist --> program-lambda-list.

* THANKS: Fix alignment of Josep Portella Florit.

10 years agoDWARF linker: encode strings using the correct form
Andy Wingo [Sat, 28 Sep 2013 16:15:44 +0000 (18:15 +0200)]
DWARF linker: encode strings using the correct form

* module/system/vm/assembler.scm (link-debug): Encode strings using the
  strp form.

10 years agoEmit minimal DWARF information
Andy Wingo [Sat, 28 Sep 2013 12:50:48 +0000 (14:50 +0200)]
Emit minimal DWARF information

* module/system/vm/assembler.scm (link-debug): New function, creates the
  necessary DWARF debugging sections.
  (link-objects): Emit debugging sections.

10 years agoadd DWARF parser
Andy Wingo [Sat, 9 Jun 2012 16:26:27 +0000 (18:26 +0200)]
add DWARF parser

* module/Makefile.am:
* module/system/vm/dwarf.scm: New module, a DWARF parser.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Fri, 13 Sep 2013 04:24:04 +0000 (00:24 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
module/srfi/srfi-9.scm
module/web/server.scm

10 years agoFix truncated documentation for 'put-char'.
Mark H Weaver [Fri, 13 Sep 2013 03:58:32 +0000 (23:58 -0400)]
Fix truncated documentation for 'put-char'.

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

* doc/ref/api-io.texi (R6RS Textual Output): Fix truncated docs
  for 'put-char'.

* THANKS: Add Josep Portella Florit to fixes section.

10 years agoWeb: Use functional setters in extend-request and extend-response.
Mark H Weaver [Thu, 12 Sep 2013 22:45:13 +0000 (18:45 -0400)]
Web: Use functional setters in extend-request and extend-response.

* module/web/client.scm (extend-request):
* module/web/server.scm (extend-response): Reimplement using
  functional setters.

10 years agoWeb client+server: Add Content-Length header for empty bodies.
Mark H Weaver [Thu, 12 Sep 2013 22:34:39 +0000 (18:34 -0400)]
Web client+server: Add Content-Length header for empty bodies.

* module/web/client.scm (sanitize-request): Add a Content-Length
  header if a body if given, even if the body is empty.

* module/web/server.scm (sanitize-response): Add a Content-Length
  header if a body if given, even if the body is empty.

10 years agoAdapt srfi-9.test to error reporting improvements; update copyright dates.
Mark H Weaver [Thu, 12 Sep 2013 22:14:54 +0000 (18:14 -0400)]
Adapt srfi-9.test to error reporting improvements; update copyright dates.

* module/srfi/srfi-9.scm: Add 2013 copyright date.

* test-suite/tests/srfi-9.test: Adapt to recent error reporting
  improvements to procedures defined by 'define-tagged-inlinable'.

10 years agoImprove error reporting of procedures defined by define-inlinable.
Mark H Weaver [Thu, 12 Sep 2013 22:04:08 +0000 (18:04 -0400)]
Improve error reporting of procedures defined by define-inlinable.

* module/ice-9/boot-9.scm (define-inlinable): Improve error reporting
  when procedures defined using 'define-inlinable' are applied to the
  wrong number of arguments.

* module/srfi/srfi-9.scm (define-tagged-inlinable): Improve error
  reporting when procedures defined using 'define-tagged-inlinable' are
  applied to the wrong number of arguments.

10 years agoTHANKS Alexandru Cojocaru
Mark H Weaver [Tue, 10 Sep 2013 06:05:26 +0000 (02:05 -0400)]
THANKS Alexandru Cojocaru

* THANKS: Add Alexandru Cojocaru to fixes section.

10 years agoweb client: HTTP methods are symbols, not strings.
Mark H Weaver [Tue, 10 Sep 2013 05:39:52 +0000 (01:39 -0400)]
web client: HTTP methods are symbols, not strings.

* module/web/client.scm (request, http-get, http-head, http-post,
  http-put, http-delete, http-trace, http-options): HTTP methods are
  symbols.

10 years agoFix extend-request to preserve method and meta.
Alexandru Cojocaru [Tue, 27 Aug 2013 13:59:39 +0000 (15:59 +0200)]
Fix extend-request to preserve method and meta.

* module/web/client.scm (extend-request): Preserve method and meta.

10 years agopsyntax: cite the paper that psyntax is based on.
Mark H Weaver [Tue, 10 Sep 2013 02:42:36 +0000 (22:42 -0400)]
psyntax: cite the paper that psyntax is based on.

* module/ice-9/psyntax.scm: cite the paper.

10 years agoMinor stylistic improvement to 'and-let*' macro.
Mark H Weaver [Tue, 10 Sep 2013 02:20:09 +0000 (22:20 -0400)]
Minor stylistic improvement to 'and-let*' macro.

* module/ice-9/and-let-star.scm (%and-let*): Use 'and' instead of
  'if'.  Suggested by Chris K. Jester-Young <cky944@gmail.com>.

10 years agoRewrite SRFI-2 'and-let*' using syntax-case.
Mark H Weaver [Mon, 9 Sep 2013 23:37:49 +0000 (19:37 -0400)]
Rewrite SRFI-2 'and-let*' using syntax-case.

* module/ice-9/and-let-star.scm (%and-let*): Helper macro.
  (and-let*): Reimplement using syntax-case.

10 years agoMicro-optimize char_decimal_value.
Andy Wingo [Sat, 31 Aug 2013 09:15:01 +0000 (11:15 +0200)]
Micro-optimize char_decimal_value.

* libguile/numbers.c (char_decimal_value): A wee micro-optimization.

10 years agoFaster scm_from_port_stringn
Andy Wingo [Sat, 31 Aug 2013 08:57:11 +0000 (10:57 +0200)]
Faster scm_from_port_stringn

* libguile/strings.c (scm_from_port_stringn): Always inline to
  scm_from_utf8_string if the byte sequence is valid utf-8.

10 years agounread-char: inline conversion from codepoint to bytes
Andy Wingo [Sat, 31 Aug 2013 08:44:07 +0000 (10:44 +0200)]
unread-char: inline conversion from codepoint to bytes

* libguile/ports.c (scm_ungetc_unlocked): Inline the conversion from
  codepoint to bytes for UTF-8 and latin-1 ports.  Speeds up a
  numbers-reading test case by 100% (!).

10 years agoAdd contification pass
Andy Wingo [Sat, 24 Aug 2013 13:02:57 +0000 (15:02 +0200)]
Add contification pass

* module/Makefile.am:
* module/language/cps/contification.scm: New pass.

* module/language/cps/compile-rtl.scm (optimize): Wire it into the
  compiler.

10 years agoAdd CPS -> RTL compiler
Andy Wingo [Sun, 11 Aug 2013 12:08:08 +0000 (14:08 +0200)]
Add CPS -> RTL compiler

* module/Makefile.am:
* module/language/cps/compile-rtl.scm:
* module/language/cps/dfg.scm:
* module/language/cps/slot-allocation.scm: New modules.

* module/language/cps/spec.scm: Register the compiler.

* test-suite/Makefile.am:
* test-suite/tests/rtl-compilation.test: Add tests.

10 years agoAdd pass to reify primcalls without corresponding VM ops
Andy Wingo [Sat, 24 Aug 2013 13:02:52 +0000 (15:02 +0200)]
Add pass to reify primcalls without corresponding VM ops

* module/Makefile.am:
* module/language/cps/reify-primitives.scm: New pass.

10 years agoAdd arity-adapting module
Andy Wingo [Thu, 18 Jul 2013 18:02:13 +0000 (20:02 +0200)]
Add arity-adapting module

* module/Makefile.am:
* module/language/cps/arities.scm: New module.  Adapts call and return
  arities, especially for primcalls.

10 years agoAdd CPS primitives info module
Andy Wingo [Sat, 24 Aug 2013 13:02:38 +0000 (15:02 +0200)]
Add CPS primitives info module

* module/Makefile.am:
* module/language/cps/primitives.scm: New file.

10 years agoRTL language
Andy Wingo [Sun, 11 Aug 2013 12:06:15 +0000 (14:06 +0200)]
RTL language

 * module/Makefile.am
 * module/language/rtl.scm:
 * module/language/rtl/spec.scm: Add a stub RTL language.

10 years agoAdd closure conversion
Andy Wingo [Tue, 23 Jul 2013 14:05:48 +0000 (16:05 +0200)]
Add closure conversion

* module/Makefile.am
* module/language/cps/closure-conversion.scm: New module, implementing a
  closure conversion pass.

10 years ago(compile foo #:to 'cps)
Andy Wingo [Tue, 23 Jul 2013 14:04:51 +0000 (16:04 +0200)]
(compile foo #:to 'cps)

* module/language/tree-il/compile-cps.scm: New module implementing CPS
  conversion of Tree-IL.

* module/Makefile.am:
* module/language/tree-il/spec.scm:
* module/language/cps/spec.scm: Integrate CPS in the build and language
  system.

10 years agoAdd CPS language
Andy Wingo [Tue, 23 Jul 2013 13:51:35 +0000 (15:51 +0200)]
Add CPS language

* module/Makefile.am:
* module/language/cps.scm:
* module/language/cps/verify.scm: Add CPS language.

* .dir-locals.el: Add indentation rules for some CPS forms.

10 years ago,xx for RTL images
Andy Wingo [Thu, 29 Aug 2013 18:50:19 +0000 (20:50 +0200)]
,xx for RTL images

* module/scripts/disassemble.scm (disassemble):
* module/system/vm/disassembler.scm (disassemble-file): Factor
  disassemble-file out.

* module/system/repl/command.scm (disassemble-file): Map ,xx to
  disassemble RTL images.

10 years agoadd ability to disassemble ELF images
Andy Wingo [Thu, 29 Aug 2013 18:43:03 +0000 (20:43 +0200)]
add ability to disassemble ELF images

* module/scripts/disassemble.scm (disassemble): Update to work with
  RTl (and only RTL, as that's the future).

* module/system/vm/debug.scm (for-each-elf-symbol): New public
  interface.
  (debug-context-from-image): New helper.
  (find-debug-context): Use the helper.

* module/system/vm/disassembler.scm (disassemble-image): New public
  interface.

10 years agoExport the assembler procedures
Andy Wingo [Sat, 24 Aug 2013 10:38:02 +0000 (12:38 +0200)]
Export the assembler procedures

* module/system/vm/assembler.scm (define-assembler):
  (define-macro-assembler): Export the assemblers.

10 years agortl vm: box-set! binds no values
Andy Wingo [Sat, 24 Aug 2013 09:34:56 +0000 (11:34 +0200)]
rtl vm: box-set! binds no values

* libguile/vm-engine.c (box-set!): Remove the OP_DST flag.

10 years agoRA == MVRA in disassembler
Andy Wingo [Mon, 12 Aug 2013 19:41:23 +0000 (21:41 +0200)]
RA == MVRA in disassembler

* module/system/vm/disassembler.scm: Modify call disassembler to assume
  RA == MVRA.

10 years agoassembler: give proper permissions to .data section
Andy Wingo [Tue, 20 Aug 2013 20:08:25 +0000 (22:08 +0200)]
assembler: give proper permissions to .data section

* module/system/vm/assembler.scm (link-data): Give stringbufs the
  "shared" flag already, so we don't attempt to set it at runtime.  Give
  .data sections the SHF_WRITE flag.

10 years agocompile-file adds #:to-disk? #t to opts
Andy Wingo [Tue, 20 Aug 2013 20:06:46 +0000 (22:06 +0200)]
compile-file adds #:to-disk? #t to opts

* module/system/base/compile.scm (compile-file): Pass #:to-disk? as an
  option to indicate that the result will be being loaded from disk.
  Perhaps a linker might want to page-align in that case.

* module/language/elisp/compile-tree-il.scm (process-options!): Accept
  and ignore the #:to-file compiler option.

10 years agoRTL: 'return-values' instruction assumes 'reset-frame' has been called.
Mark H Weaver [Sat, 17 Aug 2013 10:38:53 +0000 (06:38 -0400)]
RTL: 'return-values' instruction assumes 'reset-frame' has been called.

* libguile/vm-engine.c (return-values): Remove NVALUES operand.
  Don't reset the frame.

* test-suite/tests/rtl.test ("cached-toplevel-set!"): Adapt to the fact
  that 'return-values' has no operand now, and that 'reset-frame' must
  be done first.

10 years agoRTL VM: Rename 'apply' instruction to 'tail-apply'.
Mark H Weaver [Sat, 17 Aug 2013 09:37:45 +0000 (05:37 -0400)]
RTL VM: Rename 'apply' instruction to 'tail-apply'.

* libguile/vm-engine.c (apply, tail-apply): apply -> tail-apply.
  (RETURN_VALUE_LIST): goto op_apply -> goto op_tail_apply.

* libguile/vm.c (rtl_apply_code): scm_rtl_op_apply ->
  scm_rtl_op_tail_apply.

10 years agoRTL VM: fix multiple value returns.
Mark H Weaver [Fri, 16 Aug 2013 01:58:41 +0000 (21:58 -0400)]
RTL VM: fix multiple value returns.

* libguile/vm-engine.c (halt): Fix off-by-one error in retrieving
  multiple values from the frame.

10 years agoConvert branchable primitives into binary operations only.
Mark H Weaver [Tue, 13 Aug 2013 13:03:23 +0000 (09:03 -0400)]
Convert branchable primitives into binary operations only.

* module/language/tree-il/primitives.scm (maybe-simplify-to-eq): Wrap
  within another lambda, binding the primitive name.  If there are less
  than two arguments, expand to constant #t.  If there are more than two
  arguments, convert into a conjunction of binary applications.
  (expand-chained-comparisons): New procedure.
  (*primitive-expand-table*): Add entries for (< <= = >= > eq?).

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Sat, 24 Aug 2013 02:36:02 +0000 (22:36 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoFix 'define-public' from (ice-9 curried-definitions).
Mark H Weaver [Fri, 23 Aug 2013 05:57:50 +0000 (01:57 -0400)]
Fix 'define-public' from (ice-9 curried-definitions).

* module/ice-9/curried-definitions.scm (cdefine, cdefine*): Simplify,
  and improve error reporting by making the patterns more strict.
  (define-public): Fix bug in generated 'export' form.

10 years agoImprove error checking in 'define-public' and 'module-add!'.
Mark H Weaver [Mon, 19 Aug 2013 23:30:42 +0000 (19:30 -0400)]
Improve error checking in 'define-public' and 'module-add!'.

* module/ice-9/boot-9.scm (module-add!): Check that the symbol argument
  is actually a symbol.
  (define-public): Expand into 'define' in such a way that curried
  definitions will immediately fail.

10 years agodoc: `get-string-all' takes only one argument.
Ian Price [Mon, 19 Aug 2013 21:25:41 +0000 (22:25 +0100)]
doc: `get-string-all' takes only one argument.

* doc/ref/api-io.texi (R6RS Textual Input): Remove `count' argument.

10 years ago`write-request-line' always prints a path component.
Ian Price [Mon, 19 Aug 2013 02:43:48 +0000 (03:43 +0100)]
`write-request-line' always prints a path component.

* module/web/http.scm (write-request-line): Always write "/" when path
  is empty, regardless of query.
* test-suite/tests/web-http.test ("write-request-line"): Add test.

10 years agoIn bytevector->uint-list et al, check that SIZE divides the bv length.
Mark H Weaver [Sat, 17 Aug 2013 03:10:14 +0000 (23:10 -0400)]
In bytevector->uint-list et al, check that SIZE divides the bv length.

Fixes <http://bugs.gnu.org/15100>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/bytevectors.c (INTEGERS_TO_LIST): Enforce the R6RS
  requirement that SIZE divides the bytevector length.

* test-suite/tests/bytevectors.test: Add test.  Remove tests that
  assumes that this "divides" check is not enforced.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Sat, 17 Aug 2013 03:05:34 +0000 (23:05 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoImproved error checking in bytevector->uint-list and bytevector->sint-list.
Mark H Weaver [Sat, 17 Aug 2013 02:54:39 +0000 (22:54 -0400)]
Improved error checking in bytevector->uint-list and bytevector->sint-list.

Partially fixes <http://bugs.gnu.org/15100>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/bytevectors.c (INTEGERS_TO_LIST): Make sure SIZE isn't 0.
  Allow SIZE to be greater than the bytevector length, for consistency
  with allowing extra bytes at the end when the bytevector length is
  non-zero.  Use scm_from_size_t instead of scm_from_uint.

* test-suite/tests/bytevectors.test: Add tests.  Remove a test that
  checks for an exception when SIZE is greater than the bytevector
  length.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Thu, 15 Aug 2013 08:09:04 +0000 (04:09 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoImprove run-time error reporting in (ice-9 match).
Mark H Weaver [Thu, 15 Aug 2013 07:59:15 +0000 (03:59 -0400)]
Improve run-time error reporting in (ice-9 match).

* module/Makefile.am: match.go depends on match.upstream.scm.

* module/ice-9/match.scm (error): Accept any number of arguments.

* module/ice-9/match.upstream.scm (match-next): Call 'error' in non-tail
  context, and include the value that failed to match in the call.

10 years agoAdapt peval.test to recent associativity fixes of numeric ops.
Mark H Weaver [Wed, 14 Aug 2013 03:34:32 +0000 (23:34 -0400)]
Adapt peval.test to recent associativity fixes of numeric ops.

* test-suite/tests/peval.test ("partial evaluation"): Adapt tests to the
  fact that arithmetic operators are now expanded into binary ops with
  left-to-right associativity.

10 years agoManual: clarify that 'append!' and 'reverse!' might not mutate.
Mark H Weaver [Wed, 14 Aug 2013 00:33:18 +0000 (20:33 -0400)]
Manual: clarify that 'append!' and 'reverse!' might not mutate.

* doc/ref/api-compound.texi (Append/Reverse): Clarify that 'append!' and
  'reverse!' are not required to modify anything.

10 years agoManual: don't promise that 'append!' will modify the existing lists.
Mark H Weaver [Tue, 13 Aug 2013 23:52:48 +0000 (19:52 -0400)]
Manual: don't promise that 'append!' will modify the existing lists.

* doc/ref/api-compound.texi (Append/Reverse): Say that 'append!' *may*
  modify the given lists, but don't promise that it will.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 13 Aug 2013 01:36:45 +0000 (21:36 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoCommon numeric operations are left-to-right associative.
Mark H Weaver [Mon, 12 Aug 2013 23:40:32 +0000 (19:40 -0400)]
Common numeric operations are left-to-right associative.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Use 'match-lambda*' instead of 'case-lambda' for pattern matching.
  (*primitive-expand-table*): In primitive expanders for '+', '*', '-',
  '/', 'logior', and 'logand', assume conventional left-to-right
  associativity.

10 years agoNumerical comparisons are not negatable.
Mark H Weaver [Mon, 12 Aug 2013 22:08:59 +0000 (18:08 -0400)]
Numerical comparisons are not negatable.

* module/language/tree-il/primitives.scm (*negatable-primitives*):
  Remove (< <= > >=) from the list of negatable primitives.

10 years agoRTL VM: Fix SCM_PACK_RTL_* macros.
Mark H Weaver [Mon, 12 Aug 2013 17:47:35 +0000 (13:47 -0400)]
RTL VM: Fix SCM_PACK_RTL_* macros.

* libguile/instructions.h (SCM_PACK_RTL_8_8_8): Fix typo.
  (SCM_PACK_RTL_16_8): Fix erroneous shift offset.

10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Mon, 12 Aug 2013 02:46:22 +0000 (22:46 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

10 years agoBroken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.
Mark H Weaver [Mon, 12 Aug 2013 02:38:49 +0000 (22:38 -0400)]
Broken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.

* test-suite/tests/i18n.test (under-turkish-utf8-locale-or-unresolved):
  Disable tests of Turkish UTF-8 locale in FreeBSD 9.1.

10 years agoAdapt ecmascript compiler to tree-il prompt changes, again.
Mark H Weaver [Sun, 11 Aug 2013 21:18:09 +0000 (17:18 -0400)]
Adapt ecmascript compiler to tree-il prompt changes, again.

* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  The body of an escape-only prompt is no longer a thunk.  Adapt.

10 years agoVarious RTL VM and calling convention tweaks
Andy Wingo [Sun, 11 Aug 2013 14:42:06 +0000 (16:42 +0200)]
Various RTL VM and calling convention tweaks

* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Allow for
  five-word instructions, and for new instruction word types.

* libguile/vm-engine.c (RETURN_ONE_VALUE): Instead of returning the
  value in the fixed part of the call frame, return it in the same place
  multiple-value returns go: from slot 1.
  (BR_ARITHMETIC): Allow arithmetic tests to be negated.
  (rtl_vm_engine): Change calling convention to use the same location
  for single and multiple-value returns.  Renumber all instructions.

  (halt, halt/values): Fold into a single instruction (halt).
  (call): Take the location of the procedure instead of the location of
  the call frame.  Also take the number of args, and reset the sp before
  jumping to the procedure, so as to indicate the number of arguments.
  (call/values): Remove, as the new calling convention has RA == MVRA.
  (tail-call): Require the procedure to be shuffled down already, and
  take "nlocals" as an arg instead of "nargs".
  (receive, receive-values): New instructions, for receiving returned
  values from calls.
  (return-values): Rename from return/values.  Remove "values".
  (alloc-frame): Rename from reserve-locals.
  (reset-frame): New instruction.
  (drop-locals): Remove.
  (br-if-=, br-if-<, br-if-<=): Allow these instructions to be
  negatable.
  (br-if->, br-if->=): Remove.  Probably a bad idea, given NaN.
  (box-ref): Don't bother trying to do a reverse lookup -- the
  toplevel-box, module-box, and resolve instructions should handle
  that.
  (resolve): Add arg to check that the variable is bound.
  (toplevel-box, module-box): New instructions, replacing toplevel-ref,
  toplevel-set, module-ref, and module-set.

* libguile/vm.c (rtl_boot_continuation_code, rtl_values_code): Adapt to
  instruction set changes.

* module/Makefile.am: Make the assembler and disassembler dependent on
  vm-operations.h.

* module/system/vm/assembler.scm:
* module/system/vm/disassembler.scm: Adapt to instruction changes and
  new instruction word kinds.

* test-suite/tests/rtl.test: Adapt to instruction set changes.

10 years agoInline escape-only prompt bodies in the Tree-IL
Andy Wingo [Mon, 29 Jul 2013 19:55:39 +0000 (21:55 +0200)]
Inline escape-only prompt bodies in the Tree-IL

* module/language/scheme/decompile-tree-il.scm (do-decompile):
* module/language/tree-il/analyze.scm (analyze-lexicals):
* module/language/tree-il/canonicalize.scm (canonicalize):
* module/language/tree-il/compile-glil.scm (flatten-lambda-case):
* module/language/tree-il/cse.scm (cse):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/peval.test ("partial evaluation"):  Partially revert
  178a40928, so that escape-only prompts explicitly inline their bodies.

10 years agoremove peval abort-in-tail-position optimization
Andy Wingo [Mon, 29 Jul 2013 19:30:49 +0000 (21:30 +0200)]
remove peval abort-in-tail-position optimization

* module/language/tree-il/peval.scm (peval): Remove abort optimization;
  the CPS compiler will do much better here, and it is complicating
  things in the meantime.

10 years agoFix inappropriate uses of scm_syserror in numbers.c.
Mark H Weaver [Sat, 10 Aug 2013 15:47:54 +0000 (11:47 -0400)]
Fix inappropriate uses of scm_syserror in numbers.c.

* libguile/numbers.c (mem2ureal, left_shift_exact_integer,
  floor_right_shift_exact_integer, round_right_shift_exact_integer):
  Use 'assert' instead of 'scm_syserror' to indicate a case that should
  never happen.

10 years agodereference-pointer: check for null pointer.
Mark H Weaver [Fri, 9 Aug 2013 22:23:56 +0000 (18:23 -0400)]
dereference-pointer: check for null pointer.

* libguile/foreign.c (scm_dereference_pointer): Check for attempts to
  dereference a null pointer.

* test-suite/tests/foreign.test ("null pointer"): Add test.

10 years agoFix numerator and denominator handling of signed zeroes and infinities.
Mark H Weaver [Fri, 9 Aug 2013 09:32:23 +0000 (05:32 -0400)]
Fix numerator and denominator handling of signed zeroes and infinities.

* libguile/numbers.c (scm_numerator, scm_denominator): Handle signed
  zeroes and infinities in accordance with the corresponding R6RS flonum
  procedures.

* module/rnrs/arithmetic/flonums.scm (flnumerator, fldenominator):
  Remove special handling of infinities.

* test-suite/tests/numbers.test (numerator, denominator): Add tests.
  Convert existing tests to use 'pass-if-equal'.

* test-suite/tests/r6rs-arithmetic-flonums.test (flnumerator): Fix
  broken test of (flnumerator -0.0).

10 years agoEliminate use of deprecated 'SCM_WTA_DISPATCH_2' in numbers.c.
Mark H Weaver [Thu, 8 Aug 2013 06:19:46 +0000 (02:19 -0400)]
Eliminate use of deprecated 'SCM_WTA_DISPATCH_2' in numbers.c.

* libguile/numbers.c (scm_gcd): Use 'scm_wta_dispatch_2' not
  'SCM_WTA_DISPATCH_2'.

10 years agoFix --without-threads and SCM_DEBUG_TYPING_STRICTNESS==2 builds.
Mark H Weaver [Thu, 8 Aug 2013 05:23:04 +0000 (01:23 -0400)]
Fix --without-threads and SCM_DEBUG_TYPING_STRICTNESS==2 builds.

* libguile/hashtab.c (scm_hashv_ref, scm_hashv_set_x,
  scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x, scm_hash_remove_x):
* libguile/strports.c (scm_mkstrport):
* libguile/weak-vector.c (weak_vector_ref): Add missing SCM_UNPACK.

* libguile/ports.c (lock_port, unlock_port): Cast MUTEX to the
  expected type.

10 years agoDecompiler: fix handling of empty 'case-lambda' expressions.
Mark H Weaver [Wed, 7 Aug 2013 09:54:15 +0000 (05:54 -0400)]
Decompiler: fix handling of empty 'case-lambda' expressions.

* module/language/scheme/decompile-tree-il.scm (choose-output-names):
  A <lambda> with no <lambda-case> decompiles into a 'case-lambda'
  primitive.  Ensure that 'case-lambda' is not shadowed by a lexical.

10 years agoAdapt ecmascript compiler to recent tree-il changes for prompts.
Mark H Weaver [Wed, 7 Aug 2013 07:13:11 +0000 (03:13 -0400)]
Adapt ecmascript compiler to recent tree-il changes for prompts.

* module/language/ecmascript/compile-tree-il.scm (with-return-prompt):
  Adapt to the changes in 178a40928ab5221f6ce57c5af1067abe30a342b3.
  Prompt tree-il nodes now contain an explicit 'escape-only?' flag, and
  the body and handler are now both lambdas.

10 years agoString ports use UTF-8; ignore %default-port-encoding.
Mark H Weaver [Wed, 7 Aug 2013 04:46:34 +0000 (00:46 -0400)]
String ports use UTF-8; ignore %default-port-encoding.

* libguile/strports.c (scm_mkstrport): Use UTF-8; ignore
  %default-port-encoding.  Rename 'str_len' and 'c_pos' to
  'num_bytes' and 'c_byte_pos'.  Interpret 'pos' argument
  as a character index instead of a byte index.

* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-6 to the
  list of core features.

* module/srfi/srfi-6.scm (open-input-string, open-output-string): Simply
  re-export these, since the core versions are now compliant.

* doc/ref/api-io.texi (String Ports): Remove text that describes
  non-compliant behavior of string ports with regard to encoding.

* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-6 to the list of
  core features.
  (SRFI-6): Remove text that mentions non-compliant behavior of
  core string ports.

* module/ice-9/format.scm (format):
* module/ice-9/pretty-print.scm (truncated-print):
* module/rnrs/io/ports.scm (open-string-input-port,
  open-string-output-port):
* test-suite/test-suite/lib.scm (format-test-name):
* test-suite/tests/chars.test ("combining accent is pretty-printed",
  "combining X is pretty-printed"):
* test-suite/tests/ecmascript.test (eread, eread/1):
* test-suite/tests/rdelim.test:
* test-suite/tests/reader.test (read-string):
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-105.test (read-string): Don't set
  %default-port-encoding before creating string ports.

* benchmark-suite/benchmarks/ports.bm (%latin1-port): Use
  'set-port-encoding!' to set the string port encoding.
  (%utf8/ascii-port, %utf8/wide-port, "rdelim"): Don't set
  %default-port-encoding before creating string ports.

* test-suite/tests/r6rs-ports.test ("lookahead-u8 non-ASCII"): Don't set
  %default-port-encoding before creating string ports.
  ("put-bytevector with UTF-16 string port", "put-bytevector with
  wrong-encoding string port"): Use 'set-port-encoding!' to set the
  string port encoding.

* test-suite/tests/print.test (tprint): Use 'set-port-encoding!' to set
  the string port encoding.
  ("truncated-print"): Use 'pass-if-equal'.

* test-suite/tests/ports.test ("encoding failure leads to exception",
  "%default-port-encoding is honored", "peek-char [latin-1]", "peek-char
  [utf-8]", "peek-char [utf-16]"): Remove tests.
  ("%default-port-encoding is ignored", "peek-char"): Add tests.
  ("suitable encoding [latin-1]", "suitable encoding [latin-3]",
  "wrong encoding, error", "wrong encoding, substitute",
  "wrong encoding, escape"): Use 'set-port-encoding!' to set the
  string port encoding.
  ("%default-port-encoding, wrong encoding"): Rewrite to use
  a file port instead of a string port.

10 years agoFix display of symbols containing backslashes.
David Kastrup [Tue, 6 Aug 2013 22:01:54 +0000 (18:01 -0400)]
Fix display of symbols containing backslashes.

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

* libguile/print.c (print_extended_symbol): Double print backslashes.

Signed-off-by: Mark H Weaver <mhw@netris.org>
10 years agoMerge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 6 Aug 2013 21:37:34 +0000 (17:37 -0400)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
libguile/numbers.c
libguile/vm-i-scheme.c

10 years agoAdd files from 'copysign' and 'isfinite' Gnulib modules.
Mark H Weaver [Tue, 6 Aug 2013 21:16:04 +0000 (17:16 -0400)]
Add files from 'copysign' and 'isfinite' Gnulib modules.

* lib/copysign.c:
* lib/isfinite.c:
* lib/isnanf-nolibm.h:
* lib/isnanl-nolibm.h:
* lib/signbitd.c:
* lib/signbitf.c:
* lib/signbitl.c:
* m4/copysign.m4:
* m4/isfinite.m4:
* m4/signbit.m4: New files.

10 years agoRTL VM: Avoid untagging inums in 'logand' and 'logior'.
Mark H Weaver [Tue, 6 Aug 2013 21:03:56 +0000 (17:03 -0400)]
RTL VM: Avoid untagging inums in 'logand' and 'logior'.

* libguile/vm-engine.c (logand, logior): Avoid untagging.

10 years agoRTL VM: Avoid signed overflows in 'add1' and 'sub1'.
Mark H Weaver [Tue, 6 Aug 2013 21:00:23 +0000 (17:00 -0400)]
RTL VM: Avoid signed overflows in 'add1' and 'sub1'.

* libguile/vm-engine.c (INUM_MIN, INUM_MAX): Redefine without making
  assumptions about the representation.
  (INUM_STEP): New macro.
  (add1, sub1): Avoid signed overflows, and use INUM_STEP.

10 years agoRTL VM: ash: Use SCM_SRS and fix large right shifts in fast path.
Mark H Weaver [Tue, 6 Aug 2013 20:51:41 +0000 (16:51 -0400)]
RTL VM: ash: Use SCM_SRS and fix large right shifts in fast path.

* libguile/vm-engine.c (ash): Use SCM_SRS, and handle large right
  shifts properly.

10 years agoVM: ash: Use SCM_SRS and handle large right shift in fast path.
Mark H Weaver [Tue, 6 Aug 2013 20:38:32 +0000 (16:38 -0400)]
VM: ash: Use SCM_SRS and handle large right shift in fast path.

* libguile/vm-i-scheme.c (ash): Use SCM_SRS.  Handle inum right shift by
  more than SCM_I_FIXNUM_BIT-1 bits in fast path.

10 years agoUse Gnulib's 'isfinite' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:26:46 +0000 (16:26 -0400)]
Use Gnulib's 'isfinite' in numbers.c.

* libguile/numbers.c (DOUBLE_IS_FINITE, DOUBLE_IS_POSITIVE_INFINITY,
  DOUBLE_IS_NEGATIVE_INFINITY): Remove.
  (scm_odd_p, scm_even_p, scm_finite_p, icmplx2str, scm_rational_p,
  scm_inexact_to_exact): Use 'isfinite' instead of 'DOUBLE_IS_FINITE'.

10 years agoUse Gnulib's 'copysign' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:21:26 +0000 (16:21 -0400)]
Use Gnulib's 'copysign' in numbers.c.

* libguile/numbers.c (double_is_non_negative_zero): Remove.
  (idbl2str, scm_max, scm_min, scm_angle, log_of_shifted_double,
  scm_log10): Use 'copysign' to check signs of zeroes,
  instead of 'double_is_non_negative_zero'.

10 years agoImport 'copysign' and 'isfinite' modules from Gnulib.
Mark H Weaver [Tue, 6 Aug 2013 19:56:32 +0000 (15:56 -0400)]
Import 'copysign' and 'isfinite' modules from Gnulib.

* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Add 'copysign' and 'isfinite' Gnulib modules.

10 years agoVM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".
Mark H Weaver [Sun, 4 Aug 2013 23:39:43 +0000 (19:39 -0400)]
VM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Clobber _CX not "rcx".

10 years agoVM: Define ASM_MUL on ARM only if SMULL instruction is supported.
Mark H Weaver [Sun, 4 Aug 2013 22:01:52 +0000 (18:01 -0400)]
VM: Define ASM_MUL on ARM only if SMULL instruction is supported.

* libguile/vm-i-scheme.c (ASM_MUL): Define only if the target
  architecture is known to implement the SMULL instruction.

10 years agoVM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.
Mark H Weaver [Fri, 2 Aug 2013 00:31:21 +0000 (20:31 -0400)]
VM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB, ASM_MUL): Implement for ARM.

10 years agoVM: Avoid untagging inums in 'logand' and 'logior'.
Mark H Weaver [Thu, 1 Aug 2013 19:31:39 +0000 (15:31 -0400)]
VM: Avoid untagging inums in 'logand' and 'logior'.

* libguile/vm-i-scheme.c (logand, logior): Avoid untagging.

10 years agoVM: Add ASM_MUL for x86.
Mark H Weaver [Sat, 3 Aug 2013 19:05:59 +0000 (15:05 -0400)]
VM: Add ASM_MUL for x86.

* libguile/vm-i-scheme.c (ASM_MUL): New macro.
  (mul): Use ASM_MUL if available.

10 years agoVM: Support 32-bit x86 in ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:58:28 +0000 (14:58 -0400)]
VM: Support 32-bit x86 in ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (_CX): New macro.
  (ASM_ADD, ASM_SUB): Replace references to "rcx" with _CX.

10 years agoVM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:59:54 +0000 (14:59 -0400)]
VM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Add "cc" to the clobber
  list.  Suggested by Göran Weinholt <goran@weinholt.se>.

10 years agoVM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.
Mark H Weaver [Sat, 3 Aug 2013 18:51:07 +0000 (14:51 -0400)]
VM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.

* libguile/vm-i-scheme.c (ASM_ADD): Remove the tag from one of the
  operands before adding, to avoid overflow when the result is the most
  positive fixnum.

10 years agoVM: Avoid signed overflows in 'add1' and 'sub1'.
Mark H Weaver [Sat, 3 Aug 2013 18:46:40 +0000 (14:46 -0400)]
VM: Avoid signed overflows in 'add1' and 'sub1'.

* libguile/vm-i-scheme.c (INUM_STEP): New macro.
  (add1, sub1): Avoid signed overflows, and use INUM_STEP.

10 years agoVM: Redefine INUM_MIN and INUM_MAX without assumptions.
Mark H Weaver [Thu, 1 Aug 2013 18:01:58 +0000 (14:01 -0400)]
VM: Redefine INUM_MIN and INUM_MAX without assumptions.

* libguile/vm-i-scheme.c (INUM_MIN, INUM_MAX): Redefine to avoid
  assumptions about the representation of inums.

10 years agoAdd 'scm_i_from_double' and use it.
Mark H Weaver [Thu, 1 Aug 2013 17:50:41 +0000 (13:50 -0400)]
Add 'scm_i_from_double' and use it.

* libguile/numbers.c (scm_i_from_double): New static function.
  (scm_from_double): Just call 'scm_i_from_double'.
  (scm_inf, scm_nan, scm_abs, scm_i_inexact_floor_quotient,
  scm_i_inexact_floor_remainder, scm_i_inexact_floor_divide,
  scm_i_inexact_ceiling_quotient, scm_i_inexact_ceiling_remainder,
  scm_i_inexact_ceiling_divide, scm_i_inexact_truncate_quotient,
  scm_i_inexact_truncate_remainder, scm_i_inexact_truncate_divide,
  scm_i_inexact_centered_quotient, scm_i_inexact_centered_remainder,
  scm_i_inexact_centered_divide, scm_i_inexact_round_quotient,
  scm_i_inexact_round_remainder, scm_i_inexact_round_divide,
  scm_max, scm_min, scm_sum, scm_difference, scm_product,
  scm_divide, scm_truncate_number, scm_round_number, scm_floor,
  scm_ceiling, scm_expt, scm_sin, scm_cos, scm_tan, scm_sinh,
  scm_cosh, scm_tanh, scm_asin, scm_acos, scm_atan, scm_sys_asinh,
  scm_sys_acosh, scm_sys_atanh, scm_real_part, scm_imag_part,
  scm_magnitude, scm_angle, scm_exact_to_inexact, log_of_shifted_double,
  log_of_fraction, scm_log10, scm_exp, scm_sqrt, scm_init_numbers):
  Use 'scm_i_from_double' instead of 'scm_from_double'.