# HG changeset patch # User Aidan Kehoe # Date 1317715334 -3600 # Node ID 0b6e7ae1e78f6d81a1aab4a45315f53c894d81a6 # Parent 071b810ceb18d441cef3e92b141882ab42bc62e3 Update a comment with a better understanding of the optimizer, bytecomp.el lisp/ChangeLog addition: 2011-10-04 Aidan Kehoe * bytecomp.el (byte-compile-funcall): Correct a comment here, explaining why the optimizer doesn't expand (funcall #'(lambda ...)) in some contexts with inline labels, and why it's reasonable to do it here. diff -r 071b810ceb18 -r 0b6e7ae1e78f lisp/ChangeLog --- a/lisp/ChangeLog Mon Oct 03 20:16:14 2011 +0100 +++ b/lisp/ChangeLog Tue Oct 04 09:02:14 2011 +0100 @@ -1,3 +1,10 @@ +2011-10-04 Aidan Kehoe + + * bytecomp.el (byte-compile-funcall): + Correct a comment here, explaining why the optimizer doesn't + expand (funcall #'(lambda ...)) in some contexts with inline + labels, and why it's reasonable to do it here. + 2011-10-03 Aidan Kehoe * simple.el (handle-pre-motion-command-current-command-is-motion): diff -r 071b810ceb18 -r 0b6e7ae1e78f lisp/bytecomp.el --- a/lisp/bytecomp.el Mon Oct 03 20:16:14 2011 +0100 +++ b/lisp/bytecomp.el Tue Oct 04 09:02:14 2011 +0100 @@ -4164,9 +4164,23 @@ (not (eq (setq form (cons (cadadr form) (cddr form))) (setq form (byte-compile-unfold-lambda form)))) (prog1 nil (setq form `(funcall #',(car form) ,@(cdr form)))))) - ;; Sometimes the optimizer fails to unfold well-formed calls of the - ;; form (funcall #'(lambda ...)); since we need it to do this for - ;; (declare (inline ...)) to work properly with labels, force that here. + ;; The byte-compile part of the #'labels implementation, above, + ;; happens after macroexpansion and after the source optimizer has + ;; done its thing. When labels are to be made inline we can have code + ;; that looks like (funcall #'(lambda ...) ...), when the code that + ;; the optimizer saw looked like (funcall # + ;; ...). + ;; + ;; So, the optimizer doesn't have the opportunity to transform the + ;; former to (let (...) ...), and it's reasonable to do that here (since + ;; the labels implementation doesn't change other code that would need + ;; running through the optimizer; the lambda itself has already been + ;; through the optimizer). + ;; + ;; Equally reasonable, and conceptually a bit clearer, would be to do + ;; the transformation to (funcall #'(lambda ...) ...) in the + ;; byte-optimizer, breaking most of the #'sublis calls out of the + ;; byte-compile method. (byte-compile-form form) (mapc 'byte-compile-form (cdr form)) (byte-compile-out 'byte-call (length (cdr (cdr form))))))