aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2018-03-22 11:25:42 -0700
committerPaul Eggert2018-03-22 11:29:02 -0700
commit311bb33218b860413af699ac84e50fccfc1469c0 (patch)
treedb63ee188f3fb5db610bf4039157b3f42581a2ad
parent011186279c1041e790b81af72981547d623d9b29 (diff)
downloademacs-311bb33218b860413af699ac84e50fccfc1469c0.tar.gz
emacs-311bb33218b860413af699ac84e50fccfc1469c0.zip
Fix byte-opt lists of pure functions etc.
This fixes a bug where a byte-compiler running on 64-bit Emacs optimized (lsh -1 -1) to #x1fffffffffffffff, an optimization that is incorrect for .elc files intended for either 32- or 64-bit Emacs. While I was in the neighborhood, I noticed other glitches in the lists of pure and side-effect-free functions, and fixed the errors that I found. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Move some functions here from side-effect-and-error-free-fns, since they can now signal errors. The affected functions are current-time-string, current-time-zone, line-beginning-position, line-end-position. Rename langinfo to locale-info. Add logcount. Remove string-to-int. (side-effect-and-error-free-fns): Remove minibuffer-window, a function that can signal errors, and that is already in side-effect-free-fns. (pure-fns): Remove ash, lsh, and logb, since they are platform-dependent and .elc files should be platform-independent. Add %, logand, logcount. Sort. Clarify what is meant by “pure”.
-rw-r--r--lisp/emacs-lisp/byte-opt.el37
1 files changed, 23 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index a316364761d..55343e1e3af 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1186,6 +1186,7 @@
1186 char-equal char-to-string char-width compare-strings 1186 char-equal char-to-string char-width compare-strings
1187 compare-window-configurations concat coordinates-in-window-p 1187 compare-window-configurations concat coordinates-in-window-p
1188 copy-alist copy-sequence copy-marker cos count-lines 1188 copy-alist copy-sequence copy-marker cos count-lines
1189 current-time-string current-time-zone
1189 decode-char 1190 decode-char
1190 decode-time default-boundp default-value documentation downcase 1191 decode-time default-boundp default-value documentation downcase
1191 elt encode-char exp expt encode-time error-message-string 1192 elt encode-char exp expt encode-time error-message-string
@@ -1199,8 +1200,9 @@
1199 hash-table-count 1200 hash-table-count
1200 int-to-string intern-soft 1201 int-to-string intern-soft
1201 keymap-parent 1202 keymap-parent
1202 length local-variable-if-set-p local-variable-p log log10 logand 1203 length line-beginning-position line-end-position
1203 logb logior lognot logxor lsh langinfo 1204 local-variable-if-set-p local-variable-p locale-info
1205 log log10 logand logb logcount logior lognot logxor lsh
1204 make-list make-string make-symbol marker-buffer max member memq min 1206 make-list make-string make-symbol marker-buffer max member memq min
1205 minibuffer-selected-window minibuffer-window 1207 minibuffer-selected-window minibuffer-window
1206 mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string 1208 mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string
@@ -1210,7 +1212,7 @@
1210 radians-to-degrees rassq rassoc read-from-string regexp-quote 1212 radians-to-degrees rassq rassoc read-from-string regexp-quote
1211 region-beginning region-end reverse round 1213 region-beginning region-end reverse round
1212 sin sqrt string string< string= string-equal string-lessp string-to-char 1214 sin sqrt string string< string= string-equal string-lessp string-to-char
1213 string-to-int string-to-number substring 1215 string-to-number substring
1214 sxhash sxhash-equal sxhash-eq sxhash-eql 1216 sxhash sxhash-equal sxhash-eq sxhash-eql
1215 symbol-function symbol-name symbol-plist symbol-value string-make-unibyte 1217 symbol-function symbol-name symbol-plist symbol-value string-make-unibyte
1216 string-make-multibyte string-as-multibyte string-as-unibyte 1218 string-make-multibyte string-as-multibyte string-as-unibyte
@@ -1240,7 +1242,6 @@
1240 charsetp commandp cons consp 1242 charsetp commandp cons consp
1241 current-buffer current-global-map current-indentation 1243 current-buffer current-global-map current-indentation
1242 current-local-map current-minor-mode-maps current-time 1244 current-local-map current-minor-mode-maps current-time
1243 current-time-string current-time-zone
1244 eobp eolp eq equal eventp 1245 eobp eolp eq equal eventp
1245 floatp following-char framep 1246 floatp following-char framep
1246 get-largest-window get-lru-window 1247 get-largest-window get-lru-window
@@ -1248,9 +1249,9 @@
1248 identity ignore integerp integer-or-marker-p interactive-p 1249 identity ignore integerp integer-or-marker-p interactive-p
1249 invocation-directory invocation-name 1250 invocation-directory invocation-name
1250 keymapp keywordp 1251 keymapp keywordp
1251 line-beginning-position line-end-position list listp 1252 list listp
1252 make-marker mark mark-marker markerp max-char 1253 make-marker mark mark-marker markerp max-char
1253 memory-limit minibuffer-window 1254 memory-limit
1254 mouse-movement-p 1255 mouse-movement-p
1255 natnump nlistp not null number-or-marker-p numberp 1256 natnump nlistp not null number-or-marker-p numberp
1256 one-window-p overlayp 1257 one-window-p overlayp
@@ -1275,16 +1276,24 @@
1275 nil) 1276 nil)
1276 1277
1277 1278
1278;; pure functions are side-effect free functions whose values depend 1279;; Pure functions are side-effect free functions whose values depend
1279;; only on their arguments. For these functions, calls with constant 1280;; only on their arguments, not on the platform. For these functions,
1280;; arguments can be evaluated at compile time. This may shift run time 1281;; calls with constant arguments can be evaluated at compile time.
1281;; errors to compile time. 1282;; This may shift runtime errors to compile time. For example, logand
1283;; is pure since its results are machine-independent, whereas ash is
1284;; not pure because (ash 1 29)'s value depends on machine word size.
1285;;
1286;; When deciding whether a function is pure, do not worry about
1287;; mutable strings or markers, as they are so unlikely in real code
1288;; that they are not worth worrying about. Thus string-to-char is
1289;; pure even though it might return different values if a string is
1290;; changed, and logand is pure even though it might return different
1291;; values if a marker is moved.
1282 1292
1283(let ((pure-fns 1293(let ((pure-fns
1284 '(concat symbol-name regexp-opt regexp-quote string-to-syntax 1294 '(% concat logand logcount logior lognot logxor
1285 string-to-char 1295 regexp-opt regexp-quote
1286 ash lsh logb lognot logior logxor 1296 string-to-char string-to-syntax symbol-name)))
1287 ceiling floor)))
1288 (while pure-fns 1297 (while pure-fns
1289 (put (car pure-fns) 'pure t) 1298 (put (car pure-fns) 'pure t)
1290 (setq pure-fns (cdr pure-fns))) 1299 (setq pure-fns (cdr pure-fns)))