X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fknownfun.lisp;h=3b38e95a331d0f92e5f7b9b6c1685848c38c941a;hb=872175cd9cb5b4966a36d4bd92421cc407a0355b;hp=3d2ee4fbdeca79672ba2a14fc8059420e22baf96;hpb=a530bbe337109d898d5b4a001fc8f1afa3b5dc39;p=sbcl.git diff --git a/src/compiler/knownfun.lisp b/src/compiler/knownfun.lisp index 3d2ee4f..3b38e95 100644 --- a/src/compiler/knownfun.lisp +++ b/src/compiler/knownfun.lisp @@ -14,8 +14,7 @@ (in-package "SB!C") -(file-comment - "$Header$") +(/show0 "knownfun.lisp 17") ;;; IR1 boolean function attributes ;;; @@ -119,18 +118,18 @@ ;;;; interfaces to defining macros -;;; The TRANSFORM structure represents an IR1 transform. -(defstruct transform - ;; The function-type which enables this transform. +;;; an IR1 transform +(defstruct (transform (:copier nil)) + ;; the function-type which enables this transform (type (required-argument) :type ctype) - ;; The transformation function. Takes the Combination node and Returns a + ;; the transformation function. Takes the COMBINATION node and returns a ;; lambda, or throws out. (function (required-argument) :type function) - ;; String used in efficency notes. + ;; string used in efficency notes (note (required-argument) :type string) - ;; T if we should spew a failure note even if speed=brevity. + ;; T if we should emit a failure note even if SPEED=INHIBIT-WARNINGS. (important nil :type (member t nil)) - ;; Usable for byte code, native code, or both. + ;; usable for byte code, native code, or both (when :native :type (member :byte :native :both))) (defprinter (transform) type note important when) @@ -170,8 +169,22 @@ (info (make-function-info :attributes attributes :derive-type derive-type :optimizer optimizer)) - (target-env (or *backend-info-environment* *info-environment*))) + (target-env *info-environment*)) (dolist (name names) + (let ((old-function-info (info :function :info name))) + (when old-function-info + ;; This is handled as an error because it's generally a bad + ;; thing to blow away all the old optimization stuff. It's + ;; also a potential source of sneaky bugs: + ;; DEFKNOWN FOO + ;; DEFTRANSFORM FOO + ;; DEFKNOWN FOO ; possibly hidden inside some macroexpansion + ;; ; Now the DEFTRANSFORM doesn't exist in the target Lisp. + ;; However, it's continuable because it might be useful to do + ;; it when testing new optimization stuff interactively. + (cerror "Go ahead, overwrite it." + "~@" + old-function-info name))) (setf (info :function :type name target-env) ctype) (setf (info :function :where-from name target-env) :declared) (setf (info :function :kind name target-env) :function) @@ -179,14 +192,18 @@ names) ;;; Return the FUNCTION-INFO for NAME or die trying. Since this is -;;; used by people who want to modify the info, and the info may be +;;; used by callers who want to modify the info, and the info may be ;;; shared, we copy it. We don't have to copy the lists, since each ;;; function that has generators or transforms has already been ;;; through here. (declaim (ftype (function (t) function-info) function-info-or-lose)) (defun function-info-or-lose (name) - (let ((*info-environment* (or *backend-info-environment* - *info-environment*))) + (let (;; FIXME: Do we need this rebinding here? It's a literal + ;; translation of the old CMU CL rebinding to + ;; (OR *BACKEND-INFO-ENVIRONMENT* *INFO-ENVIRONMENT*), + ;; and it's not obvious whether the rebinding to itself is + ;; needed that SBCL doesn't need *BACKEND-INFO-ENVIRONMENT*. + (*info-environment* *info-environment*)) (let ((old (info :function :info name))) (unless old (error "~S is not a known function." name)) (setf (info :function :info name) (copy-function-info old))))) @@ -236,3 +253,5 @@ (let ((cont (nth (1- n) (combination-args call)))) (when (and cont (constant-continuation-p cont)) (specifier-type (continuation-value cont)))))) + +(/show0 "knownfun.lisp end of file")