aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2024-05-04 08:55:56 +0200
committerAndrea Corallo2024-05-13 23:09:09 +0200
commit04e7078d5e2a61c92e61946ffedea25c11951dec (patch)
tree599df9f8188322198e7e95d04989e08a28badfeb
parent9e4e6d0fc904e8a57c8433c40d6e3e9a230773d9 (diff)
downloademacs-04e7078d5e2a61c92e61946ffedea25c11951dec.tar.gz
emacs-04e7078d5e2a61c92e61946ffedea25c11951dec.zip
Add some 'compilation-safety' documentation
* lisp/emacs-lisp/bytecomp.el (compilation-safety): Better doc. * doc/lispref/functions.texi (Declare Form): Add 'safety'. * doc/lispref/compile.texi (Native-Compilation Variables): Add 'compilation-safety'.
-rw-r--r--doc/lispref/compile.texi18
-rw-r--r--doc/lispref/functions.texi13
-rw-r--r--lisp/emacs-lisp/bytecomp.el6
3 files changed, 33 insertions, 4 deletions
diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi
index 19451f31740..f8f1242586e 100644
--- a/doc/lispref/compile.texi
+++ b/doc/lispref/compile.texi
@@ -987,6 +987,24 @@ form, @pxref{Declare Form}.)
987The default value is 2. 987The default value is 2.
988@end defopt 988@end defopt
989 989
990@defopt compilation-safety
991This variable specifies the safetyness level used for the code emitted
992native code. The value of compilation-safety should be a number between
993zero and one with the following meaning:
994
995@table @asis
996@item 0
997Emitted code can misbehave or crash Emacs if function declarations are
998not correct and the function is native compiled.
999@item 1
1000Emitted code is generated in a safe matter even if function are
1001miss-declared."
1002@end table
1003
1004This can be controlled at function granularity as well by using the
1005@code{safety} @code{declare} form, @pxref{Declare Form}.
1006@end defopt
1007
990@defopt native-comp-debug 1008@defopt native-comp-debug
991This variable specifies the level of debugging information produced by 1009This variable specifies the level of debugging information produced by
992native-compilation. Its value should be a number between zero and 3, 1010native-compilation. Its value should be a number between zero and 3,
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index a77bf6e233d..9d4ecd8da25 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -2709,6 +2709,12 @@ native code emitted for the function. In particular, if @var{n} is
2709@minus{}1, native compilation of the function will emit bytecode 2709@minus{}1, native compilation of the function will emit bytecode
2710instead of native code for the function. 2710instead of native code for the function.
2711 2711
2712@item (safety @var{n})
2713Specify the value of @code{compilation-safety} in effect for this
2714function. This allows function-level control of the safety level used
2715for the code emitted for the function (@pxref{Native-Compilation
2716Variables}).
2717
2712@item (type @var{type}) 2718@item (type @var{type})
2713Declare @var{type} to be the type of this function. This is used for 2719Declare @var{type} to be the type of this function. This is used for
2714documentation by @code{describe-function}. Also it can be used by the 2720documentation by @code{describe-function}. Also it can be used by the
@@ -2756,9 +2762,10 @@ For description of additional types, see @ref{Lisp Data Types}).
2756 2762
2757Declaring a function with an incorrect type produces undefined behavior 2763Declaring a function with an incorrect type produces undefined behavior
2758and could lead to unexpected results or might even crash Emacs when code 2764and could lead to unexpected results or might even crash Emacs when code
2759is native-compiled and loaded. Note also that when redefining (or 2765is native-compiled and loaded if compiled with @ref{compilation-safety}
2760advising) a type declared function the replacement should respect the 27660. Note also that when redefining (or advising) a type declared
2761original signature to avoid undefined behavior. 2767function the replacement should respect the original signature to avoid
2768undefined behavior.
2762 2769
2763@item no-font-lock-keyword 2770@item no-font-lock-keyword
2764This is valid for macros only. Macros with this declaration are 2771This is valid for macros only. Macros with this declaration are
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 732a1629177..3e7674eeef6 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -138,7 +138,11 @@
138 :group 'lisp) 138 :group 'lisp)
139 139
140(defcustom compilation-safety 1 140(defcustom compilation-safety 1
141 "Safety level." 141 "Safety level for compilation.
142Possible values are:
1430 emitted code can misbehave or crash Emacs if function declarations are not
144correct.
1451 emitted code is generated in a safe matter even if function are miss-declared."
142 :type 'integer 146 :type 'integer
143 :safe #'integerp 147 :safe #'integerp
144 :version "30.1") 148 :version "30.1")