1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

Fix typos and doc strings in native-compilation files

* lisp/emacs-lisp/comp.el (comp-speed, comp-debug, comp-verbose)
(comp-always-compile, comp-deferred-compilation-deny-list)
(comp-bootstrap-deny-list, comp-never-optimize-functions)
(comp-async-jobs-number, comp-async-cu-done-hook)
(comp-async-all-done-hook, comp-async-env-modifier-form)
(comp-pass, comp-native-compiling, comp-post-pass-hooks)
(comp-known-predicate-p, comp-pred-to-cstr)
(comp-symbol-values-optimizable, comp-limple-assignments)
(comp-limple-calls, comp-limple-branches, comp-block)
(comp-vec--verify-idx, comp-vec-aref, comp-vec-append)
(comp-vec-prepend, comp-block-preds)
(comp-ensure-native-compiler, comp-log, comp-log-func)
(comp-loop-insn-in-block, comp-byte-frame-size)
(comp-add-func-to-ctxt, comp-spill-lap-function, comp-spill-lap)
(comp-lap-fall-through-p, comp-new-frame, comp-emit-set-call)
(comp-copy-slot, comp-latch-make-fill, comp-emit-cond-jump)
(comp-body-eff, comp-op-case, comp-prepare-args-for-top-level)
(comp-limplify-top-level, comp-negate-arithm-cmp-fun)
(comp-emit-assume, comp-cond-cstrs-target-mvar)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-form-tco-call-seq, comp-clean-up-stale-eln)
(comp-delete-or-replace-file, comp--native-compile)
(native--compile-async, native-compile)
(batch-byte-native-compile-for-bootstrap): Fix typos, wording, and
punctuation in doc strings.
* lisp/loadup.el: Fix typos.

* src/lread.c (syms_of_lread): Doc fix.
This commit is contained in:
Eli Zaretskii 2021-03-04 20:36:43 +02:00
parent 6444f69de2
commit b456b19ec4
3 changed files with 112 additions and 111 deletions

View File

@ -45,56 +45,57 @@
:group 'lisp) :group 'lisp)
(defcustom comp-speed 2 (defcustom comp-speed 2
"Compiler optimization level. From -1 to 3. "Optimization level for native compilation, a number between -1 and 3.
- -1 functions are kept in bytecode form and no native compilation is performed. -1 functions are kept in bytecode form and no native compilation is performed.
- 0 native compilation is performed with no optimizations. 0 native compilation is performed with no optimizations.
- 1 lite optimizations. 1 light optimizations.
- 2 max optimization level fully adherent to the language semantic. 2 max optimization level fully adherent to the language semantic.
- 3 max optimization level, to be used only when necessary. 3 max optimization level, to be used only when necessary.
Warning: the compiler is free to perform dangerous optimizations." Warning: with 3, the compiler is free to perform dangerous optimizations."
:type 'integer :type 'integer
:safe #'integerp :safe #'integerp
:version "28.1") :version "28.1")
(defcustom comp-debug 0 (defcustom comp-debug 0
"Compiler debug level. From 0 to 3. "Debug level for native compilation, a number between 0 and 3.
This intended for debugging the compiler itself. This is intended for debugging the compiler itself.
- 0 no debug facility. 0 no debugging output.
This is the recommended value unless you are debugging the compiler itself. This is the recommended value unless you are debugging the compiler itself.
- 1 emit debug symbols and dump pseudo C code. 1 emit debug symbols and dump pseudo C code.
- 2 dump gcc passes and libgccjit log file. 2 dump gcc passes and libgccjit log file.
- 3 dump libgccjit reproducers." 3 dump libgccjit reproducers."
:type 'integer :type 'integer
:safe #'natnump :safe #'natnump
:version "28.1") :version "28.1")
(defcustom comp-verbose 0 (defcustom comp-verbose 0
"Compiler verbosity. From 0 to 3. "Compiler verbosity for native compilation, a number between 0 and 3.
This intended for debugging the compiler itself. This is intended for debugging the compiler itself.
- 0 no logging. 0 no logging.
- 1 final limple is logged. 1 final LIMPLE is logged.
- 2 LAP and final limple and some pass info are logged. 2 LAP, final LIMPLE, and some pass info are logged.
- 3 max verbosity." 3 max verbosity."
:type 'integer :type 'integer
:risky t :risky t
:version "28.1") :version "28.1")
(defcustom comp-always-compile nil (defcustom comp-always-compile nil
"Unconditionally (re-)compile all files." "Non-nil means unconditionally (re-)compile all files."
:type 'boolean :type 'boolean
:version "28.1") :version "28.1")
(defcustom comp-deferred-compilation-deny-list (defcustom comp-deferred-compilation-deny-list
'() '()
"List of regexps to exclude files from deferred native compilation. "List of regexps to exclude matching files from deferred native compilation.
Skip if any is matching." Files whose names match any regexp is excluded from native compilation."
:type 'list :type 'list
:version "28.1") :version "28.1")
(defcustom comp-bootstrap-deny-list (defcustom comp-bootstrap-deny-list
'() '()
"List of regexps to exclude files from native compilation during bootstrap. "List of regexps to exclude files from native compilation during bootstrap.
Skip if any is matching." Files whose names match any regexp is excluded from native compilation
during bootstrap."
:type 'list :type 'list
:version "28.1") :version "28.1")
@ -103,13 +104,14 @@ Skip if any is matching."
;; correctly (see comment in `advice--add-function'). DO NOT ;; correctly (see comment in `advice--add-function'). DO NOT
;; REMOVE. ;; REMOVE.
macroexpand rename-buffer) macroexpand rename-buffer)
"Primitive functions for which we do not perform trampoline optimization." "Primitive functions to exclude from trampoline optimization."
:type 'list :type 'list
:version "28.1") :version "28.1")
(defcustom comp-async-jobs-number 0 (defcustom comp-async-jobs-number 0
"Default number of processes used for async compilation. "Default number of subprocesses used for async native compilation.
When zero use half of the CPUs or at least one." Value of zero means to use half the number of the CPU's execution units,
or one if there's just one execution unit."
:type 'integer :type 'integer
:risky t :risky t
:version "28.1") :version "28.1")
@ -118,19 +120,18 @@ When zero use half of the CPUs or at least one."
;; like `comp-async-cu-done-function'. ;; like `comp-async-cu-done-function'.
(defcustom comp-async-cu-done-hook nil (defcustom comp-async-cu-done-hook nil
"Hook run after asynchronously compiling a single compilation unit. "Hook run after asynchronously compiling a single compilation unit.
The argument FILE passed to the function is the filename used as Called with one argument FILE, the filename used as input to compilation."
compilation input."
:type 'hook :type 'hook
:version "28.1") :version "28.1")
(defcustom comp-async-all-done-hook nil (defcustom comp-async-all-done-hook nil
"Hook run after asynchronously compiling all input files." "Hook run after completing asynchronous compilation of all input files."
:type 'hook :type 'hook
:version "28.1") :version "28.1")
(defcustom comp-async-env-modifier-form nil (defcustom comp-async-env-modifier-form nil
"Form evaluated before compilation by each asynchronous compilation worker. "Form evaluated before compilation by each asynchronous compilation subprocess.
Usable to modify the compiler environment." Used to modify the compiler environment."
:type 'list :type 'list
:risky t :risky t
:version "28.1") :version "28.1")
@ -195,11 +196,12 @@ the .eln output directory."
"Name of the async compilation buffer log.") "Name of the async compilation buffer log.")
(defvar comp-native-compiling nil (defvar comp-native-compiling nil
"This gets bound to t while native compilation. "This gets bound to t during native compilation.
Can be used by code that wants to expand differently in this case.") Intended to be used by code that needs to work differently when
native compilation runs.")
(defvar comp-pass nil (defvar comp-pass nil
"Every pass has the right to bind what it likes here.") "Every native-compilation pass can bind this to whatever it likes.")
(defvar comp-curr-allocation-class 'd-default (defvar comp-curr-allocation-class 'd-default
"Current allocation class. "Current allocation class.
@ -223,7 +225,7 @@ Can be one of: 'd-default', 'd-impure' or 'd-ephemeral'. See `comp-ctxt'.")
For internal use only by the testsuite.") For internal use only by the testsuite.")
(defvar comp-post-pass-hooks '() (defvar comp-post-pass-hooks '()
"Alist PASS FUNCTIONS. "Alist whose elements are of the form (PASS FUNCTIONS...).
Each function in FUNCTIONS is run after PASS. Each function in FUNCTIONS is run after PASS.
Useful to hook into pass checkers.") Useful to hook into pass checkers.")
@ -583,16 +585,16 @@ Useful to hook into pass checkers.")
"Hash table function -> `comp-constraint'") "Hash table function -> `comp-constraint'")
(defun comp-known-predicate-p (predicate) (defun comp-known-predicate-p (predicate)
"Predicate matching if PREDICATE is known." "Return t if PREDICATE is known."
(when (gethash predicate comp-known-predicates-h) t)) (when (gethash predicate comp-known-predicates-h) t))
(defun comp-pred-to-cstr (predicate) (defun comp-pred-to-cstr (predicate)
"Given PREDICATE return the correspondig constraint." "Given PREDICATE, return the correspondig constraint."
(gethash predicate comp-known-predicates-h)) (gethash predicate comp-known-predicates-h))
(defconst comp-symbol-values-optimizable '(most-positive-fixnum (defconst comp-symbol-values-optimizable '(most-positive-fixnum
most-negative-fixnum) most-negative-fixnum)
"Symbol values we can resolve in the compile-time.") "Symbol values we can resolve at compile-time.")
(defconst comp-type-hints '(comp-hint-fixnum (defconst comp-type-hints '(comp-hint-fixnum
comp-hint-cons) comp-hint-cons)
@ -608,16 +610,16 @@ Useful to hook into pass checkers.")
(defconst comp-limple-assignments `(assume (defconst comp-limple-assignments `(assume
fetch-handler fetch-handler
,@comp-limple-sets) ,@comp-limple-sets)
"Limple operators that clobbers the first m-var argument.") "Limple operators that clobber the first m-var argument.")
(defconst comp-limple-calls '(call (defconst comp-limple-calls '(call
callref callref
direct-call direct-call
direct-callref) direct-callref)
"Limple operators use to call subrs.") "Limple operators used to call subrs.")
(defconst comp-limple-branches '(jump cond-jump) (defconst comp-limple-branches '(jump cond-jump)
"Limple operators use for conditional and unconditional branches.") "Limple operators used for conditional and unconditional branches.")
(defconst comp-limple-ops `(,@comp-limple-calls (defconst comp-limple-ops `(,@comp-limple-calls
,@comp-limple-assignments ,@comp-limple-assignments
@ -629,7 +631,7 @@ Useful to hook into pass checkers.")
"Bound to the current function by most passes.") "Bound to the current function by most passes.")
(defvar comp-block nil (defvar comp-block nil
"Bound to the current basic block by some pass.") "Bound to the current basic block by some passes.")
(define-error 'native-compiler-error-dyn-func (define-error 'native-compiler-error-dyn-func
"can't native compile a non-lexically-scoped function" "can't native compile a non-lexically-scoped function"
@ -657,12 +659,12 @@ Useful to hook into pass checkers.")
(- (comp-vec-end vec) (comp-vec-beg vec))) (- (comp-vec-end vec) (comp-vec-beg vec)))
(defsubst comp-vec--verify-idx (vec idx) (defsubst comp-vec--verify-idx (vec idx)
"Check idx is in bounds for VEC." "Check whether idx is in bounds for VEC."
(cl-assert (and (< idx (comp-vec-end vec)) (cl-assert (and (< idx (comp-vec-end vec))
(>= idx (comp-vec-beg vec))))) (>= idx (comp-vec-beg vec)))))
(defsubst comp-vec-aref (vec idx) (defsubst comp-vec-aref (vec idx)
"Return the element of VEC at index IDX." "Return the element of VEC whose index is IDX."
(declare (gv-setter (lambda (val) (declare (gv-setter (lambda (val)
`(comp-vec--verify-idx ,vec ,idx) `(comp-vec--verify-idx ,vec ,idx)
`(puthash ,idx ,val (comp-vec-data ,vec))))) `(puthash ,idx ,val (comp-vec-data ,vec)))))
@ -671,14 +673,14 @@ Useful to hook into pass checkers.")
(defsubst comp-vec-append (vec elt) (defsubst comp-vec-append (vec elt)
"Append ELT into VEC. "Append ELT into VEC.
ELT is returned." Returns ELT."
(puthash (comp-vec-end vec) elt (comp-vec-data vec)) (puthash (comp-vec-end vec) elt (comp-vec-data vec))
(cl-incf (comp-vec-end vec)) (cl-incf (comp-vec-end vec))
elt) elt)
(defsubst comp-vec-prepend (vec elt) (defsubst comp-vec-prepend (vec elt)
"Prepend ELT into VEC. "Prepend ELT into VEC.
ELT is returned." Returns ELT."
(puthash (1- (comp-vec-beg vec)) elt (comp-vec-data vec)) (puthash (1- (comp-vec-beg vec)) elt (comp-vec-data vec))
(cl-decf (comp-vec-beg vec)) (cl-decf (comp-vec-beg vec))
elt) elt)
@ -818,7 +820,7 @@ non local exit (ends with an `unreachable' insn)."))
(comp-func-edges-h comp-func)))) (comp-func-edges-h comp-func))))
(defun comp-block-preds (basic-block) (defun comp-block-preds (basic-block)
"Given BASIC-BLOCK return the list of its predecessors." "Return the list of predecessors of BASIC-BLOCK."
(mapcar #'comp-edge-src (comp-block-in-edges basic-block))) (mapcar #'comp-edge-src (comp-block-in-edges basic-block)))
(defun comp-gen-counter () (defun comp-gen-counter ()
@ -895,14 +897,14 @@ In use by the backend."
(defun comp-ensure-native-compiler () (defun comp-ensure-native-compiler ()
"Make sure Emacs has native compiler support and libgccjit is loadable. "Make sure Emacs has native compiler support and libgccjit can be loaded.
Signal an error otherwise. Signal an error otherwise.
To be used by all entry points." To be used by all entry points."
(cond (cond
((null (featurep 'nativecomp)) ((null (featurep 'nativecomp))
(error "Emacs not compiled with native compiler support (--with-nativecomp)")) (error "Emacs was not compiled with native compiler support (--with-native-compilation)"))
((null (native-comp-available-p)) ((null (native-comp-available-p))
(error "Cannot find libgccjit")))) (error "Cannot find libgccjit library"))))
(defun comp-equality-fun-p (function) (defun comp-equality-fun-p (function)
"Equality functions predicate for FUNCTION." "Equality functions predicate for FUNCTION."
@ -997,9 +999,9 @@ Assume allocation class 'd-default as default."
(cl-defun comp-log (data &optional (level 1) quoted) (cl-defun comp-log (data &optional (level 1) quoted)
"Log DATA at LEVEL. "Log DATA at LEVEL.
LEVEL is a number from 1-3; if it is less than `comp-verbose', do LEVEL is a number from 1-3, and defaults to 1; if it is less
nothing. If `noninteractive', log with `message'. Otherwise, than `comp-verbose', do nothing. If `noninteractive', log
log with `comp-log-to-buffer'." with `message'. Otherwise, log with `comp-log-to-buffer'."
(when (>= comp-verbose level) (when (>= comp-verbose level)
(if noninteractive (if noninteractive
(cl-typecase data (cl-typecase data
@ -1050,7 +1052,7 @@ log with `comp-log-to-buffer'."
(cons (concat "(" (mapconcat #'comp-prettyformat-insn insn " ") ")")))) (cons (concat "(" (mapconcat #'comp-prettyformat-insn insn " ") ")"))))
(defun comp-log-func (func verbosity) (defun comp-log-func (func verbosity)
"Log function FUNC. "Log function FUNC at VERBOSITY.
VERBOSITY is a number between 0 and 3." VERBOSITY is a number between 0 and 3."
(when (>= comp-verbose verbosity) (when (>= comp-verbose verbosity)
(comp-log (format "\nFunction: %s\n" (comp-func-name func)) verbosity) (comp-log (format "\nFunction: %s\n" (comp-func-name func)) verbosity)
@ -1080,7 +1082,7 @@ VERBOSITY is a number between 0 and 3."
(defmacro comp-loop-insn-in-block (basic-block &rest body) (defmacro comp-loop-insn-in-block (basic-block &rest body)
"Loop over all insns in BASIC-BLOCK executing BODY. "Loop over all insns in BASIC-BLOCK executing BODY.
Inside BODY `insn' and `insn-cell'can be used to read or set the Inside BODY, `insn' and `insn-cell'can be used to read or set the
current instruction or its cell." current instruction or its cell."
(declare (debug (form body)) (declare (debug (form body))
(indent defun)) (indent defun))
@ -1157,11 +1159,11 @@ clashes."
:rest rest)))) :rest rest))))
(defsubst comp-byte-frame-size (byte-compiled-func) (defsubst comp-byte-frame-size (byte-compiled-func)
"Given BYTE-COMPILED-FUNC return the frame size to be allocated." "Return the frame size to be allocated for BYTE-COMPILED-FUNC."
(aref byte-compiled-func 3)) (aref byte-compiled-func 3))
(defun comp-add-func-to-ctxt (func) (defun comp-add-func-to-ctxt (func)
"Add FUNC to the current compiler contex." "Add FUNC to the current compiler context."
(let ((name (comp-func-name func)) (let ((name (comp-func-name func))
(c-name (comp-func-c-name func))) (c-name (comp-func-c-name func)))
(puthash name c-name (comp-ctxt-sym-to-c-name-h comp-ctxt)) (puthash name c-name (comp-ctxt-sym-to-c-name-h comp-ctxt))
@ -1171,7 +1173,7 @@ clashes."
"Byte-compile INPUT and spill lap for further stages.") "Byte-compile INPUT and spill lap for further stages.")
(cl-defmethod comp-spill-lap-function ((function-name symbol)) (cl-defmethod comp-spill-lap-function ((function-name symbol))
"Byte-compile FUNCTION-NAME spilling data from the byte compiler." "Byte-compile FUNCTION-NAME, spilling data from the byte compiler."
(unless (comp-ctxt-output comp-ctxt) (unless (comp-ctxt-output comp-ctxt)
(setf (comp-ctxt-output comp-ctxt) (setf (comp-ctxt-output comp-ctxt)
(make-temp-file (comp-c-func-name function-name "freefn-") (make-temp-file (comp-c-func-name function-name "freefn-")
@ -1208,10 +1210,10 @@ clashes."
(comp-add-func-to-ctxt func)))) (comp-add-func-to-ctxt func))))
(cl-defmethod comp-spill-lap-function ((form list)) (cl-defmethod comp-spill-lap-function ((form list))
"Byte-compile FORM spilling data from the byte compiler." "Byte-compile FORM, spilling data from the byte compiler."
(unless (eq (car-safe form) 'lambda) (unless (eq (car-safe form) 'lambda)
(signal 'native-compiler-error (signal 'native-compiler-error
"Cannot native compile, form is not a lambda")) "Cannot native-compile, form is not a lambda"))
(unless (comp-ctxt-output comp-ctxt) (unless (comp-ctxt-output comp-ctxt)
(setf (comp-ctxt-output comp-ctxt) (setf (comp-ctxt-output comp-ctxt)
(make-temp-file "comp-lambda-" nil ".eln"))) (make-temp-file "comp-lambda-" nil ".eln")))
@ -1283,7 +1285,7 @@ clashes."
(comp-log lap 1 t)))) (comp-log lap 1 t))))
(cl-defmethod comp-spill-lap-function ((filename string)) (cl-defmethod comp-spill-lap-function ((filename string))
"Byte-compile FILENAME spilling data from the byte compiler." "Byte-compile FILENAME, spilling data from the byte compiler."
(byte-compile-file filename) (byte-compile-file filename)
(unless byte-to-native-top-level-forms (unless byte-to-native-top-level-forms
(signal 'native-compiler-error-empty-byte filename)) (signal 'native-compiler-error-empty-byte filename))
@ -1316,8 +1318,8 @@ clashes."
(defun comp-spill-lap (input) (defun comp-spill-lap (input)
"Byte-compile and spill the LAP representation for INPUT. "Byte-compile and spill the LAP representation for INPUT.
If INPUT is a symbol this is the function-name to be compiled. If INPUT is a symbol, it is the function-name to be compiled.
If INPUT is a string this is the filename to be compiled." If INPUT is a string, it is the filename to be compiled."
(let ((byte-native-compiling t) (let ((byte-native-compiling t)
(byte-to-native-lambdas-h (make-hash-table :test #'eq)) (byte-to-native-lambdas-h (make-hash-table :test #'eq))
(byte-to-native-top-level-forms ()) (byte-to-native-top-level-forms ())
@ -1355,7 +1357,7 @@ Points to the next slot to be filled.")
t)) t))
(defun comp-lap-fall-through-p (inst) (defun comp-lap-fall-through-p (inst)
"Return t if INST fall through, nil otherwise." "Return t if INST falls through, nil otherwise."
(when (not (memq (car inst) '(byte-goto byte-return))) (when (not (memq (car inst) '(byte-goto byte-return)))
t)) t))
@ -1442,7 +1444,7 @@ STACK-OFF is the index of the first slot frame involved."
(defun comp-new-frame (size vsize &optional ssa) (defun comp-new-frame (size vsize &optional ssa)
"Return a clean frame of meta variables of size SIZE and VSIZE. "Return a clean frame of meta variables of size SIZE and VSIZE.
If SSA non-nil populate it of m-var in ssa form." If SSA is non-nil, populate it with m-var in ssa form."
(cl-loop with v = (make-comp-vec :beg (- vsize) :end size) (cl-loop with v = (make-comp-vec :beg (- vsize) :end size)
for i from (- vsize) below size for i from (- vsize) below size
for mvar = (if ssa for mvar = (if ssa
@ -1459,13 +1461,13 @@ If SSA non-nil populate it of m-var in ssa form."
(defun comp-emit-set-call (call) (defun comp-emit-set-call (call)
"Emit CALL assigning the result the the current slot frame. "Emit CALL assigning the result the the current slot frame.
If the callee function is known to have a return type propagate it." If the callee function is known to have a return type, propagate it."
(cl-assert call) (cl-assert call)
(comp-emit (list 'set (comp-slot) call))) (comp-emit (list 'set (comp-slot) call)))
(defun comp-copy-slot (src-n &optional dst-n) (defun comp-copy-slot (src-n &optional dst-n)
"Set slot number DST-N to slot number SRC-N as source. "Set slot number DST-N to slot number SRC-N as source.
If DST-N is specified use it otherwise assume it to be the current slot." If DST-N is specified, use it; otherwise assume it to be the current slot."
(comp-with-sp (or dst-n (comp-sp)) (comp-with-sp (or dst-n (comp-sp))
(let ((src-slot (comp-slot-n src-n))) (let ((src-slot (comp-slot-n src-n)))
(cl-assert src-slot) (cl-assert src-slot)
@ -1496,7 +1498,7 @@ Add block to the current function and return it."
(defun comp-latch-make-fill (target) (defun comp-latch-make-fill (target)
"Create a latch pointing to TARGET and fill it. "Create a latch pointing to TARGET and fill it.
Return the created latch" Return the created latch."
(let ((latch (make-comp-latch :name (comp-new-block-sym "latch"))) (let ((latch (make-comp-latch :name (comp-new-block-sym "latch")))
(curr-bb (comp-limplify-curr-block comp-pass))) (curr-bb (comp-limplify-curr-block comp-pass)))
;; See `comp-make-curr-block'. ;; See `comp-make-curr-block'.
@ -1530,8 +1532,8 @@ Return the created latch"
"Emit a conditional jump to LAP-LABEL when A and B satisfy EQ. "Emit a conditional jump to LAP-LABEL when A and B satisfy EQ.
TARGET-OFFSET is the positive offset on the SP when branching to the target TARGET-OFFSET is the positive offset on the SP when branching to the target
block. block.
If NEGATED non null negate the tested condition. If NEGATED is non null, negate the tested condition.
Return value is the fall through block name." Return value is the fall-through block name."
(cl-destructuring-bind (label-num . label-sp) lap-label (cl-destructuring-bind (label-num . label-sp) lap-label
(let* ((bb (comp-block-name (comp-bb-maybe-add (let* ((bb (comp-block-name (comp-bb-maybe-add
(1+ (comp-limplify-pc comp-pass)) (1+ (comp-limplify-pc comp-pass))
@ -1682,8 +1684,8 @@ SP-DELTA is the stack adjustment."
(intern (replace-regexp-in-string "byte-" "" x))) (intern (replace-regexp-in-string "byte-" "" x)))
(defun comp-body-eff (body op-name sp-delta) (defun comp-body-eff (body op-name sp-delta)
"Given the original body BODY compute the effective one. "Given the original BODY, compute the effective one.
When BODY is auto guess function name form the LAP byte-code When BODY is `auto', guess function name from the LAP byte-code
name. Otherwise expect lname fnname." name. Otherwise expect lname fnname."
(pcase (car body) (pcase (car body)
('auto ('auto
@ -1694,8 +1696,8 @@ name. Otherwise expect lname fnname."
(defmacro comp-op-case (&rest cases) (defmacro comp-op-case (&rest cases)
"Expand CASES into the corresponding `pcase' expansion. "Expand CASES into the corresponding `pcase' expansion.
This is responsible for generating the proper stack adjustment when known and This is responsible for generating the proper stack adjustment, when known,
the annotation emission." and the annotation emission."
(declare (debug (body)) (declare (debug (body))
(indent defun)) (indent defun))
`(pcase op `(pcase op
@ -1963,7 +1965,7 @@ the annotation emission."
func) func)
(cl-defgeneric comp-prepare-args-for-top-level (function) (cl-defgeneric comp-prepare-args-for-top-level (function)
"Given FUNCTION, return the two args arguments for comp--register-...") "Given FUNCTION, return the two arguments for comp--register-...")
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-l)) (cl-defmethod comp-prepare-args-for-top-level ((function comp-func-l))
"Lexically-scoped FUNCTION." "Lexically-scoped FUNCTION."
@ -1974,7 +1976,7 @@ the annotation emission."
'many))))) 'many)))))
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-d)) (cl-defmethod comp-prepare-args-for-top-level ((function comp-func-d))
"Dynamic scoped FUNCTION." "Dynamically scoped FUNCTION."
(cons (make-comp-mvar :constant (func-arity (comp-func-byte-func function))) (cons (make-comp-mvar :constant (func-arity (comp-func-byte-func function)))
(let ((comp-curr-allocation-class 'd-default)) (let ((comp-curr-allocation-class 'd-default))
;; Lambda-lists must stay in the same relocation class of ;; Lambda-lists must stay in the same relocation class of
@ -2060,15 +2062,15 @@ These are stored in the reloc data array."
(defun comp-limplify-top-level (for-late-load) (defun comp-limplify-top-level (for-late-load)
"Create a limple function to modify the global environment at load. "Create a limple function to modify the global environment at load.
When FOR-LATE-LOAD is non-nil the emitted function modifies only When FOR-LATE-LOAD is non-nil, the emitted function modifies only
function definition. function definition.
Synthesize a function called 'top_level_run' that gets one single Synthesize a function called `top_level_run' that gets one single
parameter (the compilation unit it-self). To define native parameter (the compilation unit itself). To define native
functions 'top_level_run' will call back `comp--register-subr' functions, `top_level_run' will call back `comp--register-subr'
into the C code forwarding the compilation unit." into the C code forwarding the compilation unit."
;; Once an .eln is loaded and Emacs is dumped 'top_level_run' has no ;; Once an .eln is loaded and Emacs is dumped 'top_level_run' has no
;; reasons to be execute ever again. Therefore all objects can be ;; reasons to be executed ever again. Therefore all objects can be
;; just ephemeral. ;; just ephemeral.
(let* ((comp-curr-allocation-class 'd-ephemeral) (let* ((comp-curr-allocation-class 'd-ephemeral)
(func (make-comp-func-l :name (if for-late-load (func (make-comp-func-l :name (if for-late-load
@ -2240,8 +2242,7 @@ into the C code forwarding the compilation unit."
(defun comp-negate-arithm-cmp-fun (function) (defun comp-negate-arithm-cmp-fun (function)
"Negate FUNCTION. "Negate FUNCTION.
Return nil if we don't want to emit constraints for its Return nil if we don't want to emit constraints for its negation."
negation."
(cl-ecase function (cl-ecase function
(= nil) (= nil)
(> '<=) (> '<=)
@ -2261,7 +2262,7 @@ negation."
(defun comp-emit-assume (kind lhs rhs bb negated) (defun comp-emit-assume (kind lhs rhs bb negated)
"Emit an assume of kind KIND for mvar LHS being RHS. "Emit an assume of kind KIND for mvar LHS being RHS.
When NEGATED is non-nil the assumption is negated. When NEGATED is non-nil, the assumption is negated.
The assume is emitted at the beginning of the block BB." The assume is emitted at the beginning of the block BB."
(let ((lhs-slot (comp-mvar-slot lhs))) (let ((lhs-slot (comp-mvar-slot lhs)))
(cl-assert lhs-slot) (cl-assert lhs-slot)
@ -2335,7 +2336,7 @@ Return OP otherwise."
;; Cheap substitute to a copy propagation pass... ;; Cheap substitute to a copy propagation pass...
(defun comp-cond-cstrs-target-mvar (mvar exit-insn bb) (defun comp-cond-cstrs-target-mvar (mvar exit-insn bb)
"Given MVAR search in BB the original mvar MVAR got assigned from. "Given MVAR, search in BB the original mvar MVAR got assigned from.
Keep on searching till EXIT-INSN is encountered." Keep on searching till EXIT-INSN is encountered."
(cl-flet ((targetp (x) (cl-flet ((targetp (x)
;; Ret t if x is an mvar and target the correct slot number. ;; Ret t if x is an mvar and target the correct slot number.
@ -3029,12 +3030,12 @@ Forward propagate immediate involed in assignments."
(comp-mvar-neg lval) (comp-mvar-neg rval))) (comp-mvar-neg lval) (comp-mvar-neg rval)))
(defun comp-function-foldable-p (f args) (defun comp-function-foldable-p (f args)
"Given function F called with ARGS return non-nil when optimizable." "Given function F called with ARGS, return non-nil when optimizable."
(and (comp-function-pure-p f) (and (comp-function-pure-p f)
(cl-every #'comp-cstr-imm-vld-p args))) (cl-every #'comp-cstr-imm-vld-p args)))
(defun comp-function-call-maybe-fold (insn f args) (defun comp-function-call-maybe-fold (insn f args)
"Given INSN when F is pure if all ARGS are known remove the function call. "Given INSN, when F is pure if all ARGS are known, remove the function call.
Return non-nil if the function is folded successfully." Return non-nil if the function is folded successfully."
(cl-flet ((rewrite-insn-as-setimm (insn value) (cl-flet ((rewrite-insn-as-setimm (insn value)
;; See `comp-emit-setimm'. ;; See `comp-emit-setimm'.
@ -3372,7 +3373,7 @@ Return the list of m-var ids nuked."
;;; Tail Call Optimization pass specific code. ;;; Tail Call Optimization pass specific code.
(defun comp-form-tco-call-seq (args) (defun comp-form-tco-call-seq (args)
"Generate a tco sequence for ARGS." "Generate a TCO sequence for ARGS."
`(,@(cl-loop for arg in args `(,@(cl-loop for arg in args
for i from 0 for i from 0
collect `(set ,(make-comp-mvar :slot i) ,arg)) collect `(set ,(make-comp-mvar :slot i) ,arg))
@ -3747,7 +3748,7 @@ Return the trampoline if found or nil otherwise."
;;;###autoload ;;;###autoload
(defun comp-clean-up-stale-eln (file) (defun comp-clean-up-stale-eln (file)
"Given FILE remove all the .eln files in `comp-eln-load-path' "Given FILE remove all its *.eln files in `comp-eln-load-path'
sharing the original source filename (including FILE)." sharing the original source filename (including FILE)."
(when (string-match (rx "-" (group-n 1 (1+ hex)) "-" (1+ hex) ".eln" eos) (when (string-match (rx "-" (group-n 1 (1+ hex)) "-" (1+ hex) ".eln" eos)
file) file)
@ -3765,7 +3766,7 @@ sharing the original source filename (including FILE)."
"Replace OLDFILE with NEWFILE. "Replace OLDFILE with NEWFILE.
When NEWFILE is nil just delete OLDFILE. When NEWFILE is nil just delete OLDFILE.
Takes the necessary steps when dealing with OLDFILE being a Takes the necessary steps when dealing with OLDFILE being a
shared libraries that may be currently loaded by a running Emacs shared library that might be currently loaded into a running Emacs
session." session."
(cond ((eq 'windows-nt system-type) (cond ((eq 'windows-nt system-type)
(ignore-errors (delete-file oldfile)) (ignore-errors (delete-file oldfile))
@ -3929,8 +3930,8 @@ display a message."
(defun comp--native-compile (function-or-file &optional with-late-load output) (defun comp--native-compile (function-or-file &optional with-late-load output)
"Compile FUNCTION-OR-FILE into native code. "Compile FUNCTION-OR-FILE into native code.
This serves as internal implementation of `native-compile'. This serves as internal implementation of `native-compile'.
When WITH-LATE-LOAD non-nil mark the compilation unit for late When WITH-LATE-LOAD is non-nil, mark the compilation unit for late
load once finished compiling." load once it finishes compiling."
(comp-ensure-native-compiler) (comp-ensure-native-compiler)
(unless (or (functionp function-or-file) (unless (or (functionp function-or-file)
(stringp function-or-file)) (stringp function-or-file))
@ -3975,7 +3976,7 @@ load once finished compiling."
(native-elisp-load data)))) (native-elisp-load data))))
(defun native-compile-async-skip-p (file load selector) (defun native-compile-async-skip-p (file load selector)
"Return non-nil when FILE compilation should be skipped. "Return non-nil if FILE's compilation should be skipped.
LOAD and SELECTOR work as described in `native--compile-async'." LOAD and SELECTOR work as described in `native--compile-async'."
;; Make sure we are not already compiling `file' (bug#40838). ;; Make sure we are not already compiling `file' (bug#40838).
@ -4014,13 +4015,13 @@ of (commands) to run simultaneously.
LOAD can also be the symbol `late'. This is used internally if LOAD can also be the symbol `late'. This is used internally if
the byte code has already been loaded when this function is the byte code has already been loaded when this function is
called. It means that we requests the special kind of load, called. It means that we request the special kind of load
necessary in that situation, called \"late\" loading. necessary in that situation, called \"late\" loading.
During a \"late\" load instead of executing all top level forms During a \"late\" load, instead of executing all top-level forms
of the original files, only function definitions are of the original files, only function definitions are
loaded (paying attention to have these effective only if the loaded (paying attention to have these effective only if the
bytecode definition was not changed in the meanwhile)." bytecode definition was not changed in the meantime)."
(comp-ensure-native-compiler) (comp-ensure-native-compiler)
(unless (member load '(nil t late)) (unless (member load '(nil t late))
(error "LOAD must be nil, t or 'late")) (error "LOAD must be nil, t or 'late"))
@ -4068,13 +4069,13 @@ bytecode definition was not changed in the meanwhile)."
"Compile FUNCTION-OR-FILE into native code. "Compile FUNCTION-OR-FILE into native code.
This is the synchronous entry-point for the Emacs Lisp native This is the synchronous entry-point for the Emacs Lisp native
compiler. compiler.
FUNCTION-OR-FILE is a function symbol, a form or the filename of FUNCTION-OR-FILE is a function symbol, a form, or the filename of
an Emacs Lisp source file. an Emacs Lisp source file.
When OUTPUT is non-nil use it as filename for the compiled If OUTPUT is non-nil, use it as the filename for the compiled
object. object.
If FUNCTION-OR-FILE is a filename return the filename of the If FUNCTION-OR-FILE is a filename, return the filename of the
compiled object. If FUNCTION-OR-FILE is a function symbol or a compiled object. If FUNCTION-OR-FILE is a function symbol or a
form return the compiled function." form, return the compiled function."
(comp--native-compile function-or-file nil output)) (comp--native-compile function-or-file nil output))
;;;###autoload ;;;###autoload
@ -4092,9 +4093,9 @@ Ultra cheap impersonation of `batch-byte-compile'."
;;;###autoload ;;;###autoload
(defun batch-byte-native-compile-for-bootstrap () (defun batch-byte-native-compile-for-bootstrap ()
"As `batch-byte-compile' but used for booststrap. "Like `batch-native-compile', but used for booststrap.
Generate .elc files in addition to the .eln one. If the Generate *.elc files in addition to the *.eln files. If the
environment variable 'NATIVE_DISABLED' is set byte compile only." environment variable 'NATIVE_DISABLED' is set, only byte compile."
(comp-ensure-native-compiler) (comp-ensure-native-compiler)
(if (equal (getenv "NATIVE_DISABLED") "1") (if (equal (getenv "NATIVE_DISABLED") "1")
(batch-byte-compile) (batch-byte-compile)

View File

@ -450,8 +450,9 @@ lost after dumping")))
(when (featurep 'nativecomp) (when (featurep 'nativecomp)
;; Fix the compilation unit filename to have it working when ;; Fix the compilation unit filename to have it working when
;; when installed or if the source directory got moved. This is set to be ;; installed or if the source directory got moved. This is set to be
;; a pair in the form: (rel-path-from-install-bin . rel-path-from-local-bin). ;; a cons cell of the form:
;; (rel-filename-from-install-bin . rel-filename-from-local-bin).
(let ((h (make-hash-table :test #'eq)) (let ((h (make-hash-table :test #'eq))
(bin-dest-dir (cadr (member "--bin-dest" command-line-args))) (bin-dest-dir (cadr (member "--bin-dest" command-line-args)))
(eln-dest-dir (cadr (member "--eln-dest" command-line-args)))) (eln-dest-dir (cadr (member "--eln-dest" command-line-args))))
@ -466,12 +467,12 @@ lost after dumping")))
(native-comp-unit-set-file (native-comp-unit-set-file
cu cu
(cons (cons
;; Relative path from the installed binary. ;; Relative filename from the installed binary.
(file-relative-name (concat eln-dest-dir (file-relative-name (concat eln-dest-dir
(file-name-nondirectory (file-name-nondirectory
(native-comp-unit-file cu))) (native-comp-unit-file cu)))
bin-dest-dir) bin-dest-dir)
;; Relative path from the built uninstalled binary. ;; Relative filename from the built uninstalled binary.
(file-relative-name (native-comp-unit-file cu) (file-relative-name (native-comp-unit-file cu)
invocation-directory)))) invocation-directory))))
h)))) h))))
@ -536,8 +537,8 @@ lost after dumping")))
(t (error "unrecognized dump mode %s" dump-mode))))) (t (error "unrecognized dump mode %s" dump-mode)))))
(when (and (featurep 'nativecomp) (when (and (featurep 'nativecomp)
(equal dump-mode "pdump")) (equal dump-mode "pdump"))
;; Don't enable this before bootstrap is completed the as the ;; Don't enable this before bootstrap is completed, as the
;; compiler infrastructure may not be usable. ;; compiler infrastructure may not be usable yet.
(setq comp-enable-subr-trampolines t)) (setq comp-enable-subr-trampolines t))
(message "Dumping under the name %s" output) (message "Dumping under the name %s" output)
(condition-case () (condition-case ()

View File

@ -5200,8 +5200,7 @@ that are loaded before your customizations are read! */);
load_prefer_newer = 0; load_prefer_newer = 0;
DEFVAR_BOOL ("load-no-native", load_no_native, DEFVAR_BOOL ("load-no-native", load_no_native,
doc: /* Do not try to load the a .eln file in place of doc: /* Non-nil means not to load a .eln file when a .elc was requested. */);
a .elc one. */);
load_no_native = false; load_no_native = false;
/* Vsource_directory was initialized in init_lread. */ /* Vsource_directory was initialized in init_lread. */