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

170 commits

Author SHA1 Message Date
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
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
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
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
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
a6f823bd02 Public make-cont-folder
* module/language/cps.scm (make-cont-folder): Add global? parameter, and
  make public.
  (fold-conts): Adapt.
  (fold-local-conts): Use make-cont-folder, and take a function instead
  of a continuation.

* module/language/cps/arities.scm (fix-clause-arities, fix-arities*):
* module/language/cps/compile-bytecode.scm (collect-conts):
* module/language/cps/elide-values.scm (elide-values*): Adapt to
  fold-local-conts change.
2014-03-31 18:21:04 +02:00
Andy Wingo
dd692618b8 Add prune-top-level-scopes pass
* module/language/cps/prune-top-level-scopes.scm: New pass, to prune
  unneeded "cache-current-module!" forms.

* module/language/cps/compile-bytecode.scm:
* module/Makefile.am: Add the new pass to the build and enable by
  default.
2014-02-13 09:30:39 +01:00
Andy Wingo
b3ae2b5068 Add VM and compiler support for calls to known procedures
* module/language/cps.scm ($callk): New expression type, for calls to
  known labels.  Part of "low CPS".
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.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/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm: Adapt call sites.

* libguile/vm-engine.c (call-label, tail-call-label): New instructions.
  Renumber the rest; this is an ABI change.

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.

* doc/ref/compiler.texi (CPS in Guile): Document $callk.
2014-02-02 23:19:22 +01:00
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
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
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
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
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
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
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
Renamed from module/language/cps/compile-rtl.scm (Browse further)