Update of /cvsroot/sbcl/sbcl/src/compiler
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv10093/src/compiler
Modified Files:
info-functions.lisp proclaim.lisp
Log Message:
1.0.42.28: package locks to guard against DEFMACRO -> DEFUN and vice-versa
* Fixes lp#576637.
* PROCLAIM-AS-FUN-NAME is called quite often at compile time, but actually
does something we care about only rarely -- assert the lock only when
something changes, so that
(WITHOUT-PACKAGE-LOCKS (DEFUN LOCKED:FOO ...))
keeps working for the common case.
* Similar logic in %DEFMACRO.
* Some tests adjusted.
Index: info-functions.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/compiler/info-functions.lisp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- info-functions.lisp 22 Jun 2009 08:05:46 -0000 1.34
+++ info-functions.lisp 3 Sep 2010 13:01:34 -0000 1.35
@@ -41,15 +41,28 @@
;; legal name?
(check-fun-name name)
- ;; scrubbing old data I: possible collision with old definition
- (when (fboundp name)
- (ecase (info :function :kind name)
- (:function) ; happy case
- ((nil)) ; another happy case
- (:macro ; maybe-not-so-good case
- (compiler-style-warn "~S was previously defined as a macro." name)
- (setf (info :function :where-from name) :assumed)
- (clear-info :function :macro-function name))))
+
+ ;; KLUDGE: This can happen when eg. compiling a NAMED-LAMBDA, and isn't
+ ;; guarded against elsewhere -- so we want to assert package locks here. The
+ ;; reason we do it only when stomping on existing stuff is because we want
+ ;; to keep
+ ;; (WITHOUT-PACKAGE-LOCKS (DEFUN LOCKED:FOO ...))
+ ;; viable, which requires no compile-time violations in the harmless cases.
+ (with-single-package-locked-error ()
+ (flet ((assert-it ()
+ (assert-symbol-home-package-unlocked name "proclaiming ~S as a function")))
+
+ (let ((kind (info :function :kind name)))
+ ;; scrubbing old data I: possible collision with a macro
+ (when (and (fboundp name) (eq :macro kind))
+ (assert-it)
+ (compiler-style-warn "~S was previously defined as a macro." name)
+ (setf (info :function :where-from name) :assumed)
+ (clear-info :function :macro-function name))
+
+ (unless (eq :function kind)
+ (assert-it)
+ (setf (info :function :kind name) :function)))))
;; scrubbing old data II: dangling forward references
;;
@@ -58,11 +71,9 @@
;; in EVAL-WHEN (:COMPILE) inside something like DEFSTRUCT, in which
;; case it's reasonable style. Either way, NAME is no longer a free
;; function.)
- (when (boundp '*free-funs*) ; when compiling
+ (when (boundp '*free-funs*) ; when compiling
(remhash name *free-funs*))
- ;; recording the ordinary case
- (setf (info :function :kind name) :function)
(note-if-setf-fun-and-macro name)
(values))
Index: proclaim.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/compiler/proclaim.lisp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- proclaim.lisp 30 Jul 2009 14:10:39 -0000 1.41
+++ proclaim.lisp 3 Sep 2010 13:01:34 -0000 1.42
@@ -226,29 +226,29 @@
(error "not a function type: ~S" (first args)))
(dolist (name (rest args))
(with-single-package-locked-error
- (:symbol name "globally declaring the ftype of ~A"))
- (when (eq (info :function :where-from name) :declared)
- (let ((old-type (info :function :type name)))
- (when (type/= ctype old-type)
- ;; FIXME: changing to FTYPE-PROCLAMATION-MISMATCH
- ;; broke late-proclaim.lisp.
- (style-warn
- "~@<new FTYPE proclamation for ~S~@:_ ~S~@:_~
+ (:symbol name "globally declaring the ftype of ~A")
+ (when (eq (info :function :where-from name) :declared)
+ (let ((old-type (info :function :type name)))
+ (when (type/= ctype old-type)
+ ;; FIXME: changing to FTYPE-PROCLAMATION-MISMATCH
+ ;; broke late-proclaim.lisp.
+ (style-warn
+ "~@<new FTYPE proclamation for ~S~@:_ ~S~@:_~
does not match the old FTYPE proclamation:~@:_ ~S~@:>"
- name (type-specifier ctype) (type-specifier old-type)))))
+ name (type-specifier ctype) (type-specifier old-type)))))
- ;; Now references to this function shouldn't be warned
- ;; about as undefined, since even if we haven't seen a
- ;; definition yet, we know one is planned.
- ;;
- ;; Other consequences of we-know-you're-a-function-now
- ;; are appropriate too, e.g. any MACRO-FUNCTION goes away.
- (proclaim-as-fun-name name)
- (note-name-defined name :function)
+ ;; Now references to this function shouldn't be warned
+ ;; about as undefined, since even if we haven't seen a
+ ;; definition yet, we know one is planned.
+ ;;
+ ;; Other consequences of we-know-you're-a-function-now
+ ;; are appropriate too, e.g. any MACRO-FUNCTION goes away.
+ (proclaim-as-fun-name name)
+ (note-name-defined name :function)
- ;; the actual type declaration
- (setf (info :function :type name) ctype
- (info :function :where-from name) :declared)))
+ ;; the actual type declaration
+ (setf (info :function :type name) ctype
+ (info :function :where-from name) :declared))))
(push raw-form *queued-proclaims*)))
(freeze-type
(dolist (type args)
|