Commit graph

683 commits

Author SHA1 Message Date
Stefan Kangas
720bd747a8 Add :version tags to defcustoms in comp.el
* lisp/emacs-lisp/comp.el (comp-speed, comp-debug, comp-verbose)
(comp-never-optimize-functions, comp-async-jobs-number)
(comp-async-cu-done-hook, comp-async-all-done-hook)
(comp-async-env-modifier-form)
(comp-async-report-warnings-errors, comp-native-driver-options)
(comp-libgccjit-reproducer): Add :version tags.
2021-02-26 18:01:02 +01:00
Eli Zaretskii
5540d73441 Fix last change
* lisp/emacs-lisp/comp.el (comp-async-report-warnings-errors):
Improve wording of the doc string.
2021-02-26 16:50:41 +02:00
Andrea Corallo
ad74b1b2b6 * Improve `comp-async-report-warnings-errors' docstring
* lisp/emacs-lisp/comp.el (comp-async-report-warnings-errors):
	Improve docstring.
2021-02-26 15:24:34 +01:00
Eli Zaretskii
3266093af9 Improve documentation of last change
* lisp/emacs-lisp/comp.el (comp-async-query-on-exit)
(comp-async-report-warnings-errors): Improve wording.
2021-02-26 16:08:44 +02:00
Andrea Corallo
54df918ad1 * Add `comp-async-query-on-exit' customize.
* lisp/emacs-lisp/comp.el (comp-async-query-on-exit): New customize.
	(comp-run-async-workers): Make use of.
2021-02-26 14:33:08 +01:00
Andrea Corallo
3a31fca5db * Fix some comp-vec logic
* lisp/emacs-lisp/comp.el (comp-vec-length, comp-vec-append)
	(comp-vec-prepend): Fix logic.
	(comp-vec-aref): Fix indentation.
2021-02-25 21:00:07 +01:00
Andrea Corallo
9ae48ae714 * Fix two docstrings in comp.el
* lisp/emacs-lisp/comp.el (comp-new-frame,
	comp-maybe-add-vmvar): Fix docstring.
2021-02-25 20:26:27 +01:00
Andrea Corallo
0ee1a16769 Fix async compilation and paramenter naming
* lisp/emacs-lisp/comp.el (native--compile-async)
	(native-compile-async): Fix broken parameter renaming.
2021-02-24 00:07:07 +01:00
Andrea Corallo
bddd7a2d13 Do not emit assumptions referencing clobbered mvars (bug#46670)
* lisp/emacs-lisp/comp.el (comp-func): Add `vframe-size' slot.
	(comp-new-frame): Add `vsize' parameter.
	(comp-limplify-top-level, comp-limplify-function): Update for new
	`comp-new-frame'.
	(comp-maybe-add-vmvar): New function.
	(comp-add-cond-cstrs): Logic update to emit assumptions not
	referencing clobbered variables.
	(comp-place-phis, comp-ssa, comp-ssa-rename-insn)
	(comp-ssa-rename): Update rename logic to rename also negative
	slots.
	(comp-fwprop-insn): Update to handle `(assume mvar mvar)' form.
	* test/src/comp-tests.el (46670-1): Add testcase.
	* test/src/comp-test-funcs.el (comp-test-46670-1-f)
	(comp-test-46670-2-f): New functions.
2021-02-23 23:19:36 +01:00
Andrea Corallo
89e9b05180 * Move ssa rename from vector to comp-vec
* lisp/emacs-lisp/comp.el (comp-block): Updated `final-frame' slot
	type.
	(comp-limplify): Updated `frame' slot type.
	(comp-slot-n, comp-new-frame, comp-place-phis, comp-ssa)
	(comp-ssa-rename-insn, comp-ssa-rename, comp-finalize-phis): Use
	`comp-vec'.
2021-02-23 23:19:36 +01:00
Andrea Corallo
ec88bdba6f * Add a simple growable vector like type
* lisp/emacs-lisp/comp.el (comp-vec): Define struct.
	(comp-vec-copy, comp-vec-length, comp-vec--verify-idx)
	(comp-vec-aref, comp-vec-append, comp-vec-prepend): New functions.
2021-02-23 23:19:36 +01:00
Andrea Corallo
28ce6f980f * Some clean-up in comp.el
* lisp/emacs-lisp/comp.el (comp-func): Remove 'array-h'.
	(comp-spill-lap-function, comp-intern-func-in-ctxt)
	(comp-spill-lap-function, comp-addr-to-bb-name): Update
	accordingly.
2021-02-22 20:49:11 +01:00
Andrea Corallo
81b1013555 * Don't use paths to indicate filenames
* lisp/emacs-lisp/comp.el (native--compile-async)
	(native-compile-async): Replace `paths' argname with `files'.
2021-02-22 14:31:23 +01:00
Andrea Corallo
da4da88c76 * lisp/emacs-lisp/comp.el (comp-spill-lap): Fix doc string. 2021-02-21 22:20:59 +01:00
Andrea Corallo
d3a399dd29 * lisp/emacs-lisp/comp.el (comp-trampoline-compile): Default to speed 1. 2021-02-11 21:37:53 +01:00
Andrea Corallo
0ffb3dfaa4 Do not add unnecesary arg constraints (bug#45812 bug#45705 bug#45751).
These have the effect of bloating the IR for no effect killing compile
time.  The typical cases for that are extremely long backuoted lists.

	* lisp/emacs-lisp/comp-cstr.el (comp-cstr-t): New var.
	* lisp/emacs-lisp/comp.el (comp-add-call-cstr): No need to add
	arg call constraints if this is t.
2021-01-19 21:58:53 +01:00
Andrea Corallo
39b3bcd324 * Run dead code removal always before fwprop, optim bootstrap time (~20% less)
* lisp/emacs-lisp/comp.el (comp-passes): Remove `comp-dead-code'.
	(comp-fwprop): Call `comp-dead-code'.
	(comp-dead-code): Remove fake arg.
2021-01-17 22:42:19 +01:00
Andrea Corallo
339b4a754b * Introduce `comp-fwprop-max-insns-scan' as heuristic threshold
* lisp/emacs-lisp/comp.el (comp-fwprop-max-insns-scan): New
	constant.
	(comp-fwprop*): Give-up when `comp-fwprop-max-insns-scan' is
	exceeded.
2021-01-17 22:33:02 +01:00
Andrea Corallo
883d937320 Make `comp-enable-subr-trampolines' effective for advices (bug#45854)
* src/comp.c: Copyright update.
	(syms_of_comp): Update `comp-enable-subr-trampolines' doc.
	* lisp/emacs-lisp/comp.el (comp-subr-trampoline-install): Check
	for `comp-enable-subr-trampolines'.
2021-01-17 17:01:51 +01:00
Philip Brown
88100bed0a * Set `backtrace-line-length' in async worker processes
Philip Brown <pdbrown.git@gmail.com>

	* lisp/emacs-lisp/comp.el (comp-run-async-workers): Set
	backtrace-line-length in async worker processes.

Copyright-paperwork-exempt: yes
2021-01-16 13:32:04 +01:00
Andrea Corallo
f1efac1f9e * Normalize `comp-eln-load-path' entries for trampoline comp (bug#43475)
* lisp/emacs-lisp/comp.el (comp-eln-load-path-eff): New function.
	(comp-trampoline-search, comp-trampoline-compile)
	(comp-clean-up-stale-eln): Update to use normalized
	`comp-eln-load-path-eff'.
2021-01-14 22:38:55 +01:00
Andrea Corallo
00101a8d4c * Introduce native compilation time reports
* lisp/emacs-lisp/comp.el (comp-log-time-report): New special
	variable.
	(comp--native-compile): Rework to log time reports.
2021-01-14 22:07:12 +01:00
Andrea Corallo
42ff68ec2f Improve `comp-libgccjit-reproducer'
* src/comp.c (Fcomp__compile_ctxt_to_file): Better libgccjit
	reproducer file name.
	* lisp/emacs-lisp/comp.el (comp-libgccjit-reproducer): Doc update.
	(comp-final, comp-run-async-workers): Pass
	`comp-libgccjit-reproducer' setting to child workers.
2021-01-09 14:05:15 +01:00
Andrea Corallo
325c0765df Add new customize `comp-libgccjit-reproducer'
* lisp/emacs-lisp/comp.el (comp-libgccjit-reproducer): New customize.
	* src/comp.c (Fcomp__compile_ctxt_to_file): Use
	`comp-libgccjit-reproducer' for dumping repoducer.
	(syms_of_comp): Define 'Qcomp_libgccjit_reproducer'.
2021-01-09 12:06:45 +01:00
Andrea Corallo
213b5d7315 * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Fix typo. 2021-01-07 23:10:18 +01:00
Andrea Corallo
33b8ce865f Fix bug#45603
Reported and reduced by Mauricio Collares.

	* lisp/emacs-lisp/comp.el (comp-final): Fix coding system for the
	tmp file used to pass data the child processes.
	* test/src/comp-tests.el (45603-1): New testcase
	* test/src/comp-test-45603.el : New File.
2021-01-06 15:52:58 +01:00
Andrea Corallo
a3f2373bfb * lisp/emacs-lisp/comp.el (comp-known-predicates): Some more tweaking. 2021-01-02 13:53:10 +01:00
Andrea Corallo
43d0e8483e Fix `functionp' contraining (bug#45576)
* lisp/emacs-lisp/comp.el (comp-known-predicates)
	(comp-known-predicates-h): New constants.
	(comp-known-predicate-p, comp-pred-to-cstr): New functions.
	* lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Don't define.
	* test/src/comp-tests.el (comp-test-45576): New testcase.
	* test/src/comp-test-funcs.el (comp-test-45576-f): New function.
2021-01-02 13:07:41 +01:00
Andrea Corallo
03be03d366 * Rename dom' slot into idom' in `comp-block' struct
* lisp/emacs-lisp/comp.el (comp-block): Rename dom `slot' into
	`idom'.
	(comp-clean-ssa, comp-compute-dominator-tree)
	(comp-compute-dominator-frontiers, comp-dom-tree-walker)
	(comp-remove-unreachable-blocks): Update accordingly.
2021-01-02 12:36:40 +01:00
Andrea Corallo
9420ea6e08 Add `throw' to non returning functions
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Add throw.
2021-01-01 14:19:35 +01:00
Andrea Corallo
807471f9ff ; * lisp/emacs-lisp/comp.el (comp-compute-dominator-tree): Reindent. 2021-01-01 14:07:27 +01:00
Andrea Corallo
c29037c877 * lisp/emacs-lisp/comp.el (comp-compute-dominator-tree): Fix. 2021-01-01 14:07:27 +01:00
Andrea Corallo
93ff838575 * Clean unreachable block using dominance tree to handle circularities
With this commit unreachable basic blocks are pruned automatically by
comp-ssa relying on dominance analysis.  This solves the issue of
unreachable cluster of basic blocks referencing each other.

	* lisp/emacs-lisp/comp.el (comp-block-lap): New `no-ret' slot.
	(comp-compute-dominator-tree): Update.
	(comp-remove-unreachable-blocks): New functions.
	(comp-ssa): Update to call `comp-remove-unreachable-blocks'.
	(comp-clean-orphan-blocks): Delete.
	(comp-rewrite-non-locals): Update and simplify.
2021-01-01 14:06:00 +01:00
Andrea Corallo
67c443adc1 Introduce 'unreachable' LIMPLE operator
Introduce 'unreachable' as LIMPLE operater so we can handle correctly
in the CFG functions throwing values or signaling errors.

	* src/comp.c (retrive_block): Better error diagnostic.
	(emit_limple_insn): Add `unreachable'.
	(compile_function): Fix block iteration.
	(syms_of_comp): Define 'Qunreachable'.
	* lisp/emacs-lisp/comp.el (comp-block): New variable.
	(comp-block-lap): Add `non-ret-insn' slot.
	(comp-branch-op-p): New predicate.
	(comp-limple-lock-keywords): Color `unreachable' as red.
	(comp-compute-edges): Add `unreachable'.
	(comp-fwprop-call): Store non returning function call.
	(comp-fwprop*): Update.
	(comp-clean-orphan-blocks, comp-rewrite-non-locals): New functions.
	(comp-fwprop): Call `comp-rewrite-non-locals'.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add two
	tests.
	* test/src/comp-test-funcs.el (comp-test-non-local-1)
	(comp-test-non-local-2, comp-test-non-local-3)
	(comp-test-non-local-4): New functions.
2021-01-01 14:04:58 +01:00
Andrea Corallo
f78580a0f5 * lisp/emacs-lisp/comp.el (comp-limple-lock-keywords): Color returns as red. 2021-01-01 12:29:40 +01:00
Andrea Corallo
e81643bef5 * Add `comp-insert-insn'
* lisp/emacs-lisp/comp.el (comp-insert-insn): New inline.
	(comp-emit-call-cstr): Split logic and call `comp-insert-insn'.
2021-01-01 12:28:27 +01:00
Andrea Corallo
db2a49327a * Order function types in aphabetical order
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Reorder in
	aphabetical order and comment.
2020-12-30 14:05:19 +01:00
Andrea Corallo
0593f47876 * Add more function type specifiers
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Add more
	type specifiers.
2020-12-30 14:03:46 +01:00
Andrea Corallo
3f00d666e9 Fix missing negation handling in a bunch of predicates
* lisp/emacs-lisp/comp.el (comp-mvar-fixnum-p)
	(comp-mvar-symbol-p, comp-mvar-cons-p): Consider neg slot.
	* test/src/comp-tests.el (comp-test-not-cons): New test.
	* test/src/comp-test-funcs.el (comp-test-not-cons-f): New
	function.
2020-12-29 17:49:30 +01:00
Andrea Corallo
c4efb49a27 Constrain mvars under compare and branch with built-in predicates
* lisp/emacs-lisp/comp.el (comp-emit-assume): Update.
	(comp-known-predicate-p): New function.
	(comp-add-cond-cstrs): Extend to pattern match predicate calls.
	* lisp/emacs-lisp/comp-cstr.el (comp-cstr-null-p)
	(comp-pred-to-cstr): New function.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a
	number of tests and fix comments.
2020-12-29 17:49:30 +01:00
Andrea Corallo
2b3c7c7517 Store function type and expose it with `subr-type'
* src/lisp.h (struct Lisp_Subr): Add 'type' field.
	(SUBR_TYPE): New inline accessor.
	* src/pdumper.c (dump_subr): Update for 'type' field.
	* src/data.c (Fsubr_type): New primitive.
	(syms_of_data): Update.
	* src/comp.c (ABI_VERSION): Bump new ABI version.
	(make_subr): Set type.
	(Fcomp__register_lambda, Fcomp__register_subr)
	(Fcomp__late_register_subr): Receive and pass subr type to
	'make_subr'.
	* src/alloc.c (mark_object): Mark subr type.
	* lisp/emacs-lisp/comp.el (comp-func): Change slot type into mvar.
	(comp-emit-for-top-level, comp-emit-lambda-for-top-level): Pass
	type mvar to subr register functions.
	(comp-compute-function-type): Fix-up subr type mvars.
	* test/src/comp-tests.el (comp-tests-check-ret-type-spec): Use
	`subr-type'.
2020-12-28 16:15:23 +01:00
Andrea Corallo
5a8622ba2c Reorder subr register function arguments to make some room
* src/comp.c (Fcomp__register_lambda, Fcomp__register_subr)
	(Fcomp__late_register_subr): Use a rest arg to pass 'doc_idx' and
	'intspec' parameters.
	* lisp/emacs-lisp/comp.el (comp-emit-for-top-level)
	(comp-emit-lambda-for-top-level): Update.
2020-12-28 16:13:31 +01:00
Andrea Corallo
eafcc8eda0 Propagate function calls also when hiddend under funcall
* lisp/emacs-lisp/comp.el (comp-fwprop-call): Propagate functions
	also when called under `funcall'.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a test.
2020-12-28 16:12:08 +01:00
Andrea Corallo
e532ec9552 Compute function type for native compiled functions
* lisp/emacs-lisp/comp.el (comp-func): `type' rename from
	`ret-type-specifier'.
	(comp-args-to-lambda-list): New function.
	(comp-compute-function-type): New function from
	`comp-ret-type-spec'.
	(comp-final): Update.
	* test/src/comp-tests.el (comp-tests-check-ret-type-spec): Update.
2020-12-28 16:09:31 +01:00
Andrea Corallo
8a0467e2ef ; lisp/emacs-lisp/comp.el (comp-emit-narg-prologue): Nit. 2020-12-28 16:08:38 +01:00
Andrea Corallo
ccce15299b * Improve some slot type into comp.el
* lisp/emacs-lisp/comp.el (comp-args-base, comp-args)
	(comp-nargs, comp-func): Fix the type of some slots.
2020-12-28 16:06:49 +01:00
Andrea Corallo
42fb6de0b3 Add 1+ 1- integer range propagation support
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-one): New special var.
	* lisp/emacs-lisp/comp.el (comp-fwprop-call): Propagate integer
	ranges on +1 -1.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add two tests.
2020-12-27 21:50:34 +01:00
Andrea Corallo
7d07a71841 Add sum/subtraction integer range propagation support
* lisp/emacs-lisp/comp-cstr.el (comp-range-+, comp-range--): New
	functions.
	(comp-cstr-set-range-for-arithm): New macro.
	(comp-cstr-add-2, comp-cstr-sub-2, comp-cstr-add, comp-cstr-sub):
	New function.
	* lisp/emacs-lisp/comp.el (comp-fwprop-call): Wire-up + - integer
	range propagation.
2020-12-27 21:34:03 +01:00
Andrea Corallo
fcd8c60182 * Remove unnecessary lhs rename in `comp-ssa-rename-insn'
* lisp/emacs-lisp/comp.el (comp-ssa-rename-insn): No point to
	rename lhs as it's being replaced.
2020-12-26 12:30:58 +01:00
Andrea Corallo
c5c0c06b1c * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Add two functions. 2020-12-26 12:22:21 +01:00