X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fknownfun.lisp;h=0baae50fa32de15ebe5a32fbe519650c2a6b76f2;hb=dec94b039e8ec90baf21463df839a6181de606f6;hp=e39837204d627ad95973306aa4fac88844dce9cb;hpb=82e0a78df47685519b12683f495d7ae19e07d3cf;p=sbcl.git diff --git a/src/compiler/knownfun.lisp b/src/compiler/knownfun.lisp index e398372..0baae50 100644 --- a/src/compiler/knownfun.lisp +++ b/src/compiler/knownfun.lisp @@ -14,6 +14,8 @@ (in-package "SB!C") +(/show0 "knownfun.lisp 17") + ;;; IR1 boolean function attributes ;;; ;;; There are a number of boolean attributes of known functions which we like @@ -97,11 +99,7 @@ (predicate-type nil :type (or ctype null)) ;; If non-null, use this function to annotate the known call for the byte ;; compiler. If it returns NIL, then change the call to :full. - (byte-annotate nil :type (or function null)) - ;; If non-null, use this function to generate the byte code for this known - ;; call. This function can only give up if there is a byte-annotate function - ;; that arranged for the functional to be pushed onto the stack. - (byte-compile nil :type (or function null))) + (byte-annotate nil :type (or function null))) (defprinter (function-info) (transforms :test transforms) @@ -111,19 +109,18 @@ (ir2-convert :test ir2-convert) (templates :test templates) (predicate-type :test predicate-type) - (byte-annotate :test byte-annotate) - (byte-compile :test byte-compile)) + (byte-annotate :test byte-annotate)) ;;;; interfaces to defining macros -;;; The TRANSFORM structure represents an IR1 transform. -(defstruct 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 ;; lambda, or throws out. (function (required-argument) :type function) - ;; string used in efficency notes + ;; string used in efficiency notes (note (required-argument) :type string) ;; T if we should emit a failure note even if SPEED=INHIBIT-WARNINGS. (important nil :type (member t nil)) @@ -167,8 +164,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) @@ -176,14 +187,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))))) @@ -233,3 +248,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")