Andy Wingo
048d5d340e
Intset-next micro-optimizations
...
* module/language/cps/intset.scm (intset-next): Micro-optimizations.
2015-04-01 10:53:23 +02:00
Andy Wingo
9c8d2b85e8
Add intset-fold, intset-fold2
...
* module/language/cps/intset.scm (intset-fold, intset-fold2): New
functions.
2015-04-01 10:53:23 +02:00
Andy Wingo
b7668bd949
Add intmap-fold.
...
* module/language/cps/intmap.scm (intmap-fold): New function.
2015-04-01 10:53:21 +02:00
Andy Wingo
2a24395a0f
Add intmap-prev
...
* module/language/cps/intmap.scm (intmap-next): Starting index is
optional.
(intmap-prev): New function.
2015-04-01 10:28:19 +02:00
Andy Wingo
33ab2838de
Default "meet" operator is meet-error for intmap
...
* module/language/cps/intmap.scm (meet-error): New helper.
(intmap-add, intmap-union, intmap-intersect): The "meet" argument is
optional and defaults to meet-error.
2015-04-01 10:28:19 +02:00
Andy Wingo
50fcdfece3
Remove "free" field of $fun
...
* module/language/cps.scm ($fun): Remove unused "free" field.
* module/language/cps/arities.scm:
* 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/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.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/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all callers.
2015-04-01 10:10:10 +02:00
Andy Wingo
34ff3af9f0
Replace $letrec with $rec
...
* module/language/cps.scm ($rec): Replace $letrec with $rec, which is an
expression, not a term. This means that the names bound by the letrec
appear twice: once in the $rec term, and once in the continuation.
This is not very elegant, but the situation is better than it was
before. Adapt all callers.
* doc/ref/compiler.texi (CPS in Guile): Incomplete documentation
updates. I'll update these later when the IL settles down.
2015-04-01 10:10:10 +02:00
Andy Wingo
4ce1857019
Precise range inference on <, <=, >=, > branches
...
* module/language/cps/types.scm (restricted-comparison-ranges): New
helper.
(define-comparison-inferrer): New helper.
(<, <=, >=, >): Infer ranges precisely.
2015-04-01 10:10:10 +02:00
Andy Wingo
ef7a71b768
Fix intmap bug for maps with only one element
...
* module/language/cps/intmap.scm (intmap-ref): Fix bug referencing
values when there is only one value in the map.
2015-04-01 10:10:10 +02:00
Andy Wingo
af082f9b1c
Marginal bootstrap memory improvements
...
* module/language/cps/compile-bytecode.scm (optimize, compile-bytecode):
Marginally improve bootstrap memory usage by not retaining stale
copies of already-rewritten terms.
2015-03-12 08:20:58 +01:00
Andy Wingo
a9ec16f9c5
Remove $void CPS expression type
...
* module/language/cps.scm: Remove the $void expression type, replaced by
$const of the unspecified value.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update callers.
2015-03-11 21:51:33 +01:00
Andy Wingo
e87f059319
Reify bytevector? in the correct module
...
* module/language/cps/reify-primitives.scm (primitive-module): Reify
bytevector? in the correct module. Thanks to Nala Ginrut for the
report.
2015-02-06 15:13:32 +01:00
Andy Wingo
15e4746f17
Fix verify-cps
...
* module/language/cps/verify.scm (verify-cps): Fix. Thanks to Steven
H. Margolis for the note. Fixes bug #19389 .
2015-01-25 11:39:42 +01:00
Andy Wingo
e2fafeb901
Keywords have a tc7
...
* libguile/tags.h (scm_tc7_keyword): Allocate a tc7, so that the VM can
have cheap keyword? tests.
* libguile/keywords.c:
* libguile/keywords.h: Adapt.
* libguile/goops.c (scm_class_of, scm_sys_goops_early_init): Capture
<keyword>.
* libguile/print.c (iprin1): Inline keyword printer.
* libguile/evalext.c (scm_self_evaluating_p): Add keywords here.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_tc16_keyword): Deprecate.
* module/language/cps/compile-bytecode.scm (compile-fun): Add keyword?
case, and bitvector? case while we're at it.
* module/language/cps/effects-analysis.scm (define-primitive-effects):
Add bytevector?, keyword?, and bitvector? cases.
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
keyword?.
* module/language/cps/types.scm (bitvector?, keyword?, bytevector?): Add
branch inferrers.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*effect-free-primitives*):
(*effect+exception-free-primitives*): Add bytevector?, keyword?, and
bitvector?.
* module/oop/goops.scm (<keyword>): New class.
* module/system/base/types.scm (%tc7-keyword, cell->object): Add cases.
* module/system/vm/assembler.scm (br-if-keyword): New definition.
* module/system/vm/disassembler.scm (code-annotation): Add br-if-tc7
case for keywords.
* test-suite/tests/types.test ("clonable objects"): Update now that
keywords are cloneable.
2015-01-22 13:03:11 +01:00
Andy Wingo
27b3b5b92d
Add allocate-struct, struct-ref, struct-set! instructions
...
* libguile/vm-engine.c (allocate-struct, struct-ref, struct-set!): New
instructions, to complement their "immediate" variants.
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/system/vm/assembler.scm (system): Wire up the new instructions.
2015-01-22 12:53:33 +01:00
Andy Wingo
7f5887e70b
Separate &boolean type into &true and &false
...
* module/language/cps/types.scm (&all-types): Represent true and false
as separate bits, so that #f can be removed from types on true
branches. Adapt all users.
* module/language/cps/type-fold.scm (&scalar-types):
(fold-and-reduce): Adapt to boolean type representation change.
2014-08-24 17:07:49 +02:00
Andy Wingo
b9a5bac690
Better simplification of literal constants that continue to branches
...
* module/language/cps/simplify.scm (eta-reduce): Constants that continue
to branches eta-reduce to the true or false branch.
2014-07-22 12:18:07 +02:00
Andy Wingo
ae67b159bb
CPS will not see "not" primcalls
...
* module/language/tree-il/compile-cps.scm (convert): Remove "not"
primcalls.
* module/language/cps/effects-analysis.scm (values):
* module/language/cps/types.scm: Remove special cases for the "not"
primcall.
2014-07-22 12:18:07 +02:00
Andy Wingo
44954194c9
Simplify pass rewrite scope tree to reflect dominator tree
...
* module/language/cps/simplify.scm (redominate): Add micropass to
rewrite the scope tree to reflect the dominator tree. Will enable
better eta reduction.
2014-07-22 12:18:07 +02:00
Andy Wingo
7700e67226
Remove dead case in CSE
...
* module/language/cps/cse.scm (apply-cse): Remove a case that couldn't
occur.
2014-07-22 12:18:07 +02:00
Andy Wingo
6fc634f8a3
CSE allocate-struct fix
...
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
Fix handling of allocate-struct in tail position.
2014-07-21 21:38:17 +02:00
Andy Wingo
30411abf5c
Fix typo in arities.scm
...
* module/language/cps/arities.scm (fix-arities*): Fix typo.
2014-07-21 21:38:17 +02:00
Andy Wingo
cf7a884f12
Stabilize renumber.scm:sort-conts.
...
* module/language/cps/renumber.scm (sort-conts): Prevent spurious
continuation reordering.
2014-07-21 21:38:17 +02:00
Andy Wingo
ebca3afedb
Fix allocate-slots for $kreceive with multiple predecessors
...
* module/language/cps/slot-allocation.scm (allocate-slots): For
continuations of $call, $callk, and $values with multiple
predecessors, recalculate the set of live slots. Fixes miscompilation
of ice-9/futures.scm:process-future!, broken since the previous patch,
now that $kreceive continuations can have multiple predecessors.
2014-07-21 11:47:43 +02:00
Andy Wingo
6d7b6a171e
Block sorting to keep loop bodies together
...
* module/language/cps/renumber.scm (compute-new-labels-and-vars):
(compute-tail-path-lengths, sort-conts): Arrange to visit successors
in such a way that if branches are unsorted, the longest path length
will appear first. This keeps loop bodies together.
2014-07-05 15:46:48 +02:00
Andy Wingo
9243902a9d
logbit? strength reduction
...
* module/language/cps/type-fold.scm (fold-and-reduce): Don't require
types to check out; it could be that the reduced expression can
exhibit the same type-check effects. Reduce for all continuations,
even $kreceive. Pass dfg to reducer.
(mul): Check types.
(logbit?): New reducer.
2014-07-04 12:42:16 +02:00
Andy Wingo
74fe7fae00
Fix logand range analysis.
...
* module/language/cps/types.scm (logand): Fix range analysis.
2014-07-04 11:58:41 +02:00
Andy Wingo
42b544ebbc
Fix range analysis for mul and div
...
* module/language/cps/types.scm (mul): Avoid producing nans in the
resulting range.
(div): Fix range analysis.
2014-07-04 11:14:16 +02:00
Andy Wingo
384d1ec3b2
Type-driven strength reduction
...
* module/language/cps/type-fold.scm (*primcall-reducers*):
(define-primcall-reducer, define-unary-primcall-reducer):
(define-binary-primcall-reducer, mul): Beginnings of strength
reduction.
(fold-and-reduce): Rename from compute-folded.
(fold-constants*): Adapt.
2014-07-04 10:46:31 +02:00
Andy Wingo
c7b71b1fdd
Small type-fold cleanup
...
* module/language/cps/type-fold.scm (fold-constants*): Remove stale
branches that were there when we only type folded on limited-size
branches.
2014-07-04 09:18:36 +02:00
Andy Wingo
d613ccaaa0
Compiler emits br-if-logtest
...
* module/language/cps/compile-bytecode.scm (compile-fun):
* module/language/cps/primitives.scm (*branching-primcall-arities*):
* module/language/cps/type-fold.scm (logtest):
* module/language/cps/types.scm (logtest):
* module/system/vm/assembler.scm (system):
* module/system/vm/disassembler.scm (compute-labels): Add backend
support for the logtest instruction.
2014-07-03 15:03:40 +02:00
Andy Wingo
8006d2d6eb
Optimizer support for logtest and logbit?
...
* module/language/cps/effects-analysis.scm: Add entries for logtest and
logbit?.
* module/language/cps/types.scm (logtest, logbit?): New checkers and
inferrers.
* module/language/tree-il/peval.scm (peval): Convert (zero? (logand a
b)) to (logtest a b), in anticipation of opcode support for logtest.
*
module/language/tree-il/primitives.scm (*interesting-primitive-names*):
(*effect-free-primitives*): Add logtest and logbit?.
2014-07-03 14:45:12 +02:00
Andy Wingo
5ded849813
Convert slot allocation to use intsets
...
* module/language/cps/dfg.scm (compute-live-variables): Convert to use
intsets, and fold in compute-maximum-fixed-point.
(print-dfa): Update.
* module/language/cps/slot-allocation.scm (dead-after-def?)
(dead-after-use?, allocate-slots): Convert to use intsets.
2014-07-03 11:24:37 +02:00
Andy Wingo
7f6aafa5ae
Add bitvector->intset.
...
* module/language/cps/intset.scm (bitvector->intset): New interface.
2014-07-03 10:37:20 +02:00
Andy Wingo
4296c36ec8
Restrict intsets and maps to non-negative integers
...
* module/language/cps/intmap.scm (intmap-add):
* module/language/cps/intset.scm (intset-add): Restrict to only hold
non-negative integers.
2014-07-03 09:37:30 +02:00
Andy Wingo
e9808c14d7
Adapt visit-prompt-control-flow to use intsets.
...
* module/language/cps/dfg.scm (compute-reachable): Use intsets.
(compute-interval): Adapt.
(visit-prompt-control-flow): Adapt.
2014-07-03 09:20:11 +02:00
Andy Wingo
c1a41f96b4
CSE comments
...
* module/language/cps/cse.scm (compute-available-expressions): Add
clarifying comment.
2014-07-03 09:03:45 +02:00
Andy Wingo
41296769c7
Add intset-subtract.
...
* module/language/cps/intset.scm (intset-subtract): New interface.
2014-07-03 09:03:12 +02:00
Andy Wingo
93e838423c
Fix intset on 32-bit machines
...
* module/language/cps/intset.scm (*leaf-bits*): Define to 4 on 32-bit
machines, to stay in fixnum range.
2014-07-01 11:30:29 +02:00
Andy Wingo
0ad455ca6b
Remove size limit in elide-type-checks
...
* module/language/cps/dce.scm (elide-type-checks!): Remove limit on
label-count, now that complexity is under control.
2014-06-30 15:30:39 +02:00
Andy Wingo
e21dae43fc
Fix intmap-intersect corner case
...
* module/language/cps/intmap.scm (intmap-intersect): Fix a corner case,
as was recently fixed for intsets.
2014-06-29 19:49:49 +02:00
Andy Wingo
072b5a277c
CSE truth inference pass uses intsets
...
* module/language/cps/cse.scm (compute-truthy-expressions): Rewrite to
use intsets instead of bitvectors.
(apply-cse): Adapt.
2014-06-29 19:47:38 +02:00
Andy Wingo
793ca4c433
Result of intsect-intersect will share structure with A if it can
...
* module/language/cps/intset.scm (intset-intersect): Ensure that the
result shares structure with A if possible, as intmaps do.
2014-06-29 19:47:38 +02:00
Andy Wingo
257db78b6b
Fix an intset-intersect corner case
...
* module/language/cps/intset.scm (intset-intersect): Avoid creating
invalid intsets when lowering an intset with a higher shift.
2014-06-29 19:41:16 +02:00
Andy Wingo
b5cb1c77ff
Fix intset pruning for empty intsets
...
* module/language/cps/intset.scm (make-intset/prune): Fix empty intset
case.
2014-06-29 19:31:41 +02:00
Andy Wingo
2c02a21023
Remove namesets.
...
This was a failed experiment. It had good space complexity but terrible
time complexity.
* module/Makefile.am: Update.
* module/language/cps/nameset.scm: Remove.
2014-06-29 14:30:34 +02:00
Andy Wingo
3a12f2ce0b
Rewrite type inference to use intmaps
...
* module/language/cps/types.scm: Rewrite to use intmaps instead of
namesets.
2014-06-29 14:30:34 +02:00
Andy Wingo
b352309301
New module (language cps intmap)
...
* module/language/cps/intmap.scm: New file.
* module/Makefile.am: Add to build.
2014-06-29 14:30:25 +02:00
Andy Wingo
6fe36f220e
Rewrite CSE to use intsets.
...
* module/language/cps/cse.scm: Rewrite using intsets.
2014-06-29 14:26:02 +02:00
Andy Wingo
b1103eb980
New module: (language cps intset)
...
* module/Makefile.am: Add to build.
* module/language/cps/intset.scm: New file.
2014-06-29 14:19:03 +02:00