comparison lisp/cl-macs.el @ 5656:e9c3fe82127d

Co-operate with the byte-optimizer in the bytecomp.el labels implementation. lisp/ChangeLog addition: 2012-05-05 Aidan Kehoe <kehoea@parhasard.net> Co-operate with the byte-optimizer in the bytecomp.el labels implementation, don't work against it. * byte-optimize.el: * byte-optimize.el (byte-compile-inline-expand): Call #'byte-compile-unfold-lambda explicitly here, don't assume that the byte-optimizer will do it. * byte-optimize.el (byte-compile-unfold-lambda): Call #'byte-optimize-body on the body, don't just mapcar #'byte-optimize-form along it. * byte-optimize.el (byte-optimize-lambda): New. Optimize a lambda form. * byte-optimize.el (byte-optimize-form-code-walker): Descend lambda expressions, defun, and defmacro, relevant for lexically-oriented operators like #'labels. * byte-optimize.el (byte-optimize-body): Only return a non-eq object if we've actually optimized something * bytecomp.el (byte-compile-initial-macro-environment): In the labels implementation, work with the byte optimizer, not against it; warn when labels are defined but not used, automatically inline labels that are used only once. * bytecomp.el (byte-recompile-directory): No need to wrap #'byte-compile-report-error in a lambda with #'call-with-condition-handler here. * bytecomp.el (byte-compile-form): Don't inline compiled-function objects, they're probably labels. * bytecomp.el (byte-compile-funcall): No longer inline lambdas, trust the byte optimizer to have done it properly, even for labels. * cl-extra.el (cl-macroexpand-all): Treat labels established by the byte compiler distinctly from those established by cl-macs.el. * cl-macs.el (cl-do-proclaim): Treat labels established by the byte compiler distinctly from those established by cl-macs.el. * gui.el (make-gui-button): When referring to the #'gui-button-action label, quote it using function, otherwise there's a warning from the byte compiler.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 05 May 2012 20:48:24 +0100
parents cc6f0266bc36
children 289cf21be887
comparison
equal deleted inserted replaced
5655:b7ae5f44b950 5656:e9c3fe82127d
1861 (mapcar #'(lambda (v) (cons v byte-compile-global-bit)) 1861 (mapcar #'(lambda (v) (cons v byte-compile-global-bit))
1862 (cdr spec)) 1862 (cdr spec))
1863 byte-compile-bound-variables)))) 1863 byte-compile-bound-variables))))
1864 1864
1865 ((eq (car-safe spec) 'inline) 1865 ((eq (car-safe spec) 'inline)
1866 (while (setq spec (cdr spec)) 1866 (while (setq spec (cdr spec))
1867 (let ((assq (cdr (assq (car spec) byte-compile-macro-environment)))) 1867 (let* ((assq (cdr (assq (car spec)
1868 (if (and (consp assq) (eq (nth 1 (nth 1 assq)) 'cl-labels-args) 1868 byte-compile-macro-environment)))
1869 (atom (setq assq (nth 2 (nth 2 assq))))) 1869 (symbol (if (and (consp assq)
1870 ;; It's a label, and we're using the labels 1870 (eq (nth 1 (nth 1 assq))
1871 ;; implementation in bytecomp.el. Tell the compiler 1871 'byte-compile-labels-args))
1872 ;; to inline it, don't mark the symbol to be inlined 1872 ;; It's a label, and we're using the labels
1873 ;; globally. 1873 ;; implementation in bytecomp.el. Tell the
1874 (setf (getf (aref (compiled-function-constants assq) 0) 1874 ;; compiler to inline it, don't mark the
1875 'byte-optimizer) 1875 ;; symbol to be inlined globally.
1876 'byte-compile-inline-expand) 1876 (nth 1 (nth 1 (nth 3 assq)))
1877 (or (memq (get (car spec) 'byte-optimizer) 1877 (car spec))))
1878 '(nil byte-compile-inline-expand)) 1878 (or (memq (get symbol 'byte-optimizer)
1879 (error 1879 '(nil byte-compile-inline-expand))
1880 "%s already has a byte-optimizer, can't make it inline" 1880 (error
1881 (car spec))) 1881 "%s already has a byte-optimizer, can't make it inline"
1882 (put (car spec) 'byte-optimizer 'byte-compile-inline-expand))))) 1882 symbol))
1883 (put symbol 'byte-optimizer 'byte-compile-inline-expand))))
1883 ((eq (car-safe spec) 'notinline) 1884 ((eq (car-safe spec) 'notinline)
1884 (while (setq spec (cdr spec)) 1885 (while (setq spec (cdr spec))
1885 (let ((assq (cdr (assq (car spec) byte-compile-macro-environment)))) 1886 (let* ((assq (cdr (assq (car spec)
1886 (if (and (consp assq) (eq (nth 1 (nth 1 assq)) 'cl-labels-args) 1887 byte-compile-macro-environment)))
1887 (atom (setq assq (nth 2 (nth 2 assq))))) 1888 (symbol (if (and (consp assq)
1888 ;; It's a label, and we're using the labels 1889 (eq (nth 1 (nth 1 assq))
1889 ;; implementation in bytecomp.el. Tell the compiler 1890 'byte-compile-labels-args))
1890 ;; not to inline it. 1891 ;; It's a label, and we're using the labels
1891 (if (eq 'byte-compile-inline-expand 1892 ;; implementation in bytecomp.el. Tell the
1892 (getf (aref (compiled-function-constants assq) 0) 1893 ;; compiler not to inline it, don't mark the
1893 'byte-optimizer)) 1894 ;; symbol to be notinline globally.
1894 (remf (aref (compiled-function-constants assq) 0) 1895 (nth 1 (nth 1 (nth 3 assq)))
1895 'byte-optimizer)) 1896 (car spec))))
1896 (if (eq (get (car spec) 'byte-optimizer) 1897 (if (eq (get symbol 'byte-optimizer)
1897 'byte-compile-inline-expand) 1898 'byte-compile-inline-expand)
1898 (put (car spec) 'byte-optimizer nil)))))) 1899 (put symbol 'byte-optimizer nil)))))
1899 ((eq (car-safe spec) 'optimize) 1900 ((eq (car-safe spec) 'optimize)
1900 (let ((speed (assq (nth 1 (assq 'speed (cdr spec))) 1901 (let ((speed (assq (nth 1 (assq 'speed (cdr spec)))
1901 '((0 . nil) (1 . t) (2 . t) (3 . t)))) 1902 '((0 . nil) (1 . t) (2 . t) (3 . t))))
1902 (safety (assq (nth 1 (assq 'safety (cdr spec))) 1903 (safety (assq (nth 1 (assq 'safety (cdr spec)))
1903 '((0 . t) (1 . t) (2 . t) (3 . nil))))) 1904 '((0 . t) (1 . t) (2 . t) (3 . nil)))))