]> git.eshelyaron.com Git - emacs.git/commitdiff
Introduce 'compilation-safety' variable
authorAndrea Corallo <acorallo@gnu.org>
Fri, 3 May 2024 20:21:20 +0000 (22:21 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 16 May 2024 08:18:51 +0000 (10:18 +0200)
* lisp/emacs-lisp/bytecomp.el (compilation-safety): New customize.
* src/comp.c (comp_t): Add func_safety.
(emit_call_with_type_hint, emit_call2_with_type_hint): Make use of.
(compile_function): Set 'comp.func_safety'.

(cherry picked from commit 13ddfc201108bfc71c7fa9040ee9970e929070cf)

lisp/emacs-lisp/bytecomp.el
src/comp.c

index d9890b5c37a5b9334e220faf340c720ca834254f..e0bcdce502b917baf9bfbe84030f6dba423d9fb9 100644 (file)
   "Emacs Lisp byte-compiler."
   :group 'lisp)
 
+(defcustom compilation-safety 1
+  "Safety level."
+  :type 'integer
+  :safe #'integerp
+  :version "30.1")
+
 (defcustom emacs-lisp-file-regexp "\\.el\\'"
   "Regexp which matches Emacs Lisp source files.
 If you change this, you might want to set `byte-compile-dest-file-function'.
index 4e779cdf898d4d38f657f0c61db5d43542aff416..e8945df63ffefb5e480f2b35bddf744d95af4797 100644 (file)
@@ -633,6 +633,7 @@ typedef struct {
   gcc_jit_function *func; /* Current function being compiled.  */
   bool func_has_non_local; /* From comp-func has-non-local slot.  */
   EMACS_INT func_speed; /* From comp-func speed slot.  */
+  EMACS_INT func_safety; /* From comp-func safety slot.  */
   gcc_jit_block *block;  /* Current basic block being compiled.  */
   gcc_jit_lvalue *scratch; /* Used as scratch slot for some code sequence (switch).  */
   ptrdiff_t frame_size; /* Size of the following array in elements. */
@@ -2586,7 +2587,8 @@ emit_call_with_type_hint (gcc_jit_function *func, Lisp_Object insn,
                          Lisp_Object type)
 {
   bool hint_match =
-    !NILP (CALL2I (comp-mvar-type-hint-match-p, SECOND (insn), type));
+    !comp.func_safety
+    && !NILP (CALL2I (comp-mvar-type-hint-match-p, SECOND (insn), type));
   gcc_jit_rvalue *args[] =
     { emit_mvar_rval (SECOND (insn)),
       gcc_jit_context_new_rvalue_from_int (comp.ctxt,
@@ -2602,7 +2604,8 @@ emit_call2_with_type_hint (gcc_jit_function *func, Lisp_Object insn,
                           Lisp_Object type)
 {
   bool hint_match =
-    !NILP (CALL2I (comp-mvar-type-hint-match-p, SECOND (insn), type));
+    !comp.func_safety
+    && !NILP (CALL2I (comp-mvar-type-hint-match-p, SECOND (insn), type));
   gcc_jit_rvalue *args[] =
     { emit_mvar_rval (SECOND (insn)),
       emit_mvar_rval (THIRD (insn)),
@@ -4282,6 +4285,7 @@ compile_function (Lisp_Object func)
 
   comp.func_has_non_local = !NILP (CALL1I (comp-func-has-non-local, func));
   comp.func_speed = XFIXNUM (CALL1I (comp-func-speed, func));
+  comp.func_safety = XFIXNUM (CALL1I (comp-func-safety, func));
 
   comp.func_relocs_local =
     gcc_jit_function_new_local (comp.func,