1. 20 May, 2015 11 commits
    • Andy Wingo's avatar
      Port dead code elimination (DCE) pass to CPS2 · 48b2f190
      Andy Wingo authored
      * module/language/cps2/dce.scm: New file.
      * module/language/cps2/optimize.scm: Enable CPS2 DCE pass.
      * module/Makefile.am: Add language/cps2/dce.scm.
      48b2f190
    • Andy Wingo's avatar
      Port effects analysis to CPS2 · 80c162b6
      Andy Wingo authored
      * 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.
      80c162b6
    • Andy Wingo's avatar
      Fix bug in CPS2 simplify's "transform-conts" · 7d4ede04
      Andy Wingo authored
      * module/language/cps2/simplify.scm (transform-conts): Return a persistent intmap.
      7d4ede04
    • Andy Wingo's avatar
      intmaps and intsets print with abbreviated key ranges · 102e677b
      Andy Wingo authored
      * 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.
      102e677b
    • Andy Wingo's avatar
      Add arity to worklist-fold · 1403df41
      Andy Wingo authored
      * module/language/cps2/utils.scm (worklist-fold): Add two-seeded arity.
        (worklist-fold2): Remove.
      
      * module/language/cps2/renumber.scm (compute-tail-path-lengths): Adapt.
      1403df41
    • Andy Wingo's avatar
      Variadic intset-fold, intmap-fold · 5f7c8e5c
      Andy Wingo authored
      * 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.
      5f7c8e5c
    • Andy Wingo's avatar
      Intmaps do not treat #f specially as a value · 2b06e90c
      Andy Wingo authored
      * 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.
      2b06e90c
    • Andy Wingo's avatar
      Add two-argument fixpoint arity · cb7aa0b3
      Andy Wingo authored
      * module/language/cps2/utils.scm (fixpoint): Add two-argument arity.
      cb7aa0b3
    • Andy Wingo's avatar
      Fix bug compiling fixpoint combinator · 4632f3d9
      Andy Wingo authored
      * 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.
      4632f3d9
    • Andy Wingo's avatar
      Fix fixpoint · e0e47cb5
      Andy Wingo authored
      * 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.
      e0e47cb5
    • Andy Wingo's avatar
      Fix sub/- primcall bug · fa7df5ed
      Andy Wingo authored
      * 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.
      fa7df5ed
  2. 12 May, 2015 1 commit
    • Andy Wingo's avatar
      Add optimization pass over CPS2 · ef5f2fca
      Andy Wingo authored
      * module/language/cps2/optimize.scm: New file.
      * module/language/cps2/simplify.scm: New file, factored out of
        simplify2.scm.
      
      * module/language/cps/simplify2.scm: Remove, as it's obsolete.
      
      * module/language/cps2/compile-cps.scm: Optimize the CPS.
      
      * module/Makefile.am: Adapt for added and deleted files.
      ef5f2fca
  3. 11 May, 2015 3 commits
    • Andy Wingo's avatar
      Consolidate CPS2 above CPS in the compiler · b31af02f
      Andy Wingo authored
      This is an intermediate step.  We'll replace CPS bit by bit.  If it
      turns out to be a terrible idea we can just revert.
      
      * module/Makefile.am (TREE_IL_LANG_SOURCES): Remove compile-cps.scm.
        (CPS_LANG_SOURCES): Remove arities.scm.
      
      * module/language/cps/arities.scm: Remove.
      * module/language/tree-il/compile-cps.scm: Remove.
      
      * module/language/tree-il/spec.scm: Remove use of compile-cps.scm.
      
      * module/language/cps/compile-bytecode.scm: Remove use of arities.scm.
        Instead, incoming terms are expected to call their continuations
        with the correct number of arguments.
      b31af02f
    • Andy Wingo's avatar
      Adapt return arities in Tree-IL -> CPS2 conversion · 9833c545
      Andy Wingo authored
      * module/language/tree-il/compile-cps2.scm (adapt-arity): New
        procedure.  This is equivalent to (language cps arities), but as it
        is a necessary pass and not an optimization it's more proper to put
        it in the converter itself.  Unlike with the nested CPS
        representation, it's possible to look up continuations without
        making a DFG.
        (convert): Adapt arities as necessary.
      9833c545
    • Andy Wingo's avatar
      Build CPS2 with transient intmaps · 3ab3cdec
      Andy Wingo authored
      * module/language/tree-il/compile-cps2.scm (with-cps)
        (cps-convert/thunk): Use transient intmaps.
      3ab3cdec
  4. 09 May, 2015 4 commits
  5. 08 May, 2015 7 commits
    • Andy Wingo's avatar
      Fix convert-cps2 for "not" primcalls · d99fedc5
      Andy Wingo authored
      * module/language/tree-il/compile-cps2.scm (convert): Fix typo in "not"
        compilation.
      d99fedc5
    • Andy Wingo's avatar
      Fix intmap-add! transient bug · 0f082bd3
      Andy Wingo authored
      * module/language/cps/intmap.scm (intmap-add!): Fix a bug creating a
        transient branch out of a persistent branch.
      0f082bd3
    • Andy Wingo's avatar
      Register up cps2 compiler with language tower · 09869e78
      Andy Wingo authored
      * module/language/tree-il/compile-cps2.scm (compile-cps2): Rename from compile-cps.
      * module/language/cps2/spec.scm: New file.
      * module/Makefile.am (CPS2_LANG_SOURCES): Add spec.scm.
      * module/language/tree-il/spec.scm (tree-il): Declare compiler to cps2.
      09869e78
    • Andy Wingo's avatar
      cps2: Fix parse-cps for `prompt' · 7cd61e2b
      Andy Wingo authored
      * module/language/cps2.scm (parse-cps): Fix for `prompt'.
      7cd61e2b
    • Andy Wingo's avatar
      Add compiler from tree-il to cps2 · 773595f0
      Andy Wingo authored
      * module/language/tree-il/compile-cps2.scm: New file.
      * module/Makefile.am: Add the file to the build.
      773595f0
    • Andy Wingo's avatar
      Beginnings of CPS2 language. · 6485e892
      Andy Wingo authored
      The tentative plan is to replace CPS with CPS2, and to rename CPS2 to
      CPS.  We will add a pass to compile tree-il to CPS2, then work from
      the top down to replace the CPS compiler passes.
      
      * module/language/cps2.scm:
      * module/language/cps2/compile-cps.scm:
      * module/language/cps2/renumber.scm:
      * module/language/cps2/utils.scm: New files.
      
      * module/Makefile.am: Add new files to build.
      6485e892
    • Andy Wingo's avatar
      Add printers for <intmap> and <transient-intmap> · 6ffb6e69
      Andy Wingo authored
      * module/language/cps/intmap.scm (intmap->alist, print-intmap)
        (print-transient-intmap): New functions.
        Install the new functions as printers for <intmap> and <transient-intmap>.
      6ffb6e69
  6. 08 Apr, 2015 3 commits
    • Andy Wingo's avatar
      Add "cps2" experiment · eb9d4428
      Andy Wingo authored
      * module/Makefile.am: Add new file to makefile.
      * module/language/cps/simplify2.scm: New file.
      eb9d4428
    • Andy Wingo's avatar
      Transient intsets · 49cc76ab
      Andy Wingo authored
      * module/language/cps/intset.scm (make-atomic-reference)
        (get-atomic-reference, set-atomic-reference!): New functions.
        (*branch-size-with-edit*, *edit-index*): New constants.
        (<transient-intset>): New data type.
        (new-branch, clone-branch-and-set): Adapt to set edit field.
        (transient-intset, persistent-intset): New exports.
        (intset-add!): New interface, supporting "transient" intsets.
        (intset-ref, intset-next, intset-prev, intset-fold, intset-fold2):
        Work with transients.
      49cc76ab
    • Andy Wingo's avatar
      Add "transient" intmap interface · 95db5705
      Andy Wingo authored
      * module/language/cps/intmap.scm (make-atomic-reference):
        (get-atomic-reference, set-atomic-reference!): New helpers.
        (*branch-size-with-edit*, *edit-index*): Branches now have a trailing
        field, an atomic reference to their owner.
        (<transient-intmap>): New record type.  A mutable intmap.
        (new-branch): Set the "edit" field on the branch.
        (clone-branch-and-set): No editor for this field.
        (assert-readable!, writable-branch): New helpers.
        (transient-intmap, persistent-intmap): New exported functions.
        (intmap-add!): New function.
        (intmap-next, intmap-prev, intmap-ref): Work on transient intmaps.
        (intmap-fold): Persist the intmap before folding over it.
      95db5705
  7. 01 Apr, 2015 10 commits
    • Andy Wingo's avatar
      32-way branching in intmap.scm, not 16-way · cf512e32
      Andy Wingo authored
      * module/language/cps/intmap.scm (*branch-bits*): Switch to 32-way
        branching.  Marginally faster on lookup, and creation costs can be
        amortized via using the transient interface.  Marginal speedup for
        assembler.scm compilation.
      cf512e32
    • Andy Wingo's avatar
      Intset-next micro-optimizations · 048d5d34
      Andy Wingo authored
      * module/language/cps/intset.scm (intset-next): Micro-optimizations.
      048d5d34
    • Andy Wingo's avatar
      Add intset-fold, intset-fold2 · 9c8d2b85
      Andy Wingo authored
      * module/language/cps/intset.scm (intset-fold, intset-fold2): New
        functions.
      9c8d2b85
    • Andy Wingo's avatar
      Add intmap-fold. · b7668bd9
      Andy Wingo authored
      * module/language/cps/intmap.scm (intmap-fold): New function.
      b7668bd9
    • Andy Wingo's avatar
      Add intmap-prev · 2a24395a
      Andy Wingo authored
      * module/language/cps/intmap.scm (intmap-next): Starting index is
        optional.
        (intmap-prev): New function.
      2a24395a
    • Andy Wingo's avatar
      Default "meet" operator is meet-error for intmap · 33ab2838
      Andy Wingo authored
      * 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.
      33ab2838
    • Andy Wingo's avatar
      Remove "free" field of $fun · 50fcdfec
      Andy Wingo authored
      * 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.
      50fcdfec
    • Andy Wingo's avatar
      Replace $letrec with $rec · 34ff3af9
      Andy Wingo authored
      * 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.
      34ff3af9
    • Andy Wingo's avatar
      Precise range inference on <, <=, >=, > branches · 4ce18570
      Andy Wingo authored
      * module/language/cps/types.scm (restricted-comparison-ranges): New
        helper.
        (define-comparison-inferrer): New helper.
        (<, <=, >=, >): Infer ranges precisely.
      4ce18570
    • Andy Wingo's avatar
      Fix intmap bug for maps with only one element · ef7a71b7
      Andy Wingo authored
      * module/language/cps/intmap.scm (intmap-ref): Fix bug referencing
        values when there is only one value in the map.
      ef7a71b7
  8. 30 Mar, 2015 1 commit