Mercurial > hg > xemacs-beta
diff lisp/cl-macs.el @ 5574:d4f334808463
Support inlining labels, bytecomp.el.
lisp/ChangeLog addition:
2011-10-02 Aidan Kehoe <kehoea@parhasard.net>
* bytecomp.el (byte-compile-initial-macro-environment):
Add #'declare to this, so it doesn't need to rely on
#'cl-compiling file to determine when we're byte-compiling.
Update #'labels to support declaring labels inline, as Common Lisp
requires.
* bytecomp.el (byte-compile-function-form):
Don't error if FUNCTION is quoting a non-lambda, non-symbol, just
return it.
* cl-extra.el (cl-macroexpand-all):
If a label name has been quoted, expand to the label placeholder
quoted with 'function. This allows the byte compiler to
distinguish between uses of the placeholder as data and uses in
contexts where it should be inlined.
* cl-macs.el:
* cl-macs.el (cl-do-proclaim):
When proclaming something as inline, if it is bound as a label,
don't modify the symbol's plist; instead, treat the first element
of its placeholder constant vector as a place to store compile
information.
* cl-macs.el (declare):
Leave processing declarations while compiling to the
implementation of #'declare in
byte-compile-initial-macro-environment.
tests/ChangeLog addition:
2011-10-02 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
* automated/lisp-tests.el (+):
Test #'labels and inlining.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 02 Oct 2011 15:32:16 +0100 |
parents | 6c76f5b7e2e3 |
children | a0e81357194e |
line wrap: on
line diff
--- a/lisp/cl-macs.el Sun Sep 25 16:12:07 2011 +0100 +++ b/lisp/cl-macs.el Sun Oct 02 15:32:16 2011 +0100 @@ -1969,18 +1969,38 @@ ((eq (car-safe spec) 'inline) (while (setq spec (cdr spec)) - (or (memq (get (car spec) 'byte-optimizer) - '(nil byte-compile-inline-expand)) - (error "%s already has a byte-optimizer, can't make it inline" - (car spec))) - (put (car spec) 'byte-optimizer 'byte-compile-inline-expand))) - + (let ((assq (cdr (assq (car spec) byte-compile-macro-environment)))) + (if (and (consp assq) (eq (nth 1 (nth 1 assq)) 'cl-labels-args) + (atom (setq assq (nth 2 (nth 2 assq))))) + ;; It's a label, and we're using the labels + ;; implementation in bytecomp.el. Tell the compiler + ;; to inline it, don't mark the symbol to be inlined + ;; globally. + (setf (getf (aref (compiled-function-constants assq) 0) + 'byte-optimizer) + 'byte-compile-inline-expand) + (or (memq (get (car spec) 'byte-optimizer) + '(nil byte-compile-inline-expand)) + (error + "%s already has a byte-optimizer, can't make it inline" + (car spec))) + (put (car spec) 'byte-optimizer 'byte-compile-inline-expand))))) ((eq (car-safe spec) 'notinline) (while (setq spec (cdr spec)) - (if (eq (get (car spec) 'byte-optimizer) - 'byte-compile-inline-expand) - (put (car spec) 'byte-optimizer nil)))) - + (let ((assq (cdr (assq (car spec) byte-compile-macro-environment)))) + (if (and (consp assq) (eq (nth 1 (nth 1 assq)) 'cl-labels-args) + (atom (setq assq (nth 2 (nth 2 assq))))) + ;; It's a label, and we're using the labels + ;; implementation in bytecomp.el. Tell the compiler + ;; not to inline it. + (if (eq 'byte-compile-inline-expand + (getf (aref (compiled-function-constants assq) 0) + 'byte-optimizer)) + (remf (aref (compiled-function-constants assq) 0) + 'byte-optimizer)) + (if (eq (get (car spec) 'byte-optimizer) + 'byte-compile-inline-expand) + (put (car spec) 'byte-optimizer nil)))))) ((eq (car-safe spec) 'optimize) (let ((speed (assq (nth 1 (assq 'speed (cdr spec))) '((0 . nil) (1 . t) (2 . t) (3 . t)))) @@ -2014,14 +2034,8 @@ ;;;###autoload (defmacro declare (&rest specs) - (if (cl-compiling-file) - (while specs - (if (listp cl-declare-stack) (push (car specs) cl-declare-stack)) - (cl-do-proclaim (pop specs) nil))) nil) - - ;;; Generalized variables. ;;;###autoload