mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-24 14:30:43 -08:00
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.
This commit is contained in:
parent
acf101c636
commit
4a69e953f3
3 changed files with 39 additions and 25 deletions
|
|
@ -598,6 +598,8 @@ Each element is (INDEX . VALUE)")
|
|||
|
||||
(defvar byte-native-compiling nil
|
||||
"Non nil while native compiling.")
|
||||
(defvar byte-native-qualities nil
|
||||
"To spill default qualities from the compiled file.")
|
||||
(defvar byte-native-for-bootstrap nil
|
||||
"Non nil while compiling for bootstrap."
|
||||
;; During boostrap we produce both the .eln and the .elc together.
|
||||
|
|
@ -2216,6 +2218,11 @@ With argument ARG, insert value in current buffer after the form."
|
|||
(setq byte-compile-unresolved-functions nil)
|
||||
(setq byte-compile-noruntime-functions nil)
|
||||
(setq byte-compile-new-defuns nil)
|
||||
(when byte-native-compiling
|
||||
(defvar comp-speed)
|
||||
(push `(comp-speed . ,comp-speed) byte-native-qualities)
|
||||
(defvar comp-debug)
|
||||
(push `(comp-debug . ,comp-debug) byte-native-qualities))
|
||||
|
||||
;; Compile the forms from the input buffer.
|
||||
(while (progn
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue