From 6c77a9e046de682aaace72aaf3af78e6ba9e5489 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 29 Dec 2019 20:12:17 +0100 Subject: [PATCH] do not crash compilation trying to optimize wrong code --- lisp/emacs-lisp/comp.el | 16 +++++++++++----- 1 file 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." -- 2.39.5