Daniel Llorens [Tue, 9 Apr 2013 16:17:21 +0000 (18:17 +0200)]
Replace scm_c_generalized_vector_length in arrays.c
* libguile/arrays.c: (scm_array_contents, scm_make_shared_array):
arrays are known of rank 1 so replace by scm_c_array_length.
Daniel Llorens [Tue, 9 Apr 2013 16:09:49 +0000 (18:09 +0200)]
Replace scm_c_generalized_vector_length in random.c
* libguile/random.c: (random:solid-sphere!): array is of known
rank 1, so use scm_c_array_length() instead.
Daniel Llorens [Thu, 18 Apr 2013 13:10:29 +0000 (15:10 +0200)]
Tests for array-copy!, empty case
* test-suite/tests/ramap.test: test array-copy! with empty destination.
Fix uses of constant array as destination.
Andy Wingo [Wed, 5 Feb 2014 21:52:00 +0000 (22:52 +0100)]
Various VM stack management fixes
* libguile/vm.c (vm_increase_sp): New interface, to increase the SP to
some new level, possibly expanding the stack.
(vm_push_sp, vm_restore_sp): Intefaces to vm_increase_sp.
(vm_return_to_continuation): Don't throw an error if there's not
enough space; instead, expand.
(vm_reinstate_partial_continuation): Use the new helper.
(return_unused_stack_to_os): Avoid off-by-one error (sp points to
valid memory.)
(scm_call_n): Never write beyond the sp.
Andy Wingo [Sun, 2 Feb 2014 22:19:22 +0000 (23:19 +0100)]
Add VM and compiler support for calls to known procedures
* module/language/cps.scm ($callk): New expression type, for calls to
known labels. Part of "low CPS".
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm: Adapt call sites.
* libguile/vm-engine.c (call-label, tail-call-label): New instructions.
Renumber the rest; this is an ABI change.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* doc/ref/compiler.texi (CPS in Guile): Document $callk.
Andy Wingo [Sun, 2 Feb 2014 18:15:48 +0000 (19:15 +0100)]
Remove code to run GC more frequently as process image size increased
* libguile/gc.c: Remove code that would try to run GC more frequently as
the process image size was increasing. Before, it was often the case
that the heap was the main component of image size, but with
expandable stacks and statically allocated data that is no longer
true. Also, once scm_gc_register_allocation was incorporated, we
don't need to be so conservative any more. It seems this code was
simply causing too many gc's to run. Removing it improves some
micro-benchmarks; time will tell.
Andy Wingo [Sun, 2 Feb 2014 15:04:58 +0000 (16:04 +0100)]
Add thread-local lock-free, TLS-free freelists.
* libguile/bdw-gc.h: Remove a needless compatibility hack.
* libguile/gc-inline.h: New file, implementing thread-local freelists
providing faster allocation if we already have a scm_i_thread*
pointer. Based on gc_inline.h from libgc.
* libguile/threads.h (scm_i_thread): Add freelists here.
* libguile/threads.c (guilify_self_1, guilify_self_2): Initialize
freelists.
* libguile/vm.c: Include gc-inline.h.
* libguile/vm-engine.c: Rename current_thread to thread. Use
scm_inline_cons instead of scm_cons, scm_inline_cell instead of
scm_cell, and scm_inline_words instead of words.
Andy Wingo [Sun, 2 Feb 2014 10:43:03 +0000 (11:43 +0100)]
Add dead slot map cache
* libguile/vm.c (find_dead_slot_map, scm_i_vm_mark_stack): Use a little
cache for dead slot maps. Helps when marking very deep recursive
stacks.
Andy Wingo [Fri, 31 Jan 2014 20:41:36 +0000 (21:41 +0100)]
Return unused parts of the stack to the OS
* libguile/vm.h (struct scm_vm): Reorder fields. Add "sp_max_since_gc"
field.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
* libguile/vm.c (vm_return_to_continuation)
(vm_reinstate_partial_continuation, scm_call_n): In places where we
could increase the stack height, update sp_max_since_gc.
(vm_expand_stack): Relocate sp_max_since_gc on expansion.
(scm_bootstrap_vm): Record the page size using gnulib's getpagesize.
(return_unused_stack_to_os): New routine, run when marking stacks.
Andy Wingo [Fri, 31 Jan 2014 19:31:31 +0000 (20:31 +0100)]
Micro-optimization to scm_i_vm_mark_stack
* libguile/vm.c (scm_i_vm_mark_stack): Micro-optimize GC_MARK_AND_PUSH
to cache the plausible heap bounds locally.
Andy Wingo [Tue, 28 Jan 2014 21:28:08 +0000 (22:28 +0100)]
Minor for-each speedup
* module/ice-9/boot-9.scm (for-each): Minor speedup by unrolling
tortoise/hare loop.
Andy Wingo [Tue, 28 Jan 2014 20:56:54 +0000 (21:56 +0100)]
Unnecessary VM_HANDLE_INTERRUPTS elision
* libguile/vm-engine.c: Remove VM_HANDLE_INTERRUPTS before entering a
subr or foreign call. The bytecode stub will have already done so
when entering the stub, and the return sequence handles doing so
before returning.
Andy Wingo [Tue, 28 Jan 2014 20:31:17 +0000 (21:31 +0100)]
Fix tracing
* module/system/vm/trace.scm (print-return): Remove frame argument.
(trace-calls-to-procedure, trace-calls-in-procedure): Adapt callers.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
(trap-calls-to-procedure): Since the pop continuation hook is now
called after the continuation is popped, we need to check the right
frame. Fixes tail-calls in the trace root, and probably other things.
Andy Wingo [Sun, 26 Jan 2014 19:55:04 +0000 (20:55 +0100)]
More precise stack marking via .guile.frame-maps section
* module/language/cps/slot-allocation.scm (lookup-dead-slot-map)
(allocate-slots): For each non-tail call in a function, compute the
set of slots that are dead after the function has begun the call.
* module/language/cps/compile-bytecode.scm (compile-fun): Emit the
`dead-slot-map' macro instruction for non-tail calls.
* module/system/vm/assembler.scm (<asm>): Add `dead-slot-maps' member.
(dead-slot-map): New macro-instruction.
(link-frame-maps, link-dynamic-section, link-objects): Write dead
slots information into .guile.frame-maps sections of ELF files.
* module/system/vm/elf.scm (DT_GUILE_FRAME_MAPS): New definition.
* libguile/loader.h:
* libguile/loader.c (DT_GUILE_FRAME_MAPS, process_dynamic_segment):
(load_thunk_from_memory, register_elf): Arrange to parse
DT_GUILE_FRAME_MAPS out of the dynamic section.
(find_mapped_elf_image_unlocked, find_mapped_elf_image): New helpers.
(scm_find_mapped_elf_image): Refactor.
(scm_find_dead_slot_map_unlocked): New interface.
* libguile/vm.c (scm_i_vm_mark_stack): Mark the hottest frame
conservatively, as before. Otherwise use the dead slots map, if
available, to avoid marking data that isn't live.
Andy Wingo [Fri, 24 Jan 2014 12:15:31 +0000 (13:15 +0100)]
Add NEWS for Guile 2.2
* NEWS: Update for 2.1.1.
Andy Wingo [Fri, 24 Jan 2014 11:34:26 +0000 (12:34 +0100)]
Document top-level pseudo-hygiene
* doc/ref/api-macros.texi (Hygiene and the Top-Level): Add a section
documenting our pseudo-hygienic top-level names.
Mark H Weaver [Tue, 21 Jan 2014 08:57:04 +0000 (03:57 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/read.c
test-suite/tests/web-response.test
Mark H Weaver [Mon, 20 Jan 2014 22:15:53 +0000 (17:15 -0500)]
Fix (port-conversion-strategy #f).
Reported by Doug Evans <xdje42@gmail.com>.
* libguile/ports.c (scm_port_conversion_strategy): Don't validate
that 'port' is an open port until after the (port == #f) case
has been handled.
Andy Wingo [Sat, 18 Jan 2014 20:08:52 +0000 (21:08 +0100)]
Add support for content-disposition
* module/web/http.scm ("Content-Disposition"): Add a parser and
serializer. Defined in RFC2616 section 19.5.1.
* test-suite/tests/web-http.test ("entity headers"): New test case.
Arne Babenhauserheide [Fri, 17 Jan 2014 15:25:16 +0000 (16:25 +0100)]
doc: embedding example more readable.
* doc/ref/guile.texi (A Sample Guile Main Program): Easier to read
example code and building split into 2 subsections.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Fri, 17 Jan 2014 17:20:09 +0000 (18:20 +0100)]
Thank Sree Harsha.
Ludovic Courtès [Fri, 17 Jan 2014 17:18:41 +0000 (18:18 +0100)]
Arrange so that 'file-encoding' does not truncate the encoding name.
Fixes <http://bugs.gnu.org/16463>.
Reported by Sree Harsha Totakura <sreeharsha@totakura.in>.
* libguile/read.c (ENCODING_NAME_MAX_SIZE): New macro.
(SCM_ENCODING_SEARCH_SIZE): Change to 500 + ENCODING_NAME_MAX_SIZE.
(scm_i_scan_for_encoding): Return NULL if there's less than
ENCODING_NAME_MAX_SIZE bytes once "coding: *" has been read.
* test-suite/tests/coding.test ("line
comment")["http://bugs.gnu.org/16463"]: New test.
Andy Wingo [Thu, 16 Jan 2014 11:05:47 +0000 (12:05 +0100)]
Finish documenting the new compiler
* doc/ref/compiler.texi (An Introduction to CPS): Reword.
(Compiling CPS): New sub-sub-section.
(Bytecode): New sub-section.
Andy Wingo [Sun, 12 Jan 2014 22:02:34 +0000 (23:02 +0100)]
Fix CPS doc typos
* doc/ref/compiler.texi (CPS in Guile): Fix a couple typos.
Ludovic Courtès [Wed, 15 Jan 2014 22:41:23 +0000 (23:41 +0100)]
web: Don't throw if a response is longer than its Content-Length says.
* module/web/response.scm (make-delimited-input-port): Read at most LEN
bytes from PORT, instead of trying to read more and returning an error
if more is available. Try again when 'get-bytevector-n!' return zero.
* test-suite/tests/web-response.test (example-1): Add garbage after the
body itself.
Ludovic Courtès [Wed, 15 Jan 2014 22:07:25 +0000 (23:07 +0100)]
Custom binary input ports sanity-check the return value of 'read!'.
* libguile/r6rs-ports.c (cbip_fill_input): Throw an exception when
C_OCTETS is greater than what was requested.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port 'read!' returns too much"]: New test.
Mark H Weaver [Wed, 15 Jan 2014 08:08:32 +0000 (03:08 -0500)]
Document that we support srfi-46 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-46.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-46 to the list of core
features.
(SRFI-46): New node.
* doc/ref/api-macros.texi (Syntax Rules): Mention that the custom
ellipsis identifier support is specified by SRFI-46.
* test-suite/tests/syntax.test ("syntax-rules"): Add ellipsis hygiene
test from SRFI-46.
Mark H Weaver [Wed, 15 Jan 2014 07:37:46 +0000 (02:37 -0500)]
Document that we support srfi-87 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-87.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-87 to the list of core
features.
(SRFI-87): New node.
Mark H Weaver [Wed, 15 Jan 2014 04:53:08 +0000 (23:53 -0500)]
Merge branch 'stable-2.0'
Mark H Weaver [Wed, 15 Jan 2014 04:29:50 +0000 (23:29 -0500)]
print: In R7RS |...| symbols, print most graphic characters unescaped.
* libguile/print.c (print_r7rs_extended_symbol): Print any unicode
graphic character other than '|' or '\' unescaped. Escape any spacing
character other than ASCII space.
Mark H Weaver [Wed, 15 Jan 2014 03:23:39 +0000 (22:23 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/print.c
libguile/read.c
test-suite/tests/print.test
Mark H Weaver [Tue, 14 Jan 2014 22:38:30 +0000 (17:38 -0500)]
print: Support R7RS |...| symbol notation.
* libguile/print.c (scm_print_opts): Add 'r7rs-symbols' print option.
(symbol_has_extended_read_syntax): If the 'r7rs-symbols' option is
enabled, then disallow '|' and '\' from bare symbols.
(print_extended_symbol): Use 'scm_lfwrite' and 'scm_putc' instead of
'display_string' and 'display_character' when printing ASCII literals.
(print_r7rs_extended_symbol): New static function.
(scm_i_print_symbol_name): If the 'r7rs-symbols' option is enabled,
use 'print_r7rs_extended_symbol' instead of 'print_extended_symbol'.
* libguile/private-options.h (SCM_PRINT_R7RS_SYMBOLS_P): New macro.
(SCM_N_PRINT_OPTIONS): Increment.
* doc/ref/api-evaluation.texi (Scheme Write): Mention 'r7rs-symbols'
print option.
* test-suite/tests/print.test ("write"): Add tests.
Mark H Weaver [Sun, 12 Jan 2014 12:55:22 +0000 (07:55 -0500)]
read: Support R7RS |...| symbol notation.
* libguile/private-options.h (SCM_R7RS_SYMBOLS_P): New macro.
(SCM_N_READ_OPTIONS): Increment.
* libguile/read.c (scm_read_opts): Add entry for 'r7rs-symbols'.
(t_read_opts): Add field for 'r7rs_symbols_p'.
(scm_read_string_like_syntax): New function based on earlier
'scm_read_string' that handles either string literals or R7RS quoted
symbols (delimited by vertical bars), depending on the value of 'chr'.
(scm_read_string): Reimplement based on 'scm_read_string_like_syntax'.
(scm_read_r7rs_symbol): New static function.
* doc/ref/api-data.texi (Symbol Read Syntax): Briefly describe the R7RS
symbol syntax, mention the 'r7rs-symbols' read option, and give some
examples.
* doc/ref/api-evaluation.texi (Scheme Read): Mention the 'r7rs-symbols'
read option.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Tue, 14 Jan 2014 18:26:30 +0000 (13:26 -0500)]
Document that we support srfi-62 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-62.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-62 to the list of core
features.
(SRFI-62): New node.
Mark H Weaver [Tue, 14 Jan 2014 08:18:34 +0000 (03:18 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/chars.c
libguile/read.c
test-suite/tests/reader.test
Mark H Weaver [Tue, 14 Jan 2014 08:13:58 +0000 (03:13 -0500)]
read: use 'c_tolower' instead of 'tolower' in 'try_read_ci_chars'.
* libguile/read.c: Include <c-ctype.h>.
(try_read_ci_chars): Use 'c_tolower' instead of 'tolower'.
Mark H Weaver [Sun, 12 Jan 2014 09:36:57 +0000 (04:36 -0500)]
Recognize 'escape' character name, per R7RS.
* libguile/chars.c (scm_r7rs_charnames, scm_r7rs_charnums):
New static constants.
(SCM_N_R7RS_CHARNAMES): New macro.
(scm_i_charname, scm_i_charname_to_char): Adapt to new R7RS
char names.
* doc/ref/api-data.texi (Characters): Document #\escape.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Sun, 12 Jan 2014 09:36:29 +0000 (04:36 -0500)]
read: Accept "\|" in string literals.
* libguile/read.c (scm_read_string): Accept "\|" in string literals.
* doc/ref/api-data.texi (String Syntax): Add "\|" to the list of
supported backslash escapes.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Sun, 12 Jan 2014 09:36:02 +0000 (04:36 -0500)]
read: Support R7RS '#true' and '#false' syntax for booleans.
* libguile/read.c (try_read_ci_chars): New static function.
(scm_read_boolean, scm_read_array): Use 'try_read_ci_chars'.
* doc/ref/api-data.texi (Booleans): Update docs.
* test-suite/tests/reader.test ("reading"): Add tests.
Mark H Weaver [Tue, 14 Jan 2014 07:19:52 +0000 (02:19 -0500)]
Add srfi-16 and srfi-30 to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-16 and
srfi-30.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-16 and srfi-30 to the
list of core features.
* module/srfi/srfi-16.scm: Remove call to 'cond-expand-provide'.
Mark H Weaver [Tue, 14 Jan 2014 06:16:42 +0000 (01:16 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/hash.c
module/ice-9/psyntax-pp.scm
module/ice-9/psyntax.scm
test-suite/tests/r6rs-ports.test
Ludovic Courtès [Mon, 13 Jan 2014 22:15:28 +0000 (23:15 +0100)]
'port-position' works on CBIPs that do not support 'set-port-position!'.
* libguile/r6rs-ports.c (cbp_seek)[WHENCE == SEEK_CUR]: Break out of the
switch statement when OFFSET is zero.
Pass 'scm_wrong_type_arg_msg' a phrase suitable for use after
"expecting".
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port supports `port-position', not `set-port-position!'"]: New
test.
Andy Wingo [Sun, 12 Jan 2014 14:31:35 +0000 (15:31 +0100)]
Finish CPS documentation
* doc/ref/compiler.texi (Continuation-Passing Style): Flesh out the
documentation.
Mark H Weaver [Sun, 12 Jan 2014 12:47:00 +0000 (07:47 -0500)]
Fix 'exact-integer?' comment in numbers.test.
* test-suite/tests/numbers.test: Fix 'exact-integer?' comment.
Mark H Weaver [Sun, 12 Jan 2014 12:11:44 +0000 (07:11 -0500)]
Fix hashing of empty vectors.
Fixes a bug introduced in
cc1cd04f8111c306cf48b93e131d5c1765c808a3
"Fix hashing of vectors to run in bounded time."
* libguile/hash.c (scm_hasher): Avoid division by zero.
* test-suite/tests/hash.test ("hash"): Add tests.
Andy Wingo [Sun, 12 Jan 2014 11:37:05 +0000 (12:37 +0100)]
Rename $ktrunc to $kreceive
* module/language/cps.scm ($kreceive): Rename from ktrunc.
* module/language/cps/arities.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all users.
Andy Wingo [Sun, 12 Jan 2014 11:28:12 +0000 (12:28 +0100)]
Returning too many values to call-with-values raises a runtime error
* module/language/cps/compile-bytecode.scm (compile-fun): Now that all
$call expressions continue to $ktail or $ktrunc, remove the $kargs
case, and make receive-values bail if too many values are returned.
Mark H Weaver [Sun, 12 Jan 2014 09:16:39 +0000 (04:16 -0500)]
Bump user-visible copyright years to 2014.
* doc/ref/guile.texi: Add 2014 to list of copyright years in @copying
section.
* module/ice-9/command-line.scm (version-etc): Bump 'copyright-year' to
2014.
* module/system/repl/common.scm (*version*): Add 2014 to the range of
copyright years.
Mark H Weaver [Sat, 11 Jan 2014 15:18:40 +0000 (10:18 -0500)]
Fix hashing of vectors to run in bounded time.
* libguile/hash.c (SCM_MIN): New macro.
(scm_hasher): In vector case, do nothing if d is 0. Make sure to
recurse with a reduced d. Move the loop out of the 'if'.
Andy Wingo [Fri, 10 Jan 2014 16:44:10 +0000 (17:44 +0100)]
Insert explicit $ktrunc nodes everywhere that truncates multiple values
* module/language/tree-il/compile-cps.scm (init-default-value, convert):
Explicitly insert $ktrunc nodes on all places that can truncate to
single values.
Andy Wingo [Fri, 10 Jan 2014 21:50:12 +0000 (22:50 +0100)]
Add simplification pass
* module/Makefile.am:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/simplify.scm: New pass.
Andy Wingo [Wed, 11 Dec 2013 10:07:33 +0000 (11:07 +0100)]
Add DCE pass.
* module/language/cps/dce.scm: New pass.
* module/Makefile.am:
* module/language/cps/compile-bytecode.scm: Wire up the new pass.
Andy Wingo [Fri, 10 Jan 2014 19:42:50 +0000 (20:42 +0100)]
Shuffle the first return value from truncating calls
* module/language/cps/slot-allocation.scm (allocate-slots): For
truncating calls, shuffle the first return value (if any). Avoids
frame size growth due to sparse locals, pegged where they were left by
procedure call returns. With this patch, eval with $ktrunc nodes goes
from 31 locals to 18 (similar to the size before adding $ktrunc
nodes).
Andy Wingo [Fri, 10 Jan 2014 16:42:10 +0000 (17:42 +0100)]
All $values expressions go through allocate-values
* module/language/cps/slot-allocation.scm (allocate-slots): Make all
$values expressions go through allocate-values, and refactor
allocate-values.
Andy Wingo [Fri, 10 Jan 2014 15:40:24 +0000 (16:40 +0100)]
Fix allocate-slots bug
* module/language/cps/slot-allocation.scm (allocate-slots): Fix bug in
allocate!, whereby a previously hinted allocation would not be added
to the live set if a hint was not given later.
Andy Wingo [Fri, 10 Jan 2014 13:48:24 +0000 (14:48 +0100)]
More robust compute-hints
* module/language/cps/slot-allocation.scm (allocate-slots): Allow the
compute-hints pass to traverse through $values with 0 or 1 value.
Andy Wingo [Sun, 22 Dec 2013 16:14:13 +0000 (11:14 -0500)]
Prefer "receive" over "receive-values"+"reset-frame"
* module/language/cps/compile-bytecode.scm (compile-fun): Attempt to
emit "receive" instead of "receive-values"+"reset-frame" where
possible.
Andy Wingo [Sun, 22 Dec 2013 15:37:27 +0000 (10:37 -0500)]
Only emit receive-values if it is needed
* module/language/cps/compile-bytecode.scm (compile-fun): Don't emit
receive-values unless there is a minimum or maximum number of values.
Andy Wingo [Thu, 9 Jan 2014 18:52:58 +0000 (19:52 +0100)]
Remove "pop" from $prompt
* module/language/cps.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dfg.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Remove "pop" member from
$prompt data type, as it is no longer used.
Andy Wingo [Thu, 9 Jan 2014 18:23:03 +0000 (19:23 +0100)]
Enable prompt analysis
* module/language/cps/dfg.scm (compute-live-variables, visit-fun):
Use the new prompt analysis pass in analyze-control-flow instead of
always adding a link in the DFG. Avoids problems if there are
parts of the prompt body that have no path to the pop.
Andy Wingo [Thu, 9 Jan 2014 15:18:16 +0000 (16:18 +0100)]
Add prompt analysis to the DFG's analyze-control-flow
* module/language/cps/dfg.scm (compute-reachable, find-prompts)
(compute-interval, find-prompt-bodies, visit-prompt-control-flow): New
helpers.
(analyze-control-flow): Add a mode that adds on CFA edges
corresponding to non-local control flow in a prompt.
Andy Wingo [Thu, 9 Jan 2014 09:56:22 +0000 (10:56 +0100)]
compute-live-variables uses CFA analysis
* module/language/cps/dfg.scm ($dfa): Store a CFA instead of a separate
k-map and order.
(dfa-k-idx, dfa-k-sym, dfa-k-count): Adapt.
(compute-live-variables): Use analyze-control-flow instead of rolling
out own RPO numbering. Will allow us to fix some prompt-related
things in a central place.
Andy Wingo [Thu, 9 Jan 2014 09:21:17 +0000 (10:21 +0100)]
Internal analyze-control-flow refactor
* module/language/cps/dfg.scm (reverse-post-order): Fold-all-conts is
now a required arg.
(analyze-control-flow): Reverse CFA adds forward-reachable
continuations to the numbering.
Andy Wingo [Mon, 16 Dec 2013 12:48:59 +0000 (13:48 +0100)]
Fix constant-needs-allocation? for $values uses
* module/language/cps/dfg.scm (constant-needs-allocation?): Use of a
constant in a $values expression of any arity does not cause slot
allocation.
* module/language/cps/compile-bytecode.scm (compile-fun): Allow $values
with a constant value to be compiled in test context. Really we
should fold these in a previous pass!
Andy Wingo [Sat, 7 Dec 2013 18:58:08 +0000 (19:58 +0100)]
Add effects analysis pass on CPS
* module/Makefile.am:
* module/language/cps/effects-analysis.scm: New helper module.
Andy Wingo [Sat, 7 Dec 2013 18:41:59 +0000 (19:41 +0100)]
Fix prim -> VM op mapping for u8/s8 bytevector ops
* module/language/cps/primitives.scm (*instruction-aliases*): Fix
aliases for bytevector u8 / s8 operations.
* module/language/cps/compile-bytecode.scm (compile-fun): Fix s8
operations.
Mark H Weaver [Thu, 19 Dec 2013 18:22:50 +0000 (13:22 -0500)]
Implement R7RS 'syntax-error'.
* module/ice-9/psyntax.scm (syntax-error): New macro.
(syntax-rules): Handle 'syntax-error' templates specially
for improved error reporting.
* module/ice-9/psyntax-pp.scm: Regenerate.
* doc/ref/api-macros.texi (Syntax Rules): Add new subsection "Reporting
Syntax Errors in Macros".
* test-suite/tests/syntax.test: Add tests.
Mark H Weaver [Wed, 18 Dec 2013 23:49:37 +0000 (18:49 -0500)]
psyntax: custom ellipses using 'with-ellipsis' or R7RS syntax-rules.
* module/ice-9/psyntax.scm (binding-type): Update the header comment
to mention the new 'ellipsis' binding type.
(macros-only-env): Preserve ellipsis bindings.
(ellipsis?): Add 'r' and 'mod' as arguments. Search the lexical
environment for an ellipsis binding, and use it.
(gen-syntax): Adapt to the additional arguments of 'ellipsis?'.
(with-ellipsis): New core syntax.
(convert-pattern): Add unary 'ellipsis?' procedure as an argument.
(gen-clause): Adapt to the additional arguments of 'ellipsis?'.
Pass unary 'ellipsis?' procedure to 'convert-pattern'.
(syntax-case): Adapt to the additional arguments of 'ellipsis?'.
(syntax-local-binding): Support new 'ellipsis' binding type.
(syntax-rules): Add support for a custom ellipsis identifier as
the first operand, as per R7RS. Collect common code within new
local procedure 'expand-syntax-rules'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/local-eval.scm (analyze-identifiers): Add support for
'ellipsis' binding type.
* doc/ref/api-macros.texi (Syntax Rules): Add docs for R7RS custom
ellipsis syntax. Use @dots{}.
(Syntax Case): Add docs for 'with-ellipsis'. Use @dots{}.
(Syntax Transformer Helpers): Update to include new 'ellipsis'
binding type.
* test-suite/tests/syntax.test: Add tests.
Mark H Weaver [Tue, 24 Dec 2013 11:42:51 +0000 (06:42 -0500)]
psyntax: toplevel variable definitions discard previous syntactic binding.
* module/ice-9/psyntax.scm (expand-top-sequence): When defining a
toplevel variable, use the value of the same-named imported
_variable_, if any. Do _not_ use an existing syntactic binding.
* module/ice-9/psyntax-pp.scm: Regenerate.
Mark H Weaver [Thu, 9 Jan 2014 06:32:32 +0000 (01:32 -0500)]
Merge branch 'stable-2.0'
Conflicts:
module/system/vm/traps.scm
test-suite/tests/peval.test
Ian Price [Thu, 24 Oct 2013 04:51:47 +0000 (05:51 +0100)]
Fix trap handlers to handle applicable structs.
Reported by Jordy Dickinson <jordy.dickinson@gmail.com>.
Fixes <http://bugs.gnu.org/15691>.
* module/system/vm/traps.scm (frame-matcher): Extract procedure when
proc is an applicable struct.
Mark H Weaver [Wed, 25 Dec 2013 10:10:19 +0000 (05:10 -0500)]
Fix 'string-copy!' to work properly with overlapping src/dest.
* libguile/srfi-13.c (scm_string_copy_x): Fix to work properly with
overlapping src/dest.
* test-suite/tests/srfi-13.test ("string-copy!"): Add tests.
Mark H Weaver [Fri, 20 Dec 2013 23:12:37 +0000 (18:12 -0500)]
Implement 'exact-integer?' and 'scm_is_exact_integer'.
* libguile/numbers.c (scm_exact_integer_p, scm_is_exact_integer):
New procedures.
(scm_integer_p): Improve docstring.
* libguile/numbers.h (scm_exact_integer_p, scm_is_exact_integer):
New prototypes.
* doc/ref/api-data.texi (Integers): Add docs.
* test-suite/tests/numbers.test ("exact-integer?"): Add tests.
Mark H Weaver [Thu, 9 Jan 2014 02:39:55 +0000 (21:39 -0500)]
Fix doc that incorrectly claimed (integer? +inf.0) => #t.
Fixes <http://bugs.gnu.org/16356>.
Reported by Zefram <zefram@fysh.org>.
* doc/ref/api-data.texi (Integers): Add docs. Fix outdated example
that incorrectly showed (integer? +inf.0) => #t.
Mark H Weaver [Tue, 24 Dec 2013 11:48:44 +0000 (06:48 -0500)]
scm_primitive_load: Simplify code using 'scm_open_file_with_encoding'.
* libguile/load.c (scm_primitive_load): Use
'scm_open_file_with_encoding'.
Mark H Weaver [Tue, 24 Dec 2013 12:40:40 +0000 (07:40 -0500)]
boot-9: add comment about autoload thread-unsafety.
* module/ice-9/boot-9.scm: Add comment about lack of thread-safety in
handling of autoloads.
Mark H Weaver [Tue, 24 Dec 2013 13:00:51 +0000 (08:00 -0500)]
read: Avoid signed integer overflow in 'read_decimal_integer'.
* libguile/read.c (read_decimal_integer): Avoid overflow.
Mark H Weaver [Tue, 24 Dec 2013 19:39:44 +0000 (14:39 -0500)]
Increment SCM_N_READ_OPTIONS for 'curly-infix' option.
* libguile/private-options.h (SCM_N_READ_OPTIONS): Increment to 8.
This should have been done when the 'curly-infix' was added.
Ian Price [Wed, 23 Oct 2013 10:14:26 +0000 (11:14 +0100)]
Fix inlining of tail list to apply.
Fixes <http://bugs.gnu.org/15533>.
* module/language/tree-il/peval.scm (peval): Final list argument to
`apply' should not be inlined if it is mutable.
* test-suite/tests/peval.test ("partial evaluation"): Add test.
Ludovic Courtès [Sat, 21 Dec 2013 21:01:38 +0000 (22:01 +0100)]
Thank Aleix.
Aleix Conchillo Flaque [Thu, 3 Oct 2013 22:49:07 +0000 (15:49 -0700)]
allow specifying a required version in GUILE_PROGS
* meta/guile.m4: GUILE_PROGS now takes an optional argument to specify a
required Guile version. By default, it requires Guile >= 2.0. A micro
version can also be specified (e.g. GUILE_PROGS([2.0.10])).
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Mark H Weaver [Tue, 17 Dec 2013 03:55:25 +0000 (22:55 -0500)]
Revert "Fix bound-identifier=? to compare binding names, not just symbolic names."
This reverts commit
70c74b847680d3b239e591afa2e99c51a712980c.
Mark H Weaver [Mon, 16 Dec 2013 00:04:59 +0000 (19:04 -0500)]
Fix bound-identifier=? to compare binding names, not just symbolic names.
Fixes <http://bugs.gnu.org/16158>.
* module/ice-9/psyntax.scm (bound-id=?): Use 'id-var-name' to compare
binding names (gensyms), not just symbolic names.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add test.
Ludovic Courtès [Sun, 15 Dec 2013 21:48:41 +0000 (22:48 +0100)]
Hide EINTR returns from 'accept'.
* libguile/socket.c (scm_accept): Wrap 'accept' call in 'SCM_SYSCALL'.
Mark H Weaver [Fri, 13 Dec 2013 17:53:24 +0000 (12:53 -0500)]
syntax-case: fix error reporting for misplaced ellipses.
Reported by taylanbayirli@gmail.com (Taylan Ulrich B.).
* module/ice-9/psyntax.scm (cvt*): Use 'syntax-case' to destructure
the pattern tail, instead of 'pair?', 'car', and 'cdr'.
(gen-clause): When checking for errors, check for misplaced ellipsis
before duplicate pattern variables, to improve the error message in
case of multiple misplaced ellipses.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add tests.
Mark H Weaver [Fri, 13 Dec 2013 05:34:40 +0000 (00:34 -0500)]
THANKS Tom Tromey.
* THANKS: Add Tom Tromey to fixes section.
Mark H Weaver [Fri, 13 Dec 2013 04:44:46 +0000 (23:44 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/pairs.c
libguile/vm.c
test-suite/tests/control.test
Tom Tromey [Tue, 10 Dec 2013 14:43:33 +0000 (07:43 -0700)]
Remove unused function scm_i_tag_name.
* libguile/gc.c (scm_i_tag_name): Remove.
Tom Tromey [Tue, 10 Dec 2013 14:43:35 +0000 (07:43 -0700)]
Add missing FUNC_NAME defines for pair accessors.
* libguile/pairs.c (scm_car, scm_cdr, scm_caar, scm_cadr, scm_cdar,
scm_cddr, scm_caaar, scm_caadr, scm_cadar, scm_caddr, scm_cdaar,
scm_cdadr, scm_cddar, scm_cdddr, scm_caaaar, scm_caaadr, scm_caadar,
scm_caaddr, scm_cadaar, scm_cadadr, scm_caddar, scm_cadddr,
scm_cdaaar, scm_cdaadr, scm_cdadar, scm_cdaddr, scm_cddaar,
scm_cddadr, scm_cdddar, scm_cddddr): Add missing FUNC_NAME defines.
Tom Tromey [Tue, 10 Dec 2013 14:43:34 +0000 (07:43 -0700)]
Fix computation of LIBLOBJS.
Fixes <http://bugs.gnu.org/14193>.
* configure.ac (LIBLOBJS): Add prefix to computed .lo file name so
dependencies work properly.
Andy Wingo [Tue, 10 Dec 2013 19:03:59 +0000 (20:03 +0100)]
Fix section table writing for non-loadable sections
* module/system/vm/linker.scm (add-elf-objects): Don't fill in the
sh_addr field if the section is not loadable.
Andy Wingo [Tue, 10 Dec 2013 18:53:55 +0000 (19:53 +0100)]
Quick documentation fixes.
* doc/ref/compiler.texi: Make it build.
Andy Wingo [Tue, 10 Dec 2013 18:49:24 +0000 (19:49 +0100)]
Non-loadable sections should not have an sh_addr field set
* module/system/vm/linker.scm (relocate-section-header):
(write-linker-object): Sections that are not loadable should not have
their sh_addr fields set. Fix.
Andy Wingo [Sat, 7 Dec 2013 18:59:39 +0000 (19:59 +0100)]
Beginnings of CPS section in manual
* doc/ref/compiler.texi (Continuation-Passing Style): Beginnings of this
section. Will be finished when we fix implicit truncation.
Andy Wingo [Sat, 7 Dec 2013 18:58:43 +0000 (19:58 +0100)]
Fix cross-references in api-macros.texi
* doc/ref/api-macros.texi (Macro Expansion): Fix cross-references.
Andy Wingo [Fri, 6 Dec 2013 11:04:10 +0000 (12:04 +0100)]
Arities-fixing pass handles incoming $ktrunc with rest args
* module/language/cps/arities.scm (fix-clause-arities): Allow $ktrunc
arities with rest arguments.
Andy Wingo [Fri, 6 Dec 2013 10:39:04 +0000 (11:39 +0100)]
Elide values primcalls with continuations with rest arguments
* module/language/cps/elide-values.scm (elide-values): Elide values
primcalls when continuation has rest arguments.
Andy Wingo [Fri, 6 Dec 2013 10:08:45 +0000 (11:08 +0100)]
(call-with-values foo (lambda (a . b) a)) avoids consing rest list
* module/language/cps/slot-allocation.scm (allocate-slots): Don't
allocate slots to unused results of function calls. This can allow us
to avoid consing a rest list for call-with-values with an ignored rest
parameter, and can improve the parallel move code.
* module/language/cps/compile-bytecode.scm (compile-fun): Adapt to avoid
emitting bind-rest in values context if the rest arg is unused.
Ludovic Courtès [Thu, 5 Dec 2013 21:18:02 +0000 (22:18 +0100)]
vm: Gracefully handle stack overflows.
Fixes <http://lists.gnu.org/archive/html/guile-user/2013-12/msg00017.html>.
Reported by rvclayton@verizon.net (R. Clayton).
* libguile/vm.c (reinstate_stack_reserve): New function.
(vm_error_stack_overflow): Install it as an unwind handler.
* test-suite/tests/control.test ("the-vm")["stack overflow reinstates
stack reserve"]: New test.
Andy Wingo [Thu, 5 Dec 2013 10:55:10 +0000 (11:55 +0100)]
compiler.texi tweaks
* doc/ref/compiler.texi (Compiler Tower): Reword a couple things.
(Tree-IL): Add more vertical space, for readability in info.