X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fir1tran-lambda.lisp;h=a15394aefd8cfe375a3270c87179cfc16cc9002e;hb=670d28c10c178142146f6916c5fa0967732f3a8f;hp=88f6aba12fc874fee1544f41e3573e43796d4a7e;hpb=7c16e6bf7a5559ffd81ea0816c5a44989709f51d;p=sbcl.git diff --git a/src/compiler/ir1tran-lambda.lisp b/src/compiler/ir1tran-lambda.lisp index 88f6aba..a15394a 100644 --- a/src/compiler/ir1tran-lambda.lisp +++ b/src/compiler/ir1tran-lambda.lisp @@ -537,6 +537,12 @@ (arg-vals n-context) (arg-vals n-count)) + ;; The reason for all the noise with + ;; STACK-GROWS-DOWNWARD-NOT-UPWARD is to enable generation of + ;; slightly more efficient code on x86oid processors. (We can + ;; hoist the negation of the index outside the main parsing loop + ;; and take advantage of the base+index+displacement addressing + ;; mode on x86oids.) (when (optional-dispatch-keyp res) (let ((n-index (gensym "N-INDEX-")) (n-key (gensym "N-KEY-")) @@ -547,8 +553,15 @@ (policy *lexenv* (zerop safety)))) (found-allow-p nil)) - (temps `(,n-index (1- ,n-count)) n-key n-value-temp) - (body `(declare (fixnum ,n-index) (ignorable ,n-key ,n-value-temp))) + (temps #!-stack-grows-downward-not-upward + `(,n-index (1- ,n-count)) + #!+stack-grows-downward-not-upward + `(,n-index (- (1- ,n-count))) + #!-stack-grows-downward-not-upward n-value-temp + #!-stack-grows-downward-not-upward n-key) + (body `(declare (fixnum ,n-index) + #!-stack-grows-downward-not-upward + (ignorable ,n-value-temp ,n-key))) (collect ((tests)) (dolist (key keys) @@ -589,6 +602,7 @@ (%odd-key-args-error))) (body + #!-stack-grows-downward-not-upward `(locally (declare (optimize (safety 0))) (loop @@ -597,7 +611,16 @@ (decf ,n-index) (setq ,n-key (%more-arg ,n-context ,n-index)) (decf ,n-index) - (cond ,@(tests))))) + (cond ,@(tests)))) + #!+stack-grows-downward-not-upward + `(locally (declare (optimize (safety 0))) + (loop + (when (plusp ,n-index) (return)) + (multiple-value-bind (,n-value-temp ,n-key) + (%more-kw-arg ,n-context ,n-index) + (declare (ignorable ,n-value-temp ,n-key)) + (incf ,n-index 2) + (cond ,@(tests)))))) (unless allowp (body `(when (and ,n-losep (not ,n-allowp)) @@ -955,9 +978,11 @@ ;;; current compilation policy. Note that FUN may be a ;;; LAMBDA-WITH-LEXENV, so we may have to augment the environment to ;;; reflect the state at the definition site. -(defun ir1-convert-inline-lambda (fun &key - (source-name '.anonymous.) - debug-name) +(defun ir1-convert-inline-lambda (fun + &key + (source-name '.anonymous.) + debug-name + system-lambda) (destructuring-bind (decls macros symbol-macros &rest body) (if (eq (car fun) 'lambda-with-lexenv) (cdr fun) @@ -970,7 +995,8 @@ `(,(car x) . (macro . ,(coerce (cdr x) 'function)))) macros) - :policy (lexenv-policy *lexenv*)))) + :policy (lexenv-policy *lexenv*))) + (*allow-instrumenting* (and (not system-lambda) *allow-instrumenting*))) (ir1-convert-lambda `(lambda ,@body) :source-name source-name :debug-name debug-name)))) @@ -1031,41 +1057,31 @@ "previous declaration" "previous definition")))) -;;; Convert a lambda doing all the basic stuff we would do if we were -;;; converting a DEFUN. In the old CMU CL system, this was used both -;;; by the %DEFUN translator and for global inline expansion, but -;;; since sbcl-0.pre7.something %DEFUN does things differently. -;;; FIXME: And now it's probably worth rethinking whether this -;;; function is a good idea. -;;; -;;; Unless a :INLINE function, we temporarily clobber the inline -;;; expansion. This prevents recursive inline expansion of -;;; opportunistic pseudo-inlines. -(defun ir1-convert-lambda-for-defun (lambda var expansion converter) - (declare (cons lambda) (function converter) (type defined-fun var)) - (let ((var-expansion (defined-fun-inline-expansion var))) - (unless (eq (defined-fun-inlinep var) :inline) - (setf (defined-fun-inline-expansion var) nil)) - (let* ((name (leaf-source-name var)) - (fun (funcall converter lambda - :source-name name)) - (fun-info (info :function :info name))) - (setf (functional-inlinep fun) (defined-fun-inlinep var)) - (assert-new-definition var fun) - (setf (defined-fun-inline-expansion var) var-expansion) - ;; If definitely not an interpreter stub, then substitute for - ;; any old references. - (unless (or (eq (defined-fun-inlinep var) :notinline) - (not *block-compile*) - (and fun-info - (or (fun-info-transforms fun-info) - (fun-info-templates fun-info) - (fun-info-ir2-convert fun-info)))) - (substitute-leaf fun var) - ;; If in a simple environment, then we can allow backward - ;; references to this function from following top level forms. - (when expansion (setf (defined-fun-functional var) fun))) - fun))) +;;; Used for global inline expansion. Earlier something like this was +;;; used by %DEFUN too. FIXME: And now it's probably worth rethinking +;;; whether this function is a good idea at all. +(defun ir1-convert-inline-expansion (name expansion var inlinep info) + ;; Unless a :INLINE function, we temporarily clobber the inline + ;; expansion. This prevents recursive inline expansion of + ;; opportunistic pseudo-inlines. + (unless (eq inlinep :inline) + (setf (defined-fun-inline-expansion var) nil)) + (let ((fun (ir1-convert-inline-lambda expansion + :source-name name + ;; prevent instrumentation of + ;; known function expansions + :system-lambda (and info t)))) + (setf (functional-inlinep fun) inlinep) + (assert-new-definition var fun) + (setf (defined-fun-inline-expansion var) expansion) + ;; substitute for any old references + (unless (or (not *block-compile*) + (and info + (or (fun-info-transforms info) + (fun-info-templates info) + (fun-info-ir2-convert info)))) + (substitute-leaf fun var)) + fun)) ;;; the even-at-compile-time part of DEFUN ;;;