# HG changeset patch # User Aidan Kehoe # Date 1317667141 -3600 # Node ID 89cb6a66a61fd6f6ba721937f5c00b58792b14c3 # Parent d4f334808463b4785db56315e79b893d7a42b5e9 Force unfolding of (funcall #'(lambda () ...) if optimising, bytecomp.el. lisp/ChangeLog addition: 2011-10-03 Aidan Kehoe * bytecomp.el (byte-compile-funcall): Sometimes the optimizer shirks its responsibility and doesn't unfold a lambda when it should. Do this here, if optimization is turned on; this makes inlining labels more consistent and trustworthy. diff -r d4f334808463 -r 89cb6a66a61f lisp/ChangeLog --- a/lisp/ChangeLog Sun Oct 02 15:32:16 2011 +0100 +++ b/lisp/ChangeLog Mon Oct 03 19:39:01 2011 +0100 @@ -1,3 +1,11 @@ +2011-10-03 Aidan Kehoe + + * bytecomp.el (byte-compile-funcall): + Sometimes the optimizer shirks its responsibility and doesn't + unfold a lambda when it should. Do this here, if optimization is + turned on; this makes inlining labels more consistent and + trustworthy. + 2011-10-02 Aidan Kehoe * bytecomp.el (byte-compile-initial-macro-environment): diff -r d4f334808463 -r 89cb6a66a61f lisp/bytecomp.el --- a/lisp/bytecomp.el Sun Oct 02 15:32:16 2011 +0100 +++ b/lisp/bytecomp.el Mon Oct 03 19:39:01 2011 +0100 @@ -4157,8 +4157,19 @@ (byte-compile-constp (second form))) (byte-compile-callargs-warn (cons (cl-const-expr-val (second form)) (nthcdr 2 form)))) - (mapc 'byte-compile-form (cdr form)) - (byte-compile-out 'byte-call (length (cdr (cdr form))))) + (if (and byte-optimize + (eq 'function (car-safe (cadr form))) + (eq 'lambda (car-safe (cadadr form))) + (or + (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. + (byte-compile-form form) + (mapc 'byte-compile-form (cdr form)) + (byte-compile-out 'byte-call (length (cdr (cdr form)))))) (defun byte-compile-let (form)