guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/02: Fix bug in closure conversion


From: Andy Wingo
Subject: [Guile-commits] 01/02: Fix bug in closure conversion
Date: Sat, 11 Jan 2020 05:52:10 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit 8fcfcabec8b2aea1cb805feeeab20e742294ba4e
Author: Andy Wingo <address@hidden>
AuthorDate: Sat Jan 11 11:48:36 2020 +0100

    Fix bug in closure conversion
    
    * module/language/cps/closure-conversion.scm (convert-one):
      Strongly-connected components of letrec bindings that do not share a
      closure may include member functions that have a single free variable,
      or even no free variables as a result of free variable pruning.
      Handle this case instead of erroring out.  Thanks to Stefan Israelsson
      Tampe for the report.
---
 module/language/cps/closure-conversion.scm | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/module/language/cps/closure-conversion.scm 
b/module/language/cps/closure-conversion.scm
index 1452212..17a81f6 100644
--- a/module/language/cps/closure-conversion.scm
+++ b/module/language/cps/closure-conversion.scm
@@ -1,6 +1,6 @@
 ;;; Continuation-passing style (CPS) intermediate language (IL)
 
-;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2020 Free Software Foundation, Inc.
 
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -596,6 +596,17 @@ term."
              ($continue ktag0 src
                ($primcall 'allocate-words/immediate `(closure . ,(+ nfree 2))
                           ())))))
+        (#(#t 0)
+         (with-cps cps
+           (build-term ($continue k src ($const #f)))))
+        (#(#t 1)
+         ;; A well-known closure of one free variable is replaced
+         ;; at each use with the free variable itself, so we don't
+         ;; need a binding at all; and yet, the continuation
+         ;; expects one value, so give it something.  DCE should
+         ;; clean up later.
+         (with-cps cps
+           (build-term ($continue k src ($const #f)))))
         (#(#t 2)
          ;; Well-known closure with two free variables; the closure is a
          ;; pair.
@@ -666,17 +677,6 @@ bound to @var{var}, and continue to @var{k}."
           (#(#f 0)
            (with-cps cps
              (build-term ($continue k src ($const-fun kfun)))))
-          (#(#t 0)
-           (with-cps cps
-             (build-term ($continue k src ($const #f)))))
-          (#(#t 1)
-           ;; A well-known closure of one free variable is replaced
-           ;; at each use with the free variable itself, so we don't
-           ;; need a binding at all; and yet, the continuation
-           ;; expects one value, so give it something.  DCE should
-           ;; clean up later.
-           (with-cps cps
-             (build-term ($continue k src ($const #f)))))
           (#(well-known? nfree)
            ;; A bit of a mess, but beta conversion should remove the
            ;; final $values if possible.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]