]> git.eshelyaron.com Git - emacs.git/commitdiff
do not crash compilation trying to optimize wrong code
authorAndrea Corallo <akrl@sdf.org>
Sun, 29 Dec 2019 19:12:17 +0000 (20:12 +0100)
committerAndrea Corallo <akrl@sdf.org>
Wed, 1 Jan 2020 10:38:18 +0000 (11:38 +0100)
lisp/emacs-lisp/comp.el

index da1d3f160f097f0991896f98e355727b111e6753..039cd6cd4114c3e0da3e98db86bf0b124de55a85 100644 (file)
@@ -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."