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

2705 commits

Author SHA1 Message Date
Andy Wingo
02c624fc09 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.
2014-01-26 20:55:04 +01:00
Mark H Weaver
ba578eb044 Merge branch 'stable-2.0'
Conflicts:
	libguile/read.c
	test-suite/tests/web-response.test
2014-01-21 03:57:04 -05:00
Andy Wingo
97461d739b 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.
2014-01-18 21:08:52 +01:00
Ludovic Courtès
802a25b1ed 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.
2014-01-15 23:41:49 +01:00
Mark H Weaver
2d6a3144a1 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.
2014-01-15 03:21:07 -05:00
Mark H Weaver
da81e75d3e 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.
2014-01-15 02:37:46 -05:00
Mark H Weaver
c92ee2b38c Merge branch 'stable-2.0'
Conflicts:
	libguile/print.c
	libguile/read.c
	test-suite/tests/print.test
2014-01-14 22:23:39 -05:00
Mark H Weaver
b306fae0ab 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.
2014-01-14 13:26:30 -05:00
Mark H Weaver
cb8aaef4d0 Merge branch 'stable-2.0'
Conflicts:
	libguile/chars.c
	libguile/read.c
	test-suite/tests/reader.test
2014-01-14 03:18:34 -05:00
Mark H Weaver
61d509194c 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'.
2014-01-14 02:19:52 -05:00
Mark H Weaver
b958141cdb 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
2014-01-14 01:30:56 -05:00
Andy Wingo
3652769585 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.
2014-01-12 12:37:05 +01:00
Andy Wingo
97cfb467f9 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.
2014-01-12 12:28:12 +01:00
Mark H Weaver
f974224d97 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.
2014-01-12 04:16:39 -05:00
Andy Wingo
310866418b 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.
2014-01-11 16:01:18 +01:00
Andy Wingo
22a79b55b8 Add simplification pass
* module/Makefile.am:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/simplify.scm: New pass.
2014-01-11 16:01:18 +01:00
Andy Wingo
305cccb43c Add DCE pass.
* module/language/cps/dce.scm: New pass.
* module/Makefile.am:
* module/language/cps/compile-bytecode.scm: Wire up the new pass.
2014-01-11 16:01:11 +01:00
Andy Wingo
ad4f6be137 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).
2014-01-11 16:01:11 +01:00
Andy Wingo
8a2d420f74 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
c79f873eb1 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
f409295892 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
e4fa7d403a 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
4dfcb36006 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
7ab76a830b 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
146ce52d21 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
9002277d0f 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.
2014-01-11 16:01:11 +01:00
Andy Wingo
f235f926d1 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.
2014-01-11 16:01:10 +01:00
Andy Wingo
6eb0296027 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.
2014-01-11 16:01:10 +01:00
Andy Wingo
58ef5f0712 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!
2014-01-11 16:01:10 +01:00
Andy Wingo
d20b4a1cd2 Add effects analysis pass on CPS
* module/Makefile.am:
* module/language/cps/effects-analysis.scm: New helper module.
2014-01-11 16:01:10 +01:00
Andy Wingo
d59060ce99 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.
2014-01-11 16:01:10 +01:00
Mark H Weaver
0e18163366 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.
2014-01-09 17:43:53 -05:00
Mark H Weaver
1624e149f7 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.
2014-01-09 17:41:19 -05:00
Mark H Weaver
8de355d08e 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.
2014-01-09 17:40:43 -05:00
Mark H Weaver
1df515a077 Merge branch 'stable-2.0'
Conflicts:
	module/system/vm/traps.scm
	test-suite/tests/peval.test
2014-01-09 02:52:34 -05:00
Ian Price
306cc01d39 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.
2014-01-09 03:12:05 +00:00
Mark H Weaver
6146984cc5 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.
2014-01-08 20:57:13 -05:00
Ian Price
265e7bd92a 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.
2014-01-07 03:37:21 +00:00
Mark H Weaver
0b83be7eb6 Revert "Fix bound-identifier=? to compare binding names, not just symbolic names."
This reverts commit 70c74b8476.
2013-12-16 22:55:25 -05:00
Mark H Weaver
70c74b8476 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.
2013-12-15 19:04:59 -05:00
Mark H Weaver
aa8630efb3 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.
2013-12-13 13:25:07 -05:00
Andy Wingo
812c83d48b 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.
2013-12-10 20:03:59 +01:00
Andy Wingo
a236867dc1 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.
2013-12-10 19:49:56 +01:00
Andy Wingo
7bbfc02959 Arities-fixing pass handles incoming $ktrunc with rest args
* module/language/cps/arities.scm (fix-clause-arities): Allow $ktrunc
  arities with rest arguments.
2013-12-06 12:04:10 +01:00
Andy Wingo
67b5d06c1a Elide values primcalls with continuations with rest arguments
* module/language/cps/elide-values.scm (elide-values): Elide values
  primcalls when continuation has rest arguments.
2013-12-06 11:39:04 +01:00
Andy Wingo
fa48a2f79a (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.
2013-12-06 11:08:45 +01:00
Andy Wingo
691697de09 Rename "RTL" to "bytecode"
"RTL" didn't make any sense, and now that there's no other bytecode to
disambiguate against, just call it bytecode.

* module/Makefile.am:
* module/ice-9/eval-string.scm:
* module/language/bytecode.scm:
* module/language/bytecode/spec.scm:
* module/language/cps/arities.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/compile-rtl.scm:
* module/language/cps/contification.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/primitives.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/spec.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/rtl.scm:
* module/language/rtl/spec.scm:
* module/scripts/compile.scm:
* module/system/base/compile.scm:
* module/system/repl/common.scm:
* module/system/vm/assembler.scm:
* module/system/vm/debug.scm:
* module/system/vm/disassembler.scm:
* module/system/vm/dwarf.scm:
* test-suite/tests/cross-compilation.test:
* test-suite/tests/dwarf.test:
* test-suite/tests/rtl-compilation.test:
* test-suite/tests/rtl.test:
* test-suite/vm/run-vm-tests.scm: Fixups.
2013-12-02 21:31:47 +01:00
Andy Wingo
e54c7dd67c Fix brainfuck comment
* module/language/brainfuck/parse.scm: Fix outdated comment.
2013-12-02 19:03:50 +01:00
Andy Wingo
60ce72b9b9 Fix brainfuck->scheme compiler.
* module/language/brainfuck/compile-scheme.scm (compile-scheme): Fix
  brainfuck compiler.
2013-12-02 19:03:48 +01:00
Andy Wingo
7f71030837 Fix brainfuck comment
* module/language/brainfuck/parse.scm: Fix outdated comment.
2013-12-02 19:02:38 +01:00