0.9.13.36: global policy / null-lexenv confusion fix
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 9 Jun 2006 20:59:44 +0000 (20:59 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 9 Jun 2006 20:59:44 +0000 (20:59 +0000)
  * Do not store the global policy in null-lexenv, but include
    it in subsequent lexenvs. Fixes visibility of global policy
    in LOCALLY and MACROLET.
  * Also actually enable the SB-LDB in default build instead of
    just providing the framework to make this a good idea.
    (Accidentally left out from from 0.9.13.33)

NEWS
base-target-features.lisp-expr
src/compiler/lexenv.lisp
tests/compiler-2.impure-cload.lisp [new file with mode: 0644]
version.lisp-expr

diff --git a/NEWS b/NEWS
index 0583b27..b8a4906 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ changes in sbcl-0.9.14 relative to sbcl-0.9.13:
   * minor incompatible change: the :SB-LDB feature is now enabled by
     default, and DISABLE-DEBUGGER and ENABLE-DEBUGGER also affect
     the low-level debugger.
+  * bug fix: global optimization policy was not visible in LOCALLY and 
+    MACROLET forms.
   * bug fix: class objects can be used as specializers in methods.
     (reported by Pascal Costanza)
   * bug fix: native unparsing of pathnames with :DIRECTORY NIL failed
index a351693..6e8a691 100644 (file)
  ;; readtable configured so that the system sources can be read.
  ; :sb-show
 
- ;; Build SBCL with the old CMU CL low level debugger, "ldb". If are
- ;; aren't messing with SBCL at a very low level (e.g., trying to
- ;; diagnose GC problems, or trying to debug assembly code for a port
- ;; to a new CPU) you shouldn't need this.
- ; :sb-ldb
+ ;; Build SBCL with the old CMU CL low level debugger, "ldb". In the
+ ;; ideal world you would not need this unless you are messing with
+ ;; SBCL at a very low level (e.g., trying to diagnose GC problems, or
+ ;; trying to debug assembly code for a port to a new CPU). However,
+ ;; experience shows that sooner or later everyone lose()'s, in which
+ ;; case SB-LDB can at least provide an informative backtrace.
+ :sb-ldb
 
  ;; This isn't really a target Lisp feature at all, but controls
  ;; whether the build process produces an after-xc.core file. This
index 2e6dba6..54ef200 100644 (file)
@@ -21,7 +21,7 @@
                            (funs vars blocks tags
                                  type-restrictions
                                  lambda cleanup handled-conditions
-                                 disabled-package-locks policy)))
+                                 disabled-package-locks %policy)))
   ;; an alist of (NAME . WHAT), where WHAT is either a FUNCTIONAL (a
   ;; local function), a DEFINED-FUN, representing an
   ;; INLINE/NOTINLINE declaration, or a list (MACRO . <function>) (a
   (handled-conditions *handled-conditions*)
   ;; lexically disabled package locks (list of symbols)
   (disabled-package-locks *disabled-package-locks*)
-  ;; the current OPTIMIZE policy
-  (policy *policy* :type policy))
+  ;; the current OPTIMIZE policy. this is null in the null environment,
+  ;; and the global policy is stored in *POLICY*. (Because we want to
+  ;; be able to affect it from :WITH-COMPILATION-UNIT.) NIL here also
+  ;; works as a convenient null-lexenv identifier.
+  (%policy nil :type policy))
+
+(defun lexenv-policy (lexenv)
+  (or (lexenv-%policy lexenv) *policy*))
+
+(defun null-lexenv-p (lexenv)
+  (not (lexenv-%policy lexenv)))
 
 ;;; support for the idiom (in MACROEXPAND and elsewhere) that NIL is
 ;;; to be taken as a null lexical environment
@@ -70,9 +79,6 @@
     (null (make-null-lexenv))
     (lexenv x)))
 
-(defun null-lexenv-p (lexenv)
-  (equalp (coerce-to-lexenv lexenv) (make-null-lexenv)))
-
 (defun print-lexenv (lexenv stream level)
   (if (null-lexenv-p lexenv)
       (print-unreadable-object (lexenv stream)
diff --git a/tests/compiler-2.impure-cload.lisp b/tests/compiler-2.impure-cload.lisp
new file mode 100644 (file)
index 0000000..8c7a3a1
--- /dev/null
@@ -0,0 +1,55 @@
+;;;; -*- lisp -*-
+
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; While most of SBCL is derived from the CMU CL system, the test
+;;;; files (like this one) were written from scratch after the fork
+;;;; from CMU CL.
+;;;;
+;;;; This software is in the public domain and is provided with
+;;;; absolutely no warranty. See the COPYING and CREDITS files for
+;;;; more information.
+
+(cl:in-package :cl-user)
+
+;;;; recognize self-calls
+(declaim (optimize speed))
+
+;;;; These three forms should be equivalent.
+
+;;;; This used to be a bug in the handling of null-lexenv vs toplevel
+;;;; policy: LOCALLY and MACROLET hid the toplevel policy from view.
+
+(locally
+    (defun foo (n)
+      (frob 'foo)
+      (if (<= n 0)
+          n
+          (foo (1- n)))))
+
+(progn
+  (defun bar (n)
+    (frob 'bar)
+    (if (<= n 0)
+        n
+        (bar (1- n)))))
+
+(macrolet ()
+  (defun quux (n)
+    (frob 'quux)
+    (if (<= n 0)
+        n
+        (quux (1- n)))))
+
+(defun frob (x)
+  (setf (fdefinition x) (constantly 13)))
+
+(defun test ()
+  (list (foo 1) (bar 1) (quux 1)))
+
+(assert (equal (test) '(0 0 0)))
+(assert (equal (test) '(13 13 13))) ; sanity check
+
+(write-line "//compiler-2.impure.cload.lisp")
+
index fafd8bd..e42e9c6 100644 (file)
@@ -17,4 +17,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".)
-"0.9.13.35"
+"0.9.13.36"