- (declare (special *boot-state* *the-class-standard-generic-function*))
- (cond ((symbolp fcn)
- (set-fun-name (symbol-function fcn) new-name))
- ((funcallable-instance-p fcn)
- (if (if (eq *boot-state* 'complete)
- (typep fcn 'generic-function)
- (eq (class-of fcn) *the-class-standard-generic-function*))
- (setf (%funcallable-instance-info fcn 1) new-name)
- (bug "unanticipated function type"))
- fcn)
- (t
- ;; pw-- This seems wrong and causes trouble. Tests show
- ;; that loading CL-HTTP resulted in ~5400 closures being
- ;; passed through this code of which ~4000 of them pointed
- ;; to but 16 closure-functions, including 1015 each of
- ;; DEFUN MAKE-OPTIMIZED-STD-WRITER-METHOD-FUNCTION
- ;; DEFUN MAKE-OPTIMIZED-STD-READER-METHOD-FUNCTION
- ;; DEFUN MAKE-OPTIMIZED-STD-BOUNDP-METHOD-FUNCTION.
- ;; Since the actual functions have been moved by PURIFY
- ;; to memory not seen by GC, changing a pointer there
- ;; not only clobbers the last change but leaves a dangling
- ;; pointer invalid after the next GC. Comments in low.lisp
- ;; indicate this code need do nothing. Setting the
- ;; function-name to NIL loses some info, and not changing
- ;; it loses some info of potential hacking value. So,
- ;; lets not do this...
- #+nil
- (let ((header (%closure-fun fcn)))
- (setf (%simple-fun-name header) new-name))
-
- ;; XXX Maybe add better scheme here someday.
- fcn)))
-
-(defun intern-fun-name (name)
- (cond ((symbolp name) name)
- ((listp name)
- (intern (let ((*package* *pcl-package*)
- (*print-case* :upcase)
- (*print-pretty* nil)
- (*print-gensym* t))
- (format nil "~S" name))
- *pcl-package*))))
+ (when (valid-function-name-p fun)
+ (setq fun (fdefinition fun)))
+ (typecase fun
+ (%method-function (setf (%method-function-name fun) new-name))
+ #+sb-eval
+ (sb-eval:interpreted-function
+ (setf (sb-eval:interpreted-function-name fun) new-name))
+ (funcallable-instance ;; KLUDGE: probably a generic function...
+ (cond ((if (eq **boot-state** 'complete)
+ (typep fun 'generic-function)
+ (eq (class-of fun) *the-class-standard-generic-function*))
+ (setf (%funcallable-instance-info fun 2) new-name))
+ (t
+ (bug "unanticipated function type")))))
+ ;; Fixup name-to-function mappings in cases where the function
+ ;; hasn't been defined by DEFUN. (FIXME: is this right? This logic
+ ;; comes from CMUCL). -- CSR, 2004-12-31
+ (when (and (consp new-name)
+ (member (car new-name) '(slow-method fast-method slot-accessor)))
+ (setf (fdefinition new-name) fun))
+ fun)