2019-07-07 07:23:10 +00:00
|
|
|
|
;;; comp.el --- compilation of Lisp code into native code -*- lexical-binding: t -*-
|
|
|
|
|
|
2021-01-01 13:13:02 +00:00
|
|
|
|
;; Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
2019-07-07 07:23:10 +00:00
|
|
|
|
|
2021-04-26 00:24:48 +00:00
|
|
|
|
;; Author: Andrea Corallo <akrl@sdf.com>
|
2019-07-07 07:23:10 +00:00
|
|
|
|
;; Keywords: lisp
|
|
|
|
|
;; Package: emacs
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
2019-07-13 13:48:02 +00:00
|
|
|
|
;;; Commentary:
|
2020-11-16 02:50:10 +00:00
|
|
|
|
|
2019-07-14 12:39:29 +00:00
|
|
|
|
;; This code is an attempt to make the pig fly.
|
2019-09-23 10:45:06 +00:00
|
|
|
|
;; Or, to put it another way to make a 911 out of a turbocharged VW Bug.
|
2019-07-13 13:48:02 +00:00
|
|
|
|
|
2019-07-07 07:23:10 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2019-07-07 10:30:03 +00:00
|
|
|
|
(require 'bytecomp)
|
2019-07-08 09:37:17 +00:00
|
|
|
|
(require 'cl-extra)
|
2020-03-15 10:26:31 +00:00
|
|
|
|
(require 'cl-lib)
|
2020-02-25 22:35:02 +00:00
|
|
|
|
(require 'cl-macs)
|
2020-03-22 09:35:55 +00:00
|
|
|
|
(require 'cl-seq)
|
2020-03-15 10:26:31 +00:00
|
|
|
|
(require 'gv)
|
|
|
|
|
(require 'rx)
|
2019-07-08 09:37:17 +00:00
|
|
|
|
(require 'subr-x)
|
2020-08-15 08:54:22 +00:00
|
|
|
|
(require 'warnings)
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(require 'comp-cstr)
|
2019-07-07 07:23:10 +00:00
|
|
|
|
|
|
|
|
|
(defgroup comp nil
|
|
|
|
|
"Emacs Lisp native compiler."
|
|
|
|
|
:group 'lisp)
|
|
|
|
|
|
2021-05-06 08:12:48 +00:00
|
|
|
|
(defcustom native-comp-speed 2
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Optimization level for native compilation, a number between -1 and 3.
|
|
|
|
|
-1 functions are kept in bytecode form and no native compilation is performed.
|
|
|
|
|
0 native compilation is performed with no optimizations.
|
|
|
|
|
1 light optimizations.
|
|
|
|
|
2 max optimization level fully adherent to the language semantic.
|
|
|
|
|
3 max optimization level, to be used only when necessary.
|
|
|
|
|
Warning: with 3, the compiler is free to perform dangerous optimizations."
|
2021-02-26 17:03:19 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:safe #'integerp
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2019-11-10 13:51:38 +00:00
|
|
|
|
|
2021-05-06 08:14:00 +00:00
|
|
|
|
(defcustom native-comp-debug (if (eq 'windows-nt system-type) 1 0)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Debug level for native compilation, a number between 0 and 3.
|
|
|
|
|
This is intended for debugging the compiler itself.
|
2021-03-31 18:13:46 +00:00
|
|
|
|
0 no debug output.
|
|
|
|
|
1 emit debug symbols.
|
|
|
|
|
2 emit debug symbols and dump pseudo C code.
|
|
|
|
|
3 emit debug symbols and dump: pseudo C code, GCC intermediate
|
|
|
|
|
passes and libgccjit log file."
|
2021-02-26 17:03:19 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:safe #'natnump
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2019-11-10 13:51:38 +00:00
|
|
|
|
|
2021-05-06 08:17:12 +00:00
|
|
|
|
(defcustom native-comp-verbose 0
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Compiler verbosity for native compilation, a number between 0 and 3.
|
|
|
|
|
This is intended for debugging the compiler itself.
|
|
|
|
|
0 no logging.
|
|
|
|
|
1 final LIMPLE is logged.
|
|
|
|
|
2 LAP, final LIMPLE, and some pass info are logged.
|
|
|
|
|
3 max verbosity."
|
2021-02-26 17:03:19 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:risky t
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2019-08-11 09:59:31 +00:00
|
|
|
|
|
2021-05-06 08:18:32 +00:00
|
|
|
|
(defcustom native-comp-always-compile nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Non-nil means unconditionally (re-)compile all files."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
2019-11-10 19:01:48 +00:00
|
|
|
|
|
2020-11-23 19:25:00 +00:00
|
|
|
|
(defcustom comp-deferred-compilation-deny-list
|
2020-05-09 12:52:30 +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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"List of regexps to exclude matching files from deferred native compilation.
|
2021-04-27 05:18:14 +00:00
|
|
|
|
Files whose names match any regexp are excluded from native compilation."
|
2021-04-27 05:09:46 +00:00
|
|
|
|
:type '(repeat regexp)
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2020-05-09 12:52:30 +00:00
|
|
|
|
|
2021-05-06 08:19:35 +00:00
|
|
|
|
(defcustom native-comp-bootstrap-deny-list
|
2020-06-28 19:44:22 +00:00
|
|
|
|
'()
|
2020-05-06 17:55:33 +00:00
|
|
|
|
"List of regexps to exclude files from native compilation during bootstrap.
|
2021-04-27 05:18:14 +00:00
|
|
|
|
Files whose names match any regexp are excluded from native compilation
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
during bootstrap."
|
2021-04-27 05:09:46 +00:00
|
|
|
|
:type '(repeat regexp)
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2020-05-06 17:55:33 +00:00
|
|
|
|
|
2021-05-06 08:26:33 +00:00
|
|
|
|
(defcustom native-comp-never-optimize-functions
|
2020-09-23 07:50:01 +00:00
|
|
|
|
'(;; The following two are mandatory for Emacs to be working
|
|
|
|
|
;; correctly (see comment in `advice--add-function'). DO NOT
|
|
|
|
|
;; REMOVE.
|
|
|
|
|
macroexpand rename-buffer)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Primitive functions to exclude from trampoline optimization."
|
2021-04-27 05:09:46 +00:00
|
|
|
|
:type '(repeat symbol)
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2019-12-29 13:10:19 +00:00
|
|
|
|
|
2021-05-06 08:27:57 +00:00
|
|
|
|
(defcustom native-comp-async-jobs-number 0
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Default number of subprocesses used for async native compilation.
|
|
|
|
|
Value of zero means to use half the number of the CPU's execution units,
|
|
|
|
|
or one if there's just one execution unit."
|
2021-02-26 17:03:19 +00:00
|
|
|
|
:type 'integer
|
|
|
|
|
:risky t
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2020-03-15 19:37:51 +00:00
|
|
|
|
|
2021-04-27 01:37:43 +00:00
|
|
|
|
(defcustom comp-async-cu-done-functions nil
|
|
|
|
|
"List of functions to call after asynchronously compiling one compilation unit.
|
|
|
|
|
Called with one argument FILE, the filename used as input to
|
|
|
|
|
compilation."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:version "28.1")
|
2020-02-23 14:49:46 +00:00
|
|
|
|
|
|
|
|
|
(defcustom comp-async-all-done-hook nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Hook run after completing asynchronous compilation of all input files."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:version "28.1")
|
2020-02-23 14:49:46 +00:00
|
|
|
|
|
2020-05-18 19:45:29 +00:00
|
|
|
|
(defcustom comp-async-env-modifier-form nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Form evaluated before compilation by each asynchronous compilation subprocess.
|
|
|
|
|
Used to modify the compiler environment."
|
2021-04-27 05:09:46 +00:00
|
|
|
|
:type 'sexp
|
2021-02-26 17:03:19 +00:00
|
|
|
|
:risky t
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2020-05-18 19:45:29 +00:00
|
|
|
|
|
2020-10-23 08:26:31 +00:00
|
|
|
|
(defcustom comp-async-report-warnings-errors t
|
2021-02-26 14:15:06 +00:00
|
|
|
|
"Whether to report warnings and errors from asynchronous native compilation.
|
|
|
|
|
|
2021-02-26 14:50:41 +00:00
|
|
|
|
When native compilation happens asynchronously, it can produce
|
|
|
|
|
warnings and errors, some of which might not be emitted by a
|
|
|
|
|
byte-compilation. The typical case for that is native-compiling
|
|
|
|
|
a file that is missing some `require' of a necessary feature,
|
|
|
|
|
while having it already loaded into the environment when
|
|
|
|
|
byte-compiling.
|
|
|
|
|
|
|
|
|
|
As asynchronous native compilation always starts from a pristine
|
|
|
|
|
environment, it is more sensitive to such omissions, and might be
|
|
|
|
|
unable to compile such Lisp source files correctly.
|
|
|
|
|
|
|
|
|
|
Set this variable to nil if these warnings annoy you."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
2020-10-23 08:26:31 +00:00
|
|
|
|
|
2021-02-26 07:49:58 +00:00
|
|
|
|
(defcustom comp-async-query-on-exit nil
|
2021-02-26 14:08:44 +00:00
|
|
|
|
"Whether to query the user about killing async compilations when exiting.
|
|
|
|
|
If this is non-nil, Emacs will ask for confirmation to exit and kill the
|
|
|
|
|
asynchronous native compilations if any are running. If nil, when you
|
|
|
|
|
exit Emacs, it will silently kill those asynchronous compilations even
|
|
|
|
|
if `confirm-kill-processes' is non-nil."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
2021-02-26 07:49:58 +00:00
|
|
|
|
|
2020-08-08 20:22:43 +00:00
|
|
|
|
(defcustom comp-native-driver-options nil
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"Options passed verbatim to the native compiler's back-end driver.
|
2020-08-08 20:22:43 +00:00
|
|
|
|
Note that not all options are meaningful; typically only the options
|
|
|
|
|
affecting the assembler and linker are likely to be useful.
|
|
|
|
|
|
|
|
|
|
Passing these options is only available in libgccjit version 9
|
|
|
|
|
and above."
|
2021-04-27 05:09:46 +00:00
|
|
|
|
:type '(repeat string) ; FIXME is this right?
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:version "28.1")
|
2020-05-18 19:45:29 +00:00
|
|
|
|
|
2021-01-07 23:44:55 +00:00
|
|
|
|
(defcustom comp-libgccjit-reproducer nil
|
|
|
|
|
"When non-nil produce a libgccjit reproducer.
|
2021-01-09 11:24:15 +00:00
|
|
|
|
The reproducer is a file ELNFILENAME_libgccjit_repro.c deposed in
|
|
|
|
|
the .eln output directory."
|
2021-02-26 16:56:36 +00:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
2021-01-07 23:44:55 +00:00
|
|
|
|
|
2021-04-01 12:27:12 +00:00
|
|
|
|
(defcustom comp-warning-on-missing-source t
|
|
|
|
|
"Emit a warning if a byte-code file being loaded has no corresponding source.
|
|
|
|
|
The source file is necessary for native code file look-up and deferred
|
|
|
|
|
compilation mechanism."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2021-03-12 09:24:29 +00:00
|
|
|
|
(defvar no-native-compile nil
|
|
|
|
|
"Non-nil to prevent native-compiling of Emacs Lisp code.
|
2021-03-16 08:10:31 +00:00
|
|
|
|
Note that when `no-byte-compile' is set to non-nil it overrides the value of
|
|
|
|
|
`no-native-compile'.
|
2021-04-27 12:17:44 +00:00
|
|
|
|
This is normally set in local file variables at the end of the
|
|
|
|
|
Emacs Lisp file:
|
2021-03-12 09:24:29 +00:00
|
|
|
|
|
2021-04-25 18:47:20 +00:00
|
|
|
|
\;; Local Variables:\n;; no-native-compile: t\n;; End:")
|
2021-03-12 09:24:29 +00:00
|
|
|
|
;;;###autoload(put 'no-native-compile 'safe-local-variable 'booleanp)
|
|
|
|
|
|
2021-01-10 14:39:16 +00:00
|
|
|
|
(defvar comp-log-time-report nil
|
|
|
|
|
"If non-nil, log a time report for each pass.")
|
|
|
|
|
|
2020-02-16 10:31:46 +00:00
|
|
|
|
(defvar comp-dry-run nil
|
2020-11-16 02:50:10 +00:00
|
|
|
|
"If non-nil, run everything but the C back-end.")
|
2020-02-16 10:31:46 +00:00
|
|
|
|
|
2020-08-16 12:33:25 +00:00
|
|
|
|
(defconst comp-valid-source-re (rx ".el" (? ".gz") eos)
|
|
|
|
|
"Regexp to match filename of valid input source files.")
|
|
|
|
|
|
2019-11-24 17:34:54 +00:00
|
|
|
|
(defconst comp-log-buffer-name "*Native-compile-Log*"
|
2019-11-24 17:42:40 +00:00
|
|
|
|
"Name of the native-compiler log buffer.")
|
2019-07-07 07:23:10 +00:00
|
|
|
|
|
2019-11-24 17:42:40 +00:00
|
|
|
|
(defconst comp-async-buffer-name "*Async-native-compile-log*"
|
|
|
|
|
"Name of the async compilation buffer log.")
|
2019-11-24 17:25:04 +00:00
|
|
|
|
|
2019-09-23 09:48:19 +00:00
|
|
|
|
(defvar comp-native-compiling nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"This gets bound to t during native compilation.
|
|
|
|
|
Intended to be used by code that needs to work differently when
|
|
|
|
|
native compilation runs.")
|
2019-09-23 09:48:19 +00:00
|
|
|
|
|
2019-07-21 13:20:39 +00:00
|
|
|
|
(defvar comp-pass nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Every native-compilation pass can bind this to whatever it likes.")
|
2019-07-21 13:20:39 +00:00
|
|
|
|
|
2020-02-25 21:39:59 +00:00
|
|
|
|
(defvar comp-curr-allocation-class 'd-default
|
2020-02-25 22:35:02 +00:00
|
|
|
|
"Current allocation class.
|
2020-02-25 21:39:59 +00:00
|
|
|
|
Can be one of: 'd-default', 'd-impure' or 'd-ephemeral'. See `comp-ctxt'.")
|
2020-02-21 14:28:05 +00:00
|
|
|
|
|
2019-07-21 13:20:39 +00:00
|
|
|
|
(defconst comp-passes '(comp-spill-lap
|
2019-09-07 06:57:07 +00:00
|
|
|
|
comp-limplify
|
2020-07-12 13:05:46 +00:00
|
|
|
|
comp-fwprop
|
2019-09-18 09:30:23 +00:00
|
|
|
|
comp-call-optim
|
2020-07-05 19:26:36 +00:00
|
|
|
|
comp-ipa-pure
|
2020-12-15 15:57:23 +00:00
|
|
|
|
comp-add-cstrs
|
2020-07-12 13:05:46 +00:00
|
|
|
|
comp-fwprop
|
2020-02-16 11:19:10 +00:00
|
|
|
|
comp-tco
|
2020-07-12 13:05:46 +00:00
|
|
|
|
comp-fwprop
|
2020-05-25 19:27:46 +00:00
|
|
|
|
comp-remove-type-hints
|
2019-09-07 06:57:07 +00:00
|
|
|
|
comp-final)
|
2019-07-07 10:30:03 +00:00
|
|
|
|
"Passes to be executed in order.")
|
|
|
|
|
|
2020-07-08 13:23:09 +00:00
|
|
|
|
(defvar comp-disabled-passes '()
|
|
|
|
|
"List of disabled passes.
|
2021-04-27 12:17:44 +00:00
|
|
|
|
For internal use by the test suite only.")
|
2020-07-08 13:23:09 +00:00
|
|
|
|
|
2020-11-11 16:23:25 +00:00
|
|
|
|
(defvar comp-post-pass-hooks '()
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Alist whose elements are of the form (PASS FUNCTIONS...).
|
2020-07-02 19:29:34 +00:00
|
|
|
|
Each function in FUNCTIONS is run after PASS.
|
|
|
|
|
Useful to hook into pass checkers.")
|
|
|
|
|
|
2020-11-14 15:55:39 +00:00
|
|
|
|
;; FIXME this probably should not be here but... good for now.
|
2020-11-12 16:27:31 +00:00
|
|
|
|
(defconst comp-known-type-specifiers
|
2020-12-29 18:41:28 +00:00
|
|
|
|
`(
|
2020-12-30 12:50:23 +00:00
|
|
|
|
;; Functions we can trust not to be or if redefined should expose
|
|
|
|
|
;; the same type. Vast majority of these is either pure or
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; primitive, the original list is the union of pure +
|
2020-12-30 12:50:23 +00:00
|
|
|
|
;; side-effect-free-fns + side-effect-and-error-free-fns:
|
|
|
|
|
(% (function ((or number marker) (or number marker)) number))
|
|
|
|
|
(* (function (&rest (or number marker)) number))
|
2020-11-12 16:27:31 +00:00
|
|
|
|
(+ (function (&rest (or number marker)) number))
|
|
|
|
|
(- (function (&rest (or number marker)) number))
|
|
|
|
|
(/ (function ((or number marker) &rest (or number marker)) number))
|
2020-11-14 15:55:39 +00:00
|
|
|
|
(/= (function ((or number marker) (or number marker)) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(1+ (function ((or number marker)) number))
|
|
|
|
|
(1- (function ((or number marker)) number))
|
2020-11-14 15:55:39 +00:00
|
|
|
|
(< (function ((or number marker) &rest (or number marker)) boolean))
|
|
|
|
|
(<= (function ((or number marker) &rest (or number marker)) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(= (function ((or number marker) &rest (or number marker)) boolean))
|
2020-11-14 15:55:39 +00:00
|
|
|
|
(> (function ((or number marker) &rest (or number marker)) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(>= (function ((or number marker) &rest (or number marker)) boolean))
|
2020-11-14 15:55:39 +00:00
|
|
|
|
(abs (function (number) number))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(acos (function (number) float))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(append (function (&rest t) t))
|
|
|
|
|
(aref (function (t fixnum) t))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(arrayp (function (t) boolean))
|
|
|
|
|
(ash (function (integer integer) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(asin (function (number) float))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(assq (function (t list) list))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(atan (function (number &optional number) float))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(atom (function (t) boolean))
|
|
|
|
|
(bignump (function (t) boolean))
|
|
|
|
|
(bobp (function () boolean))
|
|
|
|
|
(bolp (function () boolean))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(bool-vector-count-consecutive (function (bool-vector boolean integer) fixnum))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(bool-vector-count-population (function (bool-vector) fixnum))
|
|
|
|
|
(bool-vector-not (function (bool-vector &optional bool-vector) bool-vector))
|
|
|
|
|
(bool-vector-p (function (t) boolean))
|
|
|
|
|
(bool-vector-subsetp (function (bool-vector bool-vector) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(boundp (function (symbol) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(buffer-end (function ((or number marker)) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(buffer-file-name (function (&optional buffer) string))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(buffer-list (function (&optional frame) list))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(buffer-local-variables (function (&optional buffer) list))
|
|
|
|
|
(buffer-modified-p (function (&optional buffer) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(buffer-size (function (&optional buffer) integer))
|
|
|
|
|
(buffer-string (function () string))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(buffer-substring (function ((or integer marker) (or integer marker)) string))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(bufferp (function (t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(byte-code-function-p (function (t) boolean))
|
|
|
|
|
(capitalize (function (or integer string) (or integer string)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(car (function (list) t))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(car-less-than-car (function (list list) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(car-safe (function (t) t))
|
|
|
|
|
(case-table-p (function (t) boolean))
|
|
|
|
|
(cdr (function (list) t))
|
|
|
|
|
(cdr-safe (function (t) t))
|
|
|
|
|
(ceiling (function (number &optional number) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(char-after (function (&optional (or marker integer)) fixnum))
|
|
|
|
|
(char-before (function (&optional (or marker integer)) fixnum))
|
|
|
|
|
(char-equal (function (integer integer) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(char-or-string-p (function (t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(char-to-string (function (fixnum) string))
|
|
|
|
|
(char-width (function (fixnum) fixnum))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(characterp (function (t &optional t) boolean))
|
|
|
|
|
(charsetp (function (t) boolean))
|
|
|
|
|
(commandp (function (t &optional t) boolean))
|
|
|
|
|
(compare-strings (function (string (or integer marker null) (or integer marker null) string (or integer marker null) (or integer marker null) &optional t) (or (member t) fixnum)))
|
|
|
|
|
(concat (function (&rest sequence) string))
|
|
|
|
|
(cons (function (t t) cons))
|
|
|
|
|
(consp (function (t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(coordinates-in-window-p (function (cons window) boolean))
|
|
|
|
|
(copy-alist (function (list) list))
|
|
|
|
|
(copy-marker (function (&optional (or integer marker) boolean) marker))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(copy-sequence (function (sequence) sequence))
|
|
|
|
|
(copysign (function (float float) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(cos (function (number) float))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(count-lines (function ((or integer marker) (or integer marker) &optional t) integer))
|
|
|
|
|
(current-buffer (function () buffer))
|
|
|
|
|
(current-global-map (function () cons))
|
|
|
|
|
(current-indentation (function () integer))
|
|
|
|
|
(current-local-map (function () cons))
|
|
|
|
|
(current-minor-mode-maps (function () cons))
|
|
|
|
|
(current-time (function () cons))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(current-time-string (function (&optional string boolean) string))
|
|
|
|
|
(current-time-zone (function (&optional string boolean) cons))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(custom-variable-p (function (symbol) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(decode-char (function (cons t) (or fixnum null)))
|
|
|
|
|
(decode-time (function (&optional string symbol symbol) cons))
|
|
|
|
|
(default-boundp (function (symbol) boolean))
|
|
|
|
|
(default-value (function (symbol) t))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(degrees-to-radians (function (number) float))
|
|
|
|
|
(documentation (function ((or function symbol subr) &optional t) (or null string)))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(downcase (function ((or fixnum string)) (or fixnum string)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(elt (function (sequence integer) t))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(encode-char (function (fixnum symbol) (or fixnum null)))
|
|
|
|
|
(encode-time (function (cons &rest t) cons))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(eobp (function () boolean))
|
|
|
|
|
(eolp (function () boolean))
|
|
|
|
|
(eq (function (t t) boolean))
|
|
|
|
|
(eql (function (t t) boolean))
|
|
|
|
|
(equal (function (t t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(error-message-string (function (list) string))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(eventp (function (t) boolean))
|
|
|
|
|
(exp (function (number) float))
|
|
|
|
|
(expt (function (number number) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(fboundp (function (symbol) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(fceiling (function (float) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(featurep (function (symbol &optional symbol) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(ffloor (function (float) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(file-directory-p (function (string) boolean))
|
|
|
|
|
(file-exists-p (function (string) boolean))
|
|
|
|
|
(file-locked-p (function (string) boolean))
|
|
|
|
|
(file-name-absolute-p (function (string) boolean))
|
|
|
|
|
(file-newer-than-file-p (function (string string) boolean))
|
|
|
|
|
(file-readable-p (function (string) boolean))
|
|
|
|
|
(file-symlink-p (function (string) boolean))
|
|
|
|
|
(file-writable-p (function (string) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(fixnump (function (t) boolean))
|
|
|
|
|
(float (function (number) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(float-time (function (&optional cons) float))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(floatp (function (t) boolean))
|
|
|
|
|
(floor (function (number &optional number) integer))
|
|
|
|
|
(following-char (function () fixnum))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(format (function (string &rest t) string))
|
|
|
|
|
(format-time-string (function (string &optional cons symbol) string))
|
|
|
|
|
(frame-first-window (function ((or frame window)) window))
|
|
|
|
|
(frame-root-window (function (&optional (or frame window)) window))
|
|
|
|
|
(frame-selected-window (function (&optional (or frame window)) window))
|
|
|
|
|
(frame-visible-p (function (frame) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(framep (function (t) boolean))
|
|
|
|
|
(fround (function (float) float))
|
|
|
|
|
(ftruncate (function (float) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(get (function (symbol symbol) t))
|
|
|
|
|
(get-buffer (function ((or buffer string)) (or buffer null)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(get-buffer-window (function (&optional (or buffer string) (or symbol (integer 0 0))) (or null window)))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(get-file-buffer (function (string) (or null buffer)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(get-largest-window (function (&optional t t t) window))
|
|
|
|
|
(get-lru-window (function (&optional t t t) window))
|
|
|
|
|
(getenv (function (string &optional frame) (or null string)))
|
|
|
|
|
(gethash (function (t hash-table &optional t) t))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(hash-table-count (function (hash-table) integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(hash-table-p (function (t) boolean))
|
|
|
|
|
(identity (function (t) t))
|
|
|
|
|
(ignore (function (&rest t) null))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(int-to-string (function (number) string))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(integer-or-marker-p (function (t) boolean))
|
|
|
|
|
(integerp (function (t) boolean))
|
|
|
|
|
(interactive-p (function () boolean))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(intern-soft (function ((or string symbol) &optional vector) symbol))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(invocation-directory (function () string))
|
|
|
|
|
(invocation-name (function () string))
|
|
|
|
|
(isnan (function (float) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(keymap-parent (function (cons) (or cons null)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(keymapp (function (t) boolean))
|
|
|
|
|
(keywordp (function (t) boolean))
|
|
|
|
|
(last (function (list &optional integer) list))
|
|
|
|
|
(lax-plist-get (function (list t) t))
|
|
|
|
|
(ldexp (function (number integer) float))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(length (function (t) (integer 0 *)))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(length< (function (sequence fixnum) boolean))
|
|
|
|
|
(length= (function (sequence fixnum) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(length> (function (sequence fixnum) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(line-beginning-position (function (&optional integer) integer))
|
|
|
|
|
(line-end-position (function (&optional integer) integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(list (function (&rest t) list))
|
|
|
|
|
(listp (function (t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(local-variable-if-set-p (function (symbol &optional buffer) boolean))
|
|
|
|
|
(local-variable-p (function (symbol &optional buffer) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(locale-info (function ((member codeset days months paper)) (or null string)))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(log (function (number number) float))
|
|
|
|
|
(log10 (function (number) float))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(logand (function (&rest (or integer marker)) integer))
|
|
|
|
|
(logb (function (number) integer))
|
|
|
|
|
(logcount (function (integer) integer))
|
|
|
|
|
(logior (function (&rest (or integer marker)) integer))
|
|
|
|
|
(lognot (function (integer) integer))
|
|
|
|
|
(logxor (function (&rest (or integer marker)) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
;; (lsh (function ((integer ,most-negative-fixnum *) integer) integer)) ?
|
|
|
|
|
(lsh (function (integer integer) integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(make-byte-code (function ((or fixnum list) string vector integer &optional string t &rest t) vector))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(make-list (function (integer t) list))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(make-marker (function () marker))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(make-string (function (integer fixnum &optional t) string))
|
|
|
|
|
(make-symbol (function (string) symbol))
|
|
|
|
|
(mark (function (&optional t) (or integer null)))
|
|
|
|
|
(mark-marker (function () marker))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(marker-buffer (function (marker) buffer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(markerp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(max (function ((or number marker) &rest (or number marker)) number))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(max-char (function () fixnum))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(member (function (t list) list))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(memory-limit (function () integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(memq (function (t list) list))
|
|
|
|
|
(memql (function (t list) list))
|
|
|
|
|
(min (function ((or number marker) &rest (or number marker)) number))
|
|
|
|
|
(minibuffer-selected-window (function () window))
|
|
|
|
|
(minibuffer-window (function (&optional frame) window))
|
|
|
|
|
(mod (function ((or number marker) (or number marker)) (or (integer 0 *) (float 0 *))))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(mouse-movement-p (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(multibyte-char-to-unibyte (function (fixnum) fixnum))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(natnump (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(next-window (function (&optional window t t) window))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(nlistp (function (t) boolean))
|
|
|
|
|
(not (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(nth (function (integer list) t))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(nthcdr (function (integer t) t))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(null (function (t) boolean))
|
|
|
|
|
(number-or-marker-p (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(number-to-string (function (number) string))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(numberp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(one-window-p (function (&optional t t) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(overlayp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(parse-colon-path (function (string) cons))
|
|
|
|
|
(plist-get (function (list t) t))
|
|
|
|
|
(plist-member (function (list t) list))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(point (function () integer))
|
|
|
|
|
(point-marker (function () marker))
|
|
|
|
|
(point-max (function () integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(point-min (function () integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(preceding-char (function () fixnum))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(previous-window (function (&optional window t t) window))
|
|
|
|
|
(prin1-to-string (function (t &optional t) string))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(processp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(proper-list-p (function (t) integer))
|
|
|
|
|
(propertize (function (string &rest t) string))
|
|
|
|
|
(radians-to-degrees (function (number) float))
|
|
|
|
|
(rassoc (function (t list) list))
|
|
|
|
|
(rassq (function (t list) list))
|
2021-01-07 22:10:18 +00:00
|
|
|
|
(read-from-string (function (string &optional integer integer) cons))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(recent-keys (function (&optional (or cons null)) vector))
|
|
|
|
|
(recursion-depth (function () integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(regexp-opt (function (list) string))
|
|
|
|
|
(regexp-quote (function (string) string))
|
|
|
|
|
(region-beginning (function () integer))
|
|
|
|
|
(region-end (function () integer))
|
|
|
|
|
(reverse (function (sequence) sequence))
|
|
|
|
|
(round (function (number &optional number) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(safe-length (function (t) integer))
|
|
|
|
|
(selected-frame (function () frame))
|
|
|
|
|
(selected-window (function () window))
|
|
|
|
|
(sequencep (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(sin (function (number) float))
|
|
|
|
|
(sqrt (function (number) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(standard-case-table (function () char-table))
|
|
|
|
|
(standard-syntax-table (function () char-table))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(string (function (&rest fixnum) string))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(string-as-multibyte (function (string) string))
|
|
|
|
|
(string-as-unibyte (function (string) string))
|
|
|
|
|
(string-equal (function ((or string symbol) (or string symbol)) boolean))
|
|
|
|
|
(string-lessp (function ((or string symbol) (or string symbol)) boolean))
|
|
|
|
|
(string-make-multibyte (function (string) string))
|
|
|
|
|
(string-make-unibyte (function (string) string))
|
2021-04-26 20:31:08 +00:00
|
|
|
|
(string-search (function (string string &optional integer) (or integer null)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(string-to-char (function (string) fixnum))
|
|
|
|
|
(string-to-multibyte (function (string) string))
|
|
|
|
|
(string-to-number (function (string &optional integer) number))
|
|
|
|
|
(string-to-syntax (function (string) cons))
|
|
|
|
|
(string< (function ((or string symbol) (or string symbol)) boolean))
|
|
|
|
|
(string= (function ((or string symbol) (or string symbol)) boolean))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(stringp (function (t) boolean))
|
|
|
|
|
(subrp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(substring (function ((or string vector) &optional integer integer) (or string vector)))
|
|
|
|
|
(sxhash (function (t) integer))
|
|
|
|
|
(sxhash-eq (function (t) integer))
|
|
|
|
|
(sxhash-eql (function (t) integer))
|
|
|
|
|
(sxhash-equal (function (t) integer))
|
|
|
|
|
(symbol-function (function (symbol) t))
|
|
|
|
|
(symbol-name (function (symbol) string))
|
|
|
|
|
(symbol-plist (function (symbol) list))
|
|
|
|
|
(symbol-value (function (symbol) t))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(symbolp (function (t) boolean))
|
|
|
|
|
(syntax-table (function () char-table))
|
|
|
|
|
(syntax-table-p (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(tan (function (number) float))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(this-command-keys (function () string))
|
|
|
|
|
(this-command-keys-vector (function () vector))
|
|
|
|
|
(this-single-command-keys (function () vector))
|
|
|
|
|
(this-single-command-raw-keys (function () vector))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(time-convert (function (t &optional (or boolean integer)) cons))
|
|
|
|
|
(truncate (function (number &optional number) integer))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(type-of (function (t) symbol))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(unibyte-char-to-multibyte (function (fixnum) fixnum)) ;; byte is fixnum
|
|
|
|
|
(upcase (function ((or fixnum string)) (or fixnum string)))
|
2021-03-14 20:54:06 +00:00
|
|
|
|
(user-full-name (function (&optional integer) (or string null)))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(user-login-name (function (&optional integer) (or string null)))
|
|
|
|
|
(user-original-login-name (function (&optional integer) (or string null)))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(user-real-login-name (function () string))
|
|
|
|
|
(user-real-uid (function () integer))
|
|
|
|
|
(user-uid (function () integer))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(vconcat (function (&rest sequence) vector))
|
2020-12-29 18:41:28 +00:00
|
|
|
|
(vector (function (&rest t) vector))
|
|
|
|
|
(vectorp (function (t) boolean))
|
|
|
|
|
(visible-frame-list (function () list))
|
|
|
|
|
(wholenump (function (t) boolean))
|
|
|
|
|
(window-configuration-p (function (t) boolean))
|
|
|
|
|
(window-live-p (function (t) boolean))
|
|
|
|
|
(window-valid-p (function (t) boolean))
|
|
|
|
|
(windowp (function (t) boolean))
|
2020-12-30 12:50:23 +00:00
|
|
|
|
(zerop (function (number) boolean))
|
2020-11-14 15:55:39 +00:00
|
|
|
|
;; Type hints
|
|
|
|
|
(comp-hint-fixnum (function (t) fixnum))
|
2020-12-26 11:22:21 +00:00
|
|
|
|
(comp-hint-cons (function (t) cons))
|
|
|
|
|
;; Non returning functions
|
2021-01-01 13:13:02 +00:00
|
|
|
|
(throw (function (t t) nil))
|
2020-12-26 11:22:21 +00:00
|
|
|
|
(error (function (string &rest t) nil))
|
|
|
|
|
(signal (function (symbol t) nil)))
|
2019-07-21 13:20:39 +00:00
|
|
|
|
"Alist used for type propagation.")
|
2019-07-07 19:49:11 +00:00
|
|
|
|
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(defconst comp-known-func-cstr-h
|
|
|
|
|
(cl-loop
|
|
|
|
|
with comp-ctxt = (make-comp-cstr-ctxt)
|
|
|
|
|
with h = (make-hash-table :test #'eq)
|
|
|
|
|
for (f type-spec) in comp-known-type-specifiers
|
|
|
|
|
for cstr = (comp-type-spec-to-cstr type-spec)
|
|
|
|
|
do (puthash f cstr h)
|
2020-12-16 17:37:39 +00:00
|
|
|
|
finally return h)
|
2021-04-25 18:47:20 +00:00
|
|
|
|
"Hash table function -> `comp-constraint'.")
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(defconst comp-known-predicates
|
|
|
|
|
'((arrayp . array)
|
|
|
|
|
(atom . atom)
|
2021-01-02 12:22:30 +00:00
|
|
|
|
(characterp . fixnum)
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(booleanp . boolean)
|
|
|
|
|
(bool-vector-p . bool-vector)
|
|
|
|
|
(bufferp . buffer)
|
2021-01-02 12:22:30 +00:00
|
|
|
|
(natnump . (integer 0 *))
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(char-table-p . char-table)
|
|
|
|
|
(hash-table-p . hash-table)
|
|
|
|
|
(consp . cons)
|
2021-01-02 12:22:30 +00:00
|
|
|
|
(integerp . integer)
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(floatp . float)
|
|
|
|
|
(functionp . (or function symbol))
|
|
|
|
|
(integerp . integer)
|
|
|
|
|
(keywordp . keyword)
|
|
|
|
|
(listp . list)
|
|
|
|
|
(numberp . number)
|
|
|
|
|
(null . null)
|
2021-01-02 12:22:30 +00:00
|
|
|
|
(numberp . number)
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(sequencep . sequence)
|
|
|
|
|
(stringp . string)
|
|
|
|
|
(symbolp . symbol)
|
|
|
|
|
(vectorp . vector)
|
|
|
|
|
(integer-or-marker-p . integer-or-marker))
|
|
|
|
|
"Alist predicate -> matched type specifier.")
|
|
|
|
|
|
|
|
|
|
(defconst comp-known-predicates-h
|
|
|
|
|
(cl-loop
|
|
|
|
|
with comp-ctxt = (make-comp-cstr-ctxt)
|
|
|
|
|
with h = (make-hash-table :test #'eq)
|
|
|
|
|
for (pred . type-spec) in comp-known-predicates
|
|
|
|
|
for cstr = (comp-type-spec-to-cstr type-spec)
|
|
|
|
|
do (puthash pred cstr h)
|
|
|
|
|
finally return h)
|
2021-04-25 18:47:20 +00:00
|
|
|
|
"Hash table function -> `comp-constraint'.")
|
2021-01-02 11:18:39 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-known-predicate-p (predicate)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return t if PREDICATE is known."
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(when (gethash predicate comp-known-predicates-h) t))
|
|
|
|
|
|
|
|
|
|
(defun comp-pred-to-cstr (predicate)
|
2021-04-27 05:18:14 +00:00
|
|
|
|
"Given PREDICATE, return the corresponding constraint."
|
2021-01-02 11:18:39 +00:00
|
|
|
|
(gethash predicate comp-known-predicates-h))
|
|
|
|
|
|
2020-06-06 22:34:21 +00:00
|
|
|
|
(defconst comp-symbol-values-optimizable '(most-positive-fixnum
|
|
|
|
|
most-negative-fixnum)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Symbol values we can resolve at compile-time.")
|
2020-06-06 22:34:21 +00:00
|
|
|
|
|
2019-09-23 09:41:36 +00:00
|
|
|
|
(defconst comp-type-hints '(comp-hint-fixnum
|
|
|
|
|
comp-hint-cons)
|
|
|
|
|
"List of fake functions used to give compiler hints.")
|
|
|
|
|
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(defconst comp-limple-sets '(set
|
|
|
|
|
setimm
|
|
|
|
|
set-par-to-local
|
|
|
|
|
set-args-to-local
|
|
|
|
|
set-rest-args-to-local)
|
|
|
|
|
"Limple set operators.")
|
|
|
|
|
|
2020-10-27 19:40:55 +00:00
|
|
|
|
(defconst comp-limple-assignments `(assume
|
|
|
|
|
fetch-handler
|
2019-09-22 16:49:11 +00:00
|
|
|
|
,@comp-limple-sets)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Limple operators that clobber the first m-var argument.")
|
2019-09-14 10:39:53 +00:00
|
|
|
|
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(defconst comp-limple-calls '(call
|
|
|
|
|
callref
|
|
|
|
|
direct-call
|
|
|
|
|
direct-callref)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Limple operators used to call subrs.")
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
2020-11-08 11:16:34 +00:00
|
|
|
|
(defconst comp-limple-branches '(jump cond-jump)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Limple operators used for conditional and unconditional branches.")
|
2020-11-08 11:16:34 +00:00
|
|
|
|
|
|
|
|
|
(defconst comp-limple-ops `(,@comp-limple-calls
|
|
|
|
|
,@comp-limple-assignments
|
|
|
|
|
,@comp-limple-branches
|
|
|
|
|
return)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"All Limple operators.")
|
2020-11-08 11:16:34 +00:00
|
|
|
|
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(defvar comp-func nil
|
|
|
|
|
"Bound to the current function by most passes.")
|
|
|
|
|
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(defvar comp-block nil
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Bound to the current basic block by some passes.")
|
2020-12-31 16:37:13 +00:00
|
|
|
|
|
2019-12-29 14:56:49 +00:00
|
|
|
|
(define-error 'native-compiler-error-dyn-func
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"can't native compile a non-lexically-scoped function"
|
2019-12-29 14:56:49 +00:00
|
|
|
|
'native-compiler-error)
|
|
|
|
|
(define-error 'native-compiler-error-empty-byte
|
|
|
|
|
"empty byte compiler output"
|
|
|
|
|
'native-compiler-error)
|
2021-02-22 14:07:00 +00:00
|
|
|
|
|
|
|
|
|
|
2021-03-12 21:19:51 +00:00
|
|
|
|
;; Moved early to avoid circularity when comp.el is loaded and
|
|
|
|
|
;; `macroexpand' needs to be advised (bug#47049).
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun comp-subr-trampoline-install (subr-name)
|
|
|
|
|
"Make SUBR-NAME effectively advice-able when called from native code."
|
|
|
|
|
(unless (or (null comp-enable-subr-trampolines)
|
2021-05-06 08:26:33 +00:00
|
|
|
|
(memq subr-name native-comp-never-optimize-functions)
|
2021-03-12 21:19:51 +00:00
|
|
|
|
(gethash subr-name comp-installed-trampolines-h))
|
|
|
|
|
(cl-assert (subr-primitive-p (symbol-function subr-name)))
|
|
|
|
|
(comp--install-trampoline
|
|
|
|
|
subr-name
|
|
|
|
|
(or (comp-trampoline-search subr-name)
|
|
|
|
|
(comp-trampoline-compile subr-name)
|
|
|
|
|
;; Should never happen.
|
|
|
|
|
(cl-assert nil)))))
|
|
|
|
|
|
|
|
|
|
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(cl-defstruct (comp-vec (:copier nil))
|
|
|
|
|
"A re-sizable vector like object."
|
|
|
|
|
(data (make-hash-table :test #'eql) :type hash-table
|
|
|
|
|
:documentation "Payload data.")
|
|
|
|
|
(beg 0 :type integer)
|
|
|
|
|
(end 0 :type natnum))
|
|
|
|
|
|
|
|
|
|
(defsubst comp-vec-copy (vec)
|
|
|
|
|
"Return a copy of VEC."
|
|
|
|
|
(make-comp-vec :data (copy-hash-table (comp-vec-data vec))
|
|
|
|
|
:beg (comp-vec-beg vec)
|
|
|
|
|
:end (comp-vec-end vec)))
|
|
|
|
|
|
|
|
|
|
(defsubst comp-vec-length (vec)
|
|
|
|
|
"Return the number of elements of VEC."
|
2021-02-25 19:46:27 +00:00
|
|
|
|
(- (comp-vec-end vec) (comp-vec-beg vec)))
|
2021-02-22 14:07:00 +00:00
|
|
|
|
|
|
|
|
|
(defsubst comp-vec--verify-idx (vec idx)
|
2021-04-25 18:47:20 +00:00
|
|
|
|
"Check whether IDX is in bounds for VEC."
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(cl-assert (and (< idx (comp-vec-end vec))
|
|
|
|
|
(>= idx (comp-vec-beg vec)))))
|
|
|
|
|
|
|
|
|
|
(defsubst comp-vec-aref (vec idx)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return the element of VEC whose index is IDX."
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(declare (gv-setter (lambda (val)
|
|
|
|
|
`(comp-vec--verify-idx ,vec ,idx)
|
2021-02-25 19:46:27 +00:00
|
|
|
|
`(puthash ,idx ,val (comp-vec-data ,vec)))))
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(comp-vec--verify-idx vec idx)
|
|
|
|
|
(gethash idx (comp-vec-data vec)))
|
|
|
|
|
|
|
|
|
|
(defsubst comp-vec-append (vec elt)
|
|
|
|
|
"Append ELT into VEC.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Returns ELT."
|
2021-02-25 19:46:27 +00:00
|
|
|
|
(puthash (comp-vec-end vec) elt (comp-vec-data vec))
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(cl-incf (comp-vec-end vec))
|
|
|
|
|
elt)
|
|
|
|
|
|
|
|
|
|
(defsubst comp-vec-prepend (vec elt)
|
|
|
|
|
"Prepend ELT into VEC.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Returns ELT."
|
2021-02-25 19:46:27 +00:00
|
|
|
|
(puthash (1- (comp-vec-beg vec)) elt (comp-vec-data vec))
|
2021-02-22 14:07:00 +00:00
|
|
|
|
(cl-decf (comp-vec-beg vec))
|
|
|
|
|
elt)
|
|
|
|
|
|
|
|
|
|
|
2019-12-29 14:56:49 +00:00
|
|
|
|
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(defconst comp-op-stack-info
|
|
|
|
|
(cl-loop with h = (make-hash-table)
|
|
|
|
|
for k across byte-code-vector
|
|
|
|
|
for v across byte-stack+-info
|
|
|
|
|
when k
|
|
|
|
|
do (puthash k v h)
|
|
|
|
|
finally return h)
|
|
|
|
|
"Hash table lap-op -> stack adjustment."))
|
|
|
|
|
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(define-hash-table-test 'comp-imm-equal-test #'equal-including-properties
|
2021-04-21 21:15:56 +00:00
|
|
|
|
#'sxhash-equal-including-properties)
|
2021-04-21 13:23:23 +00:00
|
|
|
|
|
2020-01-12 10:47:50 +00:00
|
|
|
|
(cl-defstruct comp-data-container
|
|
|
|
|
"Data relocation container structure."
|
|
|
|
|
(l () :type list
|
|
|
|
|
:documentation "Constant objects used by functions.")
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(idx (make-hash-table :test 'comp-imm-equal-test) :type hash-table
|
2020-01-12 10:47:50 +00:00
|
|
|
|
:documentation "Obj -> position into the previous field."))
|
|
|
|
|
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(cl-defstruct (comp-ctxt (:include comp-cstr-ctxt))
|
2019-09-07 06:57:07 +00:00
|
|
|
|
"Lisp side of the compiler context."
|
2019-10-13 15:41:26 +00:00
|
|
|
|
(output nil :type string
|
2019-11-22 18:15:12 +00:00
|
|
|
|
:documentation "Target output file-name for the compilation.")
|
2021-05-06 08:12:48 +00:00
|
|
|
|
(speed native-comp-speed :type number
|
2020-11-06 23:13:01 +00:00
|
|
|
|
:documentation "Default speed for this compilation unit.")
|
2021-05-06 08:14:00 +00:00
|
|
|
|
(debug native-comp-debug :type number
|
2020-11-06 23:13:01 +00:00
|
|
|
|
:documentation "Default debug level for this compilation unit.")
|
2021-03-07 19:19:20 +00:00
|
|
|
|
(driver-options comp-native-driver-options :type list
|
|
|
|
|
:documentation "Options for the GCC driver.")
|
2019-11-02 16:32:42 +00:00
|
|
|
|
(top-level-forms () :type list
|
|
|
|
|
:documentation "List of spilled top level forms.")
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(funcs-h (make-hash-table :test #'equal) :type hash-table
|
|
|
|
|
:documentation "c-name -> comp-func.")
|
|
|
|
|
(sym-to-c-name-h (make-hash-table :test #'eq) :type hash-table
|
|
|
|
|
:documentation "symbol-function -> c-name.
|
|
|
|
|
This is only for optimizing intra CU calls at speed 3.")
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(byte-func-to-func-h (make-hash-table :test #'equal) :type hash-table
|
2020-05-01 16:32:39 +00:00
|
|
|
|
:documentation "byte-function -> comp-func.
|
|
|
|
|
Needed to replace immediate byte-compiled lambdas with the compiled reference.")
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(lambda-fixups-h (make-hash-table :test #'equal) :type hash-table
|
|
|
|
|
:documentation "Hash table byte-func -> mvar to fixup.")
|
2020-04-26 08:11:33 +00:00
|
|
|
|
(function-docs (make-hash-table :test #'eql) :type (or hash-table vector)
|
2020-04-25 15:13:03 +00:00
|
|
|
|
:documentation "Documentation index -> documentation")
|
2020-02-25 21:39:59 +00:00
|
|
|
|
(d-default (make-comp-data-container) :type comp-data-container
|
2020-03-28 20:56:47 +00:00
|
|
|
|
:documentation "Standard data relocated in use by functions.")
|
2020-01-12 10:47:50 +00:00
|
|
|
|
(d-impure (make-comp-data-container) :type comp-data-container
|
2020-03-28 20:56:47 +00:00
|
|
|
|
:documentation "Relocated data that cannot be moved into pure space.
|
2020-11-20 19:34:32 +00:00
|
|
|
|
This is typically for top-level forms other than defun.")
|
2020-02-25 22:35:02 +00:00
|
|
|
|
(d-ephemeral (make-comp-data-container) :type comp-data-container
|
2020-03-17 22:24:52 +00:00
|
|
|
|
:documentation "Relocated data not necessary after load.")
|
|
|
|
|
(with-late-load nil :type boolean
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
:documentation "When non-nil support late load."))
|
2019-08-18 13:36:36 +00:00
|
|
|
|
|
2019-08-16 13:48:38 +00:00
|
|
|
|
(cl-defstruct comp-args-base
|
2020-12-28 09:48:05 +00:00
|
|
|
|
(min nil :type integer
|
2019-08-11 12:54:13 +00:00
|
|
|
|
:documentation "Minimum number of arguments allowed."))
|
|
|
|
|
|
2019-08-16 13:48:38 +00:00
|
|
|
|
(cl-defstruct (comp-args (:include comp-args-base))
|
2020-12-28 09:48:05 +00:00
|
|
|
|
(max nil :type integer
|
|
|
|
|
:documentation "Maximum number of arguments allowed."))
|
2019-08-11 12:54:13 +00:00
|
|
|
|
|
2019-08-16 13:48:38 +00:00
|
|
|
|
(cl-defstruct (comp-nargs (:include comp-args-base))
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Describe args when the function signature is of kind:
|
2019-08-11 12:54:13 +00:00
|
|
|
|
(ptrdiff_t nargs, Lisp_Object *args)."
|
2020-12-28 09:48:05 +00:00
|
|
|
|
(nonrest nil :type integer
|
2019-11-02 11:17:26 +00:00
|
|
|
|
:documentation "Number of non rest arguments.")
|
|
|
|
|
(rest nil :type boolean
|
|
|
|
|
:documentation "t if rest argument is present."))
|
2019-07-07 10:30:03 +00:00
|
|
|
|
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(cl-defstruct (comp-block (:copier nil)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(:constructor nil))
|
|
|
|
|
"A base class for basic blocks."
|
2019-09-11 19:51:37 +00:00
|
|
|
|
(name nil :type symbol)
|
2019-07-21 13:20:39 +00:00
|
|
|
|
(insns () :type list
|
2019-09-13 18:56:24 +00:00
|
|
|
|
:documentation "List of instructions.")
|
2019-10-20 14:04:29 +00:00
|
|
|
|
(closed nil :type boolean
|
|
|
|
|
:documentation "t if closed.")
|
2020-11-20 19:34:32 +00:00
|
|
|
|
;; All the following are for SSA and CGF analysis.
|
2020-02-29 17:14:43 +00:00
|
|
|
|
;; Keep in sync with `comp-clean-ssa'!!
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(in-edges () :type list
|
|
|
|
|
:documentation "List of incoming edges.")
|
|
|
|
|
(out-edges () :type list
|
2019-11-22 18:15:12 +00:00
|
|
|
|
:documentation "List of out-coming edges.")
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(idom nil :type (or null comp-block)
|
2019-09-13 18:56:24 +00:00
|
|
|
|
:documentation "Immediate dominator.")
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(df (make-hash-table) :type (or null hash-table)
|
2019-09-14 10:39:53 +00:00
|
|
|
|
:documentation "Dominance frontier set. Block-name -> block")
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(post-num nil :type (or null number)
|
2019-09-16 23:01:34 +00:00
|
|
|
|
:documentation "Post order number.")
|
2021-02-22 16:28:19 +00:00
|
|
|
|
(final-frame nil :type (or null comp-vec)
|
2019-09-16 23:01:34 +00:00
|
|
|
|
:documentation "This is a copy of the frame when leaving the block.
|
|
|
|
|
Is in use to help the SSA rename pass."))
|
2019-07-14 15:21:34 +00:00
|
|
|
|
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(cl-defstruct (comp-block-lap (:copier nil)
|
|
|
|
|
(:include comp-block)
|
|
|
|
|
(:constructor make--comp-block-lap
|
|
|
|
|
(addr sp name))) ; Positional
|
2020-12-31 16:37:13 +00:00
|
|
|
|
"A basic block created from lap (real code)."
|
2020-06-11 20:53:31 +00:00
|
|
|
|
;; These two slots are used during limplification.
|
|
|
|
|
(sp nil :type number
|
2020-09-28 19:09:00 +00:00
|
|
|
|
:documentation "When non-nil indicates the sp value while entering
|
2020-06-11 20:53:31 +00:00
|
|
|
|
into it.")
|
|
|
|
|
(addr nil :type number
|
2020-12-31 16:37:13 +00:00
|
|
|
|
:documentation "Start block LAP address.")
|
|
|
|
|
(non-ret-insn nil :type list
|
2021-01-01 10:09:00 +00:00
|
|
|
|
:documentation "Insn known to perform a non local exit.
|
2020-12-31 16:37:13 +00:00
|
|
|
|
`comp-fwprop' may identify and store here basic blocks performing
|
2021-01-01 10:09:00 +00:00
|
|
|
|
non local exits and mark it rewrite it later.")
|
|
|
|
|
(no-ret nil :type boolean
|
|
|
|
|
:documentation "t when the block is known to perform a
|
|
|
|
|
non local exit (ends with an `unreachable' insn)."))
|
2020-06-11 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
(cl-defstruct (comp-latch (:copier nil)
|
|
|
|
|
(:include comp-block))
|
|
|
|
|
"A basic block for a latch loop.")
|
|
|
|
|
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(cl-defstruct (comp-block-cstr (:copier nil)
|
|
|
|
|
(:include comp-block))
|
|
|
|
|
"A basic block holding only constraints.")
|
|
|
|
|
|
2019-09-13 15:55:16 +00:00
|
|
|
|
(cl-defstruct (comp-edge (:copier nil) (:constructor make--comp-edge))
|
|
|
|
|
"An edge connecting two basic blocks."
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(src nil :type (or null comp-block))
|
|
|
|
|
(dst nil :type (or null comp-block))
|
2019-09-13 15:55:16 +00:00
|
|
|
|
(number nil :type number
|
|
|
|
|
:documentation "The index number corresponding to this edge in the
|
2020-09-27 21:43:35 +00:00
|
|
|
|
edge hash."))
|
2019-09-13 15:55:16 +00:00
|
|
|
|
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(defun make-comp-edge (&rest args)
|
|
|
|
|
"Create a `comp-edge' with basic blocks SRC and DST."
|
|
|
|
|
(let ((n (funcall (comp-func-edge-cnt-gen comp-func))))
|
|
|
|
|
(puthash
|
|
|
|
|
n
|
|
|
|
|
(apply #'make--comp-edge :number n args)
|
|
|
|
|
(comp-func-edges-h comp-func))))
|
|
|
|
|
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(defun comp-block-preds (basic-block)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return the list of predecessors of BASIC-BLOCK."
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(mapcar #'comp-edge-src (comp-block-in-edges basic-block)))
|
|
|
|
|
|
2019-09-13 15:55:16 +00:00
|
|
|
|
(defun comp-gen-counter ()
|
|
|
|
|
"Return a sequential number generator."
|
|
|
|
|
(let ((n -1))
|
|
|
|
|
(lambda ()
|
|
|
|
|
(cl-incf n))))
|
|
|
|
|
|
2019-07-07 10:30:03 +00:00
|
|
|
|
(cl-defstruct (comp-func (:copier nil))
|
2019-07-21 13:20:39 +00:00
|
|
|
|
"LIMPLE representation of a function."
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(name nil :type symbol
|
2020-05-01 16:32:39 +00:00
|
|
|
|
:documentation "Function symbol name. Nil indicates anonymous.")
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(c-name nil :type string
|
|
|
|
|
:documentation "The function name in the native world.")
|
2019-07-07 10:30:03 +00:00
|
|
|
|
(byte-func nil
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
:documentation "Byte-compiled version.")
|
2019-11-02 16:33:55 +00:00
|
|
|
|
(doc nil :type string
|
|
|
|
|
:documentation "Doc string.")
|
2019-12-07 16:38:08 +00:00
|
|
|
|
(int-spec nil :type list
|
|
|
|
|
:documentation "Interactive form.")
|
2019-07-21 13:20:39 +00:00
|
|
|
|
(lap () :type list
|
2019-09-22 07:58:20 +00:00
|
|
|
|
:documentation "LAP assembly representation.")
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(ssa-status nil :type symbol
|
|
|
|
|
:documentation "SSA status either: 'nil', 'dirty' or 't'.
|
|
|
|
|
Once in SSA form this *must* be set to 'dirty' every time the topology of the
|
|
|
|
|
CFG is mutated by a pass.")
|
2020-12-28 09:48:05 +00:00
|
|
|
|
(frame-size nil :type integer)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(vframe-size 0 :type integer)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(blocks (make-hash-table :test #'eq) :type hash-table
|
|
|
|
|
:documentation "Basic block symbol -> basic block.")
|
2019-08-18 08:34:18 +00:00
|
|
|
|
(lap-block (make-hash-table :test #'equal) :type hash-table
|
2020-11-20 19:34:32 +00:00
|
|
|
|
:documentation "LAP label -> LIMPLE basic block name.")
|
2020-09-27 21:43:35 +00:00
|
|
|
|
(edges-h (make-hash-table) :type hash-table
|
|
|
|
|
:documentation "Hash edge-num -> edge connecting basic two blocks.")
|
2019-09-22 07:58:20 +00:00
|
|
|
|
(block-cnt-gen (funcall #'comp-gen-counter) :type function
|
|
|
|
|
:documentation "Generates block numbers.")
|
2019-09-14 10:39:53 +00:00
|
|
|
|
(edge-cnt-gen (funcall #'comp-gen-counter) :type function
|
2019-09-22 07:58:20 +00:00
|
|
|
|
:documentation "Generates edges numbers.")
|
2019-12-28 10:39:29 +00:00
|
|
|
|
(has-non-local nil :type boolean
|
2020-02-09 15:17:21 +00:00
|
|
|
|
:documentation "t if non local jumps are present.")
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(speed nil :type number
|
2021-05-06 08:12:48 +00:00
|
|
|
|
:documentation "Optimization level (see `native-comp-speed').")
|
2020-06-18 21:04:55 +00:00
|
|
|
|
(pure nil :type boolean
|
2020-11-11 16:23:25 +00:00
|
|
|
|
:documentation "t if pure nil otherwise.")
|
2020-12-28 12:41:38 +00:00
|
|
|
|
(type nil :type (or null comp-mvar)
|
|
|
|
|
:documentation "Mvar holding the derived return type."))
|
2019-07-07 10:30:03 +00:00
|
|
|
|
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(cl-defstruct (comp-func-l (:include comp-func))
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Lexically-scoped function."
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(args nil :type comp-args-base
|
|
|
|
|
:documentation "Argument specification of the function"))
|
|
|
|
|
|
|
|
|
|
(cl-defstruct (comp-func-d (:include comp-func))
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Dynamically-scoped function."
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(lambda-list nil :type list
|
|
|
|
|
:documentation "Original lambda-list."))
|
|
|
|
|
|
2020-11-12 16:27:31 +00:00
|
|
|
|
(cl-defstruct (comp-mvar (:constructor make--comp-mvar)
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(:include comp-cstr))
|
2020-11-12 16:27:31 +00:00
|
|
|
|
"A meta-variable being a slot in the meta-stack."
|
|
|
|
|
(id nil :type (or null number)
|
|
|
|
|
:documentation "Unique id when in SSA form.")
|
|
|
|
|
(slot nil :type (or fixnum symbol)
|
|
|
|
|
:documentation "Slot number in the array if a number or
|
|
|
|
|
'scratch' for scratch slot."))
|
|
|
|
|
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(defun comp-mvar-type-hint-match-p (mvar type-hint)
|
|
|
|
|
"Match MVAR against TYPE-HINT.
|
2021-04-27 12:17:44 +00:00
|
|
|
|
In use by the back-end."
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(cl-ecase type-hint
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(cons (comp-cstr-cons-p mvar))
|
|
|
|
|
(fixnum (comp-cstr-fixnum-p mvar))))
|
2019-07-07 10:30:03 +00:00
|
|
|
|
|
2019-08-18 13:36:36 +00:00
|
|
|
|
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
2020-07-26 07:36:09 +00:00
|
|
|
|
(defun comp-ensure-native-compiler ()
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Make sure Emacs has native compiler support and libgccjit can be loaded.
|
2020-11-16 02:50:10 +00:00
|
|
|
|
Signal an error otherwise.
|
2020-07-26 07:36:09 +00:00
|
|
|
|
To be used by all entry points."
|
|
|
|
|
(cond
|
2021-05-05 15:18:07 +00:00
|
|
|
|
((null (featurep 'native-compile))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
(error "Emacs was not compiled with native compiler support (--with-native-compilation)"))
|
2020-07-26 07:36:09 +00:00
|
|
|
|
((null (native-comp-available-p))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
(error "Cannot find libgccjit library"))))
|
2020-07-26 07:36:09 +00:00
|
|
|
|
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(defun comp-equality-fun-p (function)
|
|
|
|
|
"Equality functions predicate for FUNCTION."
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(when (memq function '(eq eql equal)) t))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(defun comp-arithm-cmp-fun-p (function)
|
2021-04-25 18:47:20 +00:00
|
|
|
|
"Predicate for arithmetic comparison functions."
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(when (memq function '(= > < >= <=)) t))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-set-op-p (op)
|
2019-09-22 16:49:11 +00:00
|
|
|
|
"Assignment predicate for OP."
|
2020-01-20 19:30:24 +00:00
|
|
|
|
(when (memq op comp-limple-sets) t))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-assign-op-p (op)
|
2019-09-14 15:00:16 +00:00
|
|
|
|
"Assignment predicate for OP."
|
2020-01-20 19:30:24 +00:00
|
|
|
|
(when (memq op comp-limple-assignments) t))
|
2019-09-14 15:00:16 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-call-op-p (op)
|
2020-07-05 19:00:46 +00:00
|
|
|
|
"Call predicate for OP."
|
|
|
|
|
(when (memq op comp-limple-calls) t))
|
|
|
|
|
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(defun comp-branch-op-p (op)
|
|
|
|
|
"Branch predicate for OP."
|
|
|
|
|
(when (memq op comp-limple-branches) t))
|
|
|
|
|
|
2019-12-30 23:20:35 +00:00
|
|
|
|
(defsubst comp-limple-insn-call-p (insn)
|
2019-09-22 16:49:11 +00:00
|
|
|
|
"Limple INSN call predicate."
|
2020-07-05 19:00:46 +00:00
|
|
|
|
(comp-call-op-p (car-safe insn)))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-type-hint-p (func)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Type-hint predicate for function name FUNC."
|
2020-01-20 19:30:24 +00:00
|
|
|
|
(when (memq func comp-type-hints) t))
|
2019-09-23 09:41:36 +00:00
|
|
|
|
|
2020-06-06 14:53:34 +00:00
|
|
|
|
(defun comp-func-unique-in-cu-p (func)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Return t if FUNC is known to be unique in the current compilation unit."
|
2020-06-06 14:53:34 +00:00
|
|
|
|
(if (symbolp func)
|
|
|
|
|
(cl-loop with h = (make-hash-table :test #'eq)
|
|
|
|
|
for f being the hash-value in (comp-ctxt-funcs-h comp-ctxt)
|
|
|
|
|
for name = (comp-func-name f)
|
|
|
|
|
when (gethash name h)
|
|
|
|
|
return nil
|
|
|
|
|
do (puthash name t h)
|
|
|
|
|
finally return t)
|
|
|
|
|
t))
|
|
|
|
|
|
2020-07-05 17:32:32 +00:00
|
|
|
|
(defsubst comp-symbol-func-to-fun (symbol-funcion)
|
|
|
|
|
"Given a function called SYMBOL-FUNCION return its `comp-func'."
|
|
|
|
|
(gethash (gethash symbol-funcion (comp-ctxt-sym-to-c-name-h
|
|
|
|
|
comp-ctxt))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-function-pure-p (f)
|
2020-07-05 09:21:21 +00:00
|
|
|
|
"Return t if F is pure."
|
|
|
|
|
(or (get f 'pure)
|
2020-07-05 17:32:32 +00:00
|
|
|
|
(when-let ((func (comp-symbol-func-to-fun f)))
|
2020-07-05 09:21:21 +00:00
|
|
|
|
(comp-func-pure func))))
|
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-alloc-class-to-container (alloc-class)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Given ALLOC-CLASS, return the data container for the current context.
|
|
|
|
|
Assume allocation class 'd-default as default."
|
2020-02-25 21:39:59 +00:00
|
|
|
|
(cl-struct-slot-value 'comp-ctxt (or alloc-class 'd-default) comp-ctxt))
|
2020-02-25 22:35:02 +00:00
|
|
|
|
|
2020-02-29 15:53:42 +00:00
|
|
|
|
(defsubst comp-add-const-to-relocs (obj)
|
|
|
|
|
"Keep track of OBJ into the ctxt relocations."
|
|
|
|
|
(puthash obj t (comp-data-container-idx (comp-alloc-class-to-container
|
|
|
|
|
comp-curr-allocation-class))))
|
2019-08-18 13:36:36 +00:00
|
|
|
|
|
2020-07-13 18:35:20 +00:00
|
|
|
|
|
2020-11-20 19:34:32 +00:00
|
|
|
|
;;; Log routines.
|
2020-07-13 18:35:20 +00:00
|
|
|
|
|
|
|
|
|
(defconst comp-limple-lock-keywords
|
|
|
|
|
`((,(rx bol "(comment" (1+ not-newline)) . font-lock-comment-face)
|
2020-12-13 17:02:19 +00:00
|
|
|
|
(,(rx "#(" (group-n 1 "mvar"))
|
2020-07-13 18:35:20 +00:00
|
|
|
|
(1 font-lock-function-name-face))
|
|
|
|
|
(,(rx bol "(" (group-n 1 "phi"))
|
|
|
|
|
(1 font-lock-variable-name-face))
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(,(rx bol "(" (group-n 1 (or "return" "unreachable")))
|
2020-12-31 14:27:24 +00:00
|
|
|
|
(1 font-lock-warning-face))
|
2020-07-13 18:35:20 +00:00
|
|
|
|
(,(rx (group-n 1 (or "entry"
|
|
|
|
|
(seq (or "entry_" "entry_fallback_" "bb_")
|
2020-12-22 21:53:05 +00:00
|
|
|
|
(1+ num) (? (or "_latch"
|
|
|
|
|
(seq "_cstrs_" (1+ num))))))))
|
2020-07-13 18:35:20 +00:00
|
|
|
|
(1 font-lock-constant-face))
|
2020-11-08 11:16:34 +00:00
|
|
|
|
(,(rx-to-string
|
|
|
|
|
`(seq "(" (group-n 1 (or ,@(mapcar #'symbol-name comp-limple-ops)))))
|
2020-07-13 18:35:20 +00:00
|
|
|
|
(1 font-lock-keyword-face)))
|
2021-05-06 07:57:35 +00:00
|
|
|
|
"Highlights used by `native-comp-limple-mode'.")
|
2020-07-13 18:35:20 +00:00
|
|
|
|
|
2021-05-06 07:57:35 +00:00
|
|
|
|
(define-derived-mode native-comp-limple-mode fundamental-mode "LIMPLE"
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Syntax-highlight LIMPLE IR."
|
2020-07-13 18:35:20 +00:00
|
|
|
|
(setf font-lock-defaults '(comp-limple-lock-keywords)))
|
|
|
|
|
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(cl-defun comp-log (data &optional (level 1) quoted)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
"Log DATA at LEVEL.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
LEVEL is a number from 1-3, and defaults to 1; if it is less
|
2021-05-06 08:17:12 +00:00
|
|
|
|
than `native-comp-verbose', do nothing. If `noninteractive', log
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
with `message'. Otherwise, log with `comp-log-to-buffer'."
|
2021-05-06 08:17:12 +00:00
|
|
|
|
(when (>= native-comp-verbose level)
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(if noninteractive
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(cl-typecase data
|
|
|
|
|
(atom (message "%s" data))
|
|
|
|
|
(t (dolist (elem data)
|
|
|
|
|
(message "%s" elem))))
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(comp-log-to-buffer data quoted))))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(cl-defun comp-log-to-buffer (data &optional quoted)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
"Log DATA to `comp-log-buffer-name'."
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(let* ((print-f (if quoted #'prin1 #'princ))
|
|
|
|
|
(log-buffer
|
|
|
|
|
(or (get-buffer comp-log-buffer-name)
|
|
|
|
|
(with-current-buffer (get-buffer-create comp-log-buffer-name)
|
|
|
|
|
(setf buffer-read-only t)
|
|
|
|
|
(current-buffer))))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(log-window (get-buffer-window log-buffer))
|
|
|
|
|
(inhibit-read-only t)
|
|
|
|
|
at-end-p)
|
|
|
|
|
(with-current-buffer log-buffer
|
2021-05-06 07:57:35 +00:00
|
|
|
|
(unless (eq major-mode 'native-comp-limple-mode)
|
|
|
|
|
(native-comp-limple-mode))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(when (= (point) (point-max))
|
|
|
|
|
(setf at-end-p t))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(cl-typecase data
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(atom (funcall print-f data log-buffer))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(t (dolist (elem data)
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(funcall print-f elem log-buffer)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(insert "\n"))))
|
|
|
|
|
(insert "\n"))
|
|
|
|
|
(when (and at-end-p log-window)
|
|
|
|
|
;; When log window's point is at the end, follow the tail.
|
|
|
|
|
(with-selected-window log-window
|
|
|
|
|
(goto-char (point-max)))))))
|
2019-11-09 15:56:55 +00:00
|
|
|
|
|
2020-12-13 17:02:19 +00:00
|
|
|
|
(defun comp-prettyformat-mvar (mvar)
|
|
|
|
|
(format "#(mvar %s %s %S)"
|
|
|
|
|
(comp-mvar-id mvar)
|
|
|
|
|
(comp-mvar-slot mvar)
|
|
|
|
|
(comp-cstr-to-type-spec mvar)))
|
|
|
|
|
|
|
|
|
|
(defun comp-prettyformat-insn (insn)
|
|
|
|
|
(cl-typecase insn
|
|
|
|
|
(comp-mvar (comp-prettyformat-mvar insn))
|
|
|
|
|
(atom (prin1-to-string insn))
|
|
|
|
|
(cons (concat "(" (mapconcat #'comp-prettyformat-insn insn " ") ")"))))
|
|
|
|
|
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(defun comp-log-func (func verbosity)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Log function FUNC at VERBOSITY.
|
2019-11-22 18:15:12 +00:00
|
|
|
|
VERBOSITY is a number between 0 and 3."
|
2021-05-06 08:17:12 +00:00
|
|
|
|
(when (>= native-comp-verbose verbosity)
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(comp-log (format "\nFunction: %s\n" (comp-func-name func)) verbosity)
|
2020-12-13 17:02:19 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for block-name being each hash-keys of (comp-func-blocks func)
|
|
|
|
|
using (hash-value bb)
|
|
|
|
|
do (comp-log (concat "<" (symbol-name block-name) ">") verbosity)
|
|
|
|
|
(cl-loop
|
|
|
|
|
for insn in (comp-block-insns bb)
|
|
|
|
|
do (comp-log (comp-prettyformat-insn insn) verbosity)))))
|
2019-07-21 13:20:39 +00:00
|
|
|
|
|
2019-09-11 21:13:13 +00:00
|
|
|
|
(defun comp-log-edges (func)
|
|
|
|
|
"Log edges in FUNC."
|
2020-09-27 21:43:35 +00:00
|
|
|
|
(let ((edges (comp-func-edges-h func)))
|
2019-11-24 18:50:15 +00:00
|
|
|
|
(comp-log (format "\nEdges in function: %s\n"
|
|
|
|
|
(comp-func-name func))
|
|
|
|
|
2)
|
2020-09-27 21:43:35 +00:00
|
|
|
|
(maphash (lambda (_ e)
|
|
|
|
|
(comp-log (format "n: %d src: %s dst: %s\n"
|
|
|
|
|
(comp-edge-number e)
|
|
|
|
|
(comp-block-name (comp-edge-src e))
|
|
|
|
|
(comp-block-name (comp-edge-dst e)))
|
|
|
|
|
2))
|
2019-09-11 21:13:13 +00:00
|
|
|
|
edges)))
|
|
|
|
|
|
2020-07-13 18:35:20 +00:00
|
|
|
|
|
|
|
|
|
|
2020-06-03 21:06:26 +00:00
|
|
|
|
(defmacro comp-loop-insn-in-block (basic-block &rest body)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Loop over all insns in BASIC-BLOCK executing BODY.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Inside BODY, `insn' and `insn-cell'can be used to read or set the
|
2020-12-15 16:45:53 +00:00
|
|
|
|
current instruction or its cell."
|
2020-06-03 21:06:26 +00:00
|
|
|
|
(declare (debug (form body))
|
|
|
|
|
(indent defun))
|
2020-12-15 16:45:53 +00:00
|
|
|
|
`(cl-symbol-macrolet ((insn (car insn-cell)))
|
|
|
|
|
(let ((insn-cell (comp-block-insns ,basic-block)))
|
|
|
|
|
(while insn-cell
|
|
|
|
|
,@body
|
|
|
|
|
(setf insn-cell (cdr insn-cell))))))
|
2019-07-21 13:20:39 +00:00
|
|
|
|
|
|
|
|
|
;;; spill-lap pass specific code.
|
2019-07-09 16:09:47 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-lex-byte-func-p (f)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Return t if F is a lexically-scoped byte compiled function."
|
2020-05-15 10:43:31 +00:00
|
|
|
|
(and (byte-code-function-p f)
|
|
|
|
|
(fixnump (aref f 0))))
|
|
|
|
|
|
2020-06-18 21:04:55 +00:00
|
|
|
|
(defun comp-spill-decl-spec (function-name spec)
|
|
|
|
|
"Return the declared specifier SPEC for FUNCTION-NAME."
|
|
|
|
|
(plist-get (cdr (assq function-name byte-to-native-plist-environment))
|
|
|
|
|
spec))
|
|
|
|
|
|
|
|
|
|
(defun comp-spill-speed (function-name)
|
|
|
|
|
"Return the speed for FUNCTION-NAME."
|
|
|
|
|
(or (comp-spill-decl-spec function-name 'speed)
|
2020-11-06 23:13:01 +00:00
|
|
|
|
(comp-ctxt-speed comp-ctxt)))
|
2020-06-15 18:26:00 +00:00
|
|
|
|
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
;; Autoloaded as might be used by `disassemble-internal'.
|
2020-10-01 05:55:00 +00:00
|
|
|
|
;;;###autoload
|
2020-07-02 19:32:09 +00:00
|
|
|
|
(defun comp-c-func-name (name prefix &optional first)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Given NAME, return a name suitable for the native code.
|
|
|
|
|
Add PREFIX in front of it. If FIRST is not nil, pick the first
|
2020-07-02 19:32:09 +00:00
|
|
|
|
available name ignoring compilation context and potential name
|
|
|
|
|
clashes."
|
2020-11-20 19:34:32 +00:00
|
|
|
|
;; Unfortunately not all symbol names are valid as C function names...
|
2019-07-21 13:20:39 +00:00
|
|
|
|
;; Nassi's algorithm here:
|
2019-12-23 10:51:33 +00:00
|
|
|
|
(let* ((orig-name (if (symbolp name) (symbol-name name) name))
|
2019-07-08 10:11:34 +00:00
|
|
|
|
(crypted (cl-loop with str = (make-string (* 2 (length orig-name)) 0)
|
|
|
|
|
for j from 0 by 2
|
|
|
|
|
for i across orig-name
|
|
|
|
|
for byte = (format "%x" i)
|
|
|
|
|
do (aset str j (aref byte 0))
|
2019-10-14 20:08:24 +00:00
|
|
|
|
(aset str (1+ j) (aref byte 1))
|
2019-07-08 10:11:34 +00:00
|
|
|
|
finally return str))
|
|
|
|
|
(human-readable (replace-regexp-in-string
|
2019-07-10 19:29:32 +00:00
|
|
|
|
"-" "_" orig-name))
|
|
|
|
|
(human-readable (replace-regexp-in-string
|
2019-07-14 19:10:56 +00:00
|
|
|
|
(rx (not (any "0-9a-z_"))) "" human-readable)))
|
2020-07-02 19:32:09 +00:00
|
|
|
|
(if (null first)
|
2020-04-06 19:03:34 +00:00
|
|
|
|
;; Prevent C namespace conflicts.
|
|
|
|
|
(cl-loop
|
|
|
|
|
with h = (comp-ctxt-funcs-h comp-ctxt)
|
|
|
|
|
for i from 0
|
|
|
|
|
for c-sym = (concat prefix crypted "_" human-readable "_"
|
|
|
|
|
(number-to-string i))
|
|
|
|
|
unless (gethash c-sym h)
|
|
|
|
|
return c-sym)
|
|
|
|
|
;; When called out of a compilation context (ex disassembling)
|
|
|
|
|
;; pick the first one.
|
|
|
|
|
(concat prefix crypted "_" human-readable "_0"))))
|
2019-07-08 10:11:34 +00:00
|
|
|
|
|
2019-12-29 14:56:49 +00:00
|
|
|
|
(defun comp-decrypt-arg-list (x function-name)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Decrypt argument list X for FUNCTION-NAME."
|
2019-09-07 09:17:02 +00:00
|
|
|
|
(unless (fixnump x)
|
2019-12-29 14:56:49 +00:00
|
|
|
|
(signal 'native-compiler-error-dyn-func function-name))
|
2019-07-08 13:29:32 +00:00
|
|
|
|
(let ((rest (not (= (logand x 128) 0)))
|
|
|
|
|
(mandatory (logand x 127))
|
|
|
|
|
(nonrest (ash x -8)))
|
|
|
|
|
(if (and (null rest)
|
|
|
|
|
(< nonrest 9)) ;; SUBR_MAX_ARGS
|
|
|
|
|
(make-comp-args :min mandatory
|
|
|
|
|
:max nonrest)
|
2019-08-11 12:54:13 +00:00
|
|
|
|
(make-comp-nargs :min mandatory
|
2019-11-02 11:17:26 +00:00
|
|
|
|
:nonrest nonrest
|
|
|
|
|
:rest rest))))
|
2019-07-07 10:30:03 +00:00
|
|
|
|
|
2019-11-24 15:21:43 +00:00
|
|
|
|
(defsubst comp-byte-frame-size (byte-compiled-func)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return the frame size to be allocated for BYTE-COMPILED-FUNC."
|
2019-11-24 15:21:43 +00:00
|
|
|
|
(aref byte-compiled-func 3))
|
2019-09-29 19:43:57 +00:00
|
|
|
|
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(defun comp-add-func-to-ctxt (func)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Add FUNC to the current compiler context."
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(let ((name (comp-func-name func))
|
|
|
|
|
(c-name (comp-func-c-name func)))
|
|
|
|
|
(puthash name c-name (comp-ctxt-sym-to-c-name-h comp-ctxt))
|
|
|
|
|
(puthash c-name func (comp-ctxt-funcs-h comp-ctxt))))
|
|
|
|
|
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(cl-defgeneric comp-spill-lap-function (input)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Byte-compile INPUT and spill lap for further stages.")
|
2019-11-23 16:03:08 +00:00
|
|
|
|
|
2020-10-07 18:43:00 +00:00
|
|
|
|
(cl-defmethod comp-spill-lap-function ((function-name symbol))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Byte-compile FUNCTION-NAME, spilling data from the byte compiler."
|
2020-10-10 19:16:40 +00:00
|
|
|
|
(unless (comp-ctxt-output comp-ctxt)
|
|
|
|
|
(setf (comp-ctxt-output comp-ctxt)
|
2020-10-20 19:55:11 +00:00
|
|
|
|
(make-temp-file (comp-c-func-name function-name "freefn-")
|
|
|
|
|
nil ".eln")))
|
2020-04-26 18:55:26 +00:00
|
|
|
|
(let* ((f (symbol-function function-name))
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(c-name (comp-c-func-name function-name "F"))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(func (make-comp-func-l :name function-name
|
|
|
|
|
:c-name c-name
|
2020-08-30 08:23:49 +00:00
|
|
|
|
:doc (documentation f t)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
:int-spec (interactive-form f)
|
2020-06-18 21:04:55 +00:00
|
|
|
|
:speed (comp-spill-speed function-name)
|
|
|
|
|
:pure (comp-spill-decl-spec function-name
|
|
|
|
|
'pure))))
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(when (byte-code-function-p f)
|
|
|
|
|
(signal 'native-compiler-error
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"can't native compile an already byte-compiled function"))
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(setf (comp-func-byte-func func)
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(byte-compile (comp-func-name func)))
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(let ((lap (byte-to-native-lambda-lap
|
|
|
|
|
(gethash (aref (comp-func-byte-func func) 1)
|
|
|
|
|
byte-to-native-lambdas-h))))
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(cl-assert lap)
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(comp-log lap 2 t)
|
2019-12-07 16:31:54 +00:00
|
|
|
|
(let ((arg-list (aref (comp-func-byte-func func) 0)))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(setf (comp-func-l-args func)
|
2019-12-29 14:56:49 +00:00
|
|
|
|
(comp-decrypt-arg-list arg-list function-name)
|
2019-11-24 15:21:43 +00:00
|
|
|
|
(comp-func-lap func)
|
|
|
|
|
lap
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(comp-func-frame-size func)
|
|
|
|
|
(comp-byte-frame-size (comp-func-byte-func func))))
|
2019-11-24 15:18:51 +00:00
|
|
|
|
(setf (comp-ctxt-top-level-forms comp-ctxt)
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(list (make-byte-to-native-func-def :name function-name
|
2020-03-29 10:21:55 +00:00
|
|
|
|
:c-name c-name)))
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(comp-add-func-to-ctxt func))))
|
2019-11-23 16:03:08 +00:00
|
|
|
|
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(cl-defmethod comp-spill-lap-function ((form list))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Byte-compile FORM, spilling data from the byte compiler."
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(unless (eq (car-safe form) 'lambda)
|
|
|
|
|
(signal 'native-compiler-error
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Cannot native-compile, form is not a lambda"))
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(unless (comp-ctxt-output comp-ctxt)
|
|
|
|
|
(setf (comp-ctxt-output comp-ctxt)
|
|
|
|
|
(make-temp-file "comp-lambda-" nil ".eln")))
|
|
|
|
|
(let* ((byte-code (byte-compile form))
|
|
|
|
|
(c-name (comp-c-func-name "anonymous-lambda" "F"))
|
|
|
|
|
(func (if (comp-lex-byte-func-p byte-code)
|
|
|
|
|
(make-comp-func-l :c-name c-name
|
|
|
|
|
:doc (documentation form t)
|
|
|
|
|
:int-spec (interactive-form form)
|
2020-11-06 23:13:01 +00:00
|
|
|
|
:speed (comp-ctxt-speed comp-ctxt))
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(make-comp-func-d :c-name c-name
|
|
|
|
|
:doc (documentation form t)
|
|
|
|
|
:int-spec (interactive-form form)
|
2020-11-06 23:13:01 +00:00
|
|
|
|
:speed (comp-ctxt-speed comp-ctxt)))))
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(let ((lap (byte-to-native-lambda-lap
|
|
|
|
|
(gethash (aref byte-code 1)
|
|
|
|
|
byte-to-native-lambdas-h))))
|
|
|
|
|
(cl-assert lap)
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(comp-log lap 2 t)
|
2020-10-10 20:07:59 +00:00
|
|
|
|
(if (comp-func-l-p func)
|
|
|
|
|
(setf (comp-func-l-args func)
|
|
|
|
|
(comp-decrypt-arg-list (aref byte-code 0) byte-code))
|
|
|
|
|
(setf (comp-func-d-lambda-list func) (cadr form)))
|
|
|
|
|
(setf (comp-func-lap func) lap
|
|
|
|
|
(comp-func-frame-size func) (comp-byte-frame-size
|
|
|
|
|
byte-code))
|
|
|
|
|
(setf (comp-func-byte-func func) byte-code
|
|
|
|
|
(comp-ctxt-top-level-forms comp-ctxt)
|
|
|
|
|
(list (make-byte-to-native-func-def :name '--anonymous-lambda
|
|
|
|
|
:c-name c-name)))
|
|
|
|
|
(comp-add-func-to-ctxt func))))
|
|
|
|
|
|
2020-05-03 14:11:07 +00:00
|
|
|
|
(defun comp-intern-func-in-ctxt (_ obj)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Given OBJ of type `byte-to-native-lambda', create a function in `comp-ctxt'."
|
2020-05-03 14:11:07 +00:00
|
|
|
|
(when-let ((byte-func (byte-to-native-lambda-byte-func obj)))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(let* ((lap (byte-to-native-lambda-lap obj))
|
2020-05-03 14:11:07 +00:00
|
|
|
|
(top-l-form (cl-loop
|
|
|
|
|
for form in (comp-ctxt-top-level-forms comp-ctxt)
|
|
|
|
|
when (and (byte-to-native-func-def-p form)
|
|
|
|
|
(eq (byte-to-native-func-def-byte-func form)
|
|
|
|
|
byte-func))
|
|
|
|
|
return form))
|
|
|
|
|
(name (when top-l-form
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(byte-to-native-func-def-name top-l-form)))
|
|
|
|
|
(c-name (comp-c-func-name (or name "anonymous-lambda") "F"))
|
|
|
|
|
(func (if (comp-lex-byte-func-p byte-func)
|
|
|
|
|
(make-comp-func-l
|
|
|
|
|
:args (comp-decrypt-arg-list (aref byte-func 0)
|
|
|
|
|
name))
|
|
|
|
|
(make-comp-func-d :lambda-list (aref byte-func 0)))))
|
|
|
|
|
(setf (comp-func-name func) name
|
|
|
|
|
(comp-func-byte-func func) byte-func
|
2020-08-30 08:23:49 +00:00
|
|
|
|
(comp-func-doc func) (documentation byte-func t)
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(comp-func-int-spec func) (interactive-form byte-func)
|
|
|
|
|
(comp-func-c-name func) c-name
|
|
|
|
|
(comp-func-lap func) lap
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(comp-func-frame-size func) (comp-byte-frame-size byte-func)
|
2020-06-18 21:04:55 +00:00
|
|
|
|
(comp-func-speed func) (comp-spill-speed name)
|
|
|
|
|
(comp-func-pure func) (comp-spill-decl-spec name 'pure))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; Store the c-name to have it retrievable from
|
2020-06-01 11:47:29 +00:00
|
|
|
|
;; `comp-ctxt-top-level-forms'.
|
|
|
|
|
(when top-l-form
|
|
|
|
|
(setf (byte-to-native-func-def-c-name top-l-form) c-name))
|
|
|
|
|
(unless name
|
|
|
|
|
(puthash byte-func func (comp-ctxt-byte-func-to-func-h comp-ctxt)))
|
|
|
|
|
(comp-add-func-to-ctxt func)
|
|
|
|
|
(comp-log (format "Function %s:\n" name) 1)
|
2020-11-14 15:45:50 +00:00
|
|
|
|
(comp-log lap 1 t))))
|
2020-05-03 14:11:07 +00:00
|
|
|
|
|
2020-10-07 18:43:00 +00:00
|
|
|
|
(cl-defmethod comp-spill-lap-function ((filename string))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Byte-compile FILENAME, spilling data from the byte compiler."
|
2019-09-07 09:17:02 +00:00
|
|
|
|
(byte-compile-file filename)
|
2021-03-16 17:56:34 +00:00
|
|
|
|
(when (or (null byte-native-qualities)
|
|
|
|
|
(alist-get 'no-native-compile byte-native-qualities))
|
2021-03-12 09:24:29 +00:00
|
|
|
|
(throw 'no-native-compile nil))
|
2019-11-13 20:25:00 +00:00
|
|
|
|
(unless byte-to-native-top-level-forms
|
2019-12-29 14:56:49 +00:00
|
|
|
|
(signal 'native-compiler-error-empty-byte filename))
|
2020-10-10 19:16:40 +00:00
|
|
|
|
(unless (comp-ctxt-output comp-ctxt)
|
|
|
|
|
(setf (comp-ctxt-output comp-ctxt) (comp-el-to-eln-filename
|
|
|
|
|
filename
|
|
|
|
|
(when byte-native-for-bootstrap
|
|
|
|
|
(car (last comp-eln-load-path))))))
|
2021-05-06 08:12:48 +00:00
|
|
|
|
(setf (comp-ctxt-speed comp-ctxt) (alist-get 'native-comp-speed
|
2020-11-06 23:13:01 +00:00
|
|
|
|
byte-native-qualities)
|
2021-05-06 08:14:00 +00:00
|
|
|
|
(comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug
|
2020-11-06 23:13:01 +00:00
|
|
|
|
byte-native-qualities)
|
2021-03-07 19:19:20 +00:00
|
|
|
|
(comp-ctxt-driver-options comp-ctxt) (alist-get 'comp-native-driver-options
|
|
|
|
|
byte-native-qualities)
|
2020-11-06 23:13:01 +00:00
|
|
|
|
(comp-ctxt-top-level-forms comp-ctxt)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for form in (reverse byte-to-native-top-level-forms)
|
|
|
|
|
collect
|
|
|
|
|
(if (and (byte-to-native-func-def-p form)
|
|
|
|
|
(eq -1
|
|
|
|
|
(comp-spill-speed (byte-to-native-func-def-name form))))
|
|
|
|
|
(let ((byte-code (byte-to-native-func-def-byte-func form)))
|
|
|
|
|
(remhash byte-code byte-to-native-lambdas-h)
|
|
|
|
|
(make-byte-to-native-top-level
|
|
|
|
|
:form `(defalias
|
|
|
|
|
',(byte-to-native-func-def-name form)
|
|
|
|
|
,byte-code
|
|
|
|
|
nil)
|
|
|
|
|
:lexical (comp-lex-byte-func-p byte-code)))
|
|
|
|
|
form)))
|
2020-05-03 14:11:07 +00:00
|
|
|
|
(maphash #'comp-intern-func-in-ctxt byte-to-native-lambdas-h))
|
2019-09-07 09:17:02 +00:00
|
|
|
|
|
2019-09-07 06:18:08 +00:00
|
|
|
|
(defun comp-spill-lap (input)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Byte-compile and spill the LAP representation for INPUT.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If INPUT is a symbol, it is the function-name to be compiled.
|
|
|
|
|
If INPUT is a string, it is the filename to be compiled."
|
2019-09-06 17:33:16 +00:00
|
|
|
|
(let ((byte-native-compiling t)
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(byte-to-native-lambdas-h (make-hash-table :test #'eq))
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(byte-to-native-top-level-forms ())
|
|
|
|
|
(byte-to-native-plist-environment ()))
|
2019-11-23 16:03:08 +00:00
|
|
|
|
(comp-spill-lap-function input)))
|
2019-07-08 05:56:37 +00:00
|
|
|
|
|
2019-07-21 13:20:39 +00:00
|
|
|
|
|
|
|
|
|
;;; Limplification pass specific code.
|
|
|
|
|
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(cl-defstruct (comp-limplify (:copier nil))
|
|
|
|
|
"Support structure used during function limplification."
|
2021-02-22 16:28:19 +00:00
|
|
|
|
(frame nil :type (or null comp-vec)
|
2019-10-05 15:08:48 +00:00
|
|
|
|
:documentation "Meta-stack used to flat LAP.")
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(curr-block nil :type comp-block
|
2019-11-22 18:15:12 +00:00
|
|
|
|
:documentation "Current block being limplified.")
|
2019-10-20 07:32:57 +00:00
|
|
|
|
(sp -1 :type number
|
|
|
|
|
:documentation "Current stack pointer while walking LAP.
|
|
|
|
|
Points to the next slot to be filled.")
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(pc 0 :type number
|
|
|
|
|
:documentation "Current program counter while walking LAP.")
|
2019-10-13 15:41:26 +00:00
|
|
|
|
(label-to-addr nil :type hash-table
|
|
|
|
|
:documentation "LAP hash table -> address.")
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(pending-blocks () :type list
|
2020-02-21 14:28:05 +00:00
|
|
|
|
:documentation "List of blocks waiting for limplification."))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
|
|
|
|
|
(defconst comp-lap-eob-ops
|
|
|
|
|
'(byte-goto byte-goto-if-nil byte-goto-if-not-nil byte-goto-if-nil-else-pop
|
2019-10-19 14:31:02 +00:00
|
|
|
|
byte-goto-if-not-nil-else-pop byte-return byte-pushcatch
|
2019-10-20 08:39:59 +00:00
|
|
|
|
byte-switch byte-pushconditioncase)
|
2019-10-13 08:36:22 +00:00
|
|
|
|
"LAP end of basic blocks op codes.")
|
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-lap-eob-p (inst)
|
2019-10-13 08:36:22 +00:00
|
|
|
|
"Return t if INST closes the current basic blocks, nil otherwise."
|
2020-01-20 19:30:24 +00:00
|
|
|
|
(when (memq (car inst) comp-lap-eob-ops)
|
2019-10-13 08:36:22 +00:00
|
|
|
|
t))
|
2019-10-05 15:08:48 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-lap-fall-through-p (inst)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return t if INST falls through, nil otherwise."
|
2020-01-20 19:30:24 +00:00
|
|
|
|
(when (not (memq (car inst) '(byte-goto byte-return)))
|
2019-10-19 09:20:15 +00:00
|
|
|
|
t))
|
|
|
|
|
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(defsubst comp-sp ()
|
2019-09-18 22:07:10 +00:00
|
|
|
|
"Current stack pointer."
|
2020-09-14 20:02:18 +00:00
|
|
|
|
(declare (gv-setter (lambda (val)
|
|
|
|
|
`(setf (comp-limplify-sp comp-pass) ,val))))
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(comp-limplify-sp comp-pass))
|
2019-09-18 22:07:10 +00:00
|
|
|
|
|
|
|
|
|
(defmacro comp-with-sp (sp &rest body)
|
|
|
|
|
"Execute BODY setting the stack pointer to SP.
|
|
|
|
|
Restore the original value afterwards."
|
|
|
|
|
(declare (debug (form body))
|
|
|
|
|
(indent defun))
|
|
|
|
|
(let ((sym (gensym)))
|
|
|
|
|
`(let ((,sym (comp-sp)))
|
|
|
|
|
(setf (comp-sp) ,sp)
|
|
|
|
|
(progn ,@body)
|
|
|
|
|
(setf (comp-sp) ,sym))))
|
|
|
|
|
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(defsubst comp-slot-n (n)
|
2019-09-18 22:07:10 +00:00
|
|
|
|
"Slot N into the meta-stack."
|
2021-02-22 16:28:19 +00:00
|
|
|
|
(comp-vec-aref (comp-limplify-frame comp-pass) n))
|
2019-09-18 22:07:10 +00:00
|
|
|
|
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(defsubst comp-slot ()
|
2019-09-18 22:07:10 +00:00
|
|
|
|
"Current slot into the meta-stack pointed by sp."
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(comp-slot-n (comp-sp)))
|
2019-09-18 22:07:10 +00:00
|
|
|
|
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(defsubst comp-slot+1 ()
|
2019-09-18 22:07:10 +00:00
|
|
|
|
"Slot into the meta-stack pointed by sp + 1."
|
2019-10-05 15:08:48 +00:00
|
|
|
|
(comp-slot-n (1+ (comp-sp))))
|
2019-07-08 09:37:17 +00:00
|
|
|
|
|
2019-10-13 16:58:46 +00:00
|
|
|
|
(defsubst comp-label-to-addr (label)
|
|
|
|
|
"Find the address of LABEL."
|
|
|
|
|
(or (gethash label (comp-limplify-label-to-addr comp-pass))
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(signal 'native-ice (list "label not found" label))))
|
2019-10-13 16:58:46 +00:00
|
|
|
|
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(defsubst comp-mark-curr-bb-closed ()
|
|
|
|
|
"Mark the current basic block as closed."
|
|
|
|
|
(setf (comp-block-closed (comp-limplify-curr-block comp-pass)) t))
|
|
|
|
|
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(defun comp-bb-maybe-add (lap-addr &optional sp)
|
|
|
|
|
"If necessary create a pending basic block for LAP-ADDR with stack depth SP.
|
|
|
|
|
The basic block is returned regardless it was already declared or not."
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(let ((bb (or (cl-loop ; See if the block was already limplified.
|
2019-11-01 14:28:17 +00:00
|
|
|
|
for bb being the hash-value in (comp-func-blocks comp-func)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
when (and (comp-block-lap-p bb)
|
|
|
|
|
(equal (comp-block-lap-addr bb) lap-addr))
|
2019-11-01 14:28:17 +00:00
|
|
|
|
return bb)
|
|
|
|
|
(cl-find-if (lambda (bb) ; Look within the pendings blocks.
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(and (comp-block-lap-p bb)
|
|
|
|
|
(= (comp-block-lap-addr bb) lap-addr)))
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(comp-limplify-pending-blocks comp-pass)))))
|
|
|
|
|
(if bb
|
|
|
|
|
(progn
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(unless (or (null sp) (= sp (comp-block-lap-sp bb)))
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(signal 'native-ice (list "incoherent stack pointers"
|
2020-06-11 20:53:31 +00:00
|
|
|
|
sp (comp-block-lap-sp bb))))
|
2019-11-01 14:28:17 +00:00
|
|
|
|
bb)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(car (push (make--comp-block-lap lap-addr sp (comp-new-block-sym))
|
2019-10-20 19:00:17 +00:00
|
|
|
|
(comp-limplify-pending-blocks comp-pass))))))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
|
2019-12-15 14:31:03 +00:00
|
|
|
|
(defsubst comp-call (func &rest args)
|
2019-08-21 10:17:56 +00:00
|
|
|
|
"Emit a call for function FUNC with ARGS."
|
2019-08-21 19:20:27 +00:00
|
|
|
|
`(call ,func ,@args))
|
2019-08-19 15:59:20 +00:00
|
|
|
|
|
2019-11-16 14:24:35 +00:00
|
|
|
|
(defun comp-callref (func nargs stack-off)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Emit a call using narg abi for FUNC.
|
2019-11-16 14:24:35 +00:00
|
|
|
|
NARGS is the number of arguments.
|
|
|
|
|
STACK-OFF is the index of the first slot frame involved."
|
|
|
|
|
`(callref ,func ,@(cl-loop repeat nargs
|
|
|
|
|
for sp from stack-off
|
2019-09-15 13:41:42 +00:00
|
|
|
|
collect (comp-slot-n sp))))
|
2019-08-19 15:59:20 +00:00
|
|
|
|
|
2020-02-21 14:28:05 +00:00
|
|
|
|
(cl-defun make-comp-mvar (&key slot (constant nil const-vld) type)
|
2021-04-27 05:18:14 +00:00
|
|
|
|
"`comp-mvar' initializer."
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(let ((mvar (make--comp-mvar :slot slot)))
|
|
|
|
|
(when const-vld
|
|
|
|
|
(comp-add-const-to-relocs constant)
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(setf (comp-cstr-imm mvar) constant))
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(when type
|
|
|
|
|
(setf (comp-mvar-typeset mvar) (list type)))
|
|
|
|
|
mvar))
|
2019-09-14 16:12:16 +00:00
|
|
|
|
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(defun comp-new-frame (size vsize &optional ssa)
|
2021-02-25 19:25:05 +00:00
|
|
|
|
"Return a clean frame of meta variables of size SIZE and VSIZE.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If SSA is non-nil, populate it with m-var in ssa form."
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(cl-loop with v = (make-comp-vec :beg (- vsize) :end size)
|
|
|
|
|
for i from (- vsize) below size
|
2019-10-24 20:20:38 +00:00
|
|
|
|
for mvar = (if ssa
|
|
|
|
|
(make-comp-ssa-mvar :slot i)
|
|
|
|
|
(make-comp-mvar :slot i))
|
2021-02-22 16:28:19 +00:00
|
|
|
|
do (setf (comp-vec-aref v i) mvar)
|
2019-11-02 13:34:31 +00:00
|
|
|
|
finally return v))
|
2019-07-08 07:06:58 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-emit (insn)
|
2019-10-21 09:30:39 +00:00
|
|
|
|
"Emit INSN into basic block BB."
|
|
|
|
|
(let ((bb (comp-limplify-curr-block comp-pass)))
|
2019-10-20 19:00:17 +00:00
|
|
|
|
(cl-assert (not (comp-block-closed bb)))
|
|
|
|
|
(push insn (comp-block-insns bb))))
|
2019-07-13 14:34:59 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-emit-set-call (call)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"Emit CALL assigning the result to the current slot frame.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If the callee function is known to have a return type, propagate it."
|
2019-07-13 09:33:15 +00:00
|
|
|
|
(cl-assert call)
|
2019-07-13 14:34:59 +00:00
|
|
|
|
(comp-emit (list 'set (comp-slot) call)))
|
2019-07-13 09:33:15 +00:00
|
|
|
|
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(defun comp-copy-slot (src-n &optional dst-n)
|
|
|
|
|
"Set slot number DST-N to slot number SRC-N as source.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If DST-N is specified, use it; otherwise assume it to be the current slot."
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(comp-with-sp (or dst-n (comp-sp))
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(let ((src-slot (comp-slot-n src-n)))
|
|
|
|
|
(cl-assert src-slot)
|
2019-09-14 10:39:53 +00:00
|
|
|
|
(comp-emit `(set ,(comp-slot) ,src-slot)))))
|
2019-07-08 07:06:58 +00:00
|
|
|
|
|
2019-10-24 20:20:38 +00:00
|
|
|
|
(defsubst comp-emit-annotation (str)
|
2019-07-10 16:55:19 +00:00
|
|
|
|
"Emit annotation STR."
|
2019-07-13 14:34:59 +00:00
|
|
|
|
(comp-emit `(comment ,str)))
|
2019-07-10 16:55:19 +00:00
|
|
|
|
|
2020-02-29 15:53:42 +00:00
|
|
|
|
(defsubst comp-emit-setimm (val)
|
2019-07-13 16:28:00 +00:00
|
|
|
|
"Set constant VAL to current slot."
|
2020-02-29 15:53:42 +00:00
|
|
|
|
(comp-add-const-to-relocs val)
|
|
|
|
|
;; Leave relocation index nil on purpose, will be fixed-up in final
|
|
|
|
|
;; by `comp-finalize-relocs'.
|
2020-03-01 14:42:41 +00:00
|
|
|
|
(comp-emit `(setimm ,(comp-slot) ,val)))
|
2019-07-08 15:04:33 +00:00
|
|
|
|
|
2019-10-19 14:31:02 +00:00
|
|
|
|
(defun comp-make-curr-block (block-name entry-sp &optional addr)
|
2019-10-13 08:36:22 +00:00
|
|
|
|
"Create a basic block with BLOCK-NAME and set it as current block.
|
|
|
|
|
ENTRY-SP is the sp value when entering.
|
2020-11-16 02:50:10 +00:00
|
|
|
|
Add block to the current function and return it."
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(let ((bb (make--comp-block-lap addr entry-sp block-name)))
|
2019-11-22 18:20:05 +00:00
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) bb
|
|
|
|
|
(comp-limplify-pc comp-pass) addr
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(comp-limplify-sp comp-pass) (when (comp-block-lap-p bb)
|
|
|
|
|
(comp-block-lap-sp bb)))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(puthash (comp-block-name bb) bb (comp-func-blocks comp-func))
|
|
|
|
|
bb))
|
|
|
|
|
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(defun comp-latch-make-fill (target)
|
|
|
|
|
"Create a latch pointing to TARGET and fill it.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Return the created latch."
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(let ((latch (make-comp-latch :name (comp-new-block-sym "latch")))
|
|
|
|
|
(curr-bb (comp-limplify-curr-block comp-pass)))
|
|
|
|
|
;; See `comp-make-curr-block'.
|
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) latch)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(when (< (comp-func-speed comp-func) 3)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
;; At speed 3 the programmer is responsible to manually
|
|
|
|
|
;; place `comp-maybe-gc-or-quit'.
|
|
|
|
|
(comp-emit '(call comp-maybe-gc-or-quit)))
|
|
|
|
|
;; See `comp-emit-uncond-jump'.
|
|
|
|
|
(comp-emit `(jump ,(comp-block-name target)))
|
|
|
|
|
(comp-mark-curr-bb-closed)
|
|
|
|
|
(puthash (comp-block-name latch) latch (comp-func-blocks comp-func))
|
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) curr-bb)
|
|
|
|
|
latch))
|
|
|
|
|
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(defun comp-emit-uncond-jump (lap-label)
|
|
|
|
|
"Emit an unconditional branch to LAP-LABEL."
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(cl-destructuring-bind (label-num . stack-depth) lap-label
|
2019-10-24 20:13:29 +00:00
|
|
|
|
(when stack-depth
|
|
|
|
|
(cl-assert (= (1- stack-depth) (comp-sp))))
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(let* ((target-addr (comp-label-to-addr label-num))
|
|
|
|
|
(target (comp-bb-maybe-add target-addr
|
|
|
|
|
(comp-sp)))
|
|
|
|
|
(latch (when (< target-addr (comp-limplify-pc comp-pass))
|
|
|
|
|
(comp-latch-make-fill target)))
|
|
|
|
|
(eff-target-name (comp-block-name (or latch target))))
|
|
|
|
|
(comp-emit `(jump ,eff-target-name))
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(comp-mark-curr-bb-closed))))
|
2019-07-14 16:36:57 +00:00
|
|
|
|
|
2019-08-03 15:08:55 +00:00
|
|
|
|
(defun comp-emit-cond-jump (a b target-offset lap-label negated)
|
|
|
|
|
"Emit a conditional jump to LAP-LABEL when A and B satisfy EQ.
|
2019-07-21 07:48:52 +00:00
|
|
|
|
TARGET-OFFSET is the positive offset on the SP when branching to the target
|
|
|
|
|
block.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If NEGATED is non null, negate the tested condition.
|
|
|
|
|
Return value is the fall-through block name."
|
2019-10-20 08:39:59 +00:00
|
|
|
|
(cl-destructuring-bind (label-num . label-sp) lap-label
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(let* ((bb (comp-block-name (comp-bb-maybe-add
|
|
|
|
|
(1+ (comp-limplify-pc comp-pass))
|
|
|
|
|
(comp-sp)))) ; Fall through block.
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(target-sp (+ target-offset (comp-sp)))
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(target-addr (comp-label-to-addr label-num))
|
|
|
|
|
(target (comp-bb-maybe-add target-addr target-sp))
|
|
|
|
|
(latch (when (< target-addr (comp-limplify-pc comp-pass))
|
|
|
|
|
(comp-latch-make-fill target)))
|
|
|
|
|
(eff-target-name (comp-block-name (or latch target))))
|
2019-10-20 12:42:06 +00:00
|
|
|
|
(when label-sp
|
|
|
|
|
(cl-assert (= (1- label-sp) (+ target-offset (comp-sp)))))
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(comp-emit (if negated
|
2020-12-22 08:57:51 +00:00
|
|
|
|
(list 'cond-jump a b bb eff-target-name)
|
|
|
|
|
(list 'cond-jump a b eff-target-name bb)))
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(comp-mark-curr-bb-closed)
|
2019-10-19 14:31:02 +00:00
|
|
|
|
bb)))
|
2019-10-13 18:45:14 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-emit-handler (lap-label handler-type)
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Emit a nonlocal-exit handler to LAP-LABEL of type HANDLER-TYPE."
|
2019-10-20 08:39:59 +00:00
|
|
|
|
(cl-destructuring-bind (label-num . label-sp) lap-label
|
2019-10-20 19:00:17 +00:00
|
|
|
|
(cl-assert (= (- label-sp 2) (comp-sp)))
|
2019-12-28 10:39:29 +00:00
|
|
|
|
(setf (comp-func-has-non-local comp-func) t)
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(let* ((guarded-bb (comp-bb-maybe-add (1+ (comp-limplify-pc comp-pass))
|
|
|
|
|
(comp-sp)))
|
|
|
|
|
(handler-bb (comp-bb-maybe-add (comp-label-to-addr label-num)
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(1+ (comp-sp))))
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(pop-bb (make--comp-block-lap nil (comp-sp) (comp-new-block-sym))))
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(comp-emit (list 'push-handler
|
|
|
|
|
handler-type
|
2019-10-20 19:00:17 +00:00
|
|
|
|
(comp-slot+1)
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(comp-block-name pop-bb)
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(comp-block-name guarded-bb)))
|
2019-11-10 16:02:55 +00:00
|
|
|
|
(comp-mark-curr-bb-closed)
|
|
|
|
|
;; Emit the basic block to pop the handler if we got the non local.
|
|
|
|
|
(puthash (comp-block-name pop-bb) pop-bb (comp-func-blocks comp-func))
|
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) pop-bb)
|
|
|
|
|
(comp-emit `(fetch-handler ,(comp-slot+1)))
|
|
|
|
|
(comp-emit `(jump ,(comp-block-name handler-bb)))
|
|
|
|
|
(comp-mark-curr-bb-closed))))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
|
2019-07-08 07:15:09 +00:00
|
|
|
|
(defun comp-limplify-listn (n)
|
2019-07-08 07:29:13 +00:00
|
|
|
|
"Limplify list N."
|
2019-08-03 17:42:57 +00:00
|
|
|
|
(comp-with-sp (+ (comp-sp) n -1)
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'cons
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-slot)
|
|
|
|
|
(make-comp-mvar :constant nil))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(cl-loop for sp from (+ (comp-sp) n -2) downto (comp-sp)
|
|
|
|
|
do (comp-with-sp sp
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'cons
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-slot)
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-slot+1))))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(defun comp-new-block-sym (&optional postfix)
|
|
|
|
|
"Return a unique symbol postfixing POSTFIX naming the next new basic block."
|
|
|
|
|
(intern (format (if postfix "bb_%s_%s" "bb_%s")
|
|
|
|
|
(funcall (comp-func-block-cnt-gen comp-func))
|
|
|
|
|
postfix)))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
|
2019-10-13 15:41:26 +00:00
|
|
|
|
(defun comp-fill-label-h ()
|
|
|
|
|
"Fill label-to-addr hash table for the current function."
|
|
|
|
|
(setf (comp-limplify-label-to-addr comp-pass) (make-hash-table :test 'eql))
|
|
|
|
|
(cl-loop for insn in (comp-func-lap comp-func)
|
|
|
|
|
for addr from 0
|
|
|
|
|
do (pcase insn
|
2019-10-13 16:58:46 +00:00
|
|
|
|
(`(TAG ,label . ,_)
|
2019-10-13 15:41:26 +00:00
|
|
|
|
(puthash label addr (comp-limplify-label-to-addr comp-pass))))))
|
|
|
|
|
|
2020-05-07 07:10:50 +00:00
|
|
|
|
(defun comp-jump-table-optimizable (jmp-table)
|
|
|
|
|
"Return t if JMP-TABLE can be optimized out."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with labels = (cl-loop for target-label being each hash-value of jmp-table
|
|
|
|
|
collect target-label)
|
|
|
|
|
with x = (car labels)
|
|
|
|
|
for l in (cdr-safe labels)
|
|
|
|
|
unless (= l x)
|
|
|
|
|
return nil
|
|
|
|
|
finally return t))
|
|
|
|
|
|
2019-09-16 17:47:49 +00:00
|
|
|
|
(defun comp-emit-switch (var last-insn)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"Emit a Limple for a lap jump table given VAR and LAST-INSN."
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; FIXME this not efficient for big jump tables. We should have a second
|
2019-11-17 23:05:55 +00:00
|
|
|
|
;; strategy for this case.
|
2019-09-16 17:47:49 +00:00
|
|
|
|
(pcase last-insn
|
2020-03-01 14:42:41 +00:00
|
|
|
|
(`(setimm ,_ ,jmp-table)
|
2020-05-07 07:10:50 +00:00
|
|
|
|
(unless (comp-jump-table-optimizable jmp-table)
|
|
|
|
|
(cl-loop
|
|
|
|
|
for test being each hash-keys of jmp-table
|
|
|
|
|
using (hash-value target-label)
|
|
|
|
|
with len = (hash-table-count jmp-table)
|
|
|
|
|
with test-func = (hash-table-test jmp-table)
|
|
|
|
|
for n from 1
|
|
|
|
|
for last = (= n len)
|
|
|
|
|
for m-test = (make-comp-mvar :constant test)
|
2020-09-28 19:09:00 +00:00
|
|
|
|
for target-name = (comp-block-name (comp-bb-maybe-add
|
|
|
|
|
(comp-label-to-addr target-label)
|
|
|
|
|
(comp-sp)))
|
2020-05-07 07:10:50 +00:00
|
|
|
|
for ff-bb = (if last
|
|
|
|
|
(comp-bb-maybe-add (1+ (comp-limplify-pc comp-pass))
|
|
|
|
|
(comp-sp))
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(make--comp-block-lap nil
|
|
|
|
|
(comp-sp)
|
|
|
|
|
(comp-new-block-sym)))
|
2020-05-07 07:10:50 +00:00
|
|
|
|
for ff-bb-name = (comp-block-name ff-bb)
|
|
|
|
|
if (eq test-func 'eq)
|
2020-12-22 08:57:51 +00:00
|
|
|
|
do (comp-emit (list 'cond-jump var m-test target-name ff-bb-name))
|
2020-05-07 07:10:50 +00:00
|
|
|
|
else
|
2019-11-17 23:05:55 +00:00
|
|
|
|
;; Store the result of the comparison into the scratch slot before
|
|
|
|
|
;; emitting the conditional jump.
|
2020-05-07 07:10:50 +00:00
|
|
|
|
do (comp-emit (list 'set (make-comp-mvar :slot 'scratch)
|
|
|
|
|
(comp-call test-func var m-test)))
|
|
|
|
|
(comp-emit (list 'cond-jump
|
|
|
|
|
(make-comp-mvar :slot 'scratch)
|
|
|
|
|
(make-comp-mvar :constant nil)
|
2020-12-22 08:57:51 +00:00
|
|
|
|
ff-bb-name target-name))
|
2020-05-07 07:10:50 +00:00
|
|
|
|
unless last
|
|
|
|
|
;; All fall through are artificially created here except the last one.
|
|
|
|
|
do (puthash ff-bb-name ff-bb (comp-func-blocks comp-func))
|
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) ff-bb))))
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(_ (signal 'native-ice
|
|
|
|
|
"missing previous setimm while creating a switch"))))
|
2019-08-03 15:08:55 +00:00
|
|
|
|
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(defun comp-emit-set-call-subr (subr-name sp-delta)
|
|
|
|
|
"Emit a call for SUBR-NAME.
|
|
|
|
|
SP-DELTA is the stack adjustment."
|
|
|
|
|
(let ((subr (symbol-function subr-name))
|
|
|
|
|
(nargs (1+ (- sp-delta))))
|
2020-10-26 16:31:13 +00:00
|
|
|
|
(let* ((arity (func-arity subr))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(minarg (car arity))
|
|
|
|
|
(maxarg (cdr arity)))
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(when (eq maxarg 'unevalled)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
(signal 'native-ice (list "subr contains unevalled args" subr-name)))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(if (eq maxarg 'many)
|
|
|
|
|
;; callref case.
|
|
|
|
|
(comp-emit-set-call (comp-callref subr-name nargs (comp-sp)))
|
|
|
|
|
;; Normal call.
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(unless (and (>= maxarg nargs) (<= minarg nargs))
|
|
|
|
|
(signal 'native-ice
|
|
|
|
|
(list "incoherent stack adjustment" nargs maxarg minarg)))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(let* ((subr-name subr-name)
|
|
|
|
|
(slots (cl-loop for i from 0 below maxarg
|
|
|
|
|
collect (comp-slot-n (+ i (comp-sp))))))
|
|
|
|
|
(comp-emit-set-call (apply #'comp-call (cons subr-name slots))))))))
|
|
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(defun comp-op-to-fun (x)
|
|
|
|
|
"Given the LAP op strip \"byte-\" to have the subr name."
|
|
|
|
|
(intern (replace-regexp-in-string "byte-" "" x)))
|
|
|
|
|
|
|
|
|
|
(defun comp-body-eff (body op-name sp-delta)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given the original BODY, compute the effective one.
|
|
|
|
|
When BODY is `auto', guess function name from the LAP byte-code
|
2019-11-22 18:15:12 +00:00
|
|
|
|
name. Otherwise expect lname fnname."
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(pcase (car body)
|
|
|
|
|
('auto
|
2020-09-23 19:50:20 +00:00
|
|
|
|
`((comp-emit-set-call-subr ',(comp-op-to-fun op-name) ,sp-delta)))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
((pred symbolp)
|
2020-09-23 19:50:20 +00:00
|
|
|
|
`((comp-emit-set-call-subr ',(car body) ,sp-delta)))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
(_ body))))
|
|
|
|
|
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(defmacro comp-op-case (&rest cases)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Expand CASES into the corresponding `pcase' expansion.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
This is responsible for generating the proper stack adjustment, when known,
|
|
|
|
|
and the annotation emission."
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(declare (debug (body))
|
|
|
|
|
(indent defun))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
`(pcase op
|
|
|
|
|
,@(cl-loop for (op . body) in cases
|
|
|
|
|
for sp-delta = (gethash op comp-op-stack-info)
|
|
|
|
|
for op-name = (symbol-name op)
|
|
|
|
|
if body
|
|
|
|
|
collect `(',op
|
|
|
|
|
;; Log all LAP ops except the TAG one.
|
2020-12-25 08:39:22 +00:00
|
|
|
|
;; ,(unless (eq op 'TAG)
|
|
|
|
|
;; `(comp-emit-annotation
|
|
|
|
|
;; ,(concat "LAP op " op-name)))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
;; Emit the stack adjustment if present.
|
|
|
|
|
,(when (and sp-delta (not (eq 0 sp-delta)))
|
2019-10-19 16:15:00 +00:00
|
|
|
|
`(cl-incf (comp-sp) ,sp-delta))
|
2019-10-05 14:20:57 +00:00
|
|
|
|
,@(comp-body-eff body op-name sp-delta))
|
|
|
|
|
else
|
2019-11-21 15:09:30 +00:00
|
|
|
|
collect `(',op (signal 'native-ice
|
|
|
|
|
(list "unsupported LAP op" ',op-name))))
|
|
|
|
|
(_ (signal 'native-ice (list "unexpected LAP op" (symbol-name op))))))
|
2019-07-08 07:15:09 +00:00
|
|
|
|
|
2019-07-22 09:08:53 +00:00
|
|
|
|
(defun comp-limplify-lap-inst (insn)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Limplify LAP instruction INSN pushing it in the proper basic block."
|
2019-07-22 09:08:53 +00:00
|
|
|
|
(let ((op (car insn))
|
|
|
|
|
(arg (if (consp (cdr insn))
|
|
|
|
|
(cadr insn)
|
|
|
|
|
(cdr insn))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(comp-op-case
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(TAG
|
2019-10-24 20:19:14 +00:00
|
|
|
|
(cl-destructuring-bind (_TAG label-num . label-sp) insn
|
2019-10-20 12:42:06 +00:00
|
|
|
|
;; Paranoid?
|
|
|
|
|
(when label-sp
|
2019-10-24 20:19:14 +00:00
|
|
|
|
(cl-assert (= (1- label-sp) (comp-limplify-sp comp-pass))))
|
|
|
|
|
(comp-emit-annotation (format "LAP TAG %d" label-num))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-stack-ref
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(comp-copy-slot (- (comp-sp) arg 1)))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-varref
|
2019-09-02 16:08:59 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'symbol-value (make-comp-mvar
|
2019-08-19 16:22:26 +00:00
|
|
|
|
:constant arg))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-varset
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit (comp-call 'set_internal
|
|
|
|
|
(make-comp-mvar :constant arg)
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-slot+1))))
|
2019-08-11 12:41:35 +00:00
|
|
|
|
(byte-varbind ;; Verify
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit (comp-call 'specbind
|
|
|
|
|
(make-comp-mvar :constant arg)
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-slot+1))))
|
2019-07-14 09:15:18 +00:00
|
|
|
|
(byte-call
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- arg))
|
2019-09-18 09:55:25 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'funcall (1+ arg) (comp-sp))))
|
2019-07-14 19:26:20 +00:00
|
|
|
|
(byte-unbind
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit (comp-call 'helper_unbind_n
|
|
|
|
|
(make-comp-mvar :constant arg))))
|
2019-07-21 09:38:26 +00:00
|
|
|
|
(byte-pophandler
|
|
|
|
|
(comp-emit '(pop-handler)))
|
|
|
|
|
(byte-pushconditioncase
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(comp-emit-handler (cddr insn) 'condition-case))
|
2019-07-22 09:08:53 +00:00
|
|
|
|
(byte-pushcatch
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(comp-emit-handler (cddr insn) 'catcher))
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-nth auto)
|
|
|
|
|
(byte-symbolp auto)
|
|
|
|
|
(byte-consp auto)
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-stringp auto)
|
|
|
|
|
(byte-listp auto)
|
|
|
|
|
(byte-eq auto)
|
|
|
|
|
(byte-memq auto)
|
2020-12-22 12:04:02 +00:00
|
|
|
|
(byte-not
|
|
|
|
|
(comp-emit-set-call (comp-call 'eq (comp-slot-n (comp-sp))
|
|
|
|
|
(make-comp-mvar :constant nil))))
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-car auto)
|
|
|
|
|
(byte-cdr auto)
|
|
|
|
|
(byte-cons auto)
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-list1
|
|
|
|
|
(comp-limplify-listn 1))
|
|
|
|
|
(byte-list2
|
|
|
|
|
(comp-limplify-listn 2))
|
|
|
|
|
(byte-list3
|
|
|
|
|
(comp-limplify-listn 3))
|
|
|
|
|
(byte-list4
|
|
|
|
|
(comp-limplify-listn 4))
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-length auto)
|
|
|
|
|
(byte-aref auto)
|
|
|
|
|
(byte-aset auto)
|
|
|
|
|
(byte-symbol-value auto)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-symbol-function auto)
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-set auto)
|
|
|
|
|
(byte-fset auto)
|
|
|
|
|
(byte-get auto)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-substring auto)
|
2019-07-14 08:57:46 +00:00
|
|
|
|
(byte-concat2
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'concat 2 (comp-sp))))
|
2019-07-14 08:57:46 +00:00
|
|
|
|
(byte-concat3
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'concat 3 (comp-sp))))
|
2019-07-14 08:57:46 +00:00
|
|
|
|
(byte-concat4
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'concat 4 (comp-sp))))
|
|
|
|
|
(byte-sub1 1-)
|
|
|
|
|
(byte-add1 1+)
|
|
|
|
|
(byte-eqlsign =)
|
|
|
|
|
(byte-gtr >)
|
|
|
|
|
(byte-lss <)
|
|
|
|
|
(byte-leq <=)
|
|
|
|
|
(byte-geq >=)
|
|
|
|
|
(byte-diff -)
|
2019-08-15 19:06:07 +00:00
|
|
|
|
(byte-negate
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'negate (comp-slot))))
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(byte-plus +)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-max auto)
|
|
|
|
|
(byte-min auto)
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(byte-mult *)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-point auto)
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-goto-char auto)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-insert auto)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-point-max auto)
|
|
|
|
|
(byte-point-min auto)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-char-after auto)
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-following-char auto)
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(byte-preceding-char preceding-char)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-current-column auto)
|
2019-08-15 20:23:32 +00:00
|
|
|
|
(byte-indent-to
|
2019-10-27 14:55:08 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'indent-to
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-slot)
|
|
|
|
|
(make-comp-mvar :constant nil))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-scan-buffer-OBSOLETE)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-eolp auto)
|
|
|
|
|
(byte-eobp auto)
|
|
|
|
|
(byte-bolp auto)
|
|
|
|
|
(byte-bobp auto)
|
|
|
|
|
(byte-current-buffer auto)
|
|
|
|
|
(byte-set-buffer auto)
|
2019-08-08 15:35:25 +00:00
|
|
|
|
(byte-save-current-buffer
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit (comp-call 'record_unwind_current_buffer)))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-set-mark-OBSOLETE)
|
|
|
|
|
(byte-interactive-p-OBSOLETE)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-forward-char auto)
|
|
|
|
|
(byte-forward-word auto)
|
|
|
|
|
(byte-skip-chars-forward auto)
|
|
|
|
|
(byte-skip-chars-backward auto)
|
|
|
|
|
(byte-forward-line auto)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-char-syntax auto)
|
|
|
|
|
(byte-buffer-substring auto)
|
|
|
|
|
(byte-delete-region auto)
|
2019-08-11 10:37:21 +00:00
|
|
|
|
(byte-narrow-to-region
|
2019-10-27 14:55:08 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'narrow-to-region
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-slot)
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-slot+1))))
|
2019-08-11 10:37:21 +00:00
|
|
|
|
(byte-widen
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-call 'widen)))
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-end-of-line auto)
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(byte-constant2) ; TODO
|
|
|
|
|
;; Branches.
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(byte-goto
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(comp-emit-uncond-jump (cddr insn)))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(byte-goto-if-nil
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-emit-cond-jump (comp-slot+1) (make-comp-mvar :constant nil) 0
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(cddr insn) nil))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(byte-goto-if-not-nil
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-emit-cond-jump (comp-slot+1) (make-comp-mvar :constant nil) 0
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(cddr insn) t))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(byte-goto-if-nil-else-pop
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-emit-cond-jump (comp-slot+1) (make-comp-mvar :constant nil) 1
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(cddr insn) nil))
|
2019-07-14 12:39:29 +00:00
|
|
|
|
(byte-goto-if-not-nil-else-pop
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-emit-cond-jump (comp-slot+1) (make-comp-mvar :constant nil) 1
|
2019-10-13 18:45:14 +00:00
|
|
|
|
(cddr insn) t))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-return
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-emit `(return ,(comp-slot+1))))
|
2019-07-14 21:35:04 +00:00
|
|
|
|
(byte-discard 'pass)
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-dup
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(comp-copy-slot (1- (comp-sp))))
|
2019-08-11 10:24:15 +00:00
|
|
|
|
(byte-save-excursion
|
2019-08-19 15:59:20 +00:00
|
|
|
|
(comp-emit (comp-call 'record_unwind_protect_excursion)))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-save-window-excursion-OBSOLETE)
|
2019-08-11 12:10:57 +00:00
|
|
|
|
(byte-save-restriction
|
2019-11-09 10:43:16 +00:00
|
|
|
|
(comp-emit (comp-call 'helper_save_restriction)))
|
2019-08-11 12:10:57 +00:00
|
|
|
|
(byte-catch) ;; Obsolete
|
2019-08-08 15:35:25 +00:00
|
|
|
|
(byte-unwind-protect
|
2019-09-08 14:57:40 +00:00
|
|
|
|
(comp-emit (comp-call 'helper_unwind_protect (comp-slot+1))))
|
2019-08-11 12:10:57 +00:00
|
|
|
|
(byte-condition-case) ;; Obsolete
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-temp-output-buffer-setup-OBSOLETE)
|
|
|
|
|
(byte-temp-output-buffer-show-OBSOLETE)
|
2019-08-11 12:10:57 +00:00
|
|
|
|
(byte-unbind-all) ;; Obsolete
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-set-marker auto)
|
|
|
|
|
(byte-match-beginning auto)
|
|
|
|
|
(byte-match-end auto)
|
|
|
|
|
(byte-upcase auto)
|
|
|
|
|
(byte-downcase auto)
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(byte-string= string-equal)
|
|
|
|
|
(byte-string< string-lessp)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-equal auto)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-nthcdr auto)
|
|
|
|
|
(byte-elt auto)
|
|
|
|
|
(byte-member auto)
|
|
|
|
|
(byte-assq auto)
|
|
|
|
|
(byte-nreverse auto)
|
|
|
|
|
(byte-setcar auto)
|
|
|
|
|
(byte-setcdr auto)
|
2019-07-20 15:35:57 +00:00
|
|
|
|
(byte-car-safe auto)
|
|
|
|
|
(byte-cdr-safe auto)
|
2019-07-20 14:34:37 +00:00
|
|
|
|
(byte-nconc auto)
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(byte-quo /)
|
|
|
|
|
(byte-rem %)
|
2019-07-14 22:58:03 +00:00
|
|
|
|
(byte-numberp auto)
|
|
|
|
|
(byte-integerp auto)
|
2019-07-20 16:50:41 +00:00
|
|
|
|
(byte-listN
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- 1 arg))
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'list arg (comp-sp))))
|
2019-07-14 08:57:46 +00:00
|
|
|
|
(byte-concatN
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- 1 arg))
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'concat arg (comp-sp))))
|
2019-07-20 16:50:41 +00:00
|
|
|
|
(byte-insertN
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- 1 arg))
|
2019-08-19 16:22:26 +00:00
|
|
|
|
(comp-emit-set-call (comp-callref 'insert arg (comp-sp))))
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(byte-stack-set
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(comp-copy-slot (1+ (comp-sp)) (- (comp-sp) arg -1)))
|
2019-09-08 16:48:29 +00:00
|
|
|
|
(byte-stack-set2 (cl-assert nil)) ;; TODO
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(byte-discardN
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- arg)))
|
2019-08-03 15:08:55 +00:00
|
|
|
|
(byte-switch
|
2019-09-16 17:47:49 +00:00
|
|
|
|
;; Assume to follow the emission of a setimm.
|
|
|
|
|
;; This is checked into comp-emit-switch.
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-emit-switch (comp-slot+1)
|
2020-12-25 08:39:22 +00:00
|
|
|
|
(cl-first (comp-block-insns
|
|
|
|
|
(comp-limplify-curr-block comp-pass)))))
|
2019-07-14 07:53:06 +00:00
|
|
|
|
(byte-constant
|
2020-02-29 14:12:21 +00:00
|
|
|
|
(comp-emit-setimm arg))
|
2019-07-20 16:50:41 +00:00
|
|
|
|
(byte-discardN-preserve-tos
|
2019-10-19 16:15:00 +00:00
|
|
|
|
(cl-incf (comp-sp) (- arg))
|
2019-07-20 17:26:30 +00:00
|
|
|
|
(comp-copy-slot (+ arg (comp-sp)))))))
|
2019-07-07 10:30:03 +00:00
|
|
|
|
|
2019-11-02 11:17:26 +00:00
|
|
|
|
(defun comp-emit-narg-prologue (minarg nonrest rest)
|
2019-08-11 14:44:12 +00:00
|
|
|
|
"Emit the prologue for a narg function."
|
2019-08-11 17:03:06 +00:00
|
|
|
|
(cl-loop for i below minarg
|
2019-10-14 20:08:24 +00:00
|
|
|
|
do (comp-emit `(set-args-to-local ,(comp-slot-n i)))
|
|
|
|
|
(comp-emit '(inc-args)))
|
2019-08-11 17:03:06 +00:00
|
|
|
|
(cl-loop for i from minarg below nonrest
|
2019-08-11 14:44:12 +00:00
|
|
|
|
for bb = (intern (format "entry_%s" i))
|
|
|
|
|
for fallback = (intern (format "entry_fallback_%s" i))
|
2020-12-22 08:57:51 +00:00
|
|
|
|
do (comp-emit `(cond-jump-narg-leq ,i ,fallback ,bb))
|
2019-10-14 20:08:24 +00:00
|
|
|
|
(comp-make-curr-block bb (comp-sp))
|
|
|
|
|
(comp-emit `(set-args-to-local ,(comp-slot-n i)))
|
|
|
|
|
(comp-emit '(inc-args))
|
2019-10-27 16:13:03 +00:00
|
|
|
|
finally (comp-emit '(jump entry_rest_args)))
|
2020-12-28 10:22:20 +00:00
|
|
|
|
(when (/= minarg nonrest)
|
2019-10-20 09:10:22 +00:00
|
|
|
|
(cl-loop for i from minarg below nonrest
|
2019-10-27 16:13:03 +00:00
|
|
|
|
for bb = (intern (format "entry_fallback_%s" i))
|
|
|
|
|
for next-bb = (if (= (1+ i) nonrest)
|
|
|
|
|
'entry_rest_args
|
|
|
|
|
(intern (format "entry_fallback_%s" (1+ i))))
|
2019-10-20 09:10:22 +00:00
|
|
|
|
do (comp-with-sp i
|
2019-10-27 16:13:03 +00:00
|
|
|
|
(comp-make-curr-block bb (comp-sp))
|
2020-02-29 14:12:21 +00:00
|
|
|
|
(comp-emit-setimm nil)
|
2019-10-27 16:13:03 +00:00
|
|
|
|
(comp-emit `(jump ,next-bb)))))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-make-curr-block 'entry_rest_args (comp-sp))
|
2019-11-02 11:17:26 +00:00
|
|
|
|
(comp-emit `(set-rest-args-to-local ,(comp-slot-n nonrest)))
|
|
|
|
|
(setf (comp-sp) nonrest)
|
|
|
|
|
(when (and (> nonrest 8) (null rest))
|
|
|
|
|
(cl-decf (comp-sp))))
|
2019-08-11 14:44:12 +00:00
|
|
|
|
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(defun comp-limplify-finalize-function (func)
|
|
|
|
|
"Reverse insns into all basic blocks of FUNC."
|
|
|
|
|
(cl-loop for bb being the hash-value in (comp-func-blocks func)
|
|
|
|
|
do (setf (comp-block-insns bb)
|
|
|
|
|
(nreverse (comp-block-insns bb))))
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(comp-log-func func 2)
|
2019-09-07 14:35:07 +00:00
|
|
|
|
func)
|
|
|
|
|
|
2020-06-30 17:10:19 +00:00
|
|
|
|
(cl-defgeneric comp-prepare-args-for-top-level (function)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given FUNCTION, return the two arguments for comp--register-...")
|
2020-06-30 17:10:19 +00:00
|
|
|
|
|
|
|
|
|
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-l))
|
Various typo fixes in native compiler related files
* lisp/emacs-lisp/comp.el (native-compiler-error-dyn-func)
(comp-func, comp-func-l)
(comp-func-d, comp-ensure-native-compiler, comp-type-hint-p)
(comp-func-unique-in-cu-p, comp-alloc-class-to-container)
(comp-limple-mode, comp-loop-insn-in-block)
(comp-lex-byte-func-p, comp-c-func-name, comp-decrypt-arg-list)
(comp-spill-lap-function, comp-intern-func-in-ctxt)
(comp-spill-lap-function, comp-spill-lap, comp-emit-handler)
(comp-prepare-args-for-top-level): Various typo fixes.
* src/comp.c (Fcomp_el_to_eln_filename): Fix typo in error
message.
2020-10-10 09:06:56 +00:00
|
|
|
|
"Lexically-scoped FUNCTION."
|
2020-06-30 17:10:19 +00:00
|
|
|
|
(let ((args (comp-func-l-args function)))
|
|
|
|
|
(cons (make-comp-mvar :constant (comp-args-base-min args))
|
|
|
|
|
(make-comp-mvar :constant (if (comp-args-p args)
|
|
|
|
|
(comp-args-max args)
|
|
|
|
|
'many)))))
|
|
|
|
|
|
|
|
|
|
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-d))
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Dynamically scoped FUNCTION."
|
2020-06-30 17:10:19 +00:00
|
|
|
|
(cons (make-comp-mvar :constant (func-arity (comp-func-byte-func function)))
|
|
|
|
|
(let ((comp-curr-allocation-class 'd-default))
|
|
|
|
|
;; Lambda-lists must stay in the same relocation class of
|
|
|
|
|
;; the object referenced by code to respect uninterned
|
|
|
|
|
;; symbols.
|
|
|
|
|
(make-comp-mvar :constant (comp-func-d-lambda-list function)))))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(cl-defgeneric comp-emit-for-top-level (form for-late-load)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"Emit the Limple code for top level FORM.")
|
2019-11-03 14:27:57 +00:00
|
|
|
|
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(cl-defmethod comp-emit-for-top-level ((form byte-to-native-func-def)
|
2020-03-23 15:57:48 +00:00
|
|
|
|
for-late-load)
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(let* ((name (byte-to-native-func-def-name form))
|
|
|
|
|
(c-name (byte-to-native-func-def-c-name form))
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(f (gethash c-name (comp-ctxt-funcs-h comp-ctxt)))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(args (comp-prepare-args-for-top-level f)))
|
2019-11-03 14:27:57 +00:00
|
|
|
|
(cl-assert (and name f))
|
2020-10-12 20:11:06 +00:00
|
|
|
|
(comp-emit
|
|
|
|
|
`(set ,(make-comp-mvar :slot 1)
|
|
|
|
|
,(comp-call (if for-late-load
|
|
|
|
|
'comp--late-register-subr
|
|
|
|
|
'comp--register-subr)
|
|
|
|
|
(make-comp-mvar :constant name)
|
2020-12-28 11:59:12 +00:00
|
|
|
|
(make-comp-mvar :constant c-name)
|
2020-10-12 20:11:06 +00:00
|
|
|
|
(car args)
|
|
|
|
|
(cdr args)
|
2020-12-28 12:41:38 +00:00
|
|
|
|
(setf (comp-func-type f)
|
|
|
|
|
(make-comp-mvar :constant nil))
|
2020-10-12 20:11:06 +00:00
|
|
|
|
(make-comp-mvar
|
|
|
|
|
:constant
|
2020-12-28 11:59:12 +00:00
|
|
|
|
(list
|
|
|
|
|
(let* ((h (comp-ctxt-function-docs comp-ctxt))
|
|
|
|
|
(i (hash-table-count h)))
|
|
|
|
|
(puthash i (comp-func-doc f) h)
|
|
|
|
|
i)
|
|
|
|
|
(comp-func-int-spec f)))
|
2020-10-12 20:11:06 +00:00
|
|
|
|
;; This is the compilation unit it-self passed as
|
|
|
|
|
;; parameter.
|
|
|
|
|
(make-comp-mvar :slot 0))))))
|
2019-11-03 14:27:57 +00:00
|
|
|
|
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(cl-defmethod comp-emit-for-top-level ((form byte-to-native-top-level)
|
|
|
|
|
for-late-load)
|
|
|
|
|
(unless for-late-load
|
2020-06-02 10:08:50 +00:00
|
|
|
|
(comp-emit
|
|
|
|
|
(comp-call 'eval
|
|
|
|
|
(let ((comp-curr-allocation-class 'd-impure))
|
|
|
|
|
(make-comp-mvar :constant
|
|
|
|
|
(byte-to-native-top-level-form form)))
|
|
|
|
|
(make-comp-mvar :constant
|
|
|
|
|
(byte-to-native-top-level-lexical form))))))
|
2019-11-03 14:27:57 +00:00
|
|
|
|
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(defun comp-emit-lambda-for-top-level (func)
|
|
|
|
|
"Emit the creation of subrs for lambda FUNC.
|
|
|
|
|
These are stored in the reloc data array."
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(let ((args (comp-prepare-args-for-top-level func)))
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(let ((comp-curr-allocation-class 'd-impure))
|
|
|
|
|
(comp-add-const-to-relocs (comp-func-byte-func func)))
|
|
|
|
|
(comp-emit
|
|
|
|
|
(comp-call 'comp--register-lambda
|
|
|
|
|
;; mvar to be fixed-up when containers are
|
|
|
|
|
;; finalized.
|
|
|
|
|
(or (gethash (comp-func-byte-func func)
|
|
|
|
|
(comp-ctxt-lambda-fixups-h comp-ctxt))
|
|
|
|
|
(puthash (comp-func-byte-func func)
|
|
|
|
|
(make-comp-mvar :constant nil)
|
|
|
|
|
(comp-ctxt-lambda-fixups-h comp-ctxt)))
|
2020-12-28 11:59:12 +00:00
|
|
|
|
(make-comp-mvar :constant (comp-func-c-name func))
|
2020-06-30 17:10:19 +00:00
|
|
|
|
(car args)
|
|
|
|
|
(cdr args)
|
2020-12-28 12:41:38 +00:00
|
|
|
|
(setf (comp-func-type func)
|
|
|
|
|
(make-comp-mvar :constant nil))
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(make-comp-mvar
|
2020-12-28 11:59:12 +00:00
|
|
|
|
:constant
|
|
|
|
|
(list
|
|
|
|
|
(let* ((h (comp-ctxt-function-docs comp-ctxt))
|
|
|
|
|
(i (hash-table-count h)))
|
|
|
|
|
(puthash i (comp-func-doc func) h)
|
|
|
|
|
i)
|
|
|
|
|
(comp-func-int-spec func)))
|
2020-05-02 16:29:11 +00:00
|
|
|
|
;; This is the compilation unit it-self passed as
|
|
|
|
|
;; parameter.
|
|
|
|
|
(make-comp-mvar :slot 0)))))
|
|
|
|
|
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(defun comp-limplify-top-level (for-late-load)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"Create a Limple function to modify the global environment at load.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
When FOR-LATE-LOAD is non-nil, the emitted function modifies only
|
2020-03-17 21:35:11 +00:00
|
|
|
|
function definition.
|
2019-12-22 08:13:46 +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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Synthesize a function called `top_level_run' that gets one single
|
|
|
|
|
parameter (the compilation unit itself). To define native
|
|
|
|
|
functions, `top_level_run' will call back `comp--register-subr'
|
2019-12-22 08:13:46 +00:00
|
|
|
|
into the C code forwarding the compilation unit."
|
2020-02-21 14:28:05 +00:00
|
|
|
|
;; Once an .eln is loaded and Emacs is dumped 'top_level_run' has no
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
;; reasons to be executed ever again. Therefore all objects can be
|
2020-03-09 17:35:07 +00:00
|
|
|
|
;; just ephemeral.
|
|
|
|
|
(let* ((comp-curr-allocation-class 'd-ephemeral)
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(func (make-comp-func-l :name (if for-late-load
|
|
|
|
|
'late-top-level-run
|
|
|
|
|
'top-level-run)
|
|
|
|
|
:c-name (if for-late-load
|
|
|
|
|
"late_top_level_run"
|
|
|
|
|
"top_level_run")
|
|
|
|
|
:args (make-comp-args :min 1 :max 1)
|
2020-10-12 20:11:06 +00:00
|
|
|
|
;; Frame is 2 wide: Slot 0 is the
|
|
|
|
|
;; compilation unit being loaded
|
|
|
|
|
;; (incoming parameter). Slot 1 is
|
|
|
|
|
;; the last function being
|
|
|
|
|
;; registered.
|
|
|
|
|
:frame-size 2
|
2020-11-06 23:13:01 +00:00
|
|
|
|
:speed (comp-ctxt-speed comp-ctxt)))
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(comp-func func)
|
|
|
|
|
(comp-pass (make-comp-limplify
|
2020-06-11 20:53:31 +00:00
|
|
|
|
:curr-block (make--comp-block-lap -1 0 'top-level)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
:frame (comp-new-frame 1 0))))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-make-curr-block 'entry (comp-sp))
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(comp-emit-annotation (if for-late-load
|
|
|
|
|
"Late top level"
|
|
|
|
|
"Top level"))
|
2019-12-22 08:13:46 +00:00
|
|
|
|
;; Assign the compilation unit incoming as parameter to the slot frame 0.
|
|
|
|
|
(comp-emit `(set-par-to-local ,(comp-slot-n 0) 0))
|
2020-05-01 16:32:39 +00:00
|
|
|
|
(maphash (lambda (_ func)
|
|
|
|
|
(comp-emit-lambda-for-top-level func))
|
|
|
|
|
(comp-ctxt-byte-func-to-func-h comp-ctxt))
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(mapc (lambda (x) (comp-emit-for-top-level x for-late-load))
|
|
|
|
|
(comp-ctxt-top-level-forms comp-ctxt))
|
2020-10-12 20:11:06 +00:00
|
|
|
|
(comp-emit `(return ,(make-comp-mvar :slot 1)))
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(comp-limplify-finalize-function func)))
|
|
|
|
|
|
2019-10-13 16:58:46 +00:00
|
|
|
|
(defun comp-addr-to-bb-name (addr)
|
|
|
|
|
"Search for a block starting at ADDR into pending or limplified blocks."
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; FIXME Actually we could have another hash for this.
|
2019-10-13 16:58:46 +00:00
|
|
|
|
(cl-flet ((pred (bb)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(equal (comp-block-lap-addr bb) addr)))
|
2019-10-13 16:58:46 +00:00
|
|
|
|
(if-let ((pending (cl-find-if #'pred
|
|
|
|
|
(comp-limplify-pending-blocks comp-pass))))
|
|
|
|
|
(comp-block-name pending)
|
|
|
|
|
(cl-loop for bb being the hash-value in (comp-func-blocks comp-func)
|
|
|
|
|
when (pred bb)
|
2019-11-02 13:34:31 +00:00
|
|
|
|
return (comp-block-name bb)))))
|
2019-10-13 16:58:46 +00:00
|
|
|
|
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(defun comp-limplify-block (bb)
|
|
|
|
|
"Limplify basic-block BB and add it to the current function."
|
2019-11-22 18:20:05 +00:00
|
|
|
|
(setf (comp-limplify-curr-block comp-pass) bb
|
2020-06-11 20:53:31 +00:00
|
|
|
|
(comp-limplify-sp comp-pass) (comp-block-lap-sp bb)
|
|
|
|
|
(comp-limplify-pc comp-pass) (comp-block-lap-addr bb))
|
2019-10-19 14:31:02 +00:00
|
|
|
|
(puthash (comp-block-name bb) bb (comp-func-blocks comp-func))
|
|
|
|
|
(cl-loop
|
2019-10-27 15:57:29 +00:00
|
|
|
|
for inst-cell on (nthcdr (comp-limplify-pc comp-pass)
|
2019-10-19 14:31:02 +00:00
|
|
|
|
(comp-func-lap comp-func))
|
2019-10-27 15:57:29 +00:00
|
|
|
|
for inst = (car inst-cell)
|
|
|
|
|
for next-inst = (car-safe (cdr inst-cell))
|
2019-10-19 14:31:02 +00:00
|
|
|
|
do (comp-limplify-lap-inst inst)
|
|
|
|
|
(cl-incf (comp-limplify-pc comp-pass))
|
2019-10-27 15:57:29 +00:00
|
|
|
|
when (comp-lap-fall-through-p inst)
|
|
|
|
|
do (pcase next-inst
|
|
|
|
|
(`(TAG ,_label . ,label-sp)
|
|
|
|
|
(when label-sp
|
|
|
|
|
(cl-assert (= (1- label-sp) (comp-sp))))
|
|
|
|
|
(let* ((stack-depth (if label-sp
|
|
|
|
|
(1- label-sp)
|
|
|
|
|
(comp-sp)))
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(next-bb (comp-block-name (comp-bb-maybe-add
|
|
|
|
|
(comp-limplify-pc comp-pass)
|
|
|
|
|
stack-depth))))
|
2019-10-27 15:57:29 +00:00
|
|
|
|
(unless (comp-block-closed bb)
|
|
|
|
|
(comp-emit `(jump ,next-bb))))
|
|
|
|
|
(cl-return)))
|
2019-10-19 14:31:02 +00:00
|
|
|
|
until (comp-lap-eob-p inst)))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(defun comp-limplify-function (func)
|
|
|
|
|
"Limplify a single function FUNC."
|
|
|
|
|
(let* ((frame-size (comp-func-frame-size func))
|
|
|
|
|
(comp-func func)
|
|
|
|
|
(comp-pass (make-comp-limplify
|
2021-02-23 13:35:11 +00:00
|
|
|
|
:frame (comp-new-frame frame-size 0))))
|
2019-10-13 15:41:26 +00:00
|
|
|
|
(comp-fill-label-h)
|
2019-09-07 14:35:07 +00:00
|
|
|
|
;; Prologue
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-make-curr-block 'entry (comp-sp))
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(comp-emit-annotation (concat "Lisp function: "
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(symbol-name (comp-func-name func))))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
;; Dynamic functions have parameters bound by the trampoline.
|
|
|
|
|
(when (comp-func-l-p func)
|
|
|
|
|
(let ((args (comp-func-l-args func)))
|
|
|
|
|
(if (comp-args-p args)
|
|
|
|
|
(cl-loop for i below (comp-args-max args)
|
|
|
|
|
do (cl-incf (comp-sp))
|
|
|
|
|
(comp-emit `(set-par-to-local ,(comp-slot) ,i)))
|
|
|
|
|
(comp-emit-narg-prologue (comp-args-base-min args)
|
|
|
|
|
(comp-nargs-nonrest args)
|
|
|
|
|
(comp-nargs-rest args)))))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(comp-emit '(jump bb_0))
|
2019-09-07 14:35:07 +00:00
|
|
|
|
;; Body
|
2019-11-01 14:28:17 +00:00
|
|
|
|
(comp-bb-maybe-add 0 (comp-sp))
|
2019-10-13 08:36:22 +00:00
|
|
|
|
(cl-loop for next-bb = (pop (comp-limplify-pending-blocks comp-pass))
|
|
|
|
|
while next-bb
|
|
|
|
|
do (comp-limplify-block next-bb))
|
2019-10-27 17:14:33 +00:00
|
|
|
|
;; Sanity check against block duplication.
|
|
|
|
|
(cl-loop with addr-h = (make-hash-table)
|
|
|
|
|
for bb being the hash-value in (comp-func-blocks func)
|
2020-06-11 20:53:31 +00:00
|
|
|
|
for addr = (when (comp-block-lap-p bb)
|
|
|
|
|
(comp-block-lap-addr bb))
|
2019-11-01 14:28:17 +00:00
|
|
|
|
when addr
|
|
|
|
|
do (cl-assert (null (gethash addr addr-h)))
|
|
|
|
|
(puthash addr t addr-h))
|
2019-09-07 14:35:07 +00:00
|
|
|
|
(comp-limplify-finalize-function func)))
|
|
|
|
|
|
2020-03-28 20:56:47 +00:00
|
|
|
|
(defun comp-limplify (_)
|
|
|
|
|
"Compute LIMPLE IR for forms in `comp-ctxt'."
|
|
|
|
|
(maphash (lambda (_ f) (comp-limplify-function f))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt))
|
2020-03-17 21:35:11 +00:00
|
|
|
|
(comp-add-func-to-ctxt (comp-limplify-top-level nil))
|
2020-03-17 22:24:52 +00:00
|
|
|
|
(when (comp-ctxt-with-late-load comp-ctxt)
|
|
|
|
|
(comp-add-func-to-ctxt (comp-limplify-top-level t))))
|
2019-07-07 07:23:10 +00:00
|
|
|
|
|
2020-10-27 19:40:55 +00:00
|
|
|
|
|
2020-12-15 22:53:29 +00:00
|
|
|
|
;;; add-cstrs pass specific code.
|
|
|
|
|
|
|
|
|
|
;; This pass is responsible for adding constraints, these are
|
|
|
|
|
;; generated from:
|
|
|
|
|
;;
|
|
|
|
|
;; - Conditional branches: each branch taken or non taken can be used
|
2020-12-25 09:57:02 +00:00
|
|
|
|
;; in the CFG to infer information on the tested variables.
|
|
|
|
|
;;
|
|
|
|
|
;; - Range propagation under test and branch (when the test is an
|
2020-12-29 12:29:02 +00:00
|
|
|
|
;; arithmetic comparison).
|
|
|
|
|
;;
|
|
|
|
|
;; - Type constraint under test and branch (when the test is a
|
|
|
|
|
;; known predicate).
|
2020-12-15 22:53:29 +00:00
|
|
|
|
;;
|
|
|
|
|
;; - Function calls: function calls to function assumed to be not
|
|
|
|
|
;; redefinable can be used to add constrains on the function
|
|
|
|
|
;; arguments. Ex: if we execute successfully (= x y) we know that
|
|
|
|
|
;; afterwards both x and y must satisfy the (or number marker)
|
|
|
|
|
;; type specifier.
|
2020-10-27 19:40:55 +00:00
|
|
|
|
|
2020-12-24 08:14:28 +00:00
|
|
|
|
|
|
|
|
|
(defsubst comp-mvar-used-p (mvar)
|
2021-04-27 05:18:14 +00:00
|
|
|
|
"Non-nil when MVAR is used as lhs in the current function."
|
2020-12-24 08:14:28 +00:00
|
|
|
|
(declare (gv-setter (lambda (val)
|
|
|
|
|
`(puthash ,mvar ,val comp-pass))))
|
|
|
|
|
(gethash mvar comp-pass))
|
|
|
|
|
|
|
|
|
|
(defun comp-collect-mvars (form)
|
|
|
|
|
"Add rhs m-var present in FORM into `comp-pass'."
|
|
|
|
|
(cl-loop for x in form
|
|
|
|
|
if (consp x)
|
|
|
|
|
do (comp-collect-mvars x)
|
|
|
|
|
else
|
|
|
|
|
when (comp-mvar-p x)
|
|
|
|
|
do (setf (comp-mvar-used-p x) t)))
|
|
|
|
|
|
|
|
|
|
(defun comp-collect-rhs ()
|
|
|
|
|
"Collect all lhs mvars into `comp-pass'."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for insn in (comp-block-insns b)
|
|
|
|
|
for (op . args) = insn
|
2020-12-25 09:57:02 +00:00
|
|
|
|
if (comp-assign-op-p op)
|
2020-12-24 08:14:28 +00:00
|
|
|
|
do (comp-collect-mvars (cdr args))
|
|
|
|
|
else
|
|
|
|
|
do (comp-collect-mvars args))))
|
|
|
|
|
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(defun comp-negate-arithm-cmp-fun (function)
|
|
|
|
|
"Negate FUNCTION.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
Return nil if we don't want to emit constraints for its negation."
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(cl-ecase function
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(= nil)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(> '<=)
|
|
|
|
|
(< '>=)
|
|
|
|
|
(>= '<)
|
|
|
|
|
(<= '>)))
|
|
|
|
|
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(defun comp-reverse-arithm-fun (function)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
"Reverse FUNCTION."
|
|
|
|
|
(cl-case function
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(= '=)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(> '<)
|
|
|
|
|
(< '>)
|
|
|
|
|
(>= '<=)
|
|
|
|
|
(<= '>=)
|
|
|
|
|
(t function)))
|
|
|
|
|
|
|
|
|
|
(defun comp-emit-assume (kind lhs rhs bb negated)
|
|
|
|
|
"Emit an assume of kind KIND for mvar LHS being RHS.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
When NEGATED is non-nil, the assumption is negated.
|
2020-12-12 21:20:28 +00:00
|
|
|
|
The assume is emitted at the beginning of the block BB."
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(let ((lhs-slot (comp-mvar-slot lhs)))
|
2020-12-22 14:00:44 +00:00
|
|
|
|
(cl-assert lhs-slot)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(pcase kind
|
2021-03-01 18:39:00 +00:00
|
|
|
|
((or 'and 'and-nhc)
|
2020-12-29 12:29:02 +00:00
|
|
|
|
(if (comp-mvar-p rhs)
|
|
|
|
|
(let ((tmp-mvar (if negated
|
|
|
|
|
(make-comp-mvar :slot (comp-mvar-slot rhs))
|
|
|
|
|
rhs)))
|
|
|
|
|
(push `(assume ,(make-comp-mvar :slot lhs-slot)
|
2021-03-01 18:39:00 +00:00
|
|
|
|
(,kind ,lhs ,tmp-mvar))
|
2020-12-29 12:29:02 +00:00
|
|
|
|
(comp-block-insns bb))
|
|
|
|
|
(if negated
|
|
|
|
|
(push `(assume ,tmp-mvar (not ,rhs))
|
|
|
|
|
(comp-block-insns bb))))
|
|
|
|
|
;; If is only a constraint we can negate it directly.
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(push `(assume ,(make-comp-mvar :slot lhs-slot)
|
2021-03-01 18:39:00 +00:00
|
|
|
|
(,kind ,lhs ,(if negated
|
2020-12-29 12:29:02 +00:00
|
|
|
|
(comp-cstr-negation-make rhs)
|
|
|
|
|
rhs)))
|
|
|
|
|
(comp-block-insns bb))))
|
2021-02-27 21:00:11 +00:00
|
|
|
|
((pred comp-arithm-cmp-fun-p)
|
|
|
|
|
(when-let ((kind (if negated
|
|
|
|
|
(comp-negate-arithm-cmp-fun kind)
|
|
|
|
|
kind)))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(push `(assume ,(make-comp-mvar :slot lhs-slot)
|
|
|
|
|
(,kind ,lhs
|
2021-02-27 20:26:41 +00:00
|
|
|
|
,(if-let* ((vld (comp-cstr-imm-vld-p rhs))
|
|
|
|
|
(val (comp-cstr-imm rhs))
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(ok (and (integerp val)
|
|
|
|
|
(not (memq kind '(= !=))))))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
val
|
|
|
|
|
(make-comp-mvar :slot (comp-mvar-slot rhs)))))
|
|
|
|
|
(comp-block-insns bb))))
|
|
|
|
|
(_ (cl-assert nil)))
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(setf (comp-func-ssa-status comp-func) 'dirty)))
|
|
|
|
|
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(defun comp-maybe-add-vmvar (op cmp-res insns-seq)
|
2021-02-25 19:25:05 +00:00
|
|
|
|
"If CMP-RES is clobbering OP emit a new constrained mvar and return it.
|
2021-02-23 13:35:11 +00:00
|
|
|
|
Return OP otherwise."
|
|
|
|
|
(if-let ((match (eql (comp-mvar-slot op) (comp-mvar-slot cmp-res)))
|
|
|
|
|
(new-mvar (make-comp-mvar
|
|
|
|
|
:slot
|
|
|
|
|
(- (cl-incf (comp-func-vframe-size comp-func))))))
|
|
|
|
|
(progn
|
|
|
|
|
(push `(assume ,new-mvar ,op) (cdr insns-seq))
|
|
|
|
|
new-mvar)
|
|
|
|
|
op))
|
|
|
|
|
|
2020-12-22 14:00:44 +00:00
|
|
|
|
(defun comp-add-new-block-between (bb-symbol bb-a bb-b)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
"Create a new basic-block named BB-SYMBOL and add it between BB-A and BB-B."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with new-bb = (make-comp-block-cstr :name bb-symbol
|
|
|
|
|
:insns `((jump ,(comp-block-name bb-b))))
|
|
|
|
|
with new-edge = (make-comp-edge :src bb-a :dst new-bb)
|
|
|
|
|
for ed in (comp-block-in-edges bb-b)
|
|
|
|
|
when (eq (comp-edge-src ed) bb-a)
|
|
|
|
|
do
|
|
|
|
|
;; Connect `ed' to `new-bb' and disconnect it from `bb-a'.
|
|
|
|
|
(cl-assert (memq ed (comp-block-out-edges bb-a)))
|
|
|
|
|
(setf (comp-edge-src ed) new-bb
|
|
|
|
|
(comp-block-out-edges bb-a) (delq ed (comp-block-out-edges bb-a)))
|
|
|
|
|
(push ed (comp-block-out-edges new-bb))
|
|
|
|
|
;; Connect `bb-a' `new-bb' with `new-edge'.
|
2020-12-22 14:00:44 +00:00
|
|
|
|
(push new-edge (comp-block-out-edges bb-a))
|
|
|
|
|
(push new-edge (comp-block-in-edges new-bb))
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(setf (comp-func-ssa-status comp-func) 'dirty)
|
|
|
|
|
;; Add `new-edge' to the current function and return it.
|
|
|
|
|
(cl-return (puthash bb-symbol new-bb (comp-func-blocks comp-func)))
|
|
|
|
|
finally (cl-assert nil)))
|
|
|
|
|
|
2020-12-15 22:53:29 +00:00
|
|
|
|
;; Cheap substitute to a copy propagation pass...
|
|
|
|
|
(defun comp-cond-cstrs-target-mvar (mvar exit-insn bb)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given MVAR, search in BB the original mvar MVAR got assigned from.
|
2020-12-15 22:53:29 +00:00
|
|
|
|
Keep on searching till EXIT-INSN is encountered."
|
2020-12-15 15:57:23 +00:00
|
|
|
|
(cl-flet ((targetp (x)
|
|
|
|
|
;; Ret t if x is an mvar and target the correct slot number.
|
|
|
|
|
(and (comp-mvar-p x)
|
|
|
|
|
(eql (comp-mvar-slot mvar) (comp-mvar-slot x)))))
|
|
|
|
|
(cl-loop
|
|
|
|
|
with res = nil
|
|
|
|
|
for insn in (comp-block-insns bb)
|
|
|
|
|
when (eq insn exit-insn)
|
|
|
|
|
do (cl-return (and (comp-mvar-p res) res))
|
|
|
|
|
do (pcase insn
|
|
|
|
|
(`(,(pred comp-assign-op-p) ,(pred targetp) ,rhs)
|
|
|
|
|
(setf res rhs)))
|
|
|
|
|
finally (cl-assert nil))))
|
|
|
|
|
|
|
|
|
|
(defun comp-add-cond-cstrs-target-block (curr-bb target-bb-sym)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
"Return the appropriate basic block to add constraint assumptions into.
|
|
|
|
|
CURR-BB is the current basic block.
|
|
|
|
|
TARGET-BB-SYM is the symbol name of the target block."
|
2020-12-22 21:53:05 +00:00
|
|
|
|
(let* ((target-bb (gethash target-bb-sym
|
|
|
|
|
(comp-func-blocks comp-func)))
|
|
|
|
|
(target-bb-in-edges (comp-block-in-edges target-bb)))
|
|
|
|
|
(cl-assert target-bb-in-edges)
|
2021-03-07 20:26:55 +00:00
|
|
|
|
(if (length= target-bb-in-edges 1)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
;; If block has only one predecessor is already suitable for
|
|
|
|
|
;; adding constraint assumptions.
|
|
|
|
|
target-bb
|
2020-12-22 21:53:05 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
;; Search for the first suitable basic block name.
|
|
|
|
|
for i from 0
|
|
|
|
|
for new-name = (intern (format "%s_cstrs_%d" (symbol-name target-bb-sym)
|
|
|
|
|
i))
|
|
|
|
|
until (null (gethash new-name (comp-func-blocks comp-func)))
|
|
|
|
|
finally
|
|
|
|
|
;; Add it.
|
|
|
|
|
(cl-return (comp-add-new-block-between new-name curr-bb target-bb))))))
|
2020-12-12 21:20:28 +00:00
|
|
|
|
|
2020-12-22 09:29:48 +00:00
|
|
|
|
(defun comp-add-cond-cstrs-simple ()
|
|
|
|
|
"`comp-add-cstrs' worker function for each selected function."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do
|
|
|
|
|
(cl-loop
|
|
|
|
|
named in-the-basic-block
|
|
|
|
|
for insn-seq on (comp-block-insns b)
|
|
|
|
|
do
|
|
|
|
|
(pcase insn-seq
|
2021-03-06 19:51:11 +00:00
|
|
|
|
(`((set ,(and (pred comp-mvar-p) tmp-mvar) ,(pred comp-mvar-p))
|
2020-12-25 08:39:22 +00:00
|
|
|
|
;; (comment ,_comment-str)
|
2020-12-22 09:29:48 +00:00
|
|
|
|
(cond-jump ,tmp-mvar ,obj2 . ,blocks))
|
|
|
|
|
(cl-loop
|
|
|
|
|
for branch-target-cell on blocks
|
|
|
|
|
for branch-target = (car branch-target-cell)
|
|
|
|
|
for negated in '(nil t)
|
2020-12-24 08:14:28 +00:00
|
|
|
|
when (comp-mvar-used-p tmp-mvar)
|
2020-12-22 09:29:48 +00:00
|
|
|
|
do
|
2020-12-24 08:14:28 +00:00
|
|
|
|
(let ((block-target (comp-add-cond-cstrs-target-block b branch-target)))
|
|
|
|
|
(setf (car branch-target-cell) (comp-block-name block-target))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(comp-emit-assume 'and tmp-mvar obj2 block-target negated))
|
2020-12-22 14:00:44 +00:00
|
|
|
|
finally (cl-return-from in-the-basic-block)))
|
|
|
|
|
(`((cond-jump ,obj1 ,obj2 . ,blocks))
|
|
|
|
|
(cl-loop
|
|
|
|
|
for branch-target-cell on blocks
|
|
|
|
|
for branch-target = (car branch-target-cell)
|
|
|
|
|
for negated in '(nil t)
|
2020-12-24 08:14:28 +00:00
|
|
|
|
when (comp-mvar-used-p obj1)
|
2020-12-22 14:00:44 +00:00
|
|
|
|
do
|
2020-12-24 08:14:28 +00:00
|
|
|
|
(let ((block-target (comp-add-cond-cstrs-target-block b branch-target)))
|
|
|
|
|
(setf (car branch-target-cell) (comp-block-name block-target))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(comp-emit-assume 'and obj1 obj2 block-target negated))
|
2020-12-22 09:29:48 +00:00
|
|
|
|
finally (cl-return-from in-the-basic-block)))))))
|
|
|
|
|
|
2020-12-15 15:57:23 +00:00
|
|
|
|
(defun comp-add-cond-cstrs ()
|
|
|
|
|
"`comp-add-cstrs' worker function for each selected function."
|
2020-10-27 19:40:55 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
do
|
|
|
|
|
(cl-loop
|
|
|
|
|
named in-the-basic-block
|
2021-02-23 13:35:11 +00:00
|
|
|
|
with prev-insns-seq
|
2020-12-12 21:20:28 +00:00
|
|
|
|
for insns-seq on (comp-block-insns b)
|
|
|
|
|
do
|
|
|
|
|
(pcase insns-seq
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(`((set ,(and (pred comp-mvar-p) cmp-res)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(,(pred comp-call-op-p)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
,(and (or (pred comp-equality-fun-p)
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(pred comp-arithm-cmp-fun-p))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
fun)
|
|
|
|
|
,op1 ,op2))
|
2020-12-25 08:39:22 +00:00
|
|
|
|
;; (comment ,_comment-str)
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(cond-jump ,cmp-res ,(pred comp-mvar-p) . ,blocks))
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(cl-loop
|
2020-12-15 22:53:29 +00:00
|
|
|
|
with target-mvar1 = (comp-cond-cstrs-target-mvar op1 (car insns-seq) b)
|
|
|
|
|
with target-mvar2 = (comp-cond-cstrs-target-mvar op2 (car insns-seq) b)
|
2020-12-13 11:19:30 +00:00
|
|
|
|
for branch-target-cell on blocks
|
|
|
|
|
for branch-target = (car branch-target-cell)
|
2020-12-22 08:57:51 +00:00
|
|
|
|
for negated in '(t nil)
|
2021-03-01 18:39:00 +00:00
|
|
|
|
for kind = (cl-case fun
|
|
|
|
|
(equal 'and-nhc)
|
|
|
|
|
(eql 'and-nhc)
|
|
|
|
|
(eq 'and)
|
|
|
|
|
(t fun))
|
2020-12-24 08:14:28 +00:00
|
|
|
|
when (or (comp-mvar-used-p target-mvar1)
|
|
|
|
|
(comp-mvar-used-p target-mvar2))
|
|
|
|
|
do
|
|
|
|
|
(let ((block-target (comp-add-cond-cstrs-target-block b branch-target)))
|
|
|
|
|
(setf (car branch-target-cell) (comp-block-name block-target))
|
|
|
|
|
(when (comp-mvar-used-p target-mvar1)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(comp-emit-assume kind target-mvar1
|
|
|
|
|
(comp-maybe-add-vmvar op2 cmp-res prev-insns-seq)
|
|
|
|
|
block-target negated))
|
2020-12-24 08:14:28 +00:00
|
|
|
|
(when (comp-mvar-used-p target-mvar2)
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(comp-emit-assume (comp-reverse-arithm-fun kind)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
target-mvar2
|
|
|
|
|
(comp-maybe-add-vmvar op1 cmp-res prev-insns-seq)
|
|
|
|
|
block-target negated)))
|
2020-12-29 12:29:02 +00:00
|
|
|
|
finally (cl-return-from in-the-basic-block)))
|
|
|
|
|
(`((set ,(and (pred comp-mvar-p) cmp-res)
|
|
|
|
|
(,(pred comp-call-op-p)
|
|
|
|
|
,(and (pred comp-known-predicate-p) fun)
|
|
|
|
|
,op))
|
|
|
|
|
;; (comment ,_comment-str)
|
|
|
|
|
(cond-jump ,cmp-res ,(pred comp-mvar-p) . ,blocks))
|
|
|
|
|
(cl-loop
|
|
|
|
|
with target-mvar = (comp-cond-cstrs-target-mvar op (car insns-seq) b)
|
|
|
|
|
with cstr = (comp-pred-to-cstr fun)
|
|
|
|
|
for branch-target-cell on blocks
|
|
|
|
|
for branch-target = (car branch-target-cell)
|
|
|
|
|
for negated in '(t nil)
|
|
|
|
|
when (comp-mvar-used-p target-mvar)
|
|
|
|
|
do
|
|
|
|
|
(let ((block-target (comp-add-cond-cstrs-target-block b branch-target)))
|
|
|
|
|
(setf (car branch-target-cell) (comp-block-name block-target))
|
|
|
|
|
(comp-emit-assume 'and target-mvar cstr block-target negated))
|
|
|
|
|
finally (cl-return-from in-the-basic-block)))
|
|
|
|
|
;; Match predicate on the negated branch (unless).
|
|
|
|
|
(`((set ,(and (pred comp-mvar-p) cmp-res)
|
|
|
|
|
(,(pred comp-call-op-p)
|
|
|
|
|
,(and (pred comp-known-predicate-p) fun)
|
|
|
|
|
,op))
|
|
|
|
|
(set ,neg-cmp-res (call eq ,cmp-res ,(pred comp-cstr-null-p)))
|
|
|
|
|
(cond-jump ,neg-cmp-res ,(pred comp-mvar-p) . ,blocks))
|
|
|
|
|
(cl-loop
|
|
|
|
|
with target-mvar = (comp-cond-cstrs-target-mvar op (car insns-seq) b)
|
|
|
|
|
with cstr = (comp-pred-to-cstr fun)
|
|
|
|
|
for branch-target-cell on blocks
|
|
|
|
|
for branch-target = (car branch-target-cell)
|
|
|
|
|
for negated in '(nil t)
|
|
|
|
|
when (comp-mvar-used-p target-mvar)
|
|
|
|
|
do
|
|
|
|
|
(let ((block-target (comp-add-cond-cstrs-target-block b branch-target)))
|
|
|
|
|
(setf (car branch-target-cell) (comp-block-name block-target))
|
|
|
|
|
(comp-emit-assume 'and target-mvar cstr block-target negated))
|
2021-02-23 13:35:11 +00:00
|
|
|
|
finally (cl-return-from in-the-basic-block))))
|
|
|
|
|
(setf prev-insns-seq insns-seq))))
|
2020-10-27 19:40:55 +00:00
|
|
|
|
|
2020-12-31 10:27:53 +00:00
|
|
|
|
(defsubst comp-insert-insn (insn insn-cell)
|
|
|
|
|
"Insert INSN as second insn of INSN-CELL."
|
|
|
|
|
(let ((next-cell (cdr insn-cell))
|
|
|
|
|
(new-cell `(,insn)))
|
|
|
|
|
(setf (cdr insn-cell) new-cell
|
|
|
|
|
(cdr new-cell) next-cell
|
|
|
|
|
(comp-func-ssa-status comp-func) 'dirty)))
|
|
|
|
|
|
2020-12-15 22:53:29 +00:00
|
|
|
|
(defun comp-emit-call-cstr (mvar call-cell cstr)
|
|
|
|
|
"Emit a constraint CSTR for MVAR after CALL-CELL."
|
2020-12-31 10:27:53 +00:00
|
|
|
|
(let* ((new-mvar (make-comp-mvar :slot (comp-mvar-slot mvar)))
|
2020-12-17 16:31:22 +00:00
|
|
|
|
;; Have new-mvar as LHS *and* RHS to ensure monotonicity and
|
|
|
|
|
;; fwprop convergence!!
|
2020-12-31 10:27:53 +00:00
|
|
|
|
(insn `(assume ,new-mvar (and ,new-mvar ,mvar ,cstr))))
|
|
|
|
|
(comp-insert-insn insn call-cell)))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-lambda-list-gen (lambda-list)
|
|
|
|
|
"Return a generator to iterate over LAMBDA-LIST."
|
|
|
|
|
(lambda ()
|
|
|
|
|
(cl-case (car lambda-list)
|
|
|
|
|
(&optional
|
|
|
|
|
(setf lambda-list (cdr lambda-list))
|
|
|
|
|
(prog1
|
|
|
|
|
(car lambda-list)
|
|
|
|
|
(setf lambda-list (cdr lambda-list))))
|
|
|
|
|
(&rest
|
|
|
|
|
(cadr lambda-list))
|
|
|
|
|
(t
|
|
|
|
|
(prog1
|
|
|
|
|
(car lambda-list)
|
|
|
|
|
(setf lambda-list (cdr lambda-list)))))))
|
|
|
|
|
|
|
|
|
|
(defun comp-add-call-cstr ()
|
|
|
|
|
"Add args assumptions for each function of which the type specifier is known."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for bb being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do
|
|
|
|
|
(comp-loop-insn-in-block bb
|
|
|
|
|
(when-let ((match
|
|
|
|
|
(pcase insn
|
|
|
|
|
(`(set ,lhs (,(pred comp-call-op-p) ,f . ,args))
|
|
|
|
|
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
|
2020-12-19 10:56:15 +00:00
|
|
|
|
(cl-values f cstr-f lhs args)))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
(`(,(pred comp-call-op-p) ,f . ,args)
|
|
|
|
|
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
|
2020-12-19 10:56:15 +00:00
|
|
|
|
(cl-values f cstr-f nil args))))))
|
|
|
|
|
(cl-multiple-value-bind (f cstr-f lhs args) match
|
2020-12-15 22:53:29 +00:00
|
|
|
|
(cl-loop
|
2020-12-19 10:56:15 +00:00
|
|
|
|
with gen = (comp-lambda-list-gen (comp-cstr-f-args cstr-f))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
for arg in args
|
|
|
|
|
for cstr = (funcall gen)
|
|
|
|
|
for target = (comp-cond-cstrs-target-mvar arg insn bb)
|
2020-12-19 10:56:15 +00:00
|
|
|
|
unless (comp-cstr-p cstr)
|
|
|
|
|
do (signal 'native-ice
|
|
|
|
|
(list "Incoherent type specifier for function" f))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
when (and target
|
2021-01-18 21:37:52 +00:00
|
|
|
|
;; No need to add call constraints if this is t
|
|
|
|
|
;; (bug#45812 bug#45705 bug#45751).
|
|
|
|
|
(not (equal comp-cstr-t cstr))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
(or (null lhs)
|
|
|
|
|
(not (eql (comp-mvar-slot lhs)
|
|
|
|
|
(comp-mvar-slot target)))))
|
2020-12-19 10:56:15 +00:00
|
|
|
|
do (comp-emit-call-cstr target insn-cell cstr)))))))
|
2020-12-15 22:53:29 +00:00
|
|
|
|
|
2020-12-15 15:57:23 +00:00
|
|
|
|
(defun comp-add-cstrs (_)
|
2020-10-27 19:40:55 +00:00
|
|
|
|
"Rewrite conditional branches adding appropriate 'assume' insns.
|
|
|
|
|
This is introducing and placing 'assume' insns in use by fwprop
|
2020-11-20 19:34:32 +00:00
|
|
|
|
to propagate conditional branch test information on target basic
|
2020-10-27 19:40:55 +00:00
|
|
|
|
blocks."
|
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (and (>= (comp-func-speed f) 1)
|
|
|
|
|
;; No point to run this on dynamic scope as
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; this pass is effective only on local
|
2020-10-27 19:40:55 +00:00
|
|
|
|
;; variables.
|
|
|
|
|
(comp-func-l-p f)
|
|
|
|
|
(not (comp-func-has-non-local f)))
|
2020-12-24 08:14:28 +00:00
|
|
|
|
(let ((comp-func f)
|
|
|
|
|
(comp-pass (make-hash-table :test #'eq)))
|
|
|
|
|
(comp-collect-rhs)
|
|
|
|
|
(comp-add-cond-cstrs-simple)
|
2020-12-15 15:57:23 +00:00
|
|
|
|
(comp-add-cond-cstrs)
|
2020-12-15 22:53:29 +00:00
|
|
|
|
(comp-add-call-cstr)
|
2020-10-27 19:40:55 +00:00
|
|
|
|
(comp-log-func comp-func 3))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
|
|
|
|
|
2020-07-05 19:26:36 +00:00
|
|
|
|
|
|
|
|
|
;;; pure-func pass specific code.
|
|
|
|
|
|
|
|
|
|
;; Simple IPA pass to infer function purity of functions not
|
|
|
|
|
;; explicitly declared as such. This is effective only at speed 3 to
|
|
|
|
|
;; avoid optimizing-out functions and preventing their redefinition
|
|
|
|
|
;; being effective.
|
|
|
|
|
|
|
|
|
|
(defun comp-collect-calls (f)
|
|
|
|
|
"Return a list with all the functions called by F."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with h = (make-hash-table :test #'eq)
|
|
|
|
|
for b being each hash-value of (comp-func-blocks f)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for insn in (comp-block-insns b)
|
|
|
|
|
do (pcase insn
|
|
|
|
|
(`(set ,_lval (,(pred comp-call-op-p) ,f . ,_rest))
|
|
|
|
|
(puthash f t h))
|
|
|
|
|
(`(,(pred comp-call-op-p) ,f . ,_rest)
|
|
|
|
|
(puthash f t h))))
|
|
|
|
|
finally return (cl-loop
|
|
|
|
|
for f being each hash-key of h
|
|
|
|
|
collect (if (stringp f)
|
|
|
|
|
(comp-func-name
|
|
|
|
|
(gethash f
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
|
|
|
|
f))))
|
|
|
|
|
|
|
|
|
|
(defun comp-pure-infer-func (f)
|
2020-11-20 19:34:32 +00:00
|
|
|
|
"If all functions called by F are pure then F is pure too."
|
2020-07-05 19:26:36 +00:00
|
|
|
|
(when (and (cl-every (lambda (x)
|
|
|
|
|
(or (comp-function-pure-p x)
|
|
|
|
|
(eq x (comp-func-name f))))
|
|
|
|
|
(comp-collect-calls f))
|
|
|
|
|
(not (eq (comp-func-pure f) t)))
|
|
|
|
|
(comp-log (format "%s inferred to be pure" (comp-func-name f)))
|
|
|
|
|
(setf (comp-func-pure f) t)))
|
|
|
|
|
|
|
|
|
|
(defun comp-ipa-pure (_)
|
|
|
|
|
"Infer function purity."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with pure-n = 0
|
|
|
|
|
for n from 1
|
|
|
|
|
while
|
|
|
|
|
(/= pure-n
|
|
|
|
|
(setf pure-n
|
|
|
|
|
(cl-loop
|
|
|
|
|
for f being each hash-value of (comp-ctxt-funcs-h comp-ctxt)
|
|
|
|
|
when (and (>= (comp-func-speed f) 3)
|
|
|
|
|
(comp-func-l-p f)
|
|
|
|
|
(not (comp-func-pure f)))
|
|
|
|
|
do (comp-pure-infer-func f)
|
|
|
|
|
count (comp-func-pure f))))
|
|
|
|
|
finally (comp-log (format "ipa-pure iterated %d times" n))))
|
|
|
|
|
|
2019-09-11 21:13:13 +00:00
|
|
|
|
|
|
|
|
|
;;; SSA pass specific code.
|
2019-09-14 08:52:57 +00:00
|
|
|
|
;; After limplification no edges are present between basic blocks and an
|
|
|
|
|
;; implicit phi is present for every slot at the beginning of every basic block.
|
|
|
|
|
;; This pass is responsible for building all the edges and replace all m-vars
|
|
|
|
|
;; plus placing the needed phis.
|
2019-09-14 16:12:16 +00:00
|
|
|
|
;; Because the number of phis placed is (supposed) to be the minimum necessary
|
2019-09-14 08:52:57 +00:00
|
|
|
|
;; this form is called 'minimal SSA form'.
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; This pass should be run every time basic blocks or m-var are shuffled.
|
2019-09-13 18:56:24 +00:00
|
|
|
|
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(cl-defun make-comp-ssa-mvar (&rest rest &key _slot _constant _type)
|
|
|
|
|
"Same as `make-comp-mvar' but set the `id' slot."
|
|
|
|
|
(let ((mvar (apply #'make-comp-mvar rest)))
|
2020-02-16 08:46:30 +00:00
|
|
|
|
(setf (comp-mvar-id mvar) (sxhash-eq mvar))
|
|
|
|
|
mvar))
|
2019-09-14 16:12:16 +00:00
|
|
|
|
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(defun comp-clean-ssa (f)
|
2020-11-20 19:34:32 +00:00
|
|
|
|
"Clean-up SSA for function F."
|
2020-09-27 21:43:35 +00:00
|
|
|
|
(setf (comp-func-edges-h f) (make-hash-table))
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks f)
|
|
|
|
|
do (setf (comp-block-in-edges b) ()
|
|
|
|
|
(comp-block-out-edges b) ()
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(comp-block-idom b) nil
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(comp-block-df b) (make-hash-table)
|
|
|
|
|
(comp-block-post-num b) nil
|
|
|
|
|
(comp-block-final-frame b) nil
|
|
|
|
|
;; Prune all phis.
|
|
|
|
|
(comp-block-insns b) (cl-loop for insn in (comp-block-insns b)
|
|
|
|
|
unless (eq 'phi (car insn))
|
|
|
|
|
collect insn))))
|
|
|
|
|
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(defun comp-compute-edges ()
|
|
|
|
|
"Compute the basic block edges for the current function."
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(cl-loop with blocks = (comp-func-blocks comp-func)
|
|
|
|
|
for bb being each hash-value of blocks
|
|
|
|
|
for last-insn = (car (last (comp-block-insns bb)))
|
|
|
|
|
for (op first second third forth) = last-insn
|
|
|
|
|
do (cl-case op
|
|
|
|
|
(jump
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash first blocks)))
|
|
|
|
|
(cond-jump
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash third blocks))
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash forth blocks)))
|
|
|
|
|
(cond-jump-narg-leq
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash second blocks))
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash third blocks)))
|
|
|
|
|
(push-handler
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash third blocks))
|
|
|
|
|
(make-comp-edge :src bb :dst (gethash forth blocks)))
|
|
|
|
|
(return)
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(unreachable)
|
2020-12-12 21:20:28 +00:00
|
|
|
|
(otherwise
|
|
|
|
|
(signal 'native-ice
|
|
|
|
|
(list "block does not end with a branch"
|
|
|
|
|
bb
|
|
|
|
|
(comp-func-name comp-func)))))
|
|
|
|
|
;; Update edge refs into blocks.
|
|
|
|
|
finally
|
|
|
|
|
(cl-loop
|
|
|
|
|
for edge being the hash-value in (comp-func-edges-h comp-func)
|
|
|
|
|
do
|
|
|
|
|
(push edge
|
|
|
|
|
(comp-block-out-edges (comp-edge-src edge)))
|
|
|
|
|
(push edge
|
|
|
|
|
(comp-block-in-edges (comp-edge-dst edge))))
|
|
|
|
|
(comp-log-edges comp-func)))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-collect-rev-post-order (basic-block)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Walk BASIC-BLOCK children and return their name in reversed post-order."
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(let ((visited (make-hash-table))
|
|
|
|
|
(acc ()))
|
|
|
|
|
(cl-labels ((collect-rec (bb)
|
2019-09-14 08:13:38 +00:00
|
|
|
|
(let ((name (comp-block-name bb)))
|
|
|
|
|
(unless (gethash name visited)
|
|
|
|
|
(puthash name t visited)
|
|
|
|
|
(cl-loop for e in (comp-block-out-edges bb)
|
|
|
|
|
for dst-block = (comp-edge-dst e)
|
|
|
|
|
do (collect-rec dst-block))
|
|
|
|
|
(push name acc)))))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(collect-rec basic-block)
|
|
|
|
|
acc)))
|
|
|
|
|
|
|
|
|
|
(defun comp-compute-dominator-tree ()
|
|
|
|
|
"Compute immediate dominators for each basic block in current function."
|
2019-09-14 12:51:43 +00:00
|
|
|
|
;; Originally based on: "A Simple, Fast Dominance Algorithm"
|
2019-09-13 18:56:24 +00:00
|
|
|
|
;; Cooper, Keith D.; Harvey, Timothy J.; Kennedy, Ken (2001).
|
|
|
|
|
(cl-flet ((intersect (b1 b2)
|
|
|
|
|
(let ((finger1 (comp-block-post-num b1))
|
|
|
|
|
(finger2 (comp-block-post-num b2)))
|
|
|
|
|
(while (not (= finger1 finger2))
|
|
|
|
|
(while (< finger1 finger2)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(setf b1 (comp-block-idom b1)
|
2019-11-22 18:20:05 +00:00
|
|
|
|
finger1 (comp-block-post-num b1)))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(while (< finger2 finger1)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(setf b2 (comp-block-idom b2)
|
2019-11-22 18:20:05 +00:00
|
|
|
|
finger2 (comp-block-post-num b2))))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
b1))
|
|
|
|
|
(first-processed (l)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(if-let ((p (cl-find-if (lambda (p) (comp-block-idom p)) l)))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
p
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(signal 'native-ice "cant't find first preprocessed"))))
|
2019-09-14 10:39:53 +00:00
|
|
|
|
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(when-let ((blocks (comp-func-blocks comp-func))
|
|
|
|
|
(entry (gethash 'entry blocks))
|
2019-09-14 08:52:57 +00:00
|
|
|
|
;; No point to go on if the only bb is 'entry'.
|
2021-01-01 11:00:04 +00:00
|
|
|
|
(bb0 (gethash 'bb_0 blocks)))
|
2021-01-01 12:53:08 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
with rev-bb-list = (comp-collect-rev-post-order entry)
|
|
|
|
|
with changed = t
|
|
|
|
|
while changed
|
|
|
|
|
initially (progn
|
|
|
|
|
(comp-log "Computing dominator tree...\n" 2)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(setf (comp-block-idom entry) entry)
|
2021-01-01 12:53:08 +00:00
|
|
|
|
;; Set the post order number.
|
|
|
|
|
(cl-loop for name in (reverse rev-bb-list)
|
|
|
|
|
for b = (gethash name blocks)
|
|
|
|
|
for i from 0
|
|
|
|
|
do (setf (comp-block-post-num b) i)))
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for name in (cdr rev-bb-list)
|
|
|
|
|
for b = (gethash name blocks)
|
|
|
|
|
for preds = (comp-block-preds b)
|
|
|
|
|
for new-idom = (first-processed preds)
|
|
|
|
|
initially (setf changed nil)
|
|
|
|
|
do (cl-loop for p in (delq new-idom preds)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
when (comp-block-idom p)
|
2021-01-01 12:53:08 +00:00
|
|
|
|
do (setf new-idom (intersect p new-idom)))
|
2021-01-02 10:30:10 +00:00
|
|
|
|
unless (eq (comp-block-idom b) new-idom)
|
|
|
|
|
do (setf (comp-block-idom b) (unless (and (comp-block-lap-p new-idom)
|
2021-01-01 12:53:08 +00:00
|
|
|
|
(comp-block-lap-no-ret
|
|
|
|
|
new-idom))
|
|
|
|
|
new-idom)
|
|
|
|
|
changed t))))))
|
2019-09-14 08:13:38 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-compute-dominator-frontiers ()
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Compute the dominator frontier for each basic block in `comp-func'."
|
2019-09-14 12:51:43 +00:00
|
|
|
|
;; Originally based on: "A Simple, Fast Dominance Algorithm"
|
2019-09-14 08:13:38 +00:00
|
|
|
|
;; Cooper, Keith D.; Harvey, Timothy J.; Kennedy, Ken (2001).
|
|
|
|
|
(cl-loop with blocks = (comp-func-blocks comp-func)
|
|
|
|
|
for b-name being each hash-keys of blocks
|
|
|
|
|
using (hash-value b)
|
|
|
|
|
for preds = (comp-block-preds b)
|
2021-03-07 20:26:55 +00:00
|
|
|
|
when (length> preds 1) ; All joins
|
2019-09-14 08:13:38 +00:00
|
|
|
|
do (cl-loop for p in preds
|
|
|
|
|
for runner = p
|
2021-01-02 10:30:10 +00:00
|
|
|
|
do (while (not (eq runner (comp-block-idom b)))
|
2019-09-14 08:13:38 +00:00
|
|
|
|
(puthash b-name b (comp-block-df runner))
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(setf runner (comp-block-idom runner))))))
|
2019-09-14 08:13:38 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-log-block-info ()
|
|
|
|
|
"Log basic blocks info for the current function."
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(maphash (lambda (name bb)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(let ((dom (comp-block-idom bb))
|
2019-09-14 08:52:57 +00:00
|
|
|
|
(df (comp-block-df bb)))
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(comp-log (format "block: %s idom: %s DF %s\n"
|
|
|
|
|
name
|
|
|
|
|
(when dom (comp-block-name dom))
|
|
|
|
|
(cl-loop for b being each hash-keys of df
|
|
|
|
|
collect b))
|
|
|
|
|
3)))
|
2019-09-13 18:56:24 +00:00
|
|
|
|
(comp-func-blocks comp-func)))
|
2019-09-11 21:13:13 +00:00
|
|
|
|
|
2019-09-14 10:39:53 +00:00
|
|
|
|
(defun comp-place-phis ()
|
|
|
|
|
"Place phi insns into the current function."
|
2019-09-14 12:51:43 +00:00
|
|
|
|
;; Originally based on: Static Single Assignment Book
|
2019-09-14 10:39:53 +00:00
|
|
|
|
;; Algorithm 3.1: Standard algorithm for inserting phi-functions
|
|
|
|
|
(cl-flet ((add-phi (slot-n bb)
|
|
|
|
|
;; Add a phi func for slot SLOT-N at the top of BB.
|
|
|
|
|
(push `(phi ,slot-n) (comp-block-insns bb)))
|
|
|
|
|
(slot-assigned-p (slot-n bb)
|
|
|
|
|
;; Return t if a SLOT-N was assigned within BB.
|
|
|
|
|
(cl-loop for insn in (comp-block-insns bb)
|
2019-12-28 10:39:29 +00:00
|
|
|
|
for op = (car insn)
|
|
|
|
|
when (or (and (comp-assign-op-p op)
|
|
|
|
|
(eql slot-n (comp-mvar-slot (cadr insn))))
|
|
|
|
|
;; fetch-handler is after a non local
|
|
|
|
|
;; therefore clobbers all frame!!!
|
|
|
|
|
(eq op 'fetch-handler))
|
2019-11-02 13:34:31 +00:00
|
|
|
|
return t)))
|
2019-09-14 10:39:53 +00:00
|
|
|
|
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(cl-loop for i from (- (comp-func-vframe-size comp-func))
|
|
|
|
|
below (comp-func-frame-size comp-func)
|
2019-09-14 10:39:53 +00:00
|
|
|
|
;; List of blocks with a definition of mvar i
|
2019-09-16 23:01:34 +00:00
|
|
|
|
for defs-v = (cl-loop with blocks = (comp-func-blocks comp-func)
|
2021-02-22 14:07:00 +00:00
|
|
|
|
for b being each hash-value of blocks
|
|
|
|
|
when (slot-assigned-p i b)
|
|
|
|
|
collect b)
|
2019-09-14 10:39:53 +00:00
|
|
|
|
;; Set of basic blocks where phi is added.
|
2019-09-16 23:01:34 +00:00
|
|
|
|
for f = ()
|
2019-09-14 10:39:53 +00:00
|
|
|
|
;; Worklist, set of basic blocks that contain definitions of v.
|
2019-09-16 23:01:34 +00:00
|
|
|
|
for w = defs-v
|
2019-09-14 10:39:53 +00:00
|
|
|
|
do
|
|
|
|
|
(while w
|
|
|
|
|
(let ((x (pop w)))
|
|
|
|
|
(cl-loop for y being each hash-value of (comp-block-df x)
|
|
|
|
|
unless (cl-find y f)
|
2019-10-14 20:08:24 +00:00
|
|
|
|
do (add-phi i y)
|
|
|
|
|
(push y f)
|
|
|
|
|
;; Adding a phi implies mentioning the
|
|
|
|
|
;; corresponding slot so in case adjust w.
|
|
|
|
|
(unless (cl-find y defs-v)
|
|
|
|
|
(push y w))))))))
|
2019-09-14 10:39:53 +00:00
|
|
|
|
|
2019-09-14 15:55:03 +00:00
|
|
|
|
(defun comp-dom-tree-walker (bb pre-lambda post-lambda)
|
2019-09-14 12:51:43 +00:00
|
|
|
|
"Dominator tree walker function starting from basic block BB.
|
2020-09-28 19:09:00 +00:00
|
|
|
|
PRE-LAMBDA and POST-LAMBDA are called in pre or post-order if non-nil."
|
2019-09-14 12:51:43 +00:00
|
|
|
|
(when pre-lambda
|
|
|
|
|
(funcall pre-lambda bb))
|
|
|
|
|
(when-let ((out-edges (comp-block-out-edges bb)))
|
|
|
|
|
(cl-loop for ed in out-edges
|
|
|
|
|
for child = (comp-edge-dst ed)
|
2021-01-02 10:30:10 +00:00
|
|
|
|
when (eq bb (comp-block-idom child))
|
2019-09-14 15:00:16 +00:00
|
|
|
|
;; Current block is the immediate dominator then recur.
|
2019-09-14 15:55:03 +00:00
|
|
|
|
do (comp-dom-tree-walker child pre-lambda post-lambda)))
|
2019-09-14 12:51:43 +00:00
|
|
|
|
(when post-lambda
|
|
|
|
|
(funcall post-lambda bb)))
|
|
|
|
|
|
2019-09-14 15:00:16 +00:00
|
|
|
|
(cl-defstruct (comp-ssa (:copier nil))
|
|
|
|
|
"Support structure used while SSA renaming."
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(frame (comp-new-frame (comp-func-frame-size comp-func)
|
|
|
|
|
(comp-func-vframe-size comp-func) t)
|
|
|
|
|
:type comp-vec
|
2021-02-22 16:28:19 +00:00
|
|
|
|
:documentation "`comp-vec' of m-vars."))
|
2019-09-14 15:00:16 +00:00
|
|
|
|
|
2019-09-16 20:18:58 +00:00
|
|
|
|
(defun comp-ssa-rename-insn (insn frame)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for slot-n from (- (comp-func-vframe-size comp-func))
|
|
|
|
|
below (comp-func-frame-size comp-func)
|
|
|
|
|
do
|
|
|
|
|
(cl-flet ((targetp (x)
|
|
|
|
|
;; Ret t if x is an mvar and target the correct slot number.
|
|
|
|
|
(and (comp-mvar-p x)
|
|
|
|
|
(eql slot-n (comp-mvar-slot x))))
|
|
|
|
|
(new-lvalue ()
|
|
|
|
|
;; If is an assignment make a new mvar and put it as l-value.
|
|
|
|
|
(let ((mvar (make-comp-ssa-mvar :slot slot-n)))
|
|
|
|
|
(setf (comp-vec-aref frame slot-n) mvar
|
|
|
|
|
(cadr insn) mvar))))
|
|
|
|
|
(pcase insn
|
|
|
|
|
(`(,(pred comp-assign-op-p) ,(pred targetp) . ,_)
|
|
|
|
|
(let ((mvar (comp-vec-aref frame slot-n)))
|
|
|
|
|
(setf (cddr insn) (cl-nsubst-if mvar #'targetp (cddr insn))))
|
|
|
|
|
(new-lvalue))
|
|
|
|
|
(`(fetch-handler . ,_)
|
|
|
|
|
;; Clobber all no matter what!
|
|
|
|
|
(setf (comp-vec-aref frame slot-n) (make-comp-ssa-mvar :slot slot-n)))
|
|
|
|
|
(`(phi ,n)
|
|
|
|
|
(when (equal n slot-n)
|
|
|
|
|
(new-lvalue)))
|
|
|
|
|
(_
|
|
|
|
|
(let ((mvar (comp-vec-aref frame slot-n)))
|
|
|
|
|
(setcdr insn (cl-nsubst-if mvar #'targetp (cdr insn)))))))))
|
2019-09-16 20:18:58 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-ssa-rename ()
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Entry point to rename into SSA within the current function."
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(comp-log "Renaming\n" 2)
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(let ((visited (make-hash-table)))
|
2019-09-16 20:18:58 +00:00
|
|
|
|
(cl-labels ((ssa-rename-rec (bb in-frame)
|
|
|
|
|
(unless (gethash bb visited)
|
|
|
|
|
(puthash bb t visited)
|
|
|
|
|
(cl-loop for insn in (comp-block-insns bb)
|
|
|
|
|
do (comp-ssa-rename-insn insn in-frame))
|
2019-09-16 23:01:34 +00:00
|
|
|
|
(setf (comp-block-final-frame bb)
|
|
|
|
|
(copy-sequence in-frame))
|
2019-09-16 20:18:58 +00:00
|
|
|
|
(when-let ((out-edges (comp-block-out-edges bb)))
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for ed in out-edges
|
|
|
|
|
for child = (comp-edge-dst ed)
|
|
|
|
|
;; Provide a copy of the same frame to all children.
|
2021-02-22 16:28:19 +00:00
|
|
|
|
do (ssa-rename-rec child (comp-vec-copy in-frame)))))))
|
2019-09-16 20:18:58 +00:00
|
|
|
|
|
|
|
|
|
(ssa-rename-rec (gethash 'entry (comp-func-blocks comp-func))
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(comp-new-frame (comp-func-frame-size comp-func)
|
|
|
|
|
(comp-func-vframe-size comp-func)
|
|
|
|
|
t)))))
|
2019-09-14 15:55:03 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-finalize-phis ()
|
|
|
|
|
"Fixup r-values into phis in all basic blocks."
|
|
|
|
|
(cl-flet ((finalize-phi (args b)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; Concatenate into args all incoming m-vars for this phi.
|
2019-09-14 15:55:03 +00:00
|
|
|
|
(setcdr args
|
|
|
|
|
(cl-loop with slot-n = (comp-mvar-slot (car args))
|
|
|
|
|
for e in (comp-block-in-edges b)
|
|
|
|
|
for b = (comp-edge-src e)
|
|
|
|
|
for in-frame = (comp-block-final-frame b)
|
2021-02-22 16:28:19 +00:00
|
|
|
|
collect (list (comp-vec-aref in-frame slot-n)
|
2020-09-27 21:24:24 +00:00
|
|
|
|
(comp-block-name b))))))
|
2019-09-14 15:55:03 +00:00
|
|
|
|
|
|
|
|
|
(cl-loop for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do (cl-loop for (op . args) in (comp-block-insns b)
|
|
|
|
|
when (eq op 'phi)
|
2020-02-29 17:14:43 +00:00
|
|
|
|
do (finalize-phi args b)))))
|
2019-09-14 15:00:16 +00:00
|
|
|
|
|
2021-01-01 10:09:00 +00:00
|
|
|
|
(defun comp-remove-unreachable-blocks ()
|
|
|
|
|
"Remove unreachable basic blocks.
|
|
|
|
|
Return t when one or more block was removed, nil otherwise."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with ret
|
|
|
|
|
for bb being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
for bb-name = (comp-block-name bb)
|
|
|
|
|
when (and (not (eq 'entry bb-name))
|
2021-01-02 10:30:10 +00:00
|
|
|
|
(null (comp-block-idom bb)))
|
2021-01-01 10:09:00 +00:00
|
|
|
|
do
|
|
|
|
|
(comp-log (format "Removing block: %s" bb-name) 1)
|
|
|
|
|
(remhash bb-name (comp-func-blocks comp-func))
|
|
|
|
|
(setf (comp-func-ssa-status comp-func) t
|
|
|
|
|
ret t)
|
|
|
|
|
finally return ret))
|
|
|
|
|
|
2020-02-29 17:38:50 +00:00
|
|
|
|
(defun comp-ssa ()
|
2020-11-20 19:34:32 +00:00
|
|
|
|
"Port all functions into minimal SSA form."
|
2019-09-22 13:42:49 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(let* ((comp-func f)
|
|
|
|
|
(ssa-status (comp-func-ssa-status f)))
|
|
|
|
|
(unless (eq ssa-status t)
|
2021-01-01 10:09:00 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
when (eq ssa-status 'dirty)
|
|
|
|
|
do (comp-clean-ssa f)
|
|
|
|
|
do (comp-compute-edges)
|
|
|
|
|
(comp-compute-dominator-tree)
|
|
|
|
|
until (null (comp-remove-unreachable-blocks)))
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(comp-compute-dominator-frontiers)
|
|
|
|
|
(comp-log-block-info)
|
|
|
|
|
(comp-place-phis)
|
|
|
|
|
(comp-ssa-rename)
|
|
|
|
|
(comp-finalize-phis)
|
|
|
|
|
(comp-log-func comp-func 3)
|
|
|
|
|
(setf (comp-func-ssa-status f) t))))
|
2019-09-22 13:42:49 +00:00
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2019-09-15 10:31:44 +00:00
|
|
|
|
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
|
|
|
|
;;; propagate pass specific code.
|
|
|
|
|
;; A very basic propagation pass follows.
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; This propagates values and types plus ref property in the control flow graph.
|
|
|
|
|
;; This is also responsible for removing function calls to pure functions if
|
2019-11-18 18:35:44 +00:00
|
|
|
|
;; possible.
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
2021-01-14 22:54:52 +00:00
|
|
|
|
(defconst comp-fwprop-max-insns-scan 4500
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; Chosen as ~ the greatest required value for full convergence
|
|
|
|
|
;; native compiling all Emacs code-base.
|
2021-01-14 22:54:52 +00:00
|
|
|
|
"Max number of scanned insn before giving-up.")
|
|
|
|
|
|
2019-11-09 15:22:07 +00:00
|
|
|
|
(defun comp-copy-insn (insn)
|
|
|
|
|
"Deep copy INSN."
|
2019-11-10 13:25:17 +00:00
|
|
|
|
;; Adapted from `copy-tree'.
|
|
|
|
|
(if (consp insn)
|
|
|
|
|
(let (result)
|
|
|
|
|
(while (consp insn)
|
|
|
|
|
(let ((newcar (car insn)))
|
|
|
|
|
(if (or (consp (car insn)) (comp-mvar-p (car insn)))
|
2019-11-22 18:20:05 +00:00
|
|
|
|
(setf newcar (comp-copy-insn (car insn))))
|
2019-11-10 13:25:17 +00:00
|
|
|
|
(push newcar result))
|
2019-11-22 18:20:05 +00:00
|
|
|
|
(setf insn (cdr insn)))
|
2019-11-10 13:25:17 +00:00
|
|
|
|
(nconc (nreverse result)
|
|
|
|
|
(if (comp-mvar-p insn) (comp-copy-insn insn) insn)))
|
|
|
|
|
(if (comp-mvar-p insn)
|
|
|
|
|
(copy-comp-mvar insn)
|
|
|
|
|
insn)))
|
2019-11-09 15:22:07 +00:00
|
|
|
|
|
2020-07-05 21:05:36 +00:00
|
|
|
|
(defmacro comp-apply-in-env (func &rest args)
|
|
|
|
|
"Apply FUNC to ARGS in the current compilation environment."
|
|
|
|
|
`(let ((env (cl-loop
|
|
|
|
|
for f being the hash-value in (comp-ctxt-funcs-h comp-ctxt)
|
|
|
|
|
for func-name = (comp-func-name f)
|
|
|
|
|
for byte-code = (comp-func-byte-func f)
|
|
|
|
|
when func-name
|
|
|
|
|
collect `(,func-name . ,(symbol-function func-name))
|
|
|
|
|
and do
|
|
|
|
|
(setf (symbol-function func-name) byte-code))))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(apply ,func ,@args)
|
|
|
|
|
(cl-loop
|
|
|
|
|
for (func-name . def) in env
|
|
|
|
|
do (setf (symbol-function func-name) def)))))
|
|
|
|
|
|
2020-07-12 13:05:46 +00:00
|
|
|
|
(defun comp-fwprop-prologue ()
|
2020-02-09 15:17:21 +00:00
|
|
|
|
"Prologue for the propagate pass.
|
|
|
|
|
Here goes everything that can be done not iteratively (read once).
|
2021-04-27 12:17:44 +00:00
|
|
|
|
Forward propagate immediate involed in assignments." ; FIXME: Typo. Involved or invoked?
|
2019-09-30 15:13:07 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for insn in (comp-block-insns b)
|
|
|
|
|
do (pcase insn
|
2020-03-01 14:42:41 +00:00
|
|
|
|
(`(setimm ,lval ,v)
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(setf (comp-cstr-imm lval) v))))))
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-mvar-propagate (lval rval)
|
2019-09-16 20:18:58 +00:00
|
|
|
|
"Propagate into LVAL properties of RVAL."
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(setf (comp-mvar-typeset lval) (comp-mvar-typeset rval)
|
|
|
|
|
(comp-mvar-valset lval) (comp-mvar-valset rval)
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(comp-mvar-range lval) (comp-mvar-range rval)
|
|
|
|
|
(comp-mvar-neg lval) (comp-mvar-neg rval)))
|
2019-11-18 18:35:44 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-function-foldable-p (f args)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given function F called with ARGS, return non-nil when optimizable."
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(and (comp-function-pure-p f)
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(cl-every #'comp-cstr-imm-vld-p args)))
|
2020-01-20 21:16:10 +00:00
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-function-call-maybe-fold (insn f args)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given INSN, when F is pure if all ARGS are known, remove the function call.
|
2020-11-15 11:03:59 +00:00
|
|
|
|
Return non-nil if the function is folded successfully."
|
2020-06-06 22:34:21 +00:00
|
|
|
|
(cl-flet ((rewrite-insn-as-setimm (insn value)
|
|
|
|
|
;; See `comp-emit-setimm'.
|
|
|
|
|
(comp-add-const-to-relocs value)
|
|
|
|
|
(setf (car insn) 'setimm
|
|
|
|
|
(cddr insn) `(,value))))
|
|
|
|
|
(cond
|
|
|
|
|
((eq f 'symbol-value)
|
|
|
|
|
(when-let* ((arg0 (car args))
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(const (comp-cstr-imm-vld-p arg0))
|
|
|
|
|
(ok-to-optim (member (comp-cstr-imm arg0)
|
2020-06-06 22:34:21 +00:00
|
|
|
|
comp-symbol-values-optimizable)))
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(rewrite-insn-as-setimm insn (symbol-value (comp-cstr-imm
|
2020-06-06 22:34:21 +00:00
|
|
|
|
(car args))))))
|
2020-11-08 09:40:05 +00:00
|
|
|
|
((comp-function-foldable-p f args)
|
2020-06-06 22:34:21 +00:00
|
|
|
|
(ignore-errors
|
2020-07-05 21:05:36 +00:00
|
|
|
|
;; No point to complain here in case of error because we
|
|
|
|
|
;; should do basic block pruning in order to be sure that this
|
|
|
|
|
;; is not dead-code. This is now left to gcc, to be
|
|
|
|
|
;; implemented only if we want a reliable diagnostic here.
|
|
|
|
|
(let* ((f (if-let (f-in-ctxt (comp-symbol-func-to-fun f))
|
|
|
|
|
;; If the function is IN the compilation ctxt
|
|
|
|
|
;; and know to be pure.
|
|
|
|
|
(comp-func-byte-func f-in-ctxt)
|
|
|
|
|
f))
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(value (comp-apply-in-env f (mapcar #'comp-cstr-imm args))))
|
2020-07-05 21:05:36 +00:00
|
|
|
|
(rewrite-insn-as-setimm insn value)))))))
|
2019-09-16 20:18:58 +00:00
|
|
|
|
|
2020-11-14 15:25:56 +00:00
|
|
|
|
(defun comp-fwprop-call (insn lval f args)
|
|
|
|
|
"Propagate on a call INSN into LVAL.
|
|
|
|
|
F is the function being called with arguments ARGS.
|
|
|
|
|
Fold the call in case."
|
2020-11-15 11:03:59 +00:00
|
|
|
|
(unless (comp-function-call-maybe-fold insn f args)
|
2020-12-28 10:54:34 +00:00
|
|
|
|
(when (and (eq 'funcall f)
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(comp-cstr-imm-vld-p (car args)))
|
|
|
|
|
(setf f (comp-cstr-imm (car args))
|
2020-12-28 10:54:34 +00:00
|
|
|
|
args (cdr args)))
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
|
|
|
|
|
(let ((cstr (comp-cstr-f-ret cstr-f)))
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(when (comp-cstr-empty-p cstr)
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; Store it to be rewritten as non local exit.
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(setf (comp-block-lap-non-ret-insn comp-block) insn))
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(setf (comp-mvar-range lval) (comp-cstr-range cstr)
|
|
|
|
|
(comp-mvar-valset lval) (comp-cstr-valset cstr)
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(comp-mvar-typeset lval) (comp-cstr-typeset cstr)
|
2020-12-27 13:07:08 +00:00
|
|
|
|
(comp-mvar-neg lval) (comp-cstr-neg cstr))))
|
|
|
|
|
(cl-case f
|
|
|
|
|
(+ (comp-cstr-add lval args))
|
2020-12-27 20:33:07 +00:00
|
|
|
|
(- (comp-cstr-sub lval args))
|
|
|
|
|
(1+ (comp-cstr-add lval `(,(car args) ,comp-cstr-one)))
|
|
|
|
|
(1- (comp-cstr-sub lval `(,(car args) ,comp-cstr-one))))))
|
2020-11-14 15:25:56 +00:00
|
|
|
|
|
2020-07-12 13:05:46 +00:00
|
|
|
|
(defun comp-fwprop-insn (insn)
|
2019-11-09 15:22:07 +00:00
|
|
|
|
"Propagate within INSN."
|
2019-09-15 12:43:30 +00:00
|
|
|
|
(pcase insn
|
|
|
|
|
(`(set ,lval ,rval)
|
|
|
|
|
(pcase rval
|
2020-06-06 11:30:59 +00:00
|
|
|
|
(`(,(or 'call 'callref) ,f . ,args)
|
2020-11-14 15:25:56 +00:00
|
|
|
|
(comp-fwprop-call insn lval f args))
|
2020-06-06 11:30:59 +00:00
|
|
|
|
(`(,(or 'direct-call 'direct-callref) ,f . ,args)
|
|
|
|
|
(let ((f (comp-func-name (gethash f (comp-ctxt-funcs-h comp-ctxt)))))
|
2020-11-14 15:25:56 +00:00
|
|
|
|
(comp-fwprop-call insn lval f args)))
|
2019-09-15 12:43:30 +00:00
|
|
|
|
(_
|
|
|
|
|
(comp-mvar-propagate lval rval))))
|
2021-02-23 13:35:11 +00:00
|
|
|
|
(`(assume ,lval ,(and (pred comp-mvar-p) rval))
|
|
|
|
|
(comp-mvar-propagate lval rval))
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(`(assume ,lval (,kind . ,operands))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(cl-case kind
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(and
|
|
|
|
|
(apply #'comp-cstr-intersection lval operands))
|
2021-03-01 18:39:00 +00:00
|
|
|
|
(and-nhc
|
|
|
|
|
(apply #'comp-cstr-intersection-no-hashcons lval operands))
|
2020-12-13 11:19:30 +00:00
|
|
|
|
(not
|
2020-12-18 17:37:16 +00:00
|
|
|
|
;; Prevent double negation!
|
|
|
|
|
(unless (comp-cstr-neg (car operands))
|
2020-12-25 09:57:02 +00:00
|
|
|
|
(comp-cstr-value-negation lval (car operands))))
|
|
|
|
|
(>
|
|
|
|
|
(comp-cstr-> lval (car operands) (cadr operands)))
|
|
|
|
|
(>=
|
|
|
|
|
(comp-cstr->= lval (car operands) (cadr operands)))
|
|
|
|
|
(<
|
|
|
|
|
(comp-cstr-< lval (car operands) (cadr operands)))
|
|
|
|
|
(<=
|
2021-02-27 21:00:11 +00:00
|
|
|
|
(comp-cstr-<= lval (car operands) (cadr operands)))
|
|
|
|
|
(=
|
|
|
|
|
(comp-cstr-= lval (car operands) (cadr operands)))))
|
2020-06-07 09:46:08 +00:00
|
|
|
|
(`(setimm ,lval ,v)
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(setf (comp-cstr-imm lval) v))
|
2020-11-08 19:45:43 +00:00
|
|
|
|
(`(phi ,lval . ,rest)
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
(let* ((from-latch (cl-some
|
|
|
|
|
(lambda (x)
|
2020-12-23 10:47:36 +00:00
|
|
|
|
(let* ((bb-name (cadr x))
|
|
|
|
|
(bb (gethash bb-name
|
|
|
|
|
(comp-func-blocks comp-func))))
|
|
|
|
|
(or (comp-latch-p bb)
|
|
|
|
|
(when (comp-block-cstr-p bb)
|
|
|
|
|
(comp-latch-p (car (comp-block-preds bb)))))))
|
Add comp-cstr.el and comp-cstr-tests.el
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-23 22:51:17 +00:00
|
|
|
|
rest))
|
|
|
|
|
(prop-fn (if from-latch
|
|
|
|
|
#'comp-cstr-union-no-range
|
|
|
|
|
#'comp-cstr-union))
|
|
|
|
|
(rvals (mapcar #'car rest)))
|
|
|
|
|
(apply prop-fn lval rvals)))))
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
2020-07-12 13:05:46 +00:00
|
|
|
|
(defun comp-fwprop* ()
|
2019-11-09 15:22:07 +00:00
|
|
|
|
"Propagate for set* and phi operands.
|
|
|
|
|
Return t if something was changed."
|
2021-01-14 22:54:52 +00:00
|
|
|
|
(cl-loop named outer
|
|
|
|
|
with modified = nil
|
|
|
|
|
with i = 0
|
2019-11-09 15:22:07 +00:00
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
2020-12-31 16:37:13 +00:00
|
|
|
|
do (cl-loop
|
|
|
|
|
with comp-block = b
|
|
|
|
|
for insn in (comp-block-insns b)
|
|
|
|
|
for orig-insn = (unless modified
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; Save consing after 1st change.
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(comp-copy-insn insn))
|
2021-01-14 22:54:52 +00:00
|
|
|
|
do
|
|
|
|
|
(comp-fwprop-insn insn)
|
|
|
|
|
(cl-incf i)
|
2020-12-31 16:37:13 +00:00
|
|
|
|
when (and (null modified) (not (equal insn orig-insn)))
|
|
|
|
|
do (setf modified t))
|
2021-01-14 22:54:52 +00:00
|
|
|
|
when (> i comp-fwprop-max-insns-scan)
|
|
|
|
|
do (cl-return-from outer nil)
|
2019-11-19 19:50:18 +00:00
|
|
|
|
finally return modified))
|
2019-09-15 12:43:30 +00:00
|
|
|
|
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(defun comp-rewrite-non-locals ()
|
|
|
|
|
"Make explicit in LIMPLE non-local exits if identified."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for bb being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
for non-local-insn = (and (comp-block-lap-p bb)
|
|
|
|
|
(comp-block-lap-non-ret-insn bb))
|
|
|
|
|
when non-local-insn
|
|
|
|
|
do
|
|
|
|
|
;; Rework the current block.
|
|
|
|
|
(let* ((insn-seq (memq non-local-insn (comp-block-insns bb))))
|
|
|
|
|
(setf (comp-block-lap-non-ret-insn bb) ()
|
2021-01-01 10:09:00 +00:00
|
|
|
|
(comp-block-lap-no-ret bb) t
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(comp-block-out-edges bb) ()
|
|
|
|
|
;; Prune unnecessary insns!
|
|
|
|
|
(cdr insn-seq) '((unreachable))
|
|
|
|
|
(comp-func-ssa-status comp-func) 'dirty))))
|
|
|
|
|
|
2020-07-12 13:05:46 +00:00
|
|
|
|
(defun comp-fwprop (_)
|
2020-07-12 10:22:41 +00:00
|
|
|
|
"Forward propagate types and consts within the lattice."
|
2020-02-29 17:38:50 +00:00
|
|
|
|
(comp-ssa)
|
2021-01-17 21:00:42 +00:00
|
|
|
|
(comp-dead-code)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (and (>= (comp-func-speed f) 2)
|
|
|
|
|
;; FIXME remove the following condition when tested.
|
|
|
|
|
(not (comp-func-has-non-local f)))
|
|
|
|
|
(let ((comp-func f))
|
2020-07-12 13:05:46 +00:00
|
|
|
|
(comp-fwprop-prologue)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(cl-loop
|
2020-12-17 16:31:22 +00:00
|
|
|
|
for i from 1 to 100
|
2020-07-12 13:05:46 +00:00
|
|
|
|
while (comp-fwprop*)
|
2020-12-17 16:31:22 +00:00
|
|
|
|
finally
|
|
|
|
|
(when (= i 100)
|
|
|
|
|
(display-warning
|
|
|
|
|
'comp
|
|
|
|
|
(format "fwprop pass jammed into %s?" (comp-func-name f))))
|
|
|
|
|
(comp-log (format "Propagation run %d times\n" i) 2))
|
2020-12-31 16:37:13 +00:00
|
|
|
|
(comp-rewrite-non-locals)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(comp-log-func comp-func 3))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2019-09-11 21:13:13 +00:00
|
|
|
|
|
2019-09-18 09:30:23 +00:00
|
|
|
|
|
|
|
|
|
;;; Call optimizer pass specific code.
|
2019-09-23 07:13:46 +00:00
|
|
|
|
;; This pass is responsible for the following optimizations:
|
|
|
|
|
;; - Call to subrs that are in defined in the C source and are passing through
|
|
|
|
|
;; funcall trampoline gets optimized into normal indirect calls.
|
|
|
|
|
;; This makes effectively this calls equivalent to all the subrs that got
|
|
|
|
|
;; dedicated byte-code ops.
|
2021-05-06 08:12:48 +00:00
|
|
|
|
;; Triggered at native-comp-speed >= 2.
|
2019-09-23 07:13:46 +00:00
|
|
|
|
;; - Recursive calls gets optimized into direct calls.
|
2021-05-06 08:12:48 +00:00
|
|
|
|
;; Triggered at native-comp-speed >= 2.
|
2019-09-23 07:13:46 +00:00
|
|
|
|
;; - Intra compilation unit procedure calls gets optimized into direct calls.
|
|
|
|
|
;; This can be a big win and even allow gcc to inline but does not make
|
|
|
|
|
;; function in the compilation unit re-definable safely without recompiling
|
|
|
|
|
;; the full compilation unit.
|
2021-05-06 08:12:48 +00:00
|
|
|
|
;; For this reason this is triggered only at native-comp-speed == 3.
|
2019-09-18 09:30:23 +00:00
|
|
|
|
|
2020-06-06 12:49:01 +00:00
|
|
|
|
(defun comp-func-in-unit (func)
|
|
|
|
|
"Given FUNC return the `comp-fun' definition in the current context.
|
|
|
|
|
FUNCTION can be a function-name or byte compiled function."
|
|
|
|
|
(if (symbolp func)
|
2020-07-05 17:32:32 +00:00
|
|
|
|
(comp-symbol-func-to-fun func)
|
2020-06-06 12:49:01 +00:00
|
|
|
|
(cl-assert (byte-code-function-p func))
|
|
|
|
|
(gethash func (comp-ctxt-byte-func-to-func-h comp-ctxt))))
|
|
|
|
|
|
2020-05-18 19:51:46 +00:00
|
|
|
|
(defun comp-call-optim-form-call (callee args)
|
2019-09-21 09:38:40 +00:00
|
|
|
|
(cl-flet ((fill-args (args total)
|
|
|
|
|
;; Fill missing args to reach TOTAL
|
|
|
|
|
(append args (cl-loop repeat (- total (length args))
|
2020-02-09 15:17:21 +00:00
|
|
|
|
collect (make-comp-mvar :constant nil)))))
|
2020-06-07 11:58:27 +00:00
|
|
|
|
(when (and callee
|
|
|
|
|
(or (symbolp callee)
|
2020-06-06 12:49:01 +00:00
|
|
|
|
(gethash callee (comp-ctxt-byte-func-to-func-h comp-ctxt)))
|
2021-05-06 08:26:33 +00:00
|
|
|
|
(not (memq callee native-comp-never-optimize-functions)))
|
2020-06-06 12:49:01 +00:00
|
|
|
|
(let* ((f (if (symbolp callee)
|
|
|
|
|
(symbol-function callee)
|
|
|
|
|
(cl-assert (byte-code-function-p callee))
|
|
|
|
|
callee))
|
2019-09-21 09:38:40 +00:00
|
|
|
|
(subrp (subrp f))
|
2020-06-06 12:49:01 +00:00
|
|
|
|
(comp-func-callee (comp-func-in-unit callee)))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
(cond
|
2019-09-26 10:11:13 +00:00
|
|
|
|
((and subrp (not (subr-native-elisp-p f)))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
;; Trampoline removal.
|
2019-12-29 18:16:53 +00:00
|
|
|
|
(let* ((callee (intern (subr-name f))) ; Fix aliased names.
|
|
|
|
|
(maxarg (cdr (subr-arity f)))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
(call-type (if (if subrp
|
|
|
|
|
(not (numberp maxarg))
|
2020-06-06 11:30:59 +00:00
|
|
|
|
(comp-nargs-p comp-func-callee))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
'callref
|
|
|
|
|
'call))
|
|
|
|
|
(args (if (eq call-type 'callref)
|
|
|
|
|
args
|
|
|
|
|
(fill-args args maxarg))))
|
2020-02-09 15:17:21 +00:00
|
|
|
|
`(,call-type ,callee ,@args)))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
;; Intra compilation unit procedure call optimization.
|
2020-05-18 18:04:07 +00:00
|
|
|
|
;; Attention speed 3 triggers this for non self calls too!!
|
2020-06-06 12:49:01 +00:00
|
|
|
|
((and comp-func-callee
|
2020-11-01 12:58:06 +00:00
|
|
|
|
(comp-func-c-name comp-func-callee)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(or (and (>= (comp-func-speed comp-func) 3)
|
2020-06-06 14:53:34 +00:00
|
|
|
|
(comp-func-unique-in-cu-p callee))
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(and (>= (comp-func-speed comp-func) 2)
|
2020-06-06 12:49:01 +00:00
|
|
|
|
;; Anonymous lambdas can't be redefined so are
|
|
|
|
|
;; always safe to optimize.
|
|
|
|
|
(byte-code-function-p callee))))
|
2020-06-01 11:47:29 +00:00
|
|
|
|
(let* ((func-args (comp-func-l-args comp-func-callee))
|
2019-09-23 08:51:40 +00:00
|
|
|
|
(nargs (comp-nargs-p func-args))
|
|
|
|
|
(call-type (if nargs 'direct-callref 'direct-call))
|
|
|
|
|
(args (if (eq call-type 'direct-callref)
|
|
|
|
|
args
|
|
|
|
|
(fill-args args (comp-args-max func-args)))))
|
2020-06-06 11:30:59 +00:00
|
|
|
|
`(,call-type ,(comp-func-c-name comp-func-callee) ,@args)))
|
2019-09-23 09:41:36 +00:00
|
|
|
|
((comp-type-hint-p callee)
|
|
|
|
|
`(call ,callee ,@args)))))))
|
2019-09-18 21:25:37 +00:00
|
|
|
|
|
2019-09-22 13:42:49 +00:00
|
|
|
|
(defun comp-call-optim-func ()
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Perform the trampoline call optimization for the current function."
|
2019-09-18 09:30:23 +00:00
|
|
|
|
(cl-loop
|
2019-09-22 13:42:49 +00:00
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
2020-06-03 21:06:26 +00:00
|
|
|
|
do (comp-loop-insn-in-block b
|
|
|
|
|
(pcase insn
|
|
|
|
|
(`(set ,lval (callref funcall ,f . ,rest))
|
2021-03-06 20:53:57 +00:00
|
|
|
|
(when-let ((ok (comp-cstr-imm-vld-p f))
|
|
|
|
|
(new-form (comp-call-optim-form-call
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(comp-cstr-imm f) rest)))
|
2020-06-03 21:06:26 +00:00
|
|
|
|
(setf insn `(set ,lval ,new-form))))
|
|
|
|
|
(`(callref funcall ,f . ,rest)
|
2021-03-06 20:53:57 +00:00
|
|
|
|
(when-let ((ok (comp-cstr-imm-vld-p f))
|
|
|
|
|
(new-form (comp-call-optim-form-call
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(comp-cstr-imm f) rest)))
|
2020-06-03 21:06:26 +00:00
|
|
|
|
(setf insn new-form)))))))
|
2019-09-22 13:42:49 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-call-optim (_)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Try to optimize out funcall trampoline usage when possible."
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (and (>= (comp-func-speed f) 2)
|
|
|
|
|
(comp-func-l-p f))
|
2019-09-22 13:42:49 +00:00
|
|
|
|
(let ((comp-func f))
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(comp-call-optim-func))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2019-09-18 09:30:23 +00:00
|
|
|
|
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
|
|
|
|
;;; Dead code elimination pass specific code.
|
|
|
|
|
;; This simple pass try to eliminate insns became useful after propagation.
|
|
|
|
|
;; Even if gcc would take care of this is good to perform this here
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; in the hope of removing memory references.
|
2019-09-23 09:41:36 +00:00
|
|
|
|
;;
|
2019-09-22 16:49:11 +00:00
|
|
|
|
;; This pass can be run as last optim.
|
|
|
|
|
|
|
|
|
|
(defun comp-collect-mvar-ids (insn)
|
2019-11-22 18:15:12 +00:00
|
|
|
|
"Collect the m-var unique identifiers into INSN."
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(cl-loop for x in insn
|
|
|
|
|
if (consp x)
|
2019-11-19 19:27:27 +00:00
|
|
|
|
append (comp-collect-mvar-ids x)
|
2019-09-22 16:49:11 +00:00
|
|
|
|
else
|
2019-11-19 19:27:27 +00:00
|
|
|
|
when (comp-mvar-p x)
|
|
|
|
|
collect (comp-mvar-id x)))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
2019-09-23 09:41:36 +00:00
|
|
|
|
(defun comp-dead-assignments-func ()
|
2019-11-20 18:37:47 +00:00
|
|
|
|
"Clean-up dead assignments into current function.
|
2019-11-19 19:27:27 +00:00
|
|
|
|
Return the list of m-var ids nuked."
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(let ((l-vals ())
|
|
|
|
|
(r-vals ()))
|
2019-11-22 18:15:12 +00:00
|
|
|
|
;; Collect used r and l-values.
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for insn in (comp-block-insns b)
|
|
|
|
|
for (op arg0 . rest) = insn
|
2020-12-24 07:52:56 +00:00
|
|
|
|
if (comp-assign-op-p op)
|
2019-09-22 16:49:11 +00:00
|
|
|
|
do (push (comp-mvar-id arg0) l-vals)
|
2019-10-14 20:08:24 +00:00
|
|
|
|
(setf r-vals (nconc (comp-collect-mvar-ids rest) r-vals))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
else
|
|
|
|
|
do (setf r-vals (nconc (comp-collect-mvar-ids insn) r-vals))))
|
|
|
|
|
;; Every l-value appearing that does not appear as r-value has no right to
|
|
|
|
|
;; exist and gets nuked.
|
|
|
|
|
(let ((nuke-list (cl-set-difference l-vals r-vals)))
|
2019-11-09 15:56:55 +00:00
|
|
|
|
(comp-log (format "Function %s\nl-vals %s\nr-vals %s\nNuking ids: %s\n"
|
2019-11-24 14:07:54 +00:00
|
|
|
|
(comp-func-name comp-func)
|
2019-11-09 15:56:55 +00:00
|
|
|
|
l-vals
|
|
|
|
|
r-vals
|
|
|
|
|
nuke-list)
|
|
|
|
|
3)
|
2019-09-22 16:49:11 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
2020-06-03 21:06:26 +00:00
|
|
|
|
do (comp-loop-insn-in-block b
|
|
|
|
|
(cl-destructuring-bind (op &optional arg0 arg1 &rest rest) insn
|
2020-12-24 07:52:56 +00:00
|
|
|
|
(when (and (comp-assign-op-p op)
|
2020-06-03 21:06:26 +00:00
|
|
|
|
(memq (comp-mvar-id arg0) nuke-list))
|
|
|
|
|
(setf insn
|
|
|
|
|
(if (comp-limple-insn-call-p arg1)
|
|
|
|
|
arg1
|
|
|
|
|
`(comment ,(format "optimized out: %s"
|
|
|
|
|
insn))))))))
|
2019-11-19 19:27:27 +00:00
|
|
|
|
nuke-list)))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
2021-01-17 21:00:42 +00:00
|
|
|
|
(defun comp-dead-code ()
|
2019-09-22 16:49:11 +00:00
|
|
|
|
"Dead code elimination."
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (and (>= (comp-func-speed f) 2)
|
|
|
|
|
;; FIXME remove the following condition when tested.
|
|
|
|
|
(not (comp-func-has-non-local f)))
|
|
|
|
|
(cl-loop
|
|
|
|
|
for comp-func = f
|
|
|
|
|
for i from 1
|
|
|
|
|
while (comp-dead-assignments-func)
|
|
|
|
|
finally (comp-log (format "dead code rm run %d times\n" i) 2)
|
|
|
|
|
(comp-log-func comp-func 3))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2019-09-22 16:49:11 +00:00
|
|
|
|
|
2020-02-16 11:19:10 +00:00
|
|
|
|
|
|
|
|
|
;;; Tail Call Optimization pass specific code.
|
|
|
|
|
|
|
|
|
|
(defun comp-form-tco-call-seq (args)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Generate a TCO sequence for ARGS."
|
2020-02-16 11:19:10 +00:00
|
|
|
|
`(,@(cl-loop for arg in args
|
|
|
|
|
for i from 0
|
|
|
|
|
collect `(set ,(make-comp-mvar :slot i) ,arg))
|
|
|
|
|
(jump bb_0)))
|
|
|
|
|
|
|
|
|
|
(defun comp-tco-func ()
|
|
|
|
|
"Try to pattern match and perform TCO within the current function."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
named in-the-basic-block
|
|
|
|
|
for insns-seq on (comp-block-insns b)
|
|
|
|
|
do (pcase insns-seq
|
|
|
|
|
(`((set ,l-val (direct-call ,func . ,args))
|
2020-12-25 08:39:22 +00:00
|
|
|
|
;; (comment ,_comment)
|
2020-02-16 11:19:10 +00:00
|
|
|
|
(return ,ret-val))
|
2020-07-02 19:45:42 +00:00
|
|
|
|
(when (and (string= func (comp-func-c-name comp-func))
|
2020-02-16 11:19:10 +00:00
|
|
|
|
(eq l-val ret-val))
|
|
|
|
|
(let ((tco-seq (comp-form-tco-call-seq args)))
|
|
|
|
|
(setf (car insns-seq) (car tco-seq)
|
2020-02-29 17:14:43 +00:00
|
|
|
|
(cdr insns-seq) (cdr tco-seq)
|
|
|
|
|
(comp-func-ssa-status comp-func) 'dirty)
|
2020-02-16 11:19:10 +00:00
|
|
|
|
(cl-return-from in-the-basic-block))))))))
|
|
|
|
|
|
|
|
|
|
(defun comp-tco (_)
|
|
|
|
|
"Simple peephole pass performing self TCO."
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (and (>= (comp-func-speed f) 3)
|
|
|
|
|
(comp-func-l-p f)
|
|
|
|
|
(not (comp-func-has-non-local f)))
|
2020-02-16 11:19:10 +00:00
|
|
|
|
(let ((comp-func f))
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(comp-tco-func)
|
|
|
|
|
(comp-log-func comp-func 3))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2020-02-16 11:19:10 +00:00
|
|
|
|
|
2020-05-25 19:27:46 +00:00
|
|
|
|
|
|
|
|
|
;;; Type hint removal pass specific code.
|
|
|
|
|
|
|
|
|
|
;; This must run after all SSA prop not to have the type hint
|
|
|
|
|
;; information overwritten.
|
|
|
|
|
|
|
|
|
|
(defun comp-remove-type-hints-func ()
|
|
|
|
|
"Remove type hints from the current function.
|
|
|
|
|
These are substituted with a normal 'set' op."
|
|
|
|
|
(cl-loop
|
|
|
|
|
for b being each hash-value of (comp-func-blocks comp-func)
|
2020-06-03 21:06:26 +00:00
|
|
|
|
do (comp-loop-insn-in-block b
|
|
|
|
|
(pcase insn
|
|
|
|
|
(`(set ,l-val (call ,(pred comp-type-hint-p) ,r-val))
|
|
|
|
|
(setf insn `(set ,l-val ,r-val)))))))
|
2020-05-25 19:27:46 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-remove-type-hints (_)
|
|
|
|
|
"Dead code elimination."
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(when (>= (comp-func-speed f) 2)
|
2020-05-25 19:27:46 +00:00
|
|
|
|
(let ((comp-func f))
|
|
|
|
|
(comp-remove-type-hints-func)
|
2020-06-15 18:26:00 +00:00
|
|
|
|
(comp-log-func comp-func 3))))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt)))
|
2020-05-25 19:27:46 +00:00
|
|
|
|
|
2019-08-18 15:17:56 +00:00
|
|
|
|
|
2019-09-07 06:57:07 +00:00
|
|
|
|
;;; Final pass specific code.
|
2019-08-18 15:17:56 +00:00
|
|
|
|
|
2020-12-28 10:25:39 +00:00
|
|
|
|
(defun comp-args-to-lambda-list (args)
|
2021-04-25 18:47:20 +00:00
|
|
|
|
"Return a lambda list for ARGS."
|
2020-12-28 10:25:39 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
with res
|
|
|
|
|
repeat (comp-args-base-min args)
|
|
|
|
|
do (push t res)
|
|
|
|
|
finally
|
|
|
|
|
(if (comp-args-p args)
|
|
|
|
|
(cl-loop
|
|
|
|
|
with n = (- (comp-args-max args) (comp-args-min args))
|
|
|
|
|
initially (unless (zerop n)
|
|
|
|
|
(push '&optional res))
|
|
|
|
|
repeat n
|
|
|
|
|
do (push t res))
|
|
|
|
|
(cl-loop
|
|
|
|
|
with n = (- (comp-nargs-nonrest args) (comp-nargs-min args))
|
|
|
|
|
initially (unless (zerop n)
|
|
|
|
|
(push '&optional res))
|
|
|
|
|
repeat n
|
|
|
|
|
do (push t res)
|
|
|
|
|
finally (when (comp-nargs-rest args)
|
|
|
|
|
(push '&rest res)
|
|
|
|
|
(push 't res))))
|
|
|
|
|
(cl-return (reverse res))))
|
|
|
|
|
|
|
|
|
|
(defun comp-compute-function-type (_ func)
|
2020-11-11 16:23:25 +00:00
|
|
|
|
"Compute type specifier for `comp-func' FUNC.
|
2020-12-28 10:25:39 +00:00
|
|
|
|
Set it into the `type' slot."
|
2020-12-28 12:41:38 +00:00
|
|
|
|
(when (and (comp-func-l-p func)
|
|
|
|
|
(comp-mvar-p (comp-func-type func)))
|
2020-12-28 10:25:39 +00:00
|
|
|
|
(let* ((comp-func (make-comp-func))
|
|
|
|
|
(res-mvar (apply #'comp-cstr-union
|
|
|
|
|
(make-comp-cstr)
|
|
|
|
|
(cl-loop
|
|
|
|
|
with res = nil
|
|
|
|
|
for bb being the hash-value in (comp-func-blocks
|
|
|
|
|
func)
|
|
|
|
|
do (cl-loop
|
|
|
|
|
for insn in (comp-block-insns bb)
|
|
|
|
|
;; Collect over every exit point the returned
|
|
|
|
|
;; mvars and union results.
|
|
|
|
|
do (pcase insn
|
|
|
|
|
(`(return ,mvar)
|
|
|
|
|
(push mvar res))))
|
2020-12-28 12:41:38 +00:00
|
|
|
|
finally return res)))
|
|
|
|
|
(type `(function ,(comp-args-to-lambda-list (comp-func-l-args func))
|
|
|
|
|
,(comp-cstr-to-type-spec res-mvar))))
|
|
|
|
|
(comp-add-const-to-relocs type)
|
|
|
|
|
;; Fix it up.
|
2021-02-27 20:26:41 +00:00
|
|
|
|
(setf (comp-cstr-imm (comp-func-type func)) type))))
|
2020-11-11 16:23:25 +00:00
|
|
|
|
|
2020-02-29 15:53:42 +00:00
|
|
|
|
(defun comp-finalize-container (cont)
|
|
|
|
|
"Finalize data container CONT."
|
|
|
|
|
(setf (comp-data-container-l cont)
|
|
|
|
|
(cl-loop with h = (comp-data-container-idx cont)
|
|
|
|
|
for obj each hash-keys of h
|
|
|
|
|
for i from 0
|
|
|
|
|
do (puthash obj i h)
|
2020-05-03 19:26:35 +00:00
|
|
|
|
;; Prune byte-code objects coming from lambdas.
|
|
|
|
|
;; These are not anymore necessary as they will be
|
|
|
|
|
;; replaced at load time by native-elisp-subrs.
|
|
|
|
|
;; Note: we leave the objects in the idx hash table
|
|
|
|
|
;; to still be able to retrieve the correct index
|
|
|
|
|
;; from the corresponding m-var.
|
|
|
|
|
collect (if (gethash obj
|
|
|
|
|
(comp-ctxt-byte-func-to-func-h comp-ctxt))
|
2020-05-13 07:52:47 +00:00
|
|
|
|
'lambda-fixup
|
2020-05-03 19:26:35 +00:00
|
|
|
|
obj))))
|
2020-02-29 15:53:42 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-finalize-relocs ()
|
|
|
|
|
"Finalize data containers for each relocation class.
|
|
|
|
|
Remove immediate duplicates within relocation classes.
|
|
|
|
|
Update all insn accordingly."
|
|
|
|
|
;; Symbols imported by C inlined functions. We do this here because
|
|
|
|
|
;; is better to add all objs to the relocation containers before we
|
|
|
|
|
;; compacting them.
|
|
|
|
|
(mapc #'comp-add-const-to-relocs '(nil t consp listp))
|
|
|
|
|
|
|
|
|
|
(let* ((d-default (comp-ctxt-d-default comp-ctxt))
|
|
|
|
|
(d-default-idx (comp-data-container-idx d-default))
|
|
|
|
|
(d-impure (comp-ctxt-d-impure comp-ctxt))
|
|
|
|
|
(d-impure-idx (comp-data-container-idx d-impure))
|
|
|
|
|
(d-ephemeral (comp-ctxt-d-ephemeral comp-ctxt))
|
|
|
|
|
(d-ephemeral-idx (comp-data-container-idx d-ephemeral)))
|
2020-05-02 16:29:11 +00:00
|
|
|
|
;; We never want compiled lambdas ending up in pure space. A copy must
|
|
|
|
|
;; be already present in impure (see `comp-emit-lambda-for-top-level').
|
|
|
|
|
(cl-loop for obj being each hash-keys of d-default-idx
|
|
|
|
|
when (gethash obj (comp-ctxt-lambda-fixups-h comp-ctxt))
|
|
|
|
|
do (cl-assert (gethash obj d-impure-idx))
|
|
|
|
|
(remhash obj d-default-idx))
|
2020-04-13 19:43:21 +00:00
|
|
|
|
;; Remove entries in d-impure already present in d-default.
|
2020-02-29 15:53:42 +00:00
|
|
|
|
(cl-loop for obj being each hash-keys of d-impure-idx
|
|
|
|
|
when (gethash obj d-default-idx)
|
|
|
|
|
do (remhash obj d-impure-idx))
|
2020-04-13 19:43:21 +00:00
|
|
|
|
;; Remove entries in d-ephemeral already present in d-default or
|
2020-02-29 15:53:42 +00:00
|
|
|
|
;; d-impure.
|
|
|
|
|
(cl-loop for obj being each hash-keys of d-ephemeral-idx
|
|
|
|
|
when (or (gethash obj d-default-idx) (gethash obj d-impure-idx))
|
|
|
|
|
do (remhash obj d-ephemeral-idx))
|
|
|
|
|
;; Fix-up indexes in each relocation class and fill corresponding
|
|
|
|
|
;; reloc lists.
|
2020-04-26 08:11:33 +00:00
|
|
|
|
(mapc #'comp-finalize-container (list d-default d-impure d-ephemeral))
|
|
|
|
|
;; Make a vector from the function documentation hash table.
|
|
|
|
|
(cl-loop with h = (comp-ctxt-function-docs comp-ctxt)
|
|
|
|
|
with v = (make-vector (hash-table-count h) nil)
|
|
|
|
|
for idx being each hash-keys of h
|
|
|
|
|
for doc = (gethash idx h)
|
|
|
|
|
do (setf (aref v idx) doc)
|
|
|
|
|
finally
|
2020-05-02 16:29:11 +00:00
|
|
|
|
do (setf (comp-ctxt-function-docs comp-ctxt) v))
|
|
|
|
|
;; And now we conclude with the following: We need to pass to
|
|
|
|
|
;; `comp--register-lambda' the index in the impure relocation
|
|
|
|
|
;; array to store revived lambdas, but given we know it only now
|
|
|
|
|
;; we fix it up as last.
|
|
|
|
|
(cl-loop for f being each hash-keys of (comp-ctxt-lambda-fixups-h comp-ctxt)
|
|
|
|
|
using (hash-value mvar)
|
|
|
|
|
with reverse-h = (make-hash-table) ;; Make sure idx is unique.
|
|
|
|
|
for idx = (gethash f d-impure-idx)
|
|
|
|
|
do
|
|
|
|
|
(cl-assert (null (gethash idx reverse-h)))
|
|
|
|
|
(cl-assert (fixnump idx))
|
Add initial nativecomp typeset and range propagation support
This commit add an initial support for a better type propagation and
integer range propagation.
Each mvar can be now characterized by a set of types, a set of values
and an integral range.
* lisp/emacs-lisp/comp.el (comp-known-ret-types): Store into
typeset and remove fixnum.
(comp-known-ret-ranges, comp-type-predicates): New variables.
(comp-ctxt): Remove supertype-memoize slot and add
union-typesets-mem.
(comp-mvar): Remove const-vld, constant, type slots. Add typeset,
valset, range slots.
(comp-mvar-value-vld-p, comp-mvar-value, comp-mvar-fixnum-p)
(comp-mvar-symbol-p, comp-mvar-cons-p)
(comp-mvar-type-hint-match-p, comp-func-ret-typeset)
(comp-func-ret-range): New functions.
(make-comp-mvar, make-comp-ssa-mvar): Update logic.
(comp--typeof-types): New variable.
(comp-supertypes, comp-common-supertype): Logic update.
(comp-subtype-p, comp-union-typesets, comp-range-1+)
(comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): New functions.
(comp-fwprop-prologue, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-fwprop-insn, comp-call-optim-func, comp-finalize-relocs):
Logic update.
* src/comp.c (emit_mvar_rval, emit_call_with_type_hint)
(emit_call2_with_type_hint): Logic update.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Undo the add
of fixnum and bignum as unnecessary.
* test/src/comp-tests.el
(comp-tests-mentioned-p-1, comp-tests-cond-rw-checker-val)
(comp-tests-cond-rw-checker-type, cond-rw-1, cond-rw-2)
(cond-rw-3, cond-rw-4, cond-rw-5): Update for new type interface.
(range-simple-union, range-simple-intersection): New integer range
tests.
(union-types): New union type test.
2020-11-07 20:47:30 +00:00
|
|
|
|
(setf (comp-mvar-valset mvar) ()
|
|
|
|
|
(comp-mvar-range mvar) (list (cons idx idx)))
|
2020-05-02 16:29:11 +00:00
|
|
|
|
(puthash idx t reverse-h))))
|
2020-02-29 15:53:42 +00:00
|
|
|
|
|
2019-08-18 15:17:56 +00:00
|
|
|
|
(defun comp-compile-ctxt-to-file (name)
|
2019-09-07 06:57:07 +00:00
|
|
|
|
"Compile as native code the current context naming it NAME.
|
2019-09-22 16:49:11 +00:00
|
|
|
|
Prepare every function for final compilation and drive the C back-end."
|
2020-02-06 20:23:14 +00:00
|
|
|
|
(let ((dir (file-name-directory name)))
|
|
|
|
|
(comp-finalize-relocs)
|
2020-06-08 16:34:46 +00:00
|
|
|
|
(maphash (lambda (_ f)
|
|
|
|
|
(comp-log-func f 1))
|
|
|
|
|
(comp-ctxt-funcs-h comp-ctxt))
|
2020-02-06 20:23:14 +00:00
|
|
|
|
(unless (file-exists-p dir)
|
2020-03-03 23:06:46 +00:00
|
|
|
|
;; In case it's created in the meanwhile.
|
2021-03-21 08:28:25 +00:00
|
|
|
|
(ignore-error file-already-exists
|
2020-07-19 08:46:24 +00:00
|
|
|
|
(make-directory dir t)))
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(comp--compile-ctxt-to-file name)))
|
2019-08-18 15:17:56 +00:00
|
|
|
|
|
2020-09-19 08:27:41 +00:00
|
|
|
|
(defun comp-final1 ()
|
2019-09-07 06:57:07 +00:00
|
|
|
|
(let (compile-result)
|
|
|
|
|
(comp--init-ctxt)
|
|
|
|
|
(unwind-protect
|
2019-11-22 18:20:05 +00:00
|
|
|
|
(setf compile-result
|
2019-09-18 21:25:37 +00:00
|
|
|
|
(comp-compile-ctxt-to-file (comp-ctxt-output comp-ctxt)))
|
2019-09-07 06:57:07 +00:00
|
|
|
|
(and (comp--release-ctxt)
|
|
|
|
|
compile-result))))
|
2019-08-18 15:17:56 +00:00
|
|
|
|
|
2020-12-07 11:22:48 +00:00
|
|
|
|
(defvar comp-async-compilation nil
|
2021-04-27 05:18:14 +00:00
|
|
|
|
"Non-nil while executing an asynchronous native compilation.")
|
2020-12-07 11:22:48 +00:00
|
|
|
|
|
2020-09-19 08:27:41 +00:00
|
|
|
|
(defun comp-final (_)
|
|
|
|
|
"Final pass driving the C back-end for code emission."
|
2020-12-28 10:25:39 +00:00
|
|
|
|
(maphash #'comp-compute-function-type (comp-ctxt-funcs-h comp-ctxt))
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(unless comp-dry-run
|
2020-12-07 11:22:48 +00:00
|
|
|
|
;; Always run the C side of the compilation as a sub-process
|
|
|
|
|
;; unless during bootstrap or async compilation (bug#45056). GCC
|
|
|
|
|
;; leaks memory but also interfere with the ability of Emacs to
|
|
|
|
|
;; detect when a sub-process completes (TODO understand why).
|
|
|
|
|
(if (or byte-native-for-bootstrap comp-async-compilation)
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(comp-final1)
|
|
|
|
|
;; Call comp-final1 in a child process.
|
|
|
|
|
(let* ((output (comp-ctxt-output comp-ctxt))
|
|
|
|
|
(print-escape-newlines t)
|
|
|
|
|
(print-length nil)
|
|
|
|
|
(print-level nil)
|
|
|
|
|
(print-quoted t)
|
|
|
|
|
(print-gensym t)
|
|
|
|
|
(print-circle t)
|
2020-12-20 19:53:22 +00:00
|
|
|
|
(print-escape-multibyte t)
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(expr `((require 'comp)
|
2021-05-06 08:17:12 +00:00
|
|
|
|
(setf native-comp-verbose ,native-comp-verbose
|
2021-04-21 13:23:23 +00:00
|
|
|
|
comp-libgccjit-reproducer ,comp-libgccjit-reproducer
|
|
|
|
|
comp-ctxt ,comp-ctxt
|
|
|
|
|
comp-eln-load-path ',comp-eln-load-path
|
|
|
|
|
comp-native-driver-options
|
|
|
|
|
',comp-native-driver-options
|
|
|
|
|
load-path ',load-path)
|
|
|
|
|
,comp-async-env-modifier-form
|
|
|
|
|
(message "Compiling %s..." ',output)
|
|
|
|
|
(comp-final1)))
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(temp-file (make-temp-file
|
|
|
|
|
(concat "emacs-int-comp-"
|
|
|
|
|
(file-name-base output) "-")
|
|
|
|
|
nil ".el")))
|
|
|
|
|
(with-temp-file temp-file
|
2021-01-06 14:26:38 +00:00
|
|
|
|
(insert ";; -*-coding: nil; -*-\n")
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(mapc (lambda (e)
|
|
|
|
|
(insert (prin1-to-string e)))
|
|
|
|
|
expr))
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(if (zerop
|
|
|
|
|
(call-process (expand-file-name invocation-name
|
|
|
|
|
invocation-directory)
|
|
|
|
|
nil t t "--batch" "-l" temp-file))
|
2021-03-31 18:29:32 +00:00
|
|
|
|
(progn
|
|
|
|
|
(delete-file temp-file)
|
|
|
|
|
output)
|
2020-10-25 09:41:56 +00:00
|
|
|
|
(signal 'native-compiler-error (buffer-string)))
|
|
|
|
|
(comp-log-to-buffer (buffer-string))))))))
|
2020-09-19 08:27:41 +00:00
|
|
|
|
|
2019-07-21 11:57:51 +00:00
|
|
|
|
|
2019-09-23 09:41:36 +00:00
|
|
|
|
;;; Compiler type hints.
|
2020-09-14 19:27:26 +00:00
|
|
|
|
;; Public entry points to be used by user code to give comp
|
|
|
|
|
;; suggestions about types. These are used to implement CL style
|
|
|
|
|
;; `cl-the' and hopefully parameter type declaration.
|
2019-09-23 10:45:06 +00:00
|
|
|
|
;; Note: types will propagates.
|
2019-09-23 09:41:36 +00:00
|
|
|
|
;; WARNING: At speed >= 2 type checking is not performed anymore and suggestions
|
|
|
|
|
;; are assumed just to be true. Use with extreme caution...
|
|
|
|
|
|
|
|
|
|
(defun comp-hint-fixnum (x)
|
2020-09-14 20:02:36 +00:00
|
|
|
|
(declare (gv-setter (lambda (val) `(setf ,x ,val))))
|
2020-09-14 19:27:26 +00:00
|
|
|
|
x)
|
2019-09-23 09:41:36 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-hint-cons (x)
|
2020-09-14 20:02:36 +00:00
|
|
|
|
(declare (gv-setter (lambda (val) `(setf ,x ,val))))
|
2020-09-14 19:27:26 +00:00
|
|
|
|
x)
|
2019-09-23 09:41:36 +00:00
|
|
|
|
|
2020-09-19 12:52:50 +00:00
|
|
|
|
|
2020-11-20 19:34:32 +00:00
|
|
|
|
;; Primitive function advice machinery
|
2020-09-19 12:52:50 +00:00
|
|
|
|
|
2021-01-14 20:53:41 +00:00
|
|
|
|
(defun comp-eln-load-path-eff ()
|
|
|
|
|
"Return a list of effective eln load directories.
|
2021-03-24 15:59:52 +00:00
|
|
|
|
Account for `comp-eln-load-path' and `comp-native-version-dir'."
|
2021-01-14 20:53:41 +00:00
|
|
|
|
(mapcar (lambda (dir)
|
2021-03-15 14:56:08 +00:00
|
|
|
|
(expand-file-name comp-native-version-dir
|
|
|
|
|
(file-name-as-directory
|
|
|
|
|
(expand-file-name dir invocation-directory))))
|
2021-01-14 20:53:41 +00:00
|
|
|
|
comp-eln-load-path))
|
|
|
|
|
|
* Unline some functions to optimize bootstrap time
* lisp/emacs-lisp/comp.el (comp-mvar-value-vld-p)
(comp-mvar-value, comp-mvar-fixnum-p, comp-set-op-p)
(comp-assign-op-p, comp-call-op-p, comp-type-hint-p)
(comp-func-ret-typeset, comp-function-pure-p)
(comp-alloc-class-to-container, comp-lex-byte-func-p)
(comp-lap-eob-p, comp-lap-fall-through-p, comp-emit)
(comp-emit-set-call, comp-mvar-propagate)
(comp-function-foldable-p, comp-function-call-maybe-fold)
(comp-trampoline-filename): Uninline functions.
2020-11-11 14:54:58 +00:00
|
|
|
|
(defun comp-trampoline-filename (subr-name)
|
2020-09-19 12:52:50 +00:00
|
|
|
|
"Given SUBR-NAME return the filename containing the trampoline."
|
2020-10-13 20:48:22 +00:00
|
|
|
|
(concat (comp-c-func-name subr-name "subr--trampoline-" t) ".eln"))
|
2020-09-19 12:52:50 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-make-lambda-list-from-subr (subr)
|
|
|
|
|
"Given SUBR return the equivalent lambda-list."
|
|
|
|
|
(pcase-let ((`(,min . ,max) (subr-arity subr))
|
|
|
|
|
(lambda-list '()))
|
|
|
|
|
(cl-loop repeat min
|
|
|
|
|
do (push (gensym "arg") lambda-list))
|
|
|
|
|
(if (numberp max)
|
|
|
|
|
(cl-loop
|
|
|
|
|
initially (push '&optional lambda-list)
|
|
|
|
|
repeat (- max min)
|
|
|
|
|
do (push (gensym "arg") lambda-list))
|
|
|
|
|
(push '&rest lambda-list)
|
|
|
|
|
(push (gensym "arg") lambda-list))
|
|
|
|
|
(reverse lambda-list)))
|
|
|
|
|
|
2020-10-13 20:48:22 +00:00
|
|
|
|
(defun comp-trampoline-search (subr-name)
|
2020-09-19 12:52:50 +00:00
|
|
|
|
"Search a trampoline file for SUBR-NAME.
|
2020-10-13 20:48:22 +00:00
|
|
|
|
Return the trampoline if found or nil otherwise."
|
2020-09-19 12:52:50 +00:00
|
|
|
|
(cl-loop
|
|
|
|
|
with rel-filename = (comp-trampoline-filename subr-name)
|
2021-01-14 20:53:41 +00:00
|
|
|
|
for dir in (comp-eln-load-path-eff)
|
|
|
|
|
for filename = (expand-file-name rel-filename dir)
|
2020-09-19 12:52:50 +00:00
|
|
|
|
when (file-exists-p filename)
|
2020-10-13 20:48:22 +00:00
|
|
|
|
do (cl-return (native-elisp-load filename))))
|
2020-09-19 12:52:50 +00:00
|
|
|
|
|
2020-10-10 08:13:26 +00:00
|
|
|
|
(defun comp-trampoline-compile (subr-name)
|
2020-10-13 20:48:22 +00:00
|
|
|
|
"Synthesize compile and return a trampoline for SUBR-NAME."
|
|
|
|
|
(let* ((lambda-list (comp-make-lambda-list-from-subr
|
|
|
|
|
(symbol-function subr-name)))
|
|
|
|
|
;; The synthesized trampoline must expose the exact same ABI of
|
|
|
|
|
;; the primitive we are replacing in the function reloc table.
|
|
|
|
|
(form `(lambda ,lambda-list
|
|
|
|
|
(let ((f #',subr-name))
|
|
|
|
|
(,(if (memq '&rest lambda-list) #'apply 'funcall)
|
|
|
|
|
f
|
|
|
|
|
,@(cl-loop
|
|
|
|
|
for arg in lambda-list
|
|
|
|
|
unless (memq arg '(&optional &rest))
|
|
|
|
|
collect arg)))))
|
|
|
|
|
;; Use speed 0 to maximize compilation speed and not to
|
|
|
|
|
;; optimize away funcall calls!
|
|
|
|
|
(byte-optimize nil)
|
2021-05-06 08:12:48 +00:00
|
|
|
|
(native-comp-speed 1)
|
2020-10-13 20:48:22 +00:00
|
|
|
|
(lexical-binding t))
|
2020-10-19 19:48:31 +00:00
|
|
|
|
(comp--native-compile
|
2020-10-13 20:48:22 +00:00
|
|
|
|
form nil
|
2020-10-02 12:42:43 +00:00
|
|
|
|
(cl-loop
|
2021-01-14 20:53:41 +00:00
|
|
|
|
for dir in (comp-eln-load-path-eff)
|
2020-10-02 12:42:43 +00:00
|
|
|
|
for f = (expand-file-name
|
|
|
|
|
(comp-trampoline-filename subr-name)
|
2020-10-10 08:15:21 +00:00
|
|
|
|
dir)
|
|
|
|
|
unless (file-exists-p dir)
|
|
|
|
|
do (ignore-errors
|
|
|
|
|
(make-directory dir t)
|
|
|
|
|
(cl-return f))
|
2020-10-02 12:42:43 +00:00
|
|
|
|
when (file-writable-p f)
|
|
|
|
|
do (cl-return f)
|
2020-10-10 08:13:26 +00:00
|
|
|
|
finally (error "Cannot find suitable directory for output in \
|
2020-10-02 12:42:43 +00:00
|
|
|
|
`comp-eln-load-path'")))))
|
2020-09-19 12:52:50 +00:00
|
|
|
|
|
2019-09-23 09:41:36 +00:00
|
|
|
|
|
2019-11-10 19:01:48 +00:00
|
|
|
|
;; Some entry point support code.
|
|
|
|
|
|
2020-09-06 16:17:00 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun comp-clean-up-stale-eln (file)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Given FILE remove all its *.eln files in `comp-eln-load-path'
|
2020-09-06 16:17:00 +00:00
|
|
|
|
sharing the original source filename (including FILE)."
|
2020-09-14 20:50:21 +00:00
|
|
|
|
(when (string-match (rx "-" (group-n 1 (1+ hex)) "-" (1+ hex) ".eln" eos)
|
|
|
|
|
file)
|
|
|
|
|
(cl-loop
|
|
|
|
|
with filename-hash = (match-string 1 file)
|
|
|
|
|
with regexp = (rx-to-string
|
|
|
|
|
`(seq "-" ,filename-hash "-" (1+ hex) ".eln" eos))
|
2021-03-21 08:15:25 +00:00
|
|
|
|
for dir in (comp-eln-load-path-eff)
|
2020-09-14 20:50:21 +00:00
|
|
|
|
do (cl-loop
|
2021-01-14 20:53:41 +00:00
|
|
|
|
for f in (when (file-exists-p dir)
|
|
|
|
|
(directory-files dir t regexp t))
|
2021-03-21 08:15:25 +00:00
|
|
|
|
;; We may not be able to delete the file if we have no write
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; permission.
|
2021-03-21 08:15:25 +00:00
|
|
|
|
do (ignore-error file-error
|
|
|
|
|
(comp-delete-or-replace-file f))))))
|
2020-09-06 16:17:00 +00:00
|
|
|
|
|
|
|
|
|
(defun comp-delete-or-replace-file (oldfile &optional newfile)
|
|
|
|
|
"Replace OLDFILE with NEWFILE.
|
|
|
|
|
When NEWFILE is nil just delete OLDFILE.
|
|
|
|
|
Takes the necessary steps when dealing with OLDFILE being a
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
shared library that might be currently loaded into a running Emacs
|
2020-09-06 16:17:00 +00:00
|
|
|
|
session."
|
2020-05-19 18:57:31 +00:00
|
|
|
|
(cond ((eq 'windows-nt system-type)
|
2020-09-06 16:17:00 +00:00
|
|
|
|
(ignore-errors (delete-file oldfile))
|
|
|
|
|
(while
|
2020-05-19 18:57:31 +00:00
|
|
|
|
(condition-case _
|
|
|
|
|
(progn
|
2020-09-06 16:17:00 +00:00
|
|
|
|
;; oldfile maybe recreated by another Emacs in
|
2020-05-19 18:57:31 +00:00
|
|
|
|
;; between the following two rename-file calls
|
2020-09-06 16:17:00 +00:00
|
|
|
|
(if (file-exists-p oldfile)
|
|
|
|
|
(rename-file oldfile (make-temp-file-internal
|
|
|
|
|
(file-name-sans-extension oldfile)
|
2020-05-19 18:57:31 +00:00
|
|
|
|
nil ".eln.old" nil)
|
|
|
|
|
t))
|
2020-09-06 16:17:00 +00:00
|
|
|
|
(when newfile
|
|
|
|
|
(rename-file newfile oldfile nil))
|
|
|
|
|
;; Keep on trying.
|
|
|
|
|
nil)
|
|
|
|
|
(file-already-exists
|
|
|
|
|
;; Done
|
|
|
|
|
t))))
|
2020-05-19 18:57:31 +00:00
|
|
|
|
;; Remove the old eln instead of copying the new one into it
|
|
|
|
|
;; to get a new inode and prevent crashes in case the old one
|
|
|
|
|
;; is currently loaded.
|
2020-09-06 16:17:00 +00:00
|
|
|
|
(t (delete-file oldfile)
|
|
|
|
|
(when newfile
|
|
|
|
|
(rename-file newfile oldfile)))))
|
2020-05-19 18:57:31 +00:00
|
|
|
|
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(defvar comp-files-queue ()
|
2021-04-27 12:17:44 +00:00
|
|
|
|
"List of Emacs Lisp files to be compiled.")
|
2020-03-15 10:19:22 +00:00
|
|
|
|
|
2020-04-25 13:39:11 +00:00
|
|
|
|
(defvar comp-async-compilations (make-hash-table :test #'equal)
|
|
|
|
|
"Hash table file-name -> async compilation process.")
|
2020-03-15 10:19:22 +00:00
|
|
|
|
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(defun comp-async-runnings ()
|
|
|
|
|
"Return the number of async compilations currently running.
|
|
|
|
|
This function has the side effect of cleaning-up finished
|
2020-04-25 13:39:11 +00:00
|
|
|
|
processes from `comp-async-compilations'"
|
|
|
|
|
(cl-loop
|
|
|
|
|
for file-name in (cl-loop
|
|
|
|
|
for file-name being each hash-key of comp-async-compilations
|
|
|
|
|
for prc = (gethash file-name comp-async-compilations)
|
|
|
|
|
unless (process-live-p prc)
|
|
|
|
|
collect file-name)
|
|
|
|
|
do (remhash file-name comp-async-compilations))
|
|
|
|
|
(hash-table-count comp-async-compilations))
|
2020-03-15 19:37:51 +00:00
|
|
|
|
|
2021-03-07 19:25:28 +00:00
|
|
|
|
(declare-function w32-get-nproc "w32.c")
|
2020-05-19 07:40:56 +00:00
|
|
|
|
(defvar comp-num-cpus nil)
|
2020-05-18 19:51:46 +00:00
|
|
|
|
(defun comp-effective-async-max-jobs ()
|
|
|
|
|
"Compute the effective number of async jobs."
|
2021-05-06 08:27:57 +00:00
|
|
|
|
(if (zerop native-comp-async-jobs-number)
|
2020-05-18 19:51:46 +00:00
|
|
|
|
(or comp-num-cpus
|
|
|
|
|
(setf comp-num-cpus
|
2020-05-13 19:22:17 +00:00
|
|
|
|
;; FIXME: we already have a function to determine
|
|
|
|
|
;; the number of processors, see get_native_system_info in w32.c.
|
|
|
|
|
;; The result needs to be exported to Lisp.
|
|
|
|
|
(max 1 (/ (cond ((eq 'windows-nt system-type)
|
2021-03-07 13:32:55 +00:00
|
|
|
|
(w32-get-nproc))
|
2020-05-13 19:22:17 +00:00
|
|
|
|
((executable-find "nproc")
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(string-to-number
|
|
|
|
|
(shell-command-to-string "nproc")))
|
2021-04-16 09:13:09 +00:00
|
|
|
|
((eq 'berkeley-unix system-type)
|
|
|
|
|
(string-to-number
|
|
|
|
|
(shell-command-to-string "sysctl -n hw.ncpu")))
|
2020-05-13 19:22:17 +00:00
|
|
|
|
(t 1))
|
2020-05-18 19:51:46 +00:00
|
|
|
|
2))))
|
2021-05-06 08:27:57 +00:00
|
|
|
|
native-comp-async-jobs-number))
|
2020-03-15 20:17:15 +00:00
|
|
|
|
|
2020-10-23 08:26:31 +00:00
|
|
|
|
(defvar comp-last-scanned-async-output nil)
|
|
|
|
|
(make-variable-buffer-local 'comp-last-scanned-async-output)
|
|
|
|
|
(defun comp-accept-and-process-async-output (process)
|
|
|
|
|
"Accept PROCESS output and check for diagnostic messages."
|
|
|
|
|
(if comp-async-report-warnings-errors
|
|
|
|
|
(with-current-buffer (process-buffer process)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(accept-process-output process)
|
|
|
|
|
(goto-char (or comp-last-scanned-async-output (point-min)))
|
2021-04-26 13:59:06 +00:00
|
|
|
|
(while (re-search-forward "^.*?\\(?:Error\\|Warning\\): .*$"
|
2020-10-23 08:26:31 +00:00
|
|
|
|
nil t)
|
|
|
|
|
(display-warning 'comp (match-string 0)))
|
|
|
|
|
(setq comp-last-scanned-async-output (point-max))))
|
|
|
|
|
(accept-process-output process)))
|
|
|
|
|
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(defun comp-run-async-workers ()
|
2020-03-15 10:19:22 +00:00
|
|
|
|
"Start compiling files from `comp-files-queue' asynchronously.
|
|
|
|
|
When compilation is finished, run `comp-async-all-done-hook' and
|
|
|
|
|
display a message."
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(if (or comp-files-queue
|
|
|
|
|
(> (comp-async-runnings) 0))
|
2020-03-15 20:17:15 +00:00
|
|
|
|
(unless (>= (comp-async-runnings) (comp-effective-async-max-jobs))
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(cl-loop
|
2020-03-18 19:52:36 +00:00
|
|
|
|
for (source-file . load) = (pop comp-files-queue)
|
2020-03-15 19:37:51 +00:00
|
|
|
|
while source-file
|
2020-08-16 12:33:25 +00:00
|
|
|
|
do (cl-assert (string-match-p comp-valid-source-re source-file) nil
|
2020-03-15 19:37:51 +00:00
|
|
|
|
"`comp-files-queue' should be \".el\" files: %s"
|
|
|
|
|
source-file)
|
2021-05-06 08:18:32 +00:00
|
|
|
|
when (or native-comp-always-compile
|
2020-08-15 18:12:46 +00:00
|
|
|
|
load ; Always compile when the compilation is
|
|
|
|
|
; commanded for late load.
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(file-newer-than-file-p
|
|
|
|
|
source-file (comp-el-to-eln-filename source-file)))
|
2021-04-21 13:23:23 +00:00
|
|
|
|
do (let* ((expr `((require 'comp)
|
|
|
|
|
,(when (boundp 'backtrace-line-length)
|
|
|
|
|
`(setf backtrace-line-length ,backtrace-line-length))
|
2021-05-06 08:12:48 +00:00
|
|
|
|
(setf native-comp-speed ,native-comp-speed
|
2021-05-06 08:14:00 +00:00
|
|
|
|
native-comp-debug ,native-comp-debug
|
2021-05-06 08:17:12 +00:00
|
|
|
|
native-comp-verbose ,native-comp-verbose
|
2021-04-21 13:23:23 +00:00
|
|
|
|
comp-libgccjit-reproducer ,comp-libgccjit-reproducer
|
|
|
|
|
comp-async-compilation t
|
|
|
|
|
comp-eln-load-path ',comp-eln-load-path
|
|
|
|
|
comp-native-driver-options
|
|
|
|
|
',comp-native-driver-options
|
|
|
|
|
load-path ',load-path
|
|
|
|
|
warning-fill-column most-positive-fixnum)
|
|
|
|
|
,comp-async-env-modifier-form
|
|
|
|
|
(message "Compiling %s..." ,source-file)
|
|
|
|
|
(comp--native-compile ,source-file ,(and load t))))
|
2020-03-18 19:52:36 +00:00
|
|
|
|
(source-file1 source-file) ;; Make the closure works :/
|
2020-05-08 17:04:06 +00:00
|
|
|
|
(temp-file (make-temp-file
|
|
|
|
|
(concat "emacs-async-comp-"
|
|
|
|
|
(file-name-base source-file) "-")
|
2020-08-14 06:29:28 +00:00
|
|
|
|
nil ".el"))
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(expr-strings (mapcar #'prin1-to-string expr))
|
2020-08-14 06:29:28 +00:00
|
|
|
|
(_ (progn
|
|
|
|
|
(with-temp-file temp-file
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(mapc #'insert expr-strings))
|
2020-08-14 06:29:28 +00:00
|
|
|
|
(comp-log "\n")
|
2021-04-21 13:23:23 +00:00
|
|
|
|
(mapc #'comp-log expr-strings)))
|
2020-03-18 19:52:36 +00:00
|
|
|
|
(load1 load)
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(process (make-process
|
|
|
|
|
:name (concat "Compiling: " source-file)
|
|
|
|
|
:buffer (get-buffer-create comp-async-buffer-name)
|
|
|
|
|
:command (list
|
|
|
|
|
(expand-file-name invocation-name
|
|
|
|
|
invocation-directory)
|
2020-05-08 17:04:06 +00:00
|
|
|
|
"--batch" "-l" temp-file)
|
2020-03-18 20:16:05 +00:00
|
|
|
|
:sentinel
|
|
|
|
|
(lambda (process _event)
|
|
|
|
|
(run-hook-with-args
|
2021-04-27 01:37:43 +00:00
|
|
|
|
'comp-async-cu-done-functions
|
2020-03-18 20:16:05 +00:00
|
|
|
|
source-file)
|
2020-10-23 08:26:31 +00:00
|
|
|
|
(comp-accept-and-process-async-output process)
|
2020-05-08 17:04:06 +00:00
|
|
|
|
(ignore-errors (delete-file temp-file))
|
2021-05-04 19:31:44 +00:00
|
|
|
|
(let ((eln-file (comp-el-to-eln-filename
|
|
|
|
|
source-file1)))
|
|
|
|
|
(when (and load1
|
|
|
|
|
(zerop (process-exit-status
|
|
|
|
|
process))
|
|
|
|
|
(file-exists-p eln-file))
|
|
|
|
|
(native-elisp-load eln-file
|
|
|
|
|
(eq load1 'late))))
|
2021-02-26 07:49:58 +00:00
|
|
|
|
(comp-run-async-workers))
|
|
|
|
|
:noquery (not comp-async-query-on-exit))))
|
2020-04-25 13:39:11 +00:00
|
|
|
|
(puthash source-file process comp-async-compilations))
|
2020-03-15 20:17:15 +00:00
|
|
|
|
when (>= (comp-async-runnings) (comp-effective-async-max-jobs))
|
2020-03-15 19:37:51 +00:00
|
|
|
|
do (cl-return)))
|
|
|
|
|
;; No files left to compile and all processes finished.
|
2020-10-07 05:41:00 +00:00
|
|
|
|
(run-hooks 'comp-async-all-done-hook)
|
|
|
|
|
(with-current-buffer (get-buffer-create comp-async-buffer-name)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert "Compilation finished.\n")))
|
|
|
|
|
;; `comp-deferred-pending-h' should be empty at this stage.
|
|
|
|
|
;; Reset it anyway.
|
|
|
|
|
(clrhash comp-deferred-pending-h)))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
|
2020-10-19 19:48:31 +00:00
|
|
|
|
(defun comp--native-compile (function-or-file &optional with-late-load output)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
"Compile FUNCTION-OR-FILE into native code.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
When WITH-LATE-LOAD is non-nil, mark the compilation unit for late
|
2021-04-07 13:25:57 +00:00
|
|
|
|
load once it finishes compiling.
|
|
|
|
|
This serves as internal implementation of `native-compile' but
|
|
|
|
|
allowing for WITH-LATE-LOAD to be controlled is in use also for
|
|
|
|
|
the deferred compilation mechanism."
|
2020-07-26 07:36:09 +00:00
|
|
|
|
(comp-ensure-native-compiler)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(unless (or (functionp function-or-file)
|
|
|
|
|
(stringp function-or-file))
|
2019-11-21 15:09:30 +00:00
|
|
|
|
(signal 'native-compiler-error
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(list "Not a function symbol or file" function-or-file)))
|
2021-03-12 09:24:29 +00:00
|
|
|
|
(catch 'no-native-compile
|
|
|
|
|
(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
|
|
|
|
|
:with-late-load with-late-load)))
|
|
|
|
|
(comp-log "\n\n" 1)
|
|
|
|
|
(condition-case err
|
|
|
|
|
(cl-loop
|
|
|
|
|
with report = nil
|
|
|
|
|
for t0 = (current-time)
|
|
|
|
|
for pass in comp-passes
|
|
|
|
|
unless (memq pass comp-disabled-passes)
|
2021-01-14 20:53:41 +00:00
|
|
|
|
do
|
|
|
|
|
(comp-log (format "(%s) Running pass %s:\n"
|
2021-03-12 09:24:29 +00:00
|
|
|
|
function-or-file pass)
|
|
|
|
|
2)
|
2021-01-14 20:53:41 +00:00
|
|
|
|
(setf data (funcall pass data))
|
|
|
|
|
(push (cons pass (float-time (time-since t0))) report)
|
|
|
|
|
(cl-loop for f in (alist-get pass comp-post-pass-hooks)
|
|
|
|
|
do (funcall f data))
|
2021-03-12 09:24:29 +00:00
|
|
|
|
finally
|
|
|
|
|
(when comp-log-time-report
|
|
|
|
|
(comp-log (format "Done compiling %s" data) 0)
|
|
|
|
|
(cl-loop for (pass . time) in (reverse report)
|
|
|
|
|
do (comp-log (format "Pass %s took: %fs." pass time) 0))))
|
|
|
|
|
(native-compiler-skip)
|
|
|
|
|
(t
|
|
|
|
|
(let ((err-val (cdr err)))
|
|
|
|
|
;; If we are doing an async native compilation print the
|
|
|
|
|
;; error in the correct format so is parsable and abort.
|
|
|
|
|
(if (and comp-async-compilation
|
|
|
|
|
(not (eq (car err) 'native-compiler-error)))
|
|
|
|
|
(progn
|
|
|
|
|
(message (if err-val
|
|
|
|
|
"%s: Error: %s %s"
|
|
|
|
|
"%s: Error %s")
|
|
|
|
|
function-or-file
|
|
|
|
|
(get (car err) 'error-message)
|
|
|
|
|
(car-safe err-val))
|
|
|
|
|
(kill-emacs -1))
|
|
|
|
|
;; Otherwise re-signal it adding the compilation input.
|
|
|
|
|
(signal (car err) (if (consp err-val)
|
|
|
|
|
(cons function-or-file err-val)
|
|
|
|
|
(list function-or-file err-val)))))))
|
|
|
|
|
(if (stringp function-or-file)
|
|
|
|
|
data
|
|
|
|
|
;; So we return the compiled function.
|
|
|
|
|
(native-elisp-load data)))))
|
2019-07-07 07:23:10 +00:00
|
|
|
|
|
2020-11-23 19:26:00 +00:00
|
|
|
|
(defun native-compile-async-skip-p (file load selector)
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
"Return non-nil if FILE's compilation should be skipped.
|
2020-11-23 19:26:00 +00:00
|
|
|
|
|
|
|
|
|
LOAD and SELECTOR work as described in `native--compile-async'."
|
|
|
|
|
;; Make sure we are not already compiling `file' (bug#40838).
|
|
|
|
|
(or (gethash file comp-async-compilations)
|
|
|
|
|
(cond
|
|
|
|
|
((null selector) nil)
|
|
|
|
|
((functionp selector) (not (funcall selector file)))
|
|
|
|
|
((stringp selector) (not (string-match-p selector file)))
|
|
|
|
|
(t (error "SELECTOR must be a function a regexp or nil")))
|
|
|
|
|
;; Also exclude files from deferred compilation if
|
|
|
|
|
;; any of the regexps in
|
|
|
|
|
;; `comp-deferred-compilation-deny-list' matches.
|
|
|
|
|
(and (eq load 'late)
|
|
|
|
|
(cl-some (lambda (re)
|
|
|
|
|
(string-match-p re file))
|
|
|
|
|
comp-deferred-compilation-deny-list))))
|
|
|
|
|
|
2021-02-22 13:31:23 +00:00
|
|
|
|
(defun native--compile-async (files &optional recursively load selector)
|
|
|
|
|
"Compile FILES asynchronously.
|
2021-02-23 23:03:21 +00:00
|
|
|
|
FILES is one filename or a list of filenames or directories.
|
2020-11-19 21:11:17 +00:00
|
|
|
|
|
|
|
|
|
If optional argument RECURSIVELY is non-nil, recurse into
|
|
|
|
|
subdirectories of given directories.
|
|
|
|
|
|
|
|
|
|
If optional argument LOAD is non-nil, request to load the file
|
|
|
|
|
after compiling.
|
|
|
|
|
|
2020-11-23 19:26:00 +00:00
|
|
|
|
The optional argument SELECTOR has the following valid values:
|
|
|
|
|
|
|
|
|
|
nil -- Select all files.
|
|
|
|
|
a string -- A regular expression selecting files with matching names.
|
|
|
|
|
a function -- A function selecting files with matching names.
|
|
|
|
|
|
2021-05-06 08:27:57 +00:00
|
|
|
|
The variable `native-comp-async-jobs-number' specifies the number
|
2020-11-19 21:11:17 +00:00
|
|
|
|
of (commands) to run simultaneously.
|
|
|
|
|
|
|
|
|
|
LOAD can also be the symbol `late'. This is used internally if
|
|
|
|
|
the byte code has already been loaded when this function is
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
called. It means that we request the special kind of load
|
2020-11-19 21:11:17 +00:00
|
|
|
|
necessary in that situation, called \"late\" loading.
|
|
|
|
|
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
During a \"late\" load, instead of executing all top-level forms
|
2020-11-19 21:11:17 +00:00
|
|
|
|
of the original files, only function definitions are
|
|
|
|
|
loaded (paying attention to have these effective only if the
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
bytecode definition was not changed in the meantime)."
|
2020-07-26 07:36:09 +00:00
|
|
|
|
(comp-ensure-native-compiler)
|
2020-03-18 19:52:36 +00:00
|
|
|
|
(unless (member load '(nil t late))
|
2020-11-19 21:11:17 +00:00
|
|
|
|
(error "LOAD must be nil, t or 'late"))
|
2021-02-22 13:31:23 +00:00
|
|
|
|
(unless (listp files)
|
|
|
|
|
(setf files (list files)))
|
2021-02-23 23:03:21 +00:00
|
|
|
|
(let (file-list)
|
2021-02-22 13:31:23 +00:00
|
|
|
|
(dolist (path files)
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(cond ((file-directory-p path)
|
|
|
|
|
(dolist (file (if recursively
|
2020-09-28 19:09:00 +00:00
|
|
|
|
(directory-files-recursively
|
|
|
|
|
path comp-valid-source-re)
|
2020-08-16 12:33:25 +00:00
|
|
|
|
(directory-files path t comp-valid-source-re)))
|
2021-02-23 23:03:21 +00:00
|
|
|
|
(push file file-list)))
|
|
|
|
|
((file-exists-p path) (push path file-list))
|
2020-03-15 10:19:22 +00:00
|
|
|
|
(t (signal 'native-compiler-error
|
|
|
|
|
(list "Path not a file nor directory" path)))))
|
2021-02-23 23:03:21 +00:00
|
|
|
|
(dolist (file file-list)
|
2020-03-18 19:52:36 +00:00
|
|
|
|
(if-let ((entry (cl-find file comp-files-queue :key #'car :test #'string=)))
|
2020-11-19 21:10:20 +00:00
|
|
|
|
;; Most likely the byte-compiler has requested a deferred
|
|
|
|
|
;; compilation, so update `comp-files-queue' to reflect that.
|
|
|
|
|
(unless (or (null load)
|
|
|
|
|
(eq load (cdr entry)))
|
|
|
|
|
(cl-substitute (cons file load) (car entry) comp-files-queue
|
|
|
|
|
:key #'car :test #'string=))
|
2020-11-23 19:26:00 +00:00
|
|
|
|
|
|
|
|
|
(unless (native-compile-async-skip-p file load selector)
|
2020-07-19 08:46:24 +00:00
|
|
|
|
(let* ((out-filename (comp-el-to-eln-filename file))
|
|
|
|
|
(out-dir (file-name-directory out-filename)))
|
2020-08-15 09:29:06 +00:00
|
|
|
|
(unless (file-exists-p out-dir)
|
|
|
|
|
(make-directory out-dir t))
|
|
|
|
|
(if (file-writable-p out-filename)
|
2020-05-03 12:37:38 +00:00
|
|
|
|
(setf comp-files-queue
|
|
|
|
|
(append comp-files-queue `((,file . ,load))))
|
|
|
|
|
(display-warning 'comp
|
|
|
|
|
(format "No write access for %s skipping."
|
|
|
|
|
out-filename)))))))
|
2020-03-15 19:37:51 +00:00
|
|
|
|
(when (zerop (comp-async-runnings))
|
2020-10-07 05:41:00 +00:00
|
|
|
|
(comp-run-async-workers))))
|
2019-11-10 19:01:48 +00:00
|
|
|
|
|
2020-11-23 19:26:00 +00:00
|
|
|
|
|
|
|
|
|
;;; Compiler entry points.
|
|
|
|
|
|
2021-03-21 20:55:13 +00:00
|
|
|
|
;;;###autoload
|
2021-03-21 20:24:26 +00:00
|
|
|
|
(defun comp-lookup-eln (filename)
|
|
|
|
|
"Given a Lisp source FILENAME return the corresponding .eln file if found.
|
|
|
|
|
Search happens in `comp-eln-load-path'."
|
|
|
|
|
(cl-loop
|
|
|
|
|
with eln-filename = (comp-el-to-eln-rel-filename filename)
|
|
|
|
|
for dir in comp-eln-load-path
|
|
|
|
|
for f = (expand-file-name eln-filename
|
|
|
|
|
(expand-file-name comp-native-version-dir
|
|
|
|
|
(expand-file-name
|
|
|
|
|
dir
|
|
|
|
|
invocation-directory)))
|
|
|
|
|
when (file-exists-p f)
|
|
|
|
|
do (cl-return f)))
|
|
|
|
|
|
2020-11-23 19:26:00 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun native-compile (function-or-file &optional output)
|
|
|
|
|
"Compile FUNCTION-OR-FILE into native code.
|
|
|
|
|
This is the synchronous entry-point for the Emacs Lisp native
|
|
|
|
|
compiler.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
FUNCTION-OR-FILE is a function symbol, a form, or the filename of
|
2020-11-23 19:26:00 +00:00
|
|
|
|
an Emacs Lisp source file.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If OUTPUT is non-nil, use it as the filename for the compiled
|
2020-11-23 19:26:00 +00:00
|
|
|
|
object.
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
If FUNCTION-OR-FILE is a filename, return the filename of the
|
2020-11-23 19:26:00 +00:00
|
|
|
|
compiled object. If FUNCTION-OR-FILE is a function symbol or a
|
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.
2021-03-04 18:36:43 +00:00
|
|
|
|
form, return the compiled function."
|
2020-11-23 19:26:00 +00:00
|
|
|
|
(comp--native-compile function-or-file nil output))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun batch-native-compile ()
|
2021-04-07 13:25:57 +00:00
|
|
|
|
"Perform native compilation on remaining command-line arguments.
|
|
|
|
|
Use this from the command line, with ‘-batch’;
|
|
|
|
|
it won’t work in an interactive Emacs.
|
|
|
|
|
Native compilation equivalent to `batch-byte-compile'."
|
2020-11-23 19:26:00 +00:00
|
|
|
|
(comp-ensure-native-compiler)
|
|
|
|
|
(cl-loop for file in command-line-args-left
|
|
|
|
|
if (or (null byte-native-for-bootstrap)
|
|
|
|
|
(cl-notany (lambda (re) (string-match re file))
|
2021-05-06 08:19:35 +00:00
|
|
|
|
native-comp-bootstrap-deny-list))
|
2020-11-23 19:26:00 +00:00
|
|
|
|
do (comp--native-compile file)
|
|
|
|
|
else
|
|
|
|
|
do (byte-compile-file file)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun batch-byte-native-compile-for-bootstrap ()
|
2021-04-21 13:23:33 +00:00
|
|
|
|
"Like `batch-native-compile', but used for bootstrap.
|
2021-04-07 13:25:57 +00:00
|
|
|
|
Generate .elc files in addition to the .eln files.
|
|
|
|
|
Force the produced .eln to be outputted in the eln system
|
|
|
|
|
directory (the last entry in `comp-eln-load-path').
|
|
|
|
|
If the environment variable 'NATIVE_DISABLED' is set, only byte
|
|
|
|
|
compile."
|
2020-11-23 19:26:00 +00:00
|
|
|
|
(comp-ensure-native-compiler)
|
|
|
|
|
(if (equal (getenv "NATIVE_DISABLED") "1")
|
|
|
|
|
(batch-byte-compile)
|
2021-03-07 20:26:55 +00:00
|
|
|
|
(cl-assert (length= command-line-args-left 1))
|
2020-11-23 19:26:00 +00:00
|
|
|
|
(let ((byte-native-for-bootstrap t)
|
|
|
|
|
(byte-to-native-output-file nil))
|
|
|
|
|
(batch-native-compile)
|
|
|
|
|
(pcase byte-to-native-output-file
|
|
|
|
|
(`(,tempfile . ,target-file)
|
|
|
|
|
(rename-file tempfile target-file t))))))
|
|
|
|
|
|
2020-11-19 21:18:50 +00:00
|
|
|
|
;;;###autoload
|
2021-02-22 13:31:23 +00:00
|
|
|
|
(defun native-compile-async (files &optional recursively load selector)
|
|
|
|
|
"Compile FILES asynchronously.
|
2021-02-23 23:03:21 +00:00
|
|
|
|
FILES is one file or a list of filenames or directories.
|
2020-11-19 21:18:50 +00:00
|
|
|
|
|
|
|
|
|
If optional argument RECURSIVELY is non-nil, recurse into
|
|
|
|
|
subdirectories of given directories.
|
|
|
|
|
|
|
|
|
|
If optional argument LOAD is non-nil, request to load the file
|
|
|
|
|
after compiling.
|
|
|
|
|
|
2020-11-23 19:26:00 +00:00
|
|
|
|
The optional argument SELECTOR has the following valid values:
|
|
|
|
|
|
|
|
|
|
nil -- Select all files.
|
|
|
|
|
a string -- A regular expression selecting files with matching names.
|
|
|
|
|
a function -- A function selecting files with matching names.
|
|
|
|
|
|
2021-05-06 08:27:57 +00:00
|
|
|
|
The variable `native-comp-async-jobs-number' specifies the number
|
2020-11-19 21:18:50 +00:00
|
|
|
|
of (commands) to run simultaneously."
|
|
|
|
|
;; Normalize: we only want to pass t or nil, never e.g. `late'.
|
|
|
|
|
(let ((load (not (not load))))
|
2021-02-22 13:31:23 +00:00
|
|
|
|
(native--compile-async files recursively load selector)))
|
2020-11-19 21:18:50 +00:00
|
|
|
|
|
2019-07-07 07:23:10 +00:00
|
|
|
|
(provide 'comp)
|
|
|
|
|
|
2021-04-27 12:17:44 +00:00
|
|
|
|
;; LocalWords: limplified limplified limplification limplify Limple LIMPLE libgccjit elc eln
|
|
|
|
|
|
2019-07-07 07:23:10 +00:00
|
|
|
|
;;; comp.el ends here
|