summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp.el
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-11-07 00:13:01 +0100
committerAndrea Corallo <akrl@sdf.org>2020-11-07 11:45:55 +0100
commit4a69e953f34d504809b94a0c4634444d34100039 (patch)
tree642550eb4114f1e65849c7aea29d2b026a324349 /lisp/emacs-lisp/comp.el
parentacf101c63644da5587822afbea1b186d91ff3348 (diff)
downloademacs-4a69e953f34d504809b94a0c4634444d34100039.tar.gz
emacs-4a69e953f34d504809b94a0c4634444d34100039.tar.bz2
emacs-4a69e953f34d504809b94a0c4634444d34100039.zip
Allow for native compilation qualities to be specified per input file
* lisp/emacs-lisp/bytecomp.el (byte-native-qualities): Define variable. (byte-compile-from-buffer): Spill compilation qualities. * lisp/emacs-lisp/comp.el (comp-speed, comp-debug): Make them file local variables. (comp-ctxt): Add `speed' and `debug' slots. (comp-spill-speed, comp-spill-lap-function): Make use of these. (comp-spill-lap-function): Spill qualities from `byte-native-qualities'. (comp-limplify-top-level): Do not use `comp-speed' but ctxt value unstead. (comp-final): Do not propagate qualities as they are already in the `comp-ctxt'. (comp--native-compile): Close on `byte-native-qualities'. * src/comp.c (comp_t): Add 'speed' and 'debug' fields. (emit_comment, emit_mvar_rval, emit_static_object) (emit_ctxt_code, Fcomp__init_ctxt): Use these instead of the global variables. (Fcomp__compile_ctxt_to_file): Set comp.speed and comp.debug and use them.
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r--lisp/emacs-lisp/comp.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index bb32aefcad5..9fbf60c96c2 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -51,6 +51,7 @@
- 3 max optimization level, to be used only when necessary.
Warning: the compiler is free to perform dangerous optimizations."
:type 'number
+ :safe #'numberp
:group 'comp)
(defcustom comp-debug 0
@@ -62,6 +63,7 @@ This intended for debugging the compiler itself.
- 2 dump gcc passes and libgccjit log file.
- 3 dump libgccjit reproducers."
:type 'number
+ :safe #'numberp
:group 'comp)
(defcustom comp-verbose 0
@@ -256,6 +258,10 @@ Useful to hook into pass checkers.")
"Lisp side of the compiler context."
(output nil :type string
:documentation "Target output file-name for the compilation.")
+ (speed comp-speed :type number
+ :documentation "Default speed for this compilation unit.")
+ (debug comp-debug :type number
+ :documentation "Default debug level for this compilation unit.")
(top-level-forms () :type list
:documentation "List of spilled top level forms.")
(funcs-h (make-hash-table :test #'equal) :type hash-table
@@ -605,7 +611,7 @@ instruction."
(defun comp-spill-speed (function-name)
"Return the speed for FUNCTION-NAME."
(or (comp-spill-decl-spec function-name 'speed)
- comp-speed))
+ (comp-ctxt-speed comp-ctxt)))
;; Autoloaded as might be used by `disassemble-internal'.
;;;###autoload
@@ -723,11 +729,11 @@ clashes."
(make-comp-func-l :c-name c-name
:doc (documentation form t)
:int-spec (interactive-form form)
- :speed comp-speed)
+ :speed (comp-ctxt-speed comp-ctxt))
(make-comp-func-d :c-name c-name
:doc (documentation form t)
:int-spec (interactive-form form)
- :speed comp-speed))))
+ :speed (comp-ctxt-speed comp-ctxt)))))
(let ((lap (byte-to-native-lambda-lap
(gethash (aref byte-code 1)
byte-to-native-lambdas-h))))
@@ -798,7 +804,11 @@ clashes."
filename
(when byte-native-for-bootstrap
(car (last comp-eln-load-path))))))
- (setf (comp-ctxt-top-level-forms comp-ctxt)
+ (setf (comp-ctxt-speed comp-ctxt) (alist-get 'comp-speed
+ byte-native-qualities)
+ (comp-ctxt-debug comp-ctxt) (alist-get 'comp-debug
+ byte-native-qualities)
+ (comp-ctxt-top-level-forms comp-ctxt)
(cl-loop
for form in (reverse byte-to-native-top-level-forms)
collect
@@ -1575,7 +1585,7 @@ into the C code forwarding the compilation unit."
;; the last function being
;; registered.
:frame-size 2
- :speed comp-speed))
+ :speed (comp-ctxt-speed comp-ctxt)))
(comp-func func)
(comp-pass (make-comp-limplify
:curr-block (make--comp-block-lap -1 0 'top-level)
@@ -2670,9 +2680,7 @@ Prepare every function for final compilation and drive the C back-end."
(print-circle t)
(expr `(progn
(require 'comp)
- (setf comp-speed ,comp-speed
- comp-debug ,comp-debug
- comp-verbose ,comp-verbose
+ (setf comp-verbose ,comp-verbose
comp-ctxt ,comp-ctxt
comp-eln-load-path ',comp-eln-load-path
comp-native-driver-options
@@ -2988,6 +2996,7 @@ load once finished compiling."
(list "Not a function symbol or file" function-or-file)))
(let* ((data function-or-file)
(comp-native-compiling t)
+ (byte-native-qualities nil)
;; Have byte compiler signal an error when compilation fails.
(byte-compile-debug t)
(comp-ctxt (make-comp-ctxt :output output