Compute-contification also visits body
authorAndy Wingo <wingo@pobox.com>
Sun, 24 Nov 2013 12:59:18 +0000 (13:59 +0100)
committerAndy Wingo <wingo@pobox.com>
Mon, 25 Nov 2013 19:07:53 +0000 (20:07 +0100)
* module/language/cps/contification.scm (compute-contification): If we
  decide to contify, don't forget to visit the body.  Should make
  contification converge faster.

module/language/cps/contification.scm

index 7a9252e..d78a4b4 100644 (file)
                            (($ $cont _ ($ $kclause arity body))
                             ...))))
                   ...)
-                 (unless (contify-funs term-k sym self tail-k arity body)
-                   (for-each visit-fun fun)))))))
+                 (if (contify-funs term-k sym self tail-k arity body)
+                     (for-each (cut for-each visit-cont <>) body)
+                     (for-each visit-fun fun)))))))
          (visit-term body term-k)
          (for-each visit-component
                    (split-components (map list names syms funs))))
             (if (and=> (bound-symbol k)
                        (lambda (sym)
                          (contify-fun term-k sym self tail-k arity body)))
-                (elide-function! k (lookup-cont k cont-table))
+                (begin
+                  (elide-function! k (lookup-cont k cont-table))
+                  (for-each visit-cont body))
                 (visit-fun exp)))
            (_ #t)))))