summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp.el
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2019-12-29 20:12:17 +0100
committerAndrea Corallo <akrl@sdf.org>2020-01-01 11:38:18 +0100
commit6c77a9e046de682aaace72aaf3af78e6ba9e5489 (patch)
tree2ddf584e07f8111d33981dfec6954d4c56c66006 /lisp/emacs-lisp/comp.el
parent976b7fcc8ced57fa12a0504899974b5b2057c943 (diff)
downloademacs-6c77a9e046de682aaace72aaf3af78e6ba9e5489.tar.gz
emacs-6c77a9e046de682aaace72aaf3af78e6ba9e5489.tar.bz2
emacs-6c77a9e046de682aaace72aaf3af78e6ba9e5489.zip
do not crash compilation trying to optimize wrong code
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r--lisp/emacs-lisp/comp.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index da1d3f160f0..039cd6cd411 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -450,7 +450,8 @@ Put PREFIX in front of it."
(byte-compile-file filename)
(unless byte-to-native-top-level-forms
(signal 'native-compiler-error-empty-byte filename))
- (setf (comp-ctxt-top-level-forms comp-ctxt) (reverse byte-to-native-top-level-forms))
+ (setf (comp-ctxt-top-level-forms comp-ctxt)
+ (reverse byte-to-native-top-level-forms))
(cl-loop
for f in (cl-loop for x in byte-to-native-top-level-forms ; All non anonymous.
when (and (byte-to-native-function-p x)
@@ -1551,10 +1552,15 @@ This can run just once."
"Given INSN when F is pure if all ARGS are known remove the function call."
(when (and (get f 'pure) ; Can we just optimize pure here? See byte-opt.el
(cl-every #'comp-mvar-const-vld args))
- (let ((val (apply f (mapcar #'comp-mvar-constant args))))
- ;; See `comp-emit-set-const'.
- (setf (car insn) 'setimm
- (cddr insn) (list (comp-add-const-to-relocs val) val)))))
+ (condition-case err
+ (let ((val (apply f (mapcar #'comp-mvar-constant args))))
+ ;; See `comp-emit-set-const'.
+ (setf (car insn) 'setimm
+ (cddr insn) (list (comp-add-const-to-relocs val) val)))
+ ;; FIXME Should we crash? At least we should complain once.
+ (t (message "Native compiler trying to move run-time error into \
+compile-time? %S calling %S inside function %S." err f
+(comp-func-name comp-func))))))
(defun comp-propagate-insn (insn)
"Propagate within INSN."