diff options
| author | Andrea Corallo | 2024-05-04 08:55:56 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2024-05-13 23:09:09 +0200 |
| commit | 04e7078d5e2a61c92e61946ffedea25c11951dec (patch) | |
| tree | 599df9f8188322198e7e95d04989e08a28badfeb | |
| parent | 9e4e6d0fc904e8a57c8433c40d6e3e9a230773d9 (diff) | |
| download | emacs-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.texi | 18 | ||||
| -rw-r--r-- | doc/lispref/functions.texi | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 6 |
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}.) | |||
| 987 | The default value is 2. | 987 | The default value is 2. |
| 988 | @end defopt | 988 | @end defopt |
| 989 | 989 | ||
| 990 | @defopt compilation-safety | ||
| 991 | This variable specifies the safetyness level used for the code emitted | ||
| 992 | native code. The value of compilation-safety should be a number between | ||
| 993 | zero and one with the following meaning: | ||
| 994 | |||
| 995 | @table @asis | ||
| 996 | @item 0 | ||
| 997 | Emitted code can misbehave or crash Emacs if function declarations are | ||
| 998 | not correct and the function is native compiled. | ||
| 999 | @item 1 | ||
| 1000 | Emitted code is generated in a safe matter even if function are | ||
| 1001 | miss-declared." | ||
| 1002 | @end table | ||
| 1003 | |||
| 1004 | This 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 |
| 991 | This variable specifies the level of debugging information produced by | 1009 | This variable specifies the level of debugging information produced by |
| 992 | native-compilation. Its value should be a number between zero and 3, | 1010 | native-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 |
| 2710 | instead of native code for the function. | 2710 | instead of native code for the function. |
| 2711 | 2711 | ||
| 2712 | @item (safety @var{n}) | ||
| 2713 | Specify the value of @code{compilation-safety} in effect for this | ||
| 2714 | function. This allows function-level control of the safety level used | ||
| 2715 | for the code emitted for the function (@pxref{Native-Compilation | ||
| 2716 | Variables}). | ||
| 2717 | |||
| 2712 | @item (type @var{type}) | 2718 | @item (type @var{type}) |
| 2713 | Declare @var{type} to be the type of this function. This is used for | 2719 | Declare @var{type} to be the type of this function. This is used for |
| 2714 | documentation by @code{describe-function}. Also it can be used by the | 2720 | documentation 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 | ||
| 2757 | Declaring a function with an incorrect type produces undefined behavior | 2763 | Declaring a function with an incorrect type produces undefined behavior |
| 2758 | and could lead to unexpected results or might even crash Emacs when code | 2764 | and could lead to unexpected results or might even crash Emacs when code |
| 2759 | is native-compiled and loaded. Note also that when redefining (or | 2765 | is native-compiled and loaded if compiled with @ref{compilation-safety} |
| 2760 | advising) a type declared function the replacement should respect the | 2766 | 0. Note also that when redefining (or advising) a type declared |
| 2761 | original signature to avoid undefined behavior. | 2767 | function the replacement should respect the original signature to avoid |
| 2768 | undefined behavior. | ||
| 2762 | 2769 | ||
| 2763 | @item no-font-lock-keyword | 2770 | @item no-font-lock-keyword |
| 2764 | This is valid for macros only. Macros with this declaration are | 2771 | This 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. |
| 142 | Possible values are: | ||
| 143 | 0 emitted code can misbehave or crash Emacs if function declarations are not | ||
| 144 | correct. | ||
| 145 | 1 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") |