* 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'.
* 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.
* 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.
* 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.
* 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.
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-set-cmp-range)
(comp-cstr->, comp-cstr->=, comp-cstr-<, comp-cstr-<=): New
functions.
* lisp/emacs-lisp/comp.el (comp-equality-fun-p)
(comp-range-cmp-fun-p): New functions.
(comp-collect-rhs): Use `comp-assign-op-p' in place of
`comp-set-op-p'.
(comp-negate-range-cmp-fun, comp-reverse-cmp-fun): New functions.
(comp-emit-assume): Rework to be able to emit also comparision
assumption.
(comp-add-cond-cstrs-simple): Update for new `comp-emit-assume'.
(comp-add-cond-cstrs-simple): Update to emit range assumption.
(comp-fwprop-insn): Execute range assumptions.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Add tests.
* lisp/emacs-lisp/comp.el (comp-add-call-cstr): Fix it.
* test/src/comp-tests.el (assume-in-loop-1): New test.
* test/src/comp-test-funcs.el (comp-test-assume-in-loop-1-f): New
function.
* lisp/emacs-lisp/comp.el (comp-fwprop-insn): Do not propagate in
case of double negation.
* test/src/comp-test-funcs.el (comp-test-assume-double-neg-f):
New function.
* test/src/comp-tests.el (assume-double-neg): New test.
* lisp/emacs-lisp/comp.el (comp-emit-call-cstr): Have new-mvar as
LHS *and* RHS when constraining in and to ensure monotonicity and
fwprop convergence.
(comp-fwprop): Raise a warning for debug reasons in case fwprop
does not converge within 100 iterations.
* lisp/emacs-lisp/comp.el: Add some commentary.
(comp-cond-cstrs-target-mvar): Rename and update docstring.
(comp-add-cond-cstrs): Update to use
`comp-cond-cstrs-target-mvar'.
(comp-emit-call-cstr, comp-lambda-list-gen, comp-add-call-cstr):
New functions.
(comp-add-cstrs): Call `comp-add-call-cstr'.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update two
type specifier tests.
Wire-up comp-cstr.el routines in fwprop and constraint mvars also on
the else side of branches.
* lisp/emacs-lisp/comp.el (comp-emit-assume)
(comp-cond-cstr-target-mvar, comp-cond-cstr-func)
(comp-fwprop-insn): Logic update.
(comp-mvar-value-vld-p, comp-mvar-propagate, comp-fwprop-call):
Handle neg slot.
* lisp/emacs-lisp/comp.el (comp-prettyformat-mvar)
(comp-prettyformat-insn): New function.
(comp-log-func): Update to use `comp-prettyformat-insn'.
(comp-finalize-phis): Change LIMPLE phi format to ease
`comp-prettyformat-insn' destructuring.
* lisp/emacs-lisp/comp.el (comp-final): Escape multibyte string
when offloading compilation to child process.
* test/src/comp-test-funcs.el (comp-test-45342-f): New function
* test/src/comp-tests.el (bug-45342): New test
This commit remove the limitaiton we had not being able to add
constraints derived from conditional branches to basic blocks with
multiple predecessors. When this condition is verified we add a new
dedicated basic block to hold the constraints.
* lisp/emacs-lisp/comp.el (comp-block, comp-edge): Better slot
type specifiers.
(comp-block-cstr): New struct specializing `comp-block'.
(make-comp-edge): New function.
(comp-func): Better test function + doc for `blocks' slot.
(comp-limple-lock-keywords): Update possible basic block names.
(comp-emit-assume): Recive directly the block instead of its name.
(comp-add-new-block-beetween): New function.
(comp-cond-cstr-target-block): Logic update and use
`comp-add-new-block-beetween'.
(comp-cond-cstr-func): Make use of the latter.
(comp-compute-edges): Make use of `make-comp-edge'.
* lisp/emacs-lisp/comp.el (comp-async-compilation): New variable.
(comp-final): Always run the C side of the compilation as a
sub-process unless during bootstrap or async compilation.
(comp-run-async-workers): Set `comp-async-compilation'.
* lisp/emacs-lisp/comp.el (comp-mvar-symbol-p): As all slots into
a `comp-cstr' are in or fix this logic.
(comp-mvar-cons-p): Likewise.
* test/src/comp-tests.el (bug-44968): New testcase.
* test/src/comp-test-funcs.el (comp-test-44968-f): New test
function.
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.
* lisp/emacs-lisp/comp.el (native-compile-async-skip-p): New function
ripping out logic from `native--compile-async' and accounting for
SELECTOR.
(native--compile-async): Add SELECTOR parameter, make use of
`native-compile-async-skip-p' and move it with other private
functions.
(native-compile-async): Add SELECTOR parameter.
* lisp/emacs-lisp/comp.el (comp-deferred-compilation-deny-list):
Rename from `comp-deferred-compilation-black-list'.
* lisp/emacs-lisp/comp.el (native--compile-async): Update to use
`comp-deferred-compilation-deny-list'.
(comp-bootstrap-deny-list): Rename.
(batch-native-compile): Update to use `comp-bootstrap-deny-list'.
* lisp/emacs-lisp/comp.el (native--compile-async): New defun extracted
from native-compile-async.
(native-compile-async): Remove load argument and use above new defun.
* src/comp.c (maybe_defer_native_compilation): Use above new
defun. (Bug#44676)
* lisp/emacs-lisp/comp.el (comp-mvar-symbol-p): Improve it.
(comp-cond-rw-func): Fix logic for multiple predecessor on target
block.
* test/src/comp-tests.el (comp-test-cond-rw-1): New test.
* test/src/comp-test-funcs.el (comp-test-cond-rw-1-1-f)
(comp-test-cond-rw-1-2-f): New functions.
* lisp/emacs-lisp/comp.el (comp-constraint-to-type-spec): New
function splitting out code from comp-ret-type-spec + better
handle boolean type specifier.
(comp-ret-type-spec): Rework to leverage
`comp-constraint-to-type-spec'.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a
testcase.
* lisp/emacs-lisp/comp.el (comp-log): Add `quoted' parameter and
pass it to `comp-log-to-buffer'.
(comp-log-to-buffer): Add `quoted' parameter and leverage `prin1'
or `princ' accordingly.