From a4882e3023fdd5e777169a4cbede33605281173c Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 9 Jun 2006 20:59:44 +0000 Subject: [PATCH] 0.9.13.36: global policy / null-lexenv confusion fix * 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 | 2 ++ base-target-features.lisp-expr | 12 ++++---- src/compiler/lexenv.lisp | 18 ++++++++---- tests/compiler-2.impure-cload.lisp | 55 ++++++++++++++++++++++++++++++++++++ version.lisp-expr | 2 +- 5 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 tests/compiler-2.impure-cload.lisp diff --git a/NEWS b/NEWS index 0583b27..b8a4906 100644 --- 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 diff --git a/base-target-features.lisp-expr b/base-target-features.lisp-expr index a351693..6e8a691 100644 --- a/base-target-features.lisp-expr +++ b/base-target-features.lisp-expr @@ -107,11 +107,13 @@ ;; 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 diff --git a/src/compiler/lexenv.lisp b/src/compiler/lexenv.lisp index 2e6dba6..54ef200 100644 --- a/src/compiler/lexenv.lisp +++ b/src/compiler/lexenv.lisp @@ -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 . ) (a @@ -60,8 +60,17 @@ (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 index 0000000..8c7a3a1 --- /dev/null +++ b/tests/compiler-2.impure-cload.lisp @@ -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") + diff --git a/version.lisp-expr b/version.lisp-expr index fafd8bd..e42e9c6 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4