1.0.48.14: more conservative global variable conversion
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 12 May 2011 10:42:20 +0000 (10:42 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Thu, 12 May 2011 10:42:20 +0000 (10:42 +0000)
 Based on patch by Roman Marynchak.

 Fixes lp#722734.

 * Modify IR1-CONVERT-VAR to emit SYMBOL-VALUE wrapper
   for all global variables except those which are
   ALWAYS-BOUND.

 * Modify IR1-STEP-FORM-P to return false for SYMBOL-VALUE
   with constant argument, now that virtually all global
   variables are accessed with a function call (which gets
   converted via a VOP, so the final machine code remains
   the same.)

NEWS
src/compiler/ir1tran.lisp
tests/compiler.pure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 5a9955c..353fe71 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,10 @@ changes relative to sbcl-1.0.48:
   * bug fix: blocking reads from FIFOs created by RUN-PROGRAM were
     uninterruptible, as well as blocking reads from socket streams created
     with for which :SERVE-EVENTS NIL. (regression from 1.0.42.43)
+  * bug fix: SET-SYNTAX-FROM-CHAR now removes dispatch-macro character syntax
+    from the to-char if the from-char is not a dispatch-macro character.
+  * bug fix: references to undefined variables in function calls that are
+    optimized away now signal a runtime error. (lp#722734)
 
 changes in sbcl-1.0.48 relative to sbcl-1.0.47:
   * incompatible change: SB!KERNEL:INSTANCE-LAMBDA, deprecated for over five
index 3ad34a6..81b68f7 100644 (file)
 (defun ir1-convert-var (start next result name)
   (declare (type ctran start next) (type (or lvar null) result) (symbol name))
   (let ((var (or (lexenv-find name vars) (find-free-var name))))
-    (if (and (global-var-p var) (not result))
-        ;; KLUDGE: If the reference is dead, convert using SYMBOL-VALUE
-        ;; which is not flushable, so that unbound dead variables signal
-        ;; an error (bug 412).
+    (if (and (global-var-p var) (not (info :variable :always-bound name)))
+        ;; KLUDGE: If the variable may be unbound, convert using SYMBOL-VALUE
+        ;; which is not flushable, so that unbound dead variables signal an
+        ;; error (bug 412, lp#722734): checking for null RESULT is not enough,
+        ;; since variables can become dead due to later optimizations.
         (ir1-convert start next result
                      (if (eq (global-var-kind var) :global)
                          `(symbol-global-value ',name)
 ;;; instrumentation for?
 (defun step-form-p (form)
   (flet ((step-symbol-p (symbol)
-           (not (member (symbol-package symbol)
-                        (load-time-value
-                         ;; KLUDGE: packages we're not interested in
-                         ;; stepping.
-                         (mapcar #'find-package '(sb!c sb!int sb!impl
-                                                  sb!kernel sb!pcl)))))))
+           (and (not (member (symbol-package symbol)
+                             (load-time-value
+                              ;; KLUDGE: packages we're not interested in
+                              ;; stepping.
+                              (mapcar #'find-package '(sb!c sb!int sb!impl
+                                                       sb!kernel sb!pcl)))))
+                ;; Consistent treatment of *FOO* vs (SYMBOL-VALUE '*FOO*):
+                ;; we insert calls to SYMBOL-VALUE for most non-lexical
+                ;; variable references in order to avoid them being elided
+                ;; if the value is unused.
+                (or (not (member symbol '(symbol-value symbol-global-value)))
+                    (not (constantp (second form)))))))
     (and *allow-instrumenting*
          (policy *lexenv* (= insert-step-conditions 3))
          (listp form)
index f6dcabf..3ff8d01 100644 (file)
     (nconc cycle cycle)
     (compile nil `(lambda (x)
                     (member x ',cycle)))))
+
+(with-test (:name :bug-722734)
+  (assert (raises-error?
+            (funcall (compile
+                      nil
+                      '(lambda ()
+                        (eql (make-array 6)
+                         (list unbound-variable-1 unbound-variable-2))))))))
index b03ad4f..50dfbdf 100644 (file)
@@ -20,4 +20,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.48.13"
+"1.0.48.14"