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

3371 commits

Author SHA1 Message Date
Andy Wingo
f63b2e4814 More slot-allocation simplification
* module/language/cps/slot-allocation.scm (allocate-slots): Remove
  unreachable clause.
2015-07-20 10:57:52 +02:00
Andy Wingo
365296a866 CPS1 slot-allocation simplification
* module/language/cps/slot-allocation.scm (allocate-slots): Don't pass
  around nargs, as it's not used.
2015-07-19 12:23:05 +02:00
Andy Wingo
19024bdc27 Utils refactors
* module/language/cps2/utils.scm (compute-successors): kfun is
  optional.
  (compute-sorted-strongly-connected-components): New function, moved
  from split-rec.scm.  Doesn't assume that 0 is a free node identifier.

* module/language/cps2/split-rec.scm
  (compute-sorted-strongly-connected-components): Remove, use utils.scm
  version instead.

* module/language/cps2/closure-conversion.scm (intset-select): Remove
  unused function.
2015-07-19 12:21:31 +02:00
Andy Wingo
3b1d316383 Add intset-prev and intset-fold-right
* module/language/cps/intset.scm (intset-prev): New function.
  (make-intset-folder): Add forward? argument like make-intmap-folder.
  (intset-fold-right): New function.
2015-07-19 12:21:02 +02:00
Andy Wingo
1a819eaaa7 Reify primitives in CPS2
* module/language/cps/reify-primitives.scm: Remove.
* module/language/cps2/reify-primitives.scm: New file.
* module/Makefile.am: Adapt build.

* module/language/cps/compile-bytecode.scm:
* module/language/cps2/compile-cps.scm: Reify primitives in CPS2 instead
  of CPS.
2015-07-16 11:27:14 +02:00
Andy Wingo
90aabcc565 Fix type/range inference for mul
* module/language/cps2/types.scm (mul): Fix nan testing.
2015-07-16 09:58:59 +02:00
Andy Wingo
420423f9a0 Remove CPS optimization passes and closure conversion
* module/language/cps/closure-conversion.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm: Remove these files, obsoleted by CPS2.

* module/Makefile.am: Update.
2015-07-16 07:58:36 +02:00
Andy Wingo
6f6a6aee9d Optimize first-order CPS
* module/language/cps2/optimize.scm: Move comments here from
  cps/compile-bytecode.scm.

* module/language/cps/compile-bytecode.scm: Remove optimization and
  closure conversion calls, since CPS2 does this for us.

* module/language/cps2/compile-cps.scm (compile-cps): Use set! to save
  memory at bootstrap-time.  Optimize first-order CPS, to get rid of
  strangeness introduced in closure conversion.
2015-07-16 07:44:30 +02:00
Andy Wingo
099784ca91 Beta reduction over first-order CPS
* module/language/cps2/simplify.scm (beta-reduce): Handle $closure.
2015-07-16 07:32:52 +02:00
Andy Wingo
e419e9e3df DCE works on first-order CPS
* module/language/cps2/dce.scm (compute-live-code): Use the live-labels
  set to indicate function liveness.  $closure and $callk mark their
  associated functions as live.
  (process-eliminations): Handle $closure.

* module/language/cps2/effects-analysis.scm (expression-effects): Handle
  $closure.
2015-07-16 07:24:51 +02:00
Andy Wingo
1b95487501 compute-reachable-functions refactor
* module/language/cps2/utils.scm (compute-reachable-functions): New
  function.

* module/language/cps2/verify.scm (check-label-partition)
  (compute-reachable-labels): Use the new function.

* module/language/cps2/simplify.scm (compute-singly-referenced-vars):
  Allow $closure.
  (compute-eta-reductions, compute-beta-reductions): Use
  compute-reachable-functions, which besides being a simplification also
  allows simplification to work on first-order CPS.
2015-07-16 07:22:59 +02:00
Andy Wingo
263b409918 Prepare DCE pass for first-order CPS2
* module/language/cps2/dce.scm (compute-live-code): Prepare for handling
  first-order CPS by tracking functions in the live label set.
2015-07-15 17:15:03 +02:00
Andy Wingo
030e9b7603 Enable CPS2 closure conversion
* module/language/cps2/closure-conversion.scm: Remove debug printfs.
* module/language/cps2/compile-cps.scm (compile-cps):
* module/language/cps/compile-bytecode.scm (compile-bytecode): Use CPS2
  closure conversion by default.
2015-07-15 16:44:49 +02:00
Andy Wingo
6cfb7afb61 CPS2 closure conversion bugfixes
* module/language/cps2/closure-conversion.scm
  (rewrite-shared-closure-calls): Fix to make shared closures call the
  right label.
  (closure-label): New helper.
  (prune-free-vars): If a shared closure is not well-known, don't use
  the alias optimization.
  (convert-one): Fix for shared closures with one not-well-known
  closure.
2015-07-15 16:31:10 +02:00
Andy Wingo
e9e6da1902 closure-conversion docstring tweak
* module/language/cps2/closure-conversion.scm (prune-free-vars): Fix
  docstring.
2015-07-15 15:15:41 +02:00
Andy Wingo
981802c4c2 Wire up new closure conversion pass
* module/language/cps/compile-bytecode.scm (compile-bytecode): Only
  convert closures if the #:cps2-convert? option is not passed.

* module/language/cps2/compile-cps.scm (conts->fun*, compile-cps): Add
  support for CPS2 closure conversion, disabled by default.
2015-07-15 09:43:33 +02:00
Andy Wingo
285f62a077 Add CPS2 closure conversion module
* module/language/cps2/closure-conversion.scm: New module.
* module/Makefile.am: Add new file.
2015-07-14 16:14:53 +02:00
Andy Wingo
bf5c7954ff Verify pass works on first-order CPS
* module/language/cps2/verify.scm: Work with first-order CPS.
2015-07-14 16:14:09 +02:00
Andy Wingo
e0ef087ceb Beginnings of first-order CPS optimization
* module/language/cps2/optimize.scm (optimize-higher-order-cps): Renamed
  from "optimize".
  (optimize-first-order-cps): New function.

* module/language/cps2/compile-cps.scm: Adapt.
2015-07-14 16:14:09 +02:00
Andy Wingo
363d6498e5 Tweak intset printing
* module/language/cps/intset.scm: Print members of set as absolute
  values, not diffs from set minumum.
2015-07-14 16:14:09 +02:00
Andy Wingo
a15a14203e CPS2 renumber works with first-order CPS
* module/language/cps2/renumber.scm (compute-renaming): Add support for
  $closure and $callk.
2015-07-14 16:14:09 +02:00
Andy Wingo
dc27708f0b Fix intset-subtract to reliably produce empty-intset
* module/language/cps/intset.scm (intset-subtract): Reliably produce
  empty-intset if the result is empty.
2015-07-13 11:03:00 +02:00
Andy Wingo
47a4727b78 intset-union fast paths
* module/language/cps/intset.scm (intset-union): Add fast paths for
  union with empty intset.
2015-07-13 11:02:29 +02:00
Andy Wingo
1bb7a7fa7a Reorganizing of intset/intmap helper functions
* module/language/cps2/split-rec.scm (intmap-keys): Move to utils.
* module/language/cps2/utils.scm (trivial-intset): New function.
  (intmap-keys, invert-bijection, invert-partition): New functions.
2015-07-13 11:01:43 +02:00
Andy Wingo
dbe6247acf Add split-rec pass
* module/language/cps2/split-rec.scm: New pass.
* module/language/cps2/optimize.scm: Run new pass.
* module/Makefile.am: Add new pass to build.
2015-06-07 11:16:09 +02:00
Andy Wingo
f41823538a Renumber before contifying to eliminate stale conts
* module/language/cps2/contification.scm (contify): Renumber before contifying.
2015-06-05 17:10:29 +02:00
Andy Wingo
6f4487f268 Disable CPS optimization passes
* module/language/cps/compile-bytecode.scm (compile-bytecode): Don't
  bother running the CPS optimization passes, as they are redundant
  with CPS2.
2015-06-05 00:54:18 +02:00
Andy Wingo
b926d85a17 Enable all CPS2 optimization passes
* module/language/cps2/optimize.scm (optimize): Enable all CPS2
  passes.  Wheee!
2015-06-05 00:52:27 +02:00
Andy Wingo
c028a0a7c4 Tweaks to bootstrap build order
* module/Makefile.am (SOURCES): Since intmaps and intsets are used so
  much in CPS2, bump them up.  Demote (language cps types).
2015-06-05 00:52:27 +02:00
Andy Wingo
1071e77785 Add CPS2 verification pass
* module/language/cps2/verify.scm: New diagnostic pass.
* module/Makefile.am: Add verify.scm.
* module/language/cps2/optimize.scm: Wire up verification pass.
  Always run the pass at the end, and if a variable is set run it
  between passes too.
2015-06-05 00:52:27 +02:00
Andy Wingo
b012248f04 Refactor renumber.scm
* module/language/cps2/renumber.scm (sort-labels-locally): Rewrite to
  be functional.  Yay :)
2015-06-05 00:52:27 +02:00
Andy Wingo
ff1a02bd09 Port self-references pass to CPS2
* module/language/cps2/self-references.scm: New pass, ported from CPS.
* module/language/cps2/optimize.scm: Wire up the self references pass.
* module/Makefile.am: Add new file.
2015-06-05 00:52:27 +02:00
Andy Wingo
b0148e11db Fix eta reduction on CPS2
* module/language/cps2/simplify.scm (compute-singly-referenced-vars):
  New helper.
  (compute-eta-reductions): Turns out, eta conversion on a graph
  doesn't work the same way that it works on nested terms -- since
  uses and defs are computed using the flow graph and not nested
  terms, we need to check additionally that the vars are singly-used.
2015-06-05 00:34:06 +02:00
Andy Wingo
1850497a5c Fix intmap-ref bug
* module/language/cps/intmap.scm (intmap-ref): Fix a case in which the
  not-found procedure could be called with an incorrect value.
2015-06-05 00:34:05 +02:00
Andy Wingo
8eea1fb142 Fix slot allocation hinting for intervening terms that define dead values
* module/language/cps/slot-allocation.scm (allocate-slots): Even if an
  expression does not define a live value, it might need a place to
  put its value.  In that case we should stop scanning for hints,
  otherwise e.g. an (current-module) primcall whose value isn't used
  could clobber a hinted variable.
2015-06-05 00:34:05 +02:00
Andy Wingo
f541ee1968 Port type-fold to CPS2
* module/language/cps2/type-fold.scm: New file, ported from CPS.
* module/language/cps2/optimize.scm: Wire up type-fold.
* module/Makefile.am (CPS2_LANG_SOURCES): Add language/cps2/type-fold.cps.
2015-06-03 16:40:16 +02:00
Andy Wingo
e8fa85fd25 Add setk clause to with-cps
* module/language/cps2/with-cps.scm: Add a setk clause kind.
2015-06-03 16:39:45 +02:00
Andy Wingo
c3bc1f8e93 Port CSE to CPS2
* module/language/cps2/cse.scm: New file, ported from CPS.
* module/language/cps2/optimize.scm: Wire up CSE.
* module/Makefile.am: Add language/cps2/cse.scm.

* module/language/cps/compile-bytecode.scm (optimize): Disable
  prune-top-level-scopes on old CPS.  It seems to not work if CSE has
  run beforehand.
2015-06-03 12:59:51 +02:00
Andy Wingo
ea5187ad86 Fix some cps2 utils bugs
* module/language/cps2/utils.scm (compute-function-body): $callk does
  not add to a local function graph.
  (compute-successors): Fix extraction of "handler" continuation for
  $prompt.
2015-06-03 11:20:22 +02:00
Andy Wingo
fef50ea8da Move some graph utilities from contification.scm to utils.scm
* module/language/cps2/utils.scm (compute-successors): New helper.
  (compute-reverse-post-order): Move here from contification.scm and
  rename from "sort-nodes".
  (invert-graph): New helper.
  (compute-strongly-connected-components): Move here from
  contification.scm and rename from "compute-sccs".

* module/language/cps2/contification.scm (sort-nodes, compute-sccs): Remove.
2015-06-03 10:13:15 +02:00
Andy Wingo
ba44619672 Port prune-bailouts pass to CPS2
* module/language/cps2/prune-bailouts.scm: New file.
* module/language/cps2/optimize.scm: Wire up prune-bailouts pass.

* module/Makefile.am (CPS2_LANG_SOURCES): Add language/cps2/prune-bailouts.scm.
2015-06-02 12:47:47 +02:00
Andy Wingo
726558f054 Port elide-values pass to CPS2
* module/language/cps2/elide-values.scm: New file.
* module/language/cps2/optimize.scm (optimize): Wire up elide-values.
* module/Makefile.am: Add new file.
2015-06-02 12:19:14 +02:00
Andy Wingo
467736c3fd prune-top-level-scopes elides with $values
* module/language/cps2/prune-top-level-scopes.scm
  (prune-top-level-scopes): Given that cache-current-module! is an
  instruction, it will always continue to a nullary $kargs, so $values
  is actually the correct replacement and not a values primcall.
2015-06-02 12:18:44 +02:00
Andy Wingo
0e33ee94f0 Port specialize-primcalls pass to CPS2
* module/language/cps2/specialize-primcalls.scm: New file.
* module/language/cps2/optimize.scm: Wire up specialize-primcalls.
* module/Makefile.am: Add new file.
2015-06-02 11:53:36 +02:00
Andy Wingo
42f9bdabb5 Port inline-constructors pass to CPS2
* module/language/cps2/constructors.scm: New file.
* module/language/cps2/optimize.scm: Enable inline-constructors pass.
* module/Makefile.am: Add new file to build.
2015-06-02 11:30:21 +02:00
Andy Wingo
bac96c10f5 Factor with-cps out to separate module
* module/language/cps2/with-cps.scm: New file.
* module/language/tree-il/compile-cps2.scm: Use (language cps2 with-cps).
* module/Makefile.am: Add language/cps2/with-cps.scm.

* .dir-locals.el: Add indentation rules for with-cps.
2015-06-02 11:06:37 +02:00
Andy Wingo
6e725df02f Port contification pass to CPS2.
* module/language/cps2/contification.scm: New pass, ported from CPS.  Faster!
* module/language/cps2/optimize.scm: Wire up contification pass.
* module/Makefile.am: Add language/cps2/contification.scm.
2015-06-02 10:26:59 +02:00
Andy Wingo
d78e5a260c Add "intset" syntax to construct intsets.
* module/language/cps/intset.scm (intset): New syntax.
2015-06-02 10:05:10 +02:00
Andy Wingo
8b4a523ad5 Add intmap-fold-right
* module/language/cps/intmap.scm (make-intmap-folder): Add forward? argument.
  (intmap-fold): Adapt.
  (intmap-fold-right): New function.
2015-06-02 10:05:10 +02:00
Andy Wingo
dd2e0f519d Port prune-top-level-scopes pass to CPS2
* module/language/cps2/prune-top-level-scopes.scm: Port to CPS2.

* module/language/cps2/optimize.scm: Enable prune-top-level-scopes
  pass.

* module/Makefile.am (CPS2_LANG_SOURCES): Add prune-top-level-scopes.scm.
2015-06-02 10:05:09 +02:00