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

2705 commits

Author SHA1 Message Date
Andy Wingo
b8da548fba RTL slot allocation: Don't kill variables that flow into loops
* module/language/cps/dfg.scm (dead-after-use?): Don't kill a variable
  if it was defined outside the current loop.
  (dead-after-branch?): Likewise, but I don't think this helper is
  correct yet :/
2013-10-12 16:22:45 +02:00
Andy Wingo
0e2446d4db Compute post-dominators
* module/language/cps/dfg.scm ($block): Add pdom and pdom-level fields,
  for post-dominators.
  (reverse-post-order, convert-predecessors): Arrange to work either
  way: for dominators or for post-dominators.
  (analyze-control-flow!): Compute post-dominators.
  (dominates?): Refactor.
  (post-dominates?): New helper.
2013-10-12 16:11:36 +02:00
Andy Wingo
96b8027cc4 Identify loops
* module/language/cps/dfg.scm (compute-dom-edges)
  (compute-join-edges, compute-reducible-back-edges)
  (compute-irreducible-dom-levels, compute-nodes-by-level)
  (mark-loop-body, mark-irreducible-loops, identify-loops): Identify
  loops.  Irreducible loops are TODO.

* test-suite/tests/rtl-compilation.test ("contification"): Add an
  irreducible loop test.
2013-10-12 15:19:20 +02:00
Andy Wingo
366eb4d764 DFG refactorings
* module/language/cps/dfg.scm ($block): Add "irreducible" field, format
  TBD.
  (reverse-post-order): Return a vector directly.
  (convert-predecessors, compute-dom-levels, compute-idoms):
  (analyze-control-flow!): Factor out control flow analsysis a bit
  better.
  (identify-loops): New helper.  Currently a NOP.
  (visit-fun): Adapt to compute-dominator-tree rename to
  analyze-control-flow!.
2013-10-12 15:19:16 +02:00
Andy Wingo
238ef4cf44 Replace conservatively-dominates? with a precise dominator lookup
* module/language/cps/dfg.scm (dominates?): Use the dominator tree
  instead of the scope tree.
2013-10-11 14:10:19 +02:00
Andy Wingo
3aee6cfdd7 Compute a dominator tree
* module/language/cps/dfg.scm (reverse-post-order, for-each/enumerate)
  (convert-predecessors, finish-idoms, compute-dominator-tree): Compute
  a dominator tree.  We don't use it yet.
2013-10-11 13:35:43 +02:00
Andy Wingo
f22979db66 DFG refactor to allow dominator tree construction
* module/language/cps/dfg.scm: Refactor so that we can think about
  building a dominator tree.  Split continuations out of use maps and
  put them in a separate table, which will have more flow information.
  (visit-fun): Mark clauses as using their bodies.
  (lookup-predecessors, lookup-successors): New exports.
  (find-defining-expression): Add an exception for clauses, now that
  clauses are in the flow graph.
  (continuation-bound-in?): Rename from variable-bound-in?, as it can
  currently only be used for continuations.

* module/language/cps/contification.scm (contify): Adapt to use
  lookup-predecessors and continuation-bound-in?.
2013-10-10 12:42:50 +02:00
Andy Wingo
6b71a76713 A couple of fixes when no source info is available
* module/system/vm/assembler.scm (link-debug): If there was no debugging
  info, reset the file register to 0 from its default value of 1 before
  adding the final row.

* module/system/vm/dwarf.scm (line-prog-scan-to-pc): If we rescanned
  from the beginning and still found no source info for this pc, return
  #f instead of the default value of the file register (1).
2013-10-10 12:22:20 +02:00
Andy Wingo
4a6d351979 Fix peval bug with inlining and optional argument initializers
* module/language/tree-il/peval.scm (peval): Fix a bug whereby inlined
  function applications with default argument initializers were putting
  the initializers in the wrong scope.

* test-suite/tests/peval.test ("partial evaluation"): Add a test.
2013-10-10 11:19:19 +02:00
Andy Wingo
61c7264fcc Fix slot allocation bug
* module/language/cps/slot-allocation.scm (allocate-slots): Fix
  dead-after-use computation to use the expression's label and not its
  continuation.
2013-10-05 15:57:54 +02:00
Andy Wingo
f8fb13ef8c better RTL debugging
* libguile/frames.c (scm_frame_source, scm_frame_instruction_pointer):
  Fix to work with RTL programs.

* module/system/vm/debug.scm (find-debug-context): Allow for the
  possibility of there being no ELF image.
  (find-program-debug-info, find-program-arities)
  (program-minimum-arity, find-program-docstring)
  (find-program-properties, find-source-for-addr)
  (find-program-die, find-program-sources): Don't bail if we couldn't
  get the debug context.

* module/system/vm/frame.scm (frame-next-source)
  (frame-call-representation): Allow RTL programs.

* module/system/vm/program.scm (program-arguments-alist): Placeholder
  implementation for RTL programs.
  (program-arguments-alists): Don't bail if we couldn't get the
  arities.
2013-10-04 19:55:12 +02:00
Andy Wingo
fea115c33f Fix nested contification bugs
* module/language/cps/contification.scm (contify): Exhaustively replace
  contified tail continuations, to fix a bug in nested tail-recursive
  contifications.  Likewise, call lookup-return-cont when searching for
  common return continuations.
2013-10-04 18:03:29 +02:00
Andy Wingo
c648869346 Fix variable-bound-in?
* module/language/cps/dfg.scm (variable-bound-in?): Fix to look up
  correct variable.
2013-10-04 17:30:59 +02:00
Andy Wingo
25833e807d Fix verify-cps
* module/language/cps/verify.scm (verify-cps): Fix visiting functions.
2013-10-04 16:36:17 +02:00
Andy Wingo
e9588e7032 Disassembling RTL prints source information.
* module/system/vm/disassembler.scm (disassemble-buffer): Print source
  information.
2013-10-04 15:28:40 +02:00
Andy Wingo
7ea00e230a Contify functions in the scope of their continuation.
* module/language/cps/contification.scm (contify): Fix to contify
  functions in the scope of their continuation.
2013-10-04 14:08:52 +02:00
Andy Wingo
d51fb1e67b dfg: variable-free-in?, add variable-bound-in?
* module/language/cps/dfg.scm (variable-free-in?): Rename from
  variable-used-in?, to match CWCC language.
  (variable-bound-in?): New interface.

* module/language/cps/contification.scm (contify): Adapt caller.  Add
  more comments.
2013-10-04 14:07:36 +02:00
Andy Wingo
b43e81dc60 anonymous RTl functions print with source info
* module/system/vm/debug.scm (find-program-sources): If there is no
  source location before the low-pc of the procedure we're grovelling
  for, we were skipping the source loc info.  Fix that.

* module/system/vm/program.scm (write-program): Get source info for
  anonymous RTL functions.
  (program-sources, program-sources-pre-retire): Provide program
  counters relative to the beginning of the procedure.
2013-10-03 22:48:17 +02:00
Andy Wingo
7c54029740 program-source / program-sources works with RTL programs
* libguile/programs.c (scm_program_sources): Define as %program-sources,
  and let Scheme export the program-sources proper.
  (scm_program_source): Call out to Scheme.

* module/system/vm/program.scm: Convert to use match instead of pmatch.
  Adapt existing callers.
  (program-sources, program-source): New Scheme implementations of these
  functions.
  (program-sources-pre-retire): Add RTL program case.
2013-10-03 22:31:37 +02:00
Andy Wingo
c0ada5a766 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.
2013-10-03 16:14:29 +02:00
Andy Wingo
1ed81e0229 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.
2013-10-03 16:14:25 +02:00
Andy Wingo
d56ab5a913 Serialize source positions into .debug_line
* module/system/vm/assembler.scm (link-debug): Generate a correct DWARF2
  line program.  Tests come next.
2013-10-03 16:14:20 +02:00
Andy Wingo
0a7340ac98 Emit a placeholder .debug_line section.
* module/system/vm/assembler.scm (link-debug): Emit a .debug_line
  section also.
  (link-objects): Expect .debug_line.
2013-09-30 21:49:12 +02:00
Andy Wingo
e675e9bd39 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.
2013-09-30 21:48:07 +02:00
Andy Wingo
6371e368e6 DWARF linker: encode strings using the correct form
* module/system/vm/assembler.scm (link-debug): Encode strings using the
  strp form.
2013-09-28 18:15:50 +02:00
Andy Wingo
a862d8c138 Emit minimal DWARF information
* module/system/vm/assembler.scm (link-debug): New function, creates the
  necessary DWARF debugging sections.
  (link-objects): Emit debugging sections.
2013-09-28 14:50:48 +02:00
Andy Wingo
35558f75f8 add DWARF parser
* module/Makefile.am:
* module/system/vm/dwarf.scm: New module, a DWARF parser.
2013-09-28 14:41:08 +02:00
Mark H Weaver
c04bf4337b Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	module/srfi/srfi-9.scm
	module/web/server.scm
2013-09-13 00:24:04 -04:00
Mark H Weaver
76702cdcef 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.
2013-09-12 18:45:13 -04:00
Mark H Weaver
3b2226ec91 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.
2013-09-12 18:36:45 -04:00
Mark H Weaver
361553b49d 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'.
2013-09-12 18:14:54 -04:00
Mark H Weaver
89ffbb1c2e 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.
2013-09-12 18:04:08 -04:00
Mark H Weaver
55e29bb55b 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.
2013-09-10 01:39:52 -04:00
Alexandru Cojocaru
9c85fd0221 Fix extend-request to preserve method and meta.
* module/web/client.scm (extend-request): Preserve method and meta.
2013-09-10 01:36:00 -04:00
Mark H Weaver
112fc7c2a5 psyntax: cite the paper that psyntax is based on.
* module/ice-9/psyntax.scm: cite the paper.
2013-09-09 22:42:36 -04:00
Mark H Weaver
c4b7ba688a 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>.
2013-09-09 22:20:09 -04:00
Mark H Weaver
0bf4a5fc2e 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.
2013-09-09 19:37:49 -04:00
Andy Wingo
8ac8e2dfeb 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.
2013-08-31 09:40:56 +02:00
Andy Wingo
6e8ad82335 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.
2013-08-31 09:40:56 +02:00
Andy Wingo
934e6b9515 Add pass to reify primcalls without corresponding VM ops
* module/Makefile.am:
* module/language/cps/reify-primitives.scm: New pass.
2013-08-31 09:40:56 +02:00
Andy Wingo
026b561154 Add arity-adapting module
* module/Makefile.am:
* module/language/cps/arities.scm: New module.  Adapts call and return
  arities, especially for primcalls.
2013-08-31 09:40:56 +02:00
Andy Wingo
045392f1b2 Add CPS primitives info module
* module/Makefile.am:
* module/language/cps/primitives.scm: New file.
2013-08-31 09:40:56 +02:00
Andy Wingo
43f768f48d RTL language
* module/Makefile.am
 * module/language/rtl.scm:
 * module/language/rtl/spec.scm: Add a stub RTL language.
2013-08-31 09:40:56 +02:00
Andy Wingo
4b8de65e9d Add closure conversion
* module/Makefile.am
* module/language/cps/closure-conversion.scm: New module, implementing a
  closure conversion pass.
2013-08-31 09:40:56 +02:00
Andy Wingo
4fefc3a867 (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.
2013-08-31 09:40:56 +02:00
Andy Wingo
80b01fd086 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.
2013-08-31 09:40:56 +02:00
Andy Wingo
93009a7aca ,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.
2013-08-29 20:50:19 +02:00
Andy Wingo
610295ec9d 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.
2013-08-29 20:44:55 +02:00
Andy Wingo
c96933fd54 Export the assembler procedures
* module/system/vm/assembler.scm (define-assembler):
  (define-macro-assembler): Export the assemblers.
2013-08-24 15:41:09 +02:00
Andy Wingo
70a2043143 RA == MVRA in disassembler
* module/system/vm/disassembler.scm: Modify call disassembler to assume
  RA == MVRA.
2013-08-24 15:38:27 +02:00