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

19988 commits

Author SHA1 Message Date
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
bb051f2154 Fix write beyond stack boundary in vm-engine.c
* libguile/vm-engine.c (RETURN_ONE_VALUE, RETURN_VALUE_LIST): These
  helpers, used in subr-call and the like, might not actually have
  enough space to push the return values.  Use ALLOC_FRAME instead of
  RESET_FRAME, for that reason.
2015-06-05 00:34:05 +02:00
pcpa
d0a5bd8d3d Implement new synthesized IR codes sequences
* lib/jit_rewind.c: New file implementing generic functions
	to "rewind", or rewrite IR code sequences.

	* include/lightning.h: Add several new codes, that previously
	were a function call, that would synthesize the operation.
	Now, there is a code for the operation, and a new flag to
	know an operation is synthesized.

	* include/lightning/jit_private.h: Add several new macros to
	help construct synthesized IR code sequences.

	* lib/Makefile.am: Update for lib/jit_rewind.c.

	* lib/jit_disasm.c: Update for a small rework on jit_node_t,
	so that --enable-devel-disassembler does not need a change
	in the layout of jit_node_t.

	* lib/jit_names.c: Update for the new codes.

	* lib/jit_print.c: Update to print more readable output, and
	flag synthesized IR code sequences.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
	lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_x86-sz.c,
	lib/jit_x86.c: Update for new synthesized IR code sequences.

	* lib/jit_ppc-cpu.c, lib/jit_ppc-fpu., lib/jit_ppc-sz.c,
	lib/jit_ppc.c, lib/jit_mips-cpu.c, lib/jit_mips-fpu.c,
	lib/jit_mips-sz.c, lib/jit_mips.c, lib/jit_s390-fpu.c,
	lib/jit_s390-sz.c, lib/jit_s390.c: Update for new synthesized
	IR code sequences and correct bugs in the initial varargs
	implementation support.

	* lib/jit_alpha-sz.c, lib/jit_alpha.c, lib/jit_hppa-sz.c,
	lib/jit_hppa.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c: Add generic, untested
	support for the new synthesized	IR code sequences. Known
	most likely broken right now, and should be corrected once
	access to these hosts is available.

	* lib/lightning.c: Update for new IR codes, and add support
	for not yet existing instructions that change third argument.

	* size.c: Change to use different tables for LE and BE PowerPC.
	Correct a wrong endif for x32.
2015-06-04 18:53:07 -03: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
Andy Wingo
2838c6e857 Fix compute-defining-expressions (and thereby compute-constant-values)
* module/language/cps2/utils.scm (compute-defining-expressions): Fix
  not one but two bugs in this pattern.  Grrr.
2015-06-02 10:05:09 +02:00
Andy Wingo
23379467ae Add intmap-replace!.
* module/language/cps/intmap.scm (intmap-replace!): New interface.

* module/language/cps2/dce.scm (elide-type-checks):
* module/language/cps2/simplify.scm (transform-conts):
* module/language/cps2/utils.scm (intmap-map):
* module/language/tree-il/compile-cps2.scm (cps-convert/thunk): Use intmap-replace!.
2015-06-02 10:05:09 +02:00
Andy Wingo
ad29059ff8 DCE uses type analysis to find dead code
* module/language/cps2/dce.scm (compute-effects/elide-type-checks): New helper.
  (elide-type-checks): Implement.
  (fold-nested-functions): Remove.
  (compute-live-code): Call compute-effects/elide-type-checks.
2015-06-02 10:05:09 +02:00
Andy Wingo
8481bdb278 Port type inference module to CPS2
* module/Makefile.am:
* module/language/cps2/types.scm: Port to CPS2.  Relative to the CPS1
  module, this one uses worklists, which should result in fewer
  visits, though it does use a different strategy for deciding when to
  saturate.  We'll see!
2015-06-02 10:05:09 +02:00
Andy Wingo
6a42ac74ce intset-next starting point is optional
* module/language/cps/intset.scm (intset-remove): Remove incorrect comment.
  (intset-next): "i" is optional.
2015-06-02 10:05:09 +02:00
Andy Wingo
8f578af0bb Add intmap-replace.
* module/language/cps/intmap.scm (intmap-replace): New interface.
2015-06-02 10:05:09 +02:00
Andy Wingo
10d11e6537 Fix type-fold on multiplying exact numbers
* module/language/cps/types.scm (mul): Fix bug inferring results of
  exact multiplications.
2015-06-02 10:05:09 +02:00
Andy Wingo
75ab52e490 Fix regression in compute-idoms
* module/language/cps2/utils.scm (compute-idoms): Adapt to previous
  change that makes intmap-ref throw when the key is not present.
2015-06-02 10:05:09 +02:00
pcpa
7f1e0dfb34 Move definition of jit_va_ codes, cosmetic change. 2015-05-25 16:06:55 -03:00
pcpa
e21db9c421 Use an actual, invalid code, as last jit code. 2015-05-25 16:00:01 -03:00
pcpa
1ce1d00db8 Move multiply defined macro to a single header file. 2015-05-25 15:53:17 -03:00
pcpa
0b6cc01eea Intermediate, fully functional, rework for variadic functions
* check/cva_list.c: New file implementing a test to ensure
	the value returned by jit_va_start is a valid C va_list.

	* check/va_list.ok: New simple helper file, as now the
	va_list.tst test is enabled.

	* check/va_list.tst: Rewritten for an extensive variadic
	jit functions test.

	* check/Makefile.am: Update for the new tests.

	* lib/jit_arm-cpu.c, lib/jit_arm-swf.c, lib/jit_arm-vfp.c,
	lib/jit_arm.c: Correct broken software float in a previous
	commit. Note that the hard float abi implementation is known
	broken at this time, for special cases involving variadic
	functions, and should be corrected next.

	lib/jit_x86-cpu.c, lib/jit_x86-sz.c, lib/jit_x86.c: Correct
	the jit_va_list_t semantics to match C va_list.
2015-05-25 15:20:24 -03:00
pcpa
237c90295a Bump library major.
* lib/Makefile.am: Bump library major. This is a preparation
	for a rework that was due for quite some time, but that is
	now required to properly implement variadic jit functions.
	The rework is mainly required to know at prolog parsing, if
	a function is variadic or not. This will benefit a few
	backends, and is mandatory for the hard float arm abi.
	The rework was already planned for quite some time, to
	be able to use a variable stack framesize, and for leaf
	functions optimization where applicable.
	The change will be source compatible, but will change
	some internals, and jit_code_t values, as some new will
	be added.
	The only behavior change is that, jit_arg_register_p may
	change return value on hard float arm abi, if called before
	or after jit_ellipsis. Common sense anyway, would say to
	make that call after jit_ellipsis, but documentation
	should be updated for it.
2015-05-24 14:44:04 -03:00
pcpa
316dfc6e5e aarch64: Correct va_list offsets and double load.
* lib/jit_aarch64-fpu.c, lib/jit_aarch64.c: Correct base
	aarch64 varargs code.
2015-05-24 14:34:16 -03:00
pcpa
97f69a9c9c Correct make check for systems without gcc.
* check/lightning.c: Clearly run check if clang is the system
	compiler.
2015-05-24 13:50:58 -03:00
Paulo Andrade
d6a5a90d5a alpha: Save correct offset if loading a vararg double. 2015-05-20 23:19:16 -03:00
pcpa
bd38cfa9c9 sparc: Add initial jit_va_ calls to sparc
* lib/jit_sparc-cpu.c, lib/jit_sparc-fpu.c, lib/jit_sparc.c:
	Add base support to jit vararg functions to the sparc backend.
2015-05-20 14:33:31 -03:00
Andy Wingo
48b2f190b2 Port dead code elimination (DCE) pass to CPS2
* module/language/cps2/dce.scm: New file.
* module/language/cps2/optimize.scm: Enable CPS2 DCE pass.
* module/Makefile.am: Add language/cps2/dce.scm.
2015-05-20 19:18:46 +02:00
Andy Wingo
80c162b67c Port effects analysis to CPS2
* module/Makefile.am (CPS2_LANG_SOURCES): Add effects-analysis.scm.
* module/language/cps2/effects-analysis.scm: New file, based on
  cps/effects-analysis.scm.
* module/language/cps2/utils.scm (intmap-map):
  (compute-defining-expressions, compute-constant-values): New helpers.
2015-05-20 19:18:45 +02:00
Andy Wingo
7d4ede040d Fix bug in CPS2 simplify's "transform-conts"
* module/language/cps2/simplify.scm (transform-conts): Return a persistent intmap.
2015-05-20 19:18:45 +02:00
Andy Wingo
102e677b98 intmaps and intsets print with abbreviated key ranges
* module/language/cps/intset.scm (intset-key-ranges, range-string):
  (print-helper, print-intset, print-transient-intset): New helpers.
  Install as intset printers.
* module/language/cps/intmap.scm (intmap-key-ranges, range-string):
  (print-helper): New helpers.
  (print-intmap, print-transient-intmap): Call the new helpers.
2015-05-20 19:18:45 +02:00
Andy Wingo
1403df4140 Add arity to worklist-fold
* module/language/cps2/utils.scm (worklist-fold): Add two-seeded arity.
  (worklist-fold2): Remove.

* module/language/cps2/renumber.scm (compute-tail-path-lengths): Adapt.
2015-05-20 19:18:45 +02:00
Andy Wingo
5f7c8e5cb3 Variadic intset-fold, intmap-fold
* module/language/cps/intmap.scm (intmap-fold): Add two-seeded arity.
* module/language/cps/intset.scm (intset-fold): Merge intset-fold2
  into this function, as a two-seeded arity.

* module/language/cps2/simplify.scm (compute-eta-reductions):
  (compute-singly-referenced-labels, compute-beta-reductions): Adapt
  intset-fold2 callers.
2015-05-20 19:18:45 +02:00
Andy Wingo
2b06e90ca4 Intmaps do not treat #f specially as a value
* module/language/cps/intmap.scm: Intmaps can now contain any value;
  #f does not indicate the absence of a value.  Instead we use a unique
  private sentinel to mark absent values or branches.
  (*absent*, absent?, present?): New helpers.
  (new-branch): Initialize empty elements to *absent*.
  (clone-branch-with-edit): New helper.
  (clone-branch-and-set): Use clone-branch-with-edit.
  (writable-branch): Use clone-branch-with-edit
  (empty-intmap): Initialize value to *absent*.
  (add-level): clone-branch-and-set doesn't take #f as a branch any
  more; use new-branch.
  (branch-empty?, make-intmap/prune, intmap-add!):
  (intmap-add, intmap-remove, intmap-next, intmap-prev):
  (intmap-fold, intmap-union, intmap-intersect): Use absent? to detect
  absent branches / values.
  (intmap-ref): Likewise.  Instead of returning #f if the value is not
  found, call the optional not-found procedure.  By default this will
  signal an error.

* module/language/cps/types.scm:
* module/language/cps2/renumber.scm:
* module/language/cps2/simplify.scm: Adapt to intmap-ref signalling an
  error by default if the value is not found.

* module/language/tree-il/compile-cps2.scm: Adapt to intmap-add
  signalling an error if #f was in the intmap as a value.
2015-05-20 19:18:45 +02:00
Andy Wingo
cb7aa0b3b1 Add two-argument fixpoint arity
* module/language/cps2/utils.scm (fixpoint): Add two-argument arity.
2015-05-20 19:18:45 +02:00
Andy Wingo
4632f3d998 Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.  Fix construction of rest bindings
  as well.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2015-05-20 19:18:45 +02:00
Andy Wingo
e0e47cb527 Fix fixpoint
* module/language/cps2/utils.scm (fixpoint): Fix embarrassing bug
  where it wouldn't actually fixpoint!  Didn't show up in practice
  because CPS2 hasn't run after contification yet.
2015-05-20 19:18:45 +02:00
Andy Wingo
fa7df5ed3a Fix sub/- primcall bug
* module/language/tree-il/compile-cps2.scm (convert): Fix bug
  in (apply - ...), because the instruction for "-" is "sub", and
  "sub" lookup was failing.  Caught by numbers.test.  Really I would
  like to get rid of $prim, somehow.
2015-05-20 19:18:45 +02:00