diff options
| author | Thien-Thi Nguyen | 2007-07-01 16:59:07 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2007-07-01 16:59:07 +0000 |
| commit | ed2f6a47fc1d4260bd369135c1de79e34ed4e941 (patch) | |
| tree | 2527514e4ff3bf680cd3482aac725a022eb8a447 | |
| parent | 0a963185900d6ce52b633a3913a5240a8ade896d (diff) | |
| download | emacs-ed2f6a47fc1d4260bd369135c1de79e34ed4e941.tar.gz emacs-ed2f6a47fc1d4260bd369135c1de79e34ed4e941.zip | |
Set `binding-is-magic' property on a few symbols.
(byte-compile-side-effect-free-dynamically-safe-ops): New defconst.
(byte-optimize-lapcode): Remove bindings that are not referenced
and certainly will not effect through dynamic scoping.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 77 |
2 files changed, 84 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3186832bca9..9a21e7d5d9c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2007-07-01 Paul Pogonyshev <pogonyshev@gmx.net> | ||
| 2 | |||
| 3 | * emacs-lisp/byte-opt.el: Set `binding-is-magic' | ||
| 4 | property on a few symbols. | ||
| 5 | (byte-compile-side-effect-free-dynamically-safe-ops): New defconst. | ||
| 6 | (byte-optimize-lapcode): Remove bindings that are not referenced | ||
| 7 | and certainly will not effect through dynamic scoping. | ||
| 8 | |||
| 1 | 2007-07-01 Stefan Monnier <monnier@iro.umontreal.ca> | 9 | 2007-07-01 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 10 | ||
| 3 | * files.el (find-file-confirm-inexistent-file): New var. | 11 | * files.el (find-file-confirm-inexistent-file): New var. |
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 2c9dc8e3314..7f9bcd9725e 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -1444,6 +1444,32 @@ | |||
| 1444 | byte-member byte-assq byte-quo byte-rem) | 1444 | byte-member byte-assq byte-quo byte-rem) |
| 1445 | byte-compile-side-effect-and-error-free-ops)) | 1445 | byte-compile-side-effect-and-error-free-ops)) |
| 1446 | 1446 | ||
| 1447 | (defconst byte-compile-side-effect-free-dynamically-safe-ops | ||
| 1448 | '(;; Same as `byte-compile-side-effect-free-ops' but without | ||
| 1449 | ;; `byte-varref', `byte-symbol-value' and certain editing | ||
| 1450 | ;; primitives. | ||
| 1451 | byte-constant byte-dup byte-symbolp byte-consp byte-stringp byte-listp | ||
| 1452 | byte-integerp byte-numberp byte-eq byte-equal byte-not byte-car-safe | ||
| 1453 | byte-cdr-safe byte-cons byte-list1 byte-list2 byte-point byte-point-max | ||
| 1454 | byte-point-min byte-following-char byte-preceding-char | ||
| 1455 | byte-eolp byte-eobp byte-bolp byte-bobp | ||
| 1456 | ;; | ||
| 1457 | ;; Bytecodes from `byte-compile-side-effect-and-error-free-ops'. | ||
| 1458 | ;; We are not going to remove them, so it is fine. | ||
| 1459 | byte-nth byte-memq byte-car byte-cdr byte-length byte-aref | ||
| 1460 | byte-get byte-concat2 byte-concat3 byte-sub1 byte-add1 | ||
| 1461 | byte-eqlsign byte-gtr byte-lss byte-leq byte-geq byte-diff byte-negate | ||
| 1462 | byte-plus byte-max byte-min byte-mult byte-char-after | ||
| 1463 | byte-string= byte-string< byte-nthcdr byte-elt | ||
| 1464 | byte-member byte-assq byte-quo byte-rem)) | ||
| 1465 | |||
| 1466 | (put 'debug-on-error 'binding-is-magic t) | ||
| 1467 | (put 'debug-on-abort 'binding-is-magic t) | ||
| 1468 | (put 'inhibit-quit 'binding-is-magic t) | ||
| 1469 | (put 'quit-flag 'binding-is-magic t) | ||
| 1470 | (put 'gc-cons-threshold 'binding-is-magic t) | ||
| 1471 | (put 'track-mouse 'binding-is-magic t) | ||
| 1472 | |||
| 1447 | ;; This crock is because of the way DEFVAR_BOOL variables work. | 1473 | ;; This crock is because of the way DEFVAR_BOOL variables work. |
| 1448 | ;; Consider the code | 1474 | ;; Consider the code |
| 1449 | ;; | 1475 | ;; |
| @@ -1513,7 +1539,7 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance." | |||
| 1513 | (setq rest (cdr rest)) | 1539 | (setq rest (cdr rest)) |
| 1514 | (cond ((= tmp 1) | 1540 | (cond ((= tmp 1) |
| 1515 | (byte-compile-log-lap | 1541 | (byte-compile-log-lap |
| 1516 | " %s discard\t-->\t<deleted>" lap0) | 1542 | " %s discard\t-->\t<deleted>" lap0) |
| 1517 | (setq lap (delq lap0 (delq lap1 lap)))) | 1543 | (setq lap (delq lap0 (delq lap1 lap)))) |
| 1518 | ((= tmp 0) | 1544 | ((= tmp 0) |
| 1519 | (byte-compile-log-lap | 1545 | (byte-compile-log-lap |
| @@ -1848,6 +1874,55 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance." | |||
| 1848 | (setq lap (delq lap0 lap)))) | 1874 | (setq lap (delq lap0 lap)))) |
| 1849 | (setq keep-going t)) | 1875 | (setq keep-going t)) |
| 1850 | ;; | 1876 | ;; |
| 1877 | ;; varbind-X [car/cdr/ ...] unbind-1 --> discard [car/cdr/ ...] | ||
| 1878 | ;; varbind-X [car/cdr/ ...] unbind-N | ||
| 1879 | ;; --> discard [car/cdr/ ...] unbind-(N-1) | ||
| 1880 | ;; | ||
| 1881 | ((and (eq 'byte-varbind (car lap1)) | ||
| 1882 | (not (get (cadr lap1) 'binding-is-magic))) | ||
| 1883 | (setq tmp (cdr rest)) | ||
| 1884 | (while | ||
| 1885 | (or | ||
| 1886 | (memq (caar (setq tmp (cdr tmp))) | ||
| 1887 | byte-compile-side-effect-free-dynamically-safe-ops) | ||
| 1888 | (and (eq (caar tmp) 'byte-varref) | ||
| 1889 | (not (eq (cadr (car tmp)) (cadr lap1)))))) | ||
| 1890 | (when (eq 'byte-unbind (caar tmp)) | ||
| 1891 | ;; Avoid evalling this crap when not logging anyway. | ||
| 1892 | (when (memq byte-optimize-log '(t lap)) | ||
| 1893 | (let ((format-string) | ||
| 1894 | (args)) | ||
| 1895 | (if (and (= (aref byte-stack+-info (symbol-value (car lap0))) | ||
| 1896 | 1) | ||
| 1897 | (memq (car lap0) side-effect-free)) | ||
| 1898 | (setq format-string | ||
| 1899 | " %s %s [car/cdr/ ...] %s\t-->\t[car/cdr/ ...]" | ||
| 1900 | args (list lap0 lap1 (car tmp))) | ||
| 1901 | (setq format-string | ||
| 1902 | " %s [car/cdr/ ...] %s\t-->\t%s [car/cdr/ ...]" | ||
| 1903 | args (list lap1 (car tmp) (cons 'byte-discard 0)))) | ||
| 1904 | (when (> (cdar tmp) 1) | ||
| 1905 | (setq format-string (concat format-string " %s")) | ||
| 1906 | (nconc args (list (cons 'byte-unbind (1- (cdar tmp)))))) | ||
| 1907 | (apply 'byte-compile-log-lap-1 format-string args))) | ||
| 1908 | ;; Do the real work. | ||
| 1909 | (if (and (= (aref byte-stack+-info (symbol-value (car lap0))) | ||
| 1910 | 1) | ||
| 1911 | (memq (car lap0) side-effect-free)) | ||
| 1912 | ;; Optimization: throw const/dup/... varbind right away. | ||
| 1913 | (progn | ||
| 1914 | (setcar rest (nth 2 rest)) | ||
| 1915 | (setcdr rest (nthcdr 3 rest))) | ||
| 1916 | (setcar lap1 'byte-discard) | ||
| 1917 | (setcdr lap1 0)) | ||
| 1918 | (if (= (cdar tmp) 1) | ||
| 1919 | (progn | ||
| 1920 | ;; Throw away unbind-1. | ||
| 1921 | (setcar tmp (nth 1 tmp)) | ||
| 1922 | (setcdr tmp (nthcdr 2 tmp))) | ||
| 1923 | (setcdr (car tmp) (1- (cdar tmp)))) | ||
| 1924 | (setq keep-going t))) | ||
| 1925 | ;; | ||
| 1851 | ;; X: varref-Y ... varset-Y goto-X --> | 1926 | ;; X: varref-Y ... varset-Y goto-X --> |
| 1852 | ;; X: varref-Y Z: ... dup varset-Y goto-Z | 1927 | ;; X: varref-Y Z: ... dup varset-Y goto-Z |
| 1853 | ;; (varset-X goto-BACK, BACK: varref-X --> copy the varref down.) | 1928 | ;; (varset-X goto-BACK, BACK: varref-X --> copy the varref down.) |