Fix a bug in walk-procedure that manifested itself in sf/subst.
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 4 May 1990 15:15:18 +0000 (15:15 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 4 May 1990 15:15:18 +0000 (15:15 +0000)
The free variables in closures are determined exclusively by the
closure block, not by the free variables of the procedure block.

v7/src/compiler/fgopt/subfre.scm

index 48d8585480ecb87fa2f7b4292486817f21d13f7a..41d37b9fd60d7e37c058fc538858e03338814fcd 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/fgopt/subfre.scm,v 1.5 1990/05/03 15:09:24 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/fgopt/subfre.scm,v 1.6 1990/05/04 15:15:18 jinx Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -74,32 +74,31 @@ MIT in each case. |#
 
 (define (walk-procedure proc)
   (define (default)
-    ;; This should be OK for open procedures, but perhaps
-    ;; we should look at the closure block for closures.
     (list-transform-negative
        (block-free-variables (procedure-block proc))
       lvalue-integrated?))
 
+  (define (closure)
+    (block-bound-variables
+     (block-shared-block (procedure-closing-block proc))))
+
   (if (or (not (procedure/closure? proc))
          (procedure/trivial-closure? proc))
       (default)
       (let ((how (procedure-closure-cons proc)))
        (case (car how)
          ((NORMAL)
-          (default))
+          (closure))
          ((DESCENDANT)
-          ;; This will automatically imply saving the ancestor
+          ;; This should automatically imply saving the ancestor
           ;; for stack overwrites since that is how the free
           ;; variables will be obtained.
-          ;; Is this really true?
-          ;; What if some of them are in registers?
-          ;; What if it is a descendant of an indirected procedure?
-          (default))
+          (closure))
          ((INDIRECTED)
           ;; In reality, only the indirection variable or the default
           ;; set is needed, depending on where the reference occurs.
           ;; This is always safe, however.
-          (cons (cdr how) (default)))
+          (cons (cdr how) (closure)))
          (else
           (error "walk-procedure: Unknown closure method" proc))))))