Mercurial > hg > xemacs-beta
changeset 5577:0b6e7ae1e78f
Update a comment with a better understanding of the optimizer, bytecomp.el
lisp/ChangeLog addition:
2011-10-04 Aidan Kehoe <kehoea@parhasard.net>
* 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.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 04 Oct 2011 09:02:14 +0100 |
parents | 071b810ceb18 |
children | 4a6f90020a59 |
files | lisp/ChangeLog lisp/bytecomp.el |
diffstat | 2 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <kehoea@parhasard.net> + + * 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 <kehoea@parhasard.net> * simple.el (handle-pre-motion-command-current-command-is-motion):
--- 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 #<compiled-function ...> + ;; ...). + ;; + ;; 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))))))