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

3252 commits

Author SHA1 Message Date
Andy Wingo
5f4ac529e1 Use a bootstrapped -O0 compiler to compile the -O2 Guile
This reduces total build time to around 30 minutes or so.

* Makefile.am (SUBDIRS): Visit bootstrap/ before module/.

* bootstrap/Makefile.am: New file.

* configure.ac: Generate bootstrap/Makefile.

* meta/uninstalled-env.in (top_builddir): Add bootstrap/ to the
  GUILE_LOAD_COMPILED_PATH.

* module/Makefile.am: Simplify to just sort files in alphabetical order;
  since bootstrap/ was already compiled, we don't need to try to
  optimize compilation order.  Although the compiler will get faster as
  more of the compiler itself is optimized, this isn't a significant
  enough effect to worry about.
2015-10-23 13:29:03 +00:00
Andy Wingo
f169be9fc8 Wire up `guild compile -O0 foo.scm'
* module/scripts/compile.scm (%options): Resurrect -O option and make it
  follow GCC, more or less.  The default is equivalent to -O2.

* module/language/cps/compile-bytecode.scm (lower-cps):
* module/language/cps/optimize.scm (optimize-higher-order-cps): Move
  split-rec to run unconditionally for now, as closure conversion fails
  without it.
  (define-optimizer): Only verify the result if we are debugging, to
  save time.
  (cps-default-optimization-options): New exported procedure.

* module/language/tree-il/optimize.scm
  (tree-il-default-optimization-options): New exported procedure.
2015-10-22 17:44:17 +00:00
Andy Wingo
467e587d68 Update VM documentation for new stack layout
* doc/ref/vm.texi: Update for new stack layout.
* module/system/vm/disassembler.scm (code-annotation): Print the frame
  sizes after alloc-frame, reset-frame, etc to make reading the
  disassembly easier.
2015-10-22 11:02:18 +00:00
Andy Wingo
f03960412e Add stack size computation to disassembler
* module/system/vm/disassembler.scm (define-stack-effect-parser)
  (stack-effect-parsers, instruction-stack-size-after): New stack size
  facility.
  (define-clobber-parser, clobber-parsers, instruction-slot-clobbers):
  Take incoming and outgoing stack sizes as arguments to interpret
  SP-relative clobbers.

* module/system/vm/frame.scm (compute-frame-sizes): New helper that
  computes frame sizes for each position in a function.
  (compute-killv): Adapt to compute the clobbered set given the computed
  frame sizes.
2015-10-21 15:02:28 +02:00
Andy Wingo
4afb46f859 Minor assembler cleanups
* module/system/vm/assembler.scm (shuffling-assembler): Minor renames.
2015-10-21 15:02:08 +02:00
Andy Wingo
70c317ab51 SP-relative local addressing
* libguile/vm-engine.c: S24/S12/S8 operands addressed relative to the
  SP, not the FP.  Cache the SP instead of a FP-relative locals
  pointer.  Further cleanups to follow.

* libguile/vm.c (vm_builtin_call_with_values_code): Adapt to mov operand
  addresing change.

* module/language/cps/compile-bytecode.scm (compile-function): Reify
  SP-relative local indexes where appropriate.

* module/system/vm/assembler.scm (emit-fmov*): New helper, exported as
  emit-fmov.
  (shuffling-assembler, define-shuffling-assembler): Rewrite to shuffle
  via push/pop/drop.
  (standard-prelude, opt-prelude, kw-prelude): No need to provide for
  shuffling args.

* test-suite/tests/rtl.test: Update.

* module/language/cps/slot-allocation.scm: Don't reserve slots 253-255.
2015-10-21 11:49:20 +02:00
Andy Wingo
0da0308b84 Prepare for SP-addressed locals
* libguile/vm-engine.c: Renumber opcodes, and take the opportunity to
  fold recent additions into more logical places.  Be more precise when
  describing the encoding of operands, to shuffle local references only
  and not constants, immediates, or other such values.
  (SP_REF, SP_SET): New helpers.
  (BR_BINARY, BR_ARITHMETIC): Take full 24-bit operands.  Our shuffle
  strategy is to emit push when needed to bring far locals near, then
  pop afterwards, shuffling away far destination values as needed; but
  that doesn't work for conditionals, unless we introduce a trampoline.
  Let's just do the simple thing for now.  Native compilation will use
  condition codes.
  (push, pop, drop): Back from the dead!  We'll only use these for
  temporary shuffling though, when an opcode can't address the full
  24-bit range.
  (long-fmov): New instruction, like long-mov but relative to the frame
  pointer.
  (load-typed-array, make-array): Don't use a compressed encoding so
  that we can avoid the shuffling case.  It would be a pain, given that
  they have so many operands already.

* module/language/bytecode.scm (compute-instruction-arity): Update for
  new instrution word encodings.

* module/system/vm/assembler.scm: Update to expose some opcodes
  directly, without the need for shuffling wrappers.  Adapt to
  instruction word encodings change.

* module/system/vm/disassembler.scm (disassembler): Adapt to instruction
  coding change.
2015-10-21 11:49:20 +02:00
Andy Wingo
d7199da8c9 Fix prompt miscompilation
* module/language/cps/compile-bytecode.scm (compile-function): Fix
  miscompilation when the handler body is forwarded.
2015-10-21 11:49:20 +02:00
Mark H Weaver
315adb6347 Fix typo in CPS conversion.
Fixes <http://bugs.gnu.org/21614>.
Reported by tantalum <sph@posteo.eu>.

* module/language/tree-il/compile-cps.scm (convert): Add missing 'cps'
  argument to the continuation passed to 'convert-arg'.
2015-10-06 10:09:12 -04:00
Andy Wingo
78fdc3e673 Remove unused (language tree-il inline) module.
* module/language/tree-il/inline.scm: Remove.
* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove inline.scm.
2015-09-17 12:45:36 +02:00
Andy Wingo
48412395c6 Add closure effects
* module/language/cps/effects-analysis.scm: Add closure effects, to
  enable hoisting/CSE of free-ref/free-set!.
2015-07-27 15:19:45 +02:00
Andy Wingo
90c11483e6 Better codegen for $values terms that don't shuffle
* module/language/cps/compile-bytecode.scm (compute-forwarding-labels):
  Analyze forwarding labels before emitting code.  This lets us elide
  conts that cause no shuffles, allowing more fallthrough.
2015-07-27 14:53:59 +02:00
Andy Wingo
3b60e79879 Loop peeling
* module/language/cps/peel-loops.scm: New pass.  Only enabled if the
  loop has one successor.

* module/language/cps/optimize.scm: Peel instead of doing LICM on
  higher-order CPS, then LICM on first-order CPS.

* module/Makefile.am: Wire up new pass.
2015-07-27 13:45:23 +02:00
Andy Wingo
4792577ab8 solve-flow-equations tweak
* module/language/cps/utils.scm (solve-flow-equations): Revert to take
  separate in and out maps.  Take an optional initial worklist.

* module/language/cps/slot-allocation.scm: Adapt to solve-flow-equations
  change.
2015-07-27 13:25:38 +02:00
Andy Wingo
ce2888701c Simplify rotate-loops.scm
* module/language/cps/rotate-loops.scm: Clean up unused code.
2015-07-27 12:59:09 +02:00
Andy Wingo
e54fbff185 Loop inversion with multiple exits
* module/language/cps/rotate-loops.scm (rotate-loop): Instead of
  restricting rotation to loops with just one exit node, restrict to
  loops with just one exit successor.
2015-07-25 11:03:59 +02:00
Andy Wingo
ee85e2969f Rotate comparisons down to loop back-edges
* module/language/cps/rotate-loops.scm: New pass.
* module/Makefile.am:
* module/language/cps/optimize.scm: Wire up the new pass.
2015-07-24 16:51:04 +02:00
Andy Wingo
bf6930b3f6 Eliminate trampoline gotos when possible in compile-bytecode
* module/language/cps/compile-bytecode.scm (compile-function): Eliminate
  trampoline jumps for conditional branches that don't shuffle.
2015-07-24 16:51:04 +02:00
Andy Wingo
bcfa9fe70e Small expression-effects tweak
* module/language/cps/effects-analysis.scm (expression-effects):
  Closures with zero free vars don't allocate.
2015-07-24 16:51:04 +02:00
Andy Wingo
ec9554d138 Loop-invariant code motion
* module/language/cps/licm.scm: New pass.
* module/language/cps/optimize.scm: Wire up new pass.
* module/Makefile.am: Add new file.
2015-07-24 16:50:58 +02:00
Andy Wingo
bebc70c8b1 Move solve-flow-equations to utils
* module/language/cps/slot-allocation.scm (compute-lazy-vars):
  (compute-live-variables):  Adapt to solve-flow-equations interface
  change.

* module/language/cps/utils.scm (solve-flow-equations): Move here.  Use
  an init value instead of an init map.
2015-07-24 11:40:00 +02:00
Andy Wingo
b40fac1e98 Factor out compute-effects/elide-type-checks from dce.scm
* module/language/cps/type-checks.scm: New module.
* module/language/cps/dce.scm: Use new module.
* module/Makefile.am: Add new module.
2015-07-24 11:39:18 +02:00
Andy Wingo
4aabc205cc Add missing files
Last commit meant to rename files, not delete them.  Whoops!
2015-07-22 18:27:37 +02:00
Andy Wingo
aa7f0e25ac Rename CPS2 to CPS 2015-07-22 17:19:04 +02:00
Andy Wingo
0d4c937722 Remove CPS1 language
* module/language/cps.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dfg.scm:
* module/language/cps/renumber.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/spec.scm:
* module/language/cps/verify.scm:
* module/language/cps2/compile-cps.scm: Delete.
* module/Makefile.am: Remove deleted files.
2015-07-22 17:15:06 +02:00
Andy Wingo
39777b11b3 Compile CPS2 directly to bytecode
* module/language/cps2/spec.scm (cps2): Compile directly to bytecode.
2015-07-22 17:01:53 +02:00
Andy Wingo
910054bfbc Slot allocation and bytecode compilation from CPS2.
* module/language/cps2/compile-bytecode.scm: New file.
* module/language/cps2/slot-allocation.scm: New file.
* module/Makefile.am: Add new files.
2015-07-22 17:01:19 +02:00
Andy Wingo
16d92c566f Fix CPS2 compute-successors
* module/language/cps2/utils.scm (compute-successors): Propagate $kfun
  to $ktail so that we don't leave off the tail if the body iloops.
2015-07-22 17:00:34 +02:00
Andy Wingo
2df454b95b intset-intersect bugfix
* module/language/cps/intset.scm (intset-intersect): Remove new-leaf
  procedure, inlining to single call site.  An empty intersection
  properly produces #f so that the set can be pruned.
2015-07-22 16:59:47 +02:00
Andy Wingo
ff2beb186e Fix bad return shuffles for multiply-used $kreceive conts
* module/language/cps2/reify-primitives.scm (uniquify-receive):
  (reify-primitives): Ensure that $kreceive conts can have only one
  predecessor.  Otherwise return shuffles are incorrectly allocated.
2015-07-21 17:48:22 +02:00
Andy Wingo
08cf30f2a0 Fix error printing some wrong-num-args backtraces
* module/system/repl/debug.scm (print-frame): Pass #:top-frame? #t for
  the top frame.

* module/system/vm/frame.scm (available-bindings): Be permissive and
  allow #:top-frame? #f even when the IP is at the start of the
  function.
2015-07-20 16:24:49 +02:00
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