1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 12:20:26 +02:00
Commit graph

3371 commits

Author SHA1 Message Date
Andy Wingo
84d3ce20cd Disable Tree-IL CSE
* module/language/tree-il/optimize.scm (optimize): Disable Tree-IL CSE
  by default.
2014-04-05 11:40:21 +02:00
Andy Wingo
a79f4f67e2 Fix effects analysis for cached-module-box
* module/language/cps/effects-analysis.scm (cached-module-box): Fix
  expected arity.
2014-04-05 11:40:21 +02:00
Andy Wingo
8c6a0b7e13 More bailout preparation work
* module/language/cps/cse.scm (compute-available-expressions): Compute a
  bailout set -- or at least, set things up so that we can do so.
  (compute-idoms): Don't add predecessors that bail out.
  (apply-cse, cse, compute-equivalent-subexpressions): Thread the
  bailout set through the computations.
2014-04-04 14:29:11 +02:00
Andy Wingo
780ad383bb Prepare for CSE bailout propagation
* module/language/cps/cse.scm (compute-available-expressions): Prepare
  for being able to prune joins from bailouts.  Always loop after the
  first iteration.

* module/language/cps/effects-analysis.scm: Remove &possible-bailout.
  Rename &definite-bailout to &bailout, and rename
  &all-effects-but-bailout to &unknown-effects.
2014-04-04 14:22:51 +02:00
Andy Wingo
7a08e47967 Add common subexpression elimination pass on CPS
* module/language/cps/cse.scm: New file.
* module/language/cps/compile-bytecode.scm: Wire up CSE, on by default.
  Currently using the #:cps-cse? keyword.

* module/Makefile.am: Add new file.
2014-04-04 12:15:10 +02:00
Andy Wingo
a11778dd8e Effects analysis tweaks
* module/language/cps/effects-analysis.scm: Add &fluid-environment
  effect, a dependency of fluid-ref and fluid-set!, and an effect of
  push-fluid/pop-fluid.
  (list): Depend on &cdr.
  (resolve, cached-toplevel-box, cached-module-box): Don't depend on
  &box.
2014-04-04 12:08:52 +02:00
Andy Wingo
b764157a7b Fix verify-cps to work
* module/language/cps/verify.scm (verify-cps): Relax requirements for
  variable names to be symbols.
2014-04-04 12:07:24 +02:00
Andy Wingo
36aeda5b6a constant-needs-allocation? fix
* module/language/cps/dfg.scm (constant-needs-allocation?): Constants
  need allocation when they are used as a slot-needing operand, not when
  they are not used as an immediate operand.  Fixes the case where one
  var is used in both ways after CSE, in struct-set!/immediate.
2014-04-04 12:06:59 +02:00
Andy Wingo
f85ce39610 Remove variable-set! clause from compile-fun
* module/language/cps/compile-bytecode.scm (compile-fun): Remove
  vestigial `variable-set!' clause.
2014-04-04 12:05:18 +02:00
Andy Wingo
19ceadab51 Effects analysis: define causes-all-effects?
* module/language/cps/effects-analysis.scm (causes-all-effects?): New
  export.
2014-04-03 16:37:07 +02:00
Andy Wingo
f5fcd7f203 build-cps niceties
* module/language/cps.scm (build-cps-exp, build-cont-body): Respect
  unquote in list builders (kargs, call, callk, primcall, and values).
2014-04-03 16:36:23 +02:00
Andy Wingo
54c7882a75 Minor CSE optimization
* module/language/tree-il/cse.scm (cse): Use hashq instead of modulo to
  convert a full-width hash value to a vector index.
2014-04-03 09:40:18 +02:00
Andy Wingo
3e1b97c1b0 Add with-fresh-name-state-from-dfg
* module/language/cps/dfg.scm (with-fresh-name-state-from-dfg): New
  helper.
  ($dfg, compute-dfg): Store max-var and max-label in the dfg.

* module/language/cps.scm (with-fresh-name-state): Don't raise an error
  on recursive invocation; that was mostly useful when finding a bug.

* module/language/cps/arities.scm (fix-arities):
* module/language/cps/specialize-primcalls.scm (specialize-primcalls):
  Use the new helper.

* .dir-locals.el: Update.
2014-04-03 09:29:05 +02:00
Andy Wingo
48e65b4468 Refactor toplevel scope name generation in compile-cps
* module/language/tree-il/compile-cps.scm (scope-counter, fresh-scope-id):
  (toplevel-box, capture-toplevel-scope, convert, cps-convert/thunk):
  Refactor to avoid abusing the var counter to generate scope
  identifiers.
2014-04-02 15:58:06 +02:00
Andy Wingo
408da79015 compute-max-label-and-var takes letrec vars into account.
* module/language/cps.scm (compute-max-label-and-var): Fix to take
  letrec vars into account.
2014-04-02 15:48:13 +02:00
Andy Wingo
ce1dbe8c1b Fix DCE for refactor-introduced borkage
* module/language/cps/dce.scm ($fun-data, compute-live-code)
  (process-eliminations): Fix clownshoes regarding fun-data field names
  and order.
2014-04-02 15:41:14 +02:00
Andy Wingo
b7dc00b1e7 Fix prune-top-level-scopes to allow collisions between var, scope, cont names
* module/language/cps/prune-top-level-scopes.scm (compute-referenced-scopes):
  Fix to not assume that scope names, continuation names, and var names
  are mutually unique.
  (prune-top-level-scopes): Better variable names.
2014-04-02 15:40:03 +02:00
Andy Wingo
2896942751 Update old-style REPL code for deprecation
* module/ice-9/scm-style-repl.scm:
* module/ice-9/save-stack.scm: As the deprecated bindings have been
  removed from the default environment, use #:export instead of
  #:replace.
2014-04-02 12:08:48 +02:00
Andy Wingo
a7324faf1b Remove CFA data type
* module/language/cps/dfg.scm: Remove CFA data type.
  (analyze-reverse-control-flow): Take min-label and label-count as
  args, and return multiple values instead of returning a CFA object.
  (compute-live-variables): Rework to accept multiple values from
  analyze-reverse-control-flow.
  ($dfa): Update comments.
2014-04-02 12:00:09 +02:00
Andy Wingo
a57f6e1e36 $dfa includes CFA fields
* module/language/cps/dfg.scm ($dfa): Include CFA min-label, k-map, and
  k-order inline.
  (dfa-k-idx, dfa-k-sym, dfa-k-count): Adapt.
  (compute-live-variables): Extract fields of CFA for make-dfa.
  (print-dfa): Adapt (and fix positional record matching).
2014-04-02 11:45:26 +02:00
Andy Wingo
4ec3ded05d More CFA removals
* module/language/cps/dfg.scm (compute-reachable): Reword docstring.
  (visit-prompt-control-flow): Likewise.
  ($dominator-analysis): Change to store min-label instead of CFA.
  (compute-idoms, compute-join-edges, mark-loop-body, identify-loops):
  Take min-label and label-count, and use the DFG's preds list instead
  of requiring a fresh renumbered one.
  (analyze-dominators): Adapt to use a DFG with a label range instead of
  a CFA.
2014-04-02 11:39:36 +02:00
Andy Wingo
ae0388b698 Simplify analyze-reverse-control-flow
* module/language/cps/dfg.scm (analyze-reverse-control-flow): Use the
  DFG's label count and min label analysis instead of rolling our own.
2014-04-02 11:04:04 +02:00
Andy Wingo
16af91e862 analyze-control-flow only used in reverse direction; make private
* module/language/cps/dfg.scm ($cfa): Use a vector to map labels to
  indices.  Don't export any CFA bindings.
  (cfa-k-idx): Adapt.
  (compute-reachable, find-prompts, compute-interval):
  (find-prompt-bodies, visit-prompt-control-flow): Take a DFG as an
  argument instead of a CFA.
  (analyze-reverse-control-flow): Refactor from analyze-control-flow, as
  it is only used in the reverse case.  Simplify accordingly, inlining
  the RPO sort.
  (compute-live-variables): Adapt to call analyze-reverse-control-flow
  instead.
2014-04-02 11:01:39 +02:00
Andy Wingo
0a44542fce Fix DFG compute-reachable bug
* module/language/cps/dfg.scm (compute-reachable): Fix embarassing bug
  where we wouldn't actually iterate to fixpoint.  I haven't seen it
  yet, but that's just luck...
2014-04-01 20:55:31 +02:00
Andy Wingo
f082c5f30a Optimize two-list srfi-1 map
* module/srfi/srfi-1.scm (map): Optimize the two-list variant.
2014-04-01 20:52:15 +02:00
Andy Wingo
545274a035 Speed up compute-label-and-var-ranges
* module/language/cps/dfg.scm (compute-label-and-var-ranges): Duplicate
  the cont-folder cases in the global/not-global cases.  Lets the
  optimizer DTRT.
2014-04-01 18:20:02 +02:00
Andy Wingo
0912202a51 Fix compute-label-and-var-ranges for global DFG computation
* module/language/cps/dfg.scm (compute-label-and-var-ranges): Fix to
  work with global DFGs -- it wasn't taking $letrec into account for var
  ranges.

* module/language/cps/dce.scm (compute-live-code): Use bitvectors to
  represent the live var set.
2014-04-01 18:16:00 +02:00
Andy Wingo
f9bceb770b Renumber doesn't visit unreachable continuations
* module/language/cps/renumber.scm (compute-new-labels-and-vars): Don't
  visit functions that are not reachable.
  (renumber): Reindent.
2014-04-01 17:51:26 +02:00
Andy Wingo
cc8eb19545 Renumber returns label/var counters for use in let-fresh
* module/language/cps/renumber.scm (renumber): Refactor to return the
  label and var counters as additional values.

* module/language/cps/dce.scm (eliminate-dead-code): Use the renumber
  label/var counters to initialize the fresh name state.
2014-04-01 16:47:11 +02:00
Andy Wingo
3269e1b647 Refactor DCE to not build a CFA
* module/language/cps/effects-analysis.scm (compute-effects): Change to
  analyze the effects for a subrange of a DFG's continuations.

* module/language/cps/dce.scm (compute-defs, $fun-data, compute-live-code):
  (process-eliminations, eliminate-dead-code): Renumber before
  eliminating dead code, to avoid computing a CFG and other data.
2014-04-01 16:43:55 +02:00
Andy Wingo
c79c02d694 Simplification renumbers instead of local prune-continuation pass
* module/language/cps/simplify.scm (simplify): Use renumbering instead
  of rolling our own prune-continuations pass.
2014-04-01 15:56:45 +02:00
Andy Wingo
7c4977e699 DFA uses DFG var numbering
* module/language/cps/dfg.scm ($dfa): Instead of a var-map table an a
  syms vector, use the DFG's var numbering.
  (dfa-var-idx, dfa-var-sym, compute-live-variables): Adapt.
2014-04-01 15:42:12 +02:00
Andy Wingo
7dbf40ea8b Allocate-slots avoids building CFA
* module/language/cps/slot-allocation.scm (allocate-slots): Rework to
  avoid computing a CFA, and just relying on the incoming term to have
  sorted labels.
2014-04-01 15:21:28 +02:00
Andy Wingo
a8430ab1d7 Compile-fun takes advantage of sorted output of "renumber", avoids CFA
* module/language/cps/dfg.scm ($dfg): Rename nvars and nlabels fields to
  var-count and label-count.  Export dfg-min-var, dfg-min-label,
  dfg-label-count, dfg-var-count.

* module/language/cps/compile-bytecode.scm (compile-fun): No need to
  build a CFA given the renumbering pass.  Adapt to treat labels as
  ordered small integer in a contiguous vector.
2014-04-01 14:51:05 +02:00
Andy Wingo
09220d215f CPS renumbering pass sorts conts in topological order
* module/language/cps/renumber.scm (sort-conts)
  (compute-new-labels-and-vars): Rework to sort the labels in
  topological order, and to prune any unreachable labels.
2014-04-01 14:51:01 +02:00
Andy Wingo
2c3c086ef3 Add visit-cont-successors helper
* module/language/cps/dfg.scm (lookup-successors, control-point?): Use
  the new helper.

* module/language/cps.scm (visit-cont-successors): New helper.
2014-04-01 11:59:03 +02:00
Andy Wingo
6e5e9ffb75 Fix analyze-control-flow to preserve order among unordered labels
* module/language/cps/dfg.scm (analyze-control-flow): Sort blocks to
  preserve order among unordered successors.
  (lookup-successors): Choose a more natural order, now that it doesn't
  matter.
2014-03-31 18:54:19 +02:00
Andy Wingo
90dce16db4 Use Tree-IL-like case-lambda clause chaining in CPS
* module/language/cps.scm ($kclause, $kentry): Instead of having an
  entry continuation contain a list of clauses, have the clauses contain
  clauses (as in Tree-IL).  In some ways it's not as convenient but it
  does reflect the continuation tree correctly.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt aaaaaaall users.
2014-03-31 18:54:12 +02:00
Andy Wingo
a3a45279c0 Rewrite control-point? to avoid consing
* module/language/cps/dfg.scm (control-point?): Rewrite to avoid consing
  a successors list.
2014-03-31 18:21:04 +02:00
Andy Wingo
4bf757b810 Remove succs from DFG
* module/language/cps/dfg.scm ($dfg): Remove "succs" from DFG.  Instead
  we can compute the successors set on-demand.
  (lookup-successors): Adapt.
2014-03-31 18:21:04 +02:00
Andy Wingo
4926024cfb Simplify boot-9 and srfi-1 map
* module/ice-9/boot-9.scm (map):
* module/srfi/srfi-1.scm (map): Simplify the implementations to check
  for list? beforehand.  It's faster, and it will be needed if we decide
  to go recursive.
2014-03-31 18:21:04 +02:00
Andy Wingo
de3cbadcc0 Avoid consing in compute-label-and-var-ranges.
* module/language/cps/dfg.scm (compute-label-and-var-ranges): Avoid
  consing.
2014-03-31 18:21:04 +02:00
Andy Wingo
5fc403911e Scope and scope-level in DFG vector
* module/language/cps/dfg.scm ($dfg): Hoist scopes and scope levels out
  of $block and into $dfg.  Adapt all callers.
2014-03-31 18:21:04 +02:00
Andy Wingo
21d6d183a9 Predecessors and successors in DFG vectors
* module/language/cps/dfg.scm ($dfg, $block): Record predecessors and
  successors in vectors instead of in $block data structures.  Adapt
  users.
2014-03-31 18:21:04 +02:00
Andy Wingo
f49e994b52 DFG refactor
* module/language/cps/dfg.scm (lookup-cont, lookup-block):
  (lookup-def, constant-needs-allocation?): Rework these accessors to
  avoid completely destructuring the $dfg.
2014-03-31 18:21:04 +02:00
Andy Wingo
62b7180bfd Renumber functions before emitting code
* module/language/cps/compile-bytecode.scm (compile-bytecode): Renumber
  a function before going to compile it, so that the vars and labels are
  contiguous within each function.
2014-03-31 18:21:04 +02:00
Andy Wingo
f05517b24e Add renumber module
* module/language/cps/renumber.scm: New module.
* module/Makefile.am: Add to build.

fix renumber
2014-03-31 18:21:04 +02:00
Andy Wingo
98c5b69fa0 Replace use-map in DFG with separate def / use vectors
* module/language/cps/dfg.scm ($dfg, $use-map): Replace use-map vector
  with "defs" and "uses" vectors.  Adapt callers.
2014-03-31 18:21:04 +02:00
Andy Wingo
b99553301c Remove "sym" from $use-map
* module/language/cps/dfg.scm ($use-map): Remove "sym" from use-map;
  it's redundant.  Adapt callers.
2014-03-31 18:21:04 +02:00
Andy Wingo
cec43eb8f6 $use-map no longer has name member
* module/language/cps/dfg.scm ($use-map): Remove name member.  Adapt
  users.
2014-03-31 18:21:04 +02:00