Commit graph

610 commits

Author SHA1 Message Date
Andrea Corallo
53ca0d9844 Rework native compilation `comp-debug' (bug#46495)
* lisp/emacs-lisp/comp.el (comp-debug): Update docstring and
	move default on Windows systems from 0 to 1.
	* src/comp.c (Fcomp__compile_ctxt_to_file): Tweak debug
	levels.
2021-03-31 20:25:08 +02:00
Andrea Corallo
aa159bf696 * lisp/emacs-lisp/comp.el (comp-debug): Fix docstring. 2021-03-31 10:24:55 +02:00
Andrea Corallo
92914ade6d Improve two native compiler related docstrings.
* lisp/emacs-lisp/comp.el (comp-eln-load-path-eff): Improve docstring.
	* src/comp.c (comp-eln-load-path): Likewise.
2021-03-24 17:02:40 +01:00
Andrea Corallo
7ba816ee1c * lisp/emacs-lisp/comp.el (comp-lookup-eln): Add autoload cookie. 2021-03-21 21:55:13 +01:00
Andrea Corallo
6351953dcd * lisp/emacs-lisp/comp.el (comp-lookup-eln): Add new function. 2021-03-21 21:50:22 +01:00
Andrea Corallo
d0280ce1b1 Revert "* lisp/emacs-lisp/comp.el (comp-clean-up-stale-eln): Clean-up all..."
This reverts commit be22cda7be.

Older binaries might still need those .eln if they where preloaded.
2021-03-21 15:34:38 +01:00
Andrea Corallo
08682ccc31 ; Remove two unnecessary quotes
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-=): Remove unnecessary
	quote.
	* lisp/emacs-lisp/comp.el (comp-compile-ctxt-to-file): Likewise.
2021-03-21 09:28:25 +01:00
Andrea Corallo
be22cda7be * lisp/emacs-lisp/comp.el (comp-clean-up-stale-eln): Clean-up all .eln dirs. 2021-03-21 09:15:25 +01:00
Andrea Corallo
3e133cc050 Fix `no-byte-compile' native compilation interaction (bug#47169)
* lisp/emacs-lisp/comp.el (comp-spill-lap-function): Throw
	no-native-compile when `byte-native-qualities' are null.
	* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): No need
	to consider `no-byte-compile'.
2021-03-16 19:02:57 +01:00
Andrea Corallo
f3abb17118 Have no-byte-compile' implies also no-native-compile'.
* lisp/emacs-lisp/comp.el (no-native-compile): Update doctring.
	* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): when
	`no-byte-compile' is set to non-nil it overrides this.
2021-03-16 09:12:46 +01:00
Eli Zaretskii
aabda4263b Prefer expand-file-name to concat in native-compilation code
* lisp/emacs-lisp/comp.el (comp-eln-load-path-eff):
* src/comp.c (Fcomp_el_to_eln_filename)
(eln_load_path_final_clean_up): Prefer expand-file-name to concat.
(Bug#43725)
2021-03-15 16:56:08 +02:00
Andrea Corallo
5e4ec4d3c9 Fix some entry in `comp-known-type-specifiers' (bug#46847)
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Some
	fix.
	* test/src/comp-tests.el (comp-tests-46670-1): Update test.
2021-03-14 22:05:02 +01:00
Andrea Corallo
d018584814 * Fix circular dependecy when loading a modified comp.el (bug#47049)
* lisp/emacs-lisp/comp.el (comp-subr-trampoline-install): Move it
	before other functional code.
2021-03-12 22:35:23 +01:00
Andrea Corallo
d9cd55a4f1 Implement `no-native-compile' (bug#46983)
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Capture
	`no-native-compile'.
	* lisp/emacs-lisp/comp.el (no-native-compile): Define new
	variable.
	(comp-spill-lap-function): Throw when `no-native-compile' was
	captured non-nil.
	(comp--native-compile): Catch `no-native-compile' if necessary and
	return nil in case.
2021-03-12 13:11:45 +01:00
Andrea Corallo
0144764d1d * Fix error reporting for async native compilation (bug#47024)
* lisp/emacs-lisp/comp.el (comp--native-compile): During async
	compilation if we catch an error print it in a parsable way so we
	can report it to the user.
2021-03-12 10:03:09 +01:00
Andrea Corallo
fe1c081c38 * Fix truncated warnings (bug#47024)
* lisp/emacs-lisp/comp.el (comp-run-async-workers): Bind
	`warning-fill-column' to `most-positive-fixnum'.
2021-03-10 15:50:58 +01:00
Andrea Corallo
9809f7ed2c Use `length=' and family where possible in native comp code
* lisp/emacs-lisp/comp-cstr.el (comp-intersect-typesets)
	(comp-cstr-imm): Use Use `length=' and family where possible.
	* lisp/emacs-lisp/comp.el (comp-add-cond-cstrs-target-block)
	(comp-compute-dominator-frontiers)
	(batch-byte-native-compile-for-bootstrap): Likewise.
2021-03-07 21:33:53 +01:00
Andrea Corallo
b6f06c32b4 * lisp/emacs-lisp/comp.el (w32-get-nproc): Suppress warning declaring it.
For non Windows system.
2021-03-07 20:26:46 +01:00
Andrea Corallo
dbdc44db15 Allow for `comp-native-driver-options' to work as a file-local variable. 2021-03-07 20:19:20 +01:00
Eli Zaretskii
619f66f423 Use MS-Windows system APIs to get number of processors
* lisp/emacs-lisp/comp.el: Use 'w32-get-nproc' instead of the
environment variable NUMBER_OF_PROCESSORS.

* src/w32proc.c (Fw32_get_nproc): New primitive.
* src/w32.c (w32_get_nproc): New function.
(sample_system_load): Call w32_get_nproc to initialize the number
of processors on this system.
* src/w32.h (w32_get_nproc): Add prototype.
2021-03-07 15:32:55 +02:00
Pip Cet
6c73418c95 Fix miscompilation of funcall forms in some cases (bug#46974)
* lisp/emacs-lisp/comp.el (comp-call-optim-func): Call
comp-cstr-imm-vld-p before relying on comp-cstr-imm to return the
right value.
2021-03-06 20:53:57 +00:00
Andrea Corallo
3848f3bff0 * lisp/emacs-lisp/comp.el (comp-add-cond-cstrs-simple): Suppress warning. 2021-03-06 20:52:34 +01:00
Eli Zaretskii
b456b19ec4 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 20:36:43 +02:00
Andrea Corallo
3d014e1bf4 Fix eql' equal' propagation of non hash consed values (bug#46843)
Extend assumes allowing the following form:

(assume dst (and-nhc src1 src2))

`and-nhc' assume operator allow for constraining correctly
intersections where non hash consed values are not propagated as
values but rather promoted to their types.

	* lisp/emacs-lisp/comp-cstr.el
	(comp-cstr-intersection-no-hashcons): New function.
	* lisp/emacs-lisp/comp.el (comp-emit-assume): Logic update to emit
	`and-nhc' operator (implemented in fwprop by
	`comp-cstr-intersection-no-hashcons').
	(comp-add-cond-cstrs): Map `eq' to `and' assume operator and
	`equal' `eql' into `and-nhc'.
	(comp-fwprop-insn): Update to handle `and-nhc'.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add two
	tests covering `eql' and `equal' propagation of non hash consed
	values.
2021-03-01 18:09:40 +01:00
Andrea Corallo
5bc08559e8 Don't treat '=' as simple equality emitting constraints (bug#46812)
Extend assumes allowing the following form

(assume dst (= src1 src2))

to caputure '=' semanting during fwprop handling float integer
conversions.

	* lisp/emacs-lisp/comp.el (comp-equality-fun-p): Don't treat '=' as
	simple equality.
	(comp-arithm-cmp-fun-p, comp-negate-arithm-cmp-fun)
	(comp-reverse-arithm-fun): Rename and add '=' '!='.
	(comp-emit-assume, comp-add-cond-cstrs, comp-fwprop-insn): Update
	for new function nameing and to handle '='.
	* lisp/emacs-lisp/comp-cstr.el (comp-cstr-=): New function.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a bunch
	of '=' specific tests.
2021-02-28 23:30:03 +01:00
Andrea Corallo
2acc46b55b Migrate and rename a bunch of functions from comp.el to comp-cstr.el
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-imm-vld-p)
	(comp-cstr-imm, comp-cstr-fixnum-p, comp-cstr-symbol-p)
	(comp-cstr-cons-p): Move and rename from 'comp.el'.
	* lisp/emacs-lisp/comp.el (comp-mvar-type-hint-match-p)
	(make-comp-mvar, comp-emit-assume, comp-fwprop-prologue)
	(comp-function-foldable-p, comp-function-call-maybe-fold)
	(comp-fwprop-call, comp-fwprop-insn, comp-call-optim-func)
	(comp-compute-function-type): Update for renamed functions.
	* src/comp.c (emit_mvar_rval): Likewise.
	* test/src/comp-tests.el (comp-tests-mentioned-p-1)
	(comp-tests-cond-rw-checker-val): Likewise.
2021-02-28 23:29:49 +01:00
Stefan Kangas
cedc55041e Make some defcustom types stricter in comp.el
* lisp/emacs-lisp/comp.el (comp-speed, comp-debug, comp-verbose)
(comp-async-jobs-number, comp-async-env-modifier-form): Use stricter
types.
2021-02-26 18:11:29 +01:00
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