summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp-common.el
Commit message (Collapse)AuthorAgeFilesLines
* Add 'message' to 'comp-primitive-type-specifiers'Andrea Corallo2024-06-031-0/+1
| | | | | * lisp/emacs-lisp/comp-common.el (comp-primitive-type-specifiers): Add message.
* Redirect calls to `subr-native-elisp-p` to `native-comp-function-p`Stefan Monnier2024-05-281-1/+1
| | | | | | | | | | | | | | | | | * test/src/comp-tests.el (comp-tests-bootstrap, lambda-return) (lambda-return2, free-fun, free-fun2, free-fun-silly-name, speed--1) (compile-forms, comp-test-defsubst, primitive-redefine-compile-44221) (48029-1, 61917-1, tco, fw-prop-1, pure): * test/lisp/help-fns-tests.el (help-fns-test-lisp-defun): * lisp/subr.el (subr-primitive-p, primitive-function-p, symbol-file): * lisp/help-fns.el (find-lisp-object-file-name): * lisp/emacs-lisp/disass.el (disassemble-internal): * lisp/emacs-lisp/comp.el (comp--call-optim-form-call): * lisp/emacs-lisp/comp-run.el (comp-warn-primitives): * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): * lisp/emacs-lisp/bytecomp.el (<trailer>): Rename `subr-native-elisp-p` to `native-comp-function-p`.
* Remove unnecessary cons in function-type propertyAndrea Corallo2024-05-051-1/+1
| | | | | | | | * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): Remove unnecessary car. * lisp/emacs-lisp/comp.el (comp--intern-func-in-ctxt): Likewise. * lisp/emacs-lisp/byte-run.el (byte-run--set-function-type): Update lambda list.
* Rename property 'declared-type' to 'function-type'Andrea Corallo2024-04-291-1/+1
| | | | | | * lisp/emacs-lisp/byte-run.el (byte-run--set-function-type): Rename. (defun-declarations-alist): Update. * lisp/emacs-lisp/comp.el (comp--get-function-cstr): Likewise.
* Move lisp function arg type declarations to the functions itselfAndrea Corallo2024-04-291-34/+3
| | | | | | | | | | | | | | | | | * lisp/emacs-lisp/comp-common.el (comp-primitive-type-specifiers): Remove type declaration of lisp functions. * lisp/window.el (get-lru-window, get-largest-window) (one-window-p): Declare type. * lisp/subr.el (ignore, error, zerop, fixnump, bignump, lsh) (last, eventp, mouse-movement-p, log10, memory-limit) (interactive-p): Likewise. * lisp/simple.el (count-lines, mark, lax-plist-get): Likewise. * lisp/files.el (parse-colon-path): Likewise. * lisp/env.el (getenv): Likewise. * lisp/emacs-lisp/regexp-opt.el (regexp-opt): Likewise. * lisp/emacs-lisp/lisp.el (buffer-end): Likewise. * lisp/emacs-lisp/comp.el (comp-hint-fixnum, comp-hint-cons): Likewise. * lisp/custom.el (custom-variable-p): Likewise.
* Make use of Lisp function declarationsAndrea Corallo2024-04-291-12/+17
| | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename. (comp--get-function-cstr): Define new function. (comp--add-call-cstr, comp--fwprop-call): Update. * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): Update. * lisp/help-fns.el (help-fns--signature): Mention when a type is declared. * lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename.
* Use a dedicated type to represent interpreted-function valuesStefan Monnier2024-04-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change `function` so that when evaluating #'(lambda ...) we return an object of type `interpreted-function` rather than a list starting with one of `lambda` or `closure`. The new type reuses the existing PVEC_CLOSURE (nee PVEC_COMPILED) tag and tries to align the corresponding elements: - the arglist, the docstring, and the interactive-form go in the same slots as for byte-code functions. - the body of the function goes in the slot used for the bytecode string. - the lexical context goes in the slot used for the constants of bytecoded functions. The first point above means that `help-function-arglist`, `documentation`, and `interactive-form`s don't need to distinguish interpreted and bytecode functions any more. Main benefits of the change: - We can now reliably distinguish a list from a function value. - `cl-defmethod` can dispatch on `interactive-function` and `closure`. Dispatch on `function` also works now for interpreted functions but still won't work for functions represented as lists or as symbols, of course. - Function values are now self-evaluating. That was alrready the case when byte-compiled, but not when interpreted since (eval '(closure ...)) signals a void-function error. That also avoids false-positive warnings about "don't quote your lambdas" when doing things like `(mapcar ',func ...)`. * src/eval.c (Fmake_interpreted_closure): New function. (Ffunction): Use it and change calling convention of `Vinternal_make_interpreted_closure_function`. (FUNCTIONP, Fcommandp, eval_sub, funcall_general, funcall_lambda) (Ffunc_arity, lambda_arity): Simplify. (funcall_lambda): Adjust to new representation. (syms_of_eval): `defsubr` the new function. Remove definition of `Qclosure`. * lisp/emacs-lisp/cconv.el (cconv-make-interpreted-closure): Change calling convention and use `make-interpreted-closure`. * src/data.c (Fcl_type_of): Distinguish `byte-code-function`s from `interpreted-function`s. (Fclosurep, finterpreted_function_p): New functions. (Fbyte_code_function_p): Don't be confused by `interpreted-function`s. (Finteractive_form, Fcommand_modes): Simplify. (syms_of_data): Define new type symbols and `defsubr` the two new functions. * lisp/emacs-lisp/cl-print.el (cl-print-object) <interpreted-function>: New method. * lisp/emacs-lisp/oclosure.el (oclosure): Refine the parent to be `closure`. (oclosure--fix-type, oclosure-type): Simplify. (oclosure--copy, oclosure--get, oclosure--set): Adjust to new representation. * src/callint.c (Fcall_interactively): Adjust to new representation. * src/lread.c (bytecode_from_rev_list): * lisp/simple.el (function-documentation): * lisp/help.el (help-function-arglist): Remove the old `closure` case and adjust the byte-code case so it handles `interpreted-function`s. * lisp/emacs-lisp/cl-preloaded.el (closure): New type. (byte-code-function): Add it as a parent. (interpreted-function): Adjust parent (the type itself was already added earlier by accident). * lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Adjust to new representation. (byte-compile): Use `interpreted-function-p`. * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust to new representation. (side-effect-free-fns): Add `interpreted-function-p` and `closurep`. * src/profiler.c (trace_hash, ffunction_equal): Simplify. * lisp/profiler.el (profiler-function-equal): Simplify. * lisp/emacs-lisp/nadvice.el (advice--interactive-form-1): Use `interpreted-function-p`; adjust to new representation; and take advantage of the fact that function values are now self-evaluating. * lisp/emacs-lisp/lisp-mode.el (closure): Remove `lisp-indent-function` property. * lisp/emacs-lisp/disass.el (disassemble-internal): Adjust to new representation. * lisp/emacs-lisp/edebug.el (edebug--strip-instrumentation): Use `interpreted-function-p`. * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Add `closurep` and `interpreted-function-p`. * test/lisp/help-fns-tests.el (help-fns-test-lisp-defun): Adjust to more precise type info in `describe-function`. * test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d--render-entries): Use `interpreted-function-p`. * test/lisp/emacs-lisp/macroexp-resources/vk.el (vk-f4, vk-f5): Don't hardcode function values. * doc/lispref/functions.texi (Anonymous Functions): Don't suggest that function values are lists. Reword "self-quoting" to reflect the fact that #' doesn't return the exact same object. Update examples with the new shape of the return value. * doc/lispref/variables.texi (Lexical Binding): * doc/lispref/lists.texi (Rearrangement): * doc/lispref/control.texi (Handling Errors): Update examples to reflect new representation of function values.
* * Fix `capitalize` entry in `comp-known-type-specifiers` (bug#69631)Andrea Corallo2024-03-081-1/+1
| | | | | * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Fix 'capitalize' entry.
* Add a proper type for obarraysMattias EngdegÄrd2024-02-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new opaque type replaces the previous use of vectors for obarrays. `obarray-make` now returns objects of this type. Functions that take obarrays continue to accept vectors for compatibility, now just using their first slot to store an actual obarray object. obarray-size and obarray-default-size now obsolete. * lisp/obarray.el (obarray-default-size, obarray-size): Declare obsolete. (obarray-make, obarrayp, obarray-clear): Remove from here. * src/fns.c (reduce_emacs_uint_to_hash_hash): Remove from here. * src/lisp.h (struct Lisp_Obarray, OBARRAYP, XOBARRAY, CHECK_OBARRAY) (make_lisp_obarray, obarray_size, check_obarray) (obarray_iter_t, make_obarray_iter, obarray_iter_at_end) (obarray_iter_step, obarray_iter_symbol, DOOBARRAY, knuth_hash): New. (reduce_emacs_uint_to_hash_hash): Moved here. * src/lread.c (check_obarray): Renamed and reworked as... (checked_obarray_slow): ...this. (intern_sym, Funintern, oblookup, map_obarray) (Finternal__obarray_buckets): Adapt to new type. (obarray_index, allocate_obarray, make_obarray, grow_obarray) (obarray_default_bits, Fobarray_make, Fobarrayp, Fobarray_clear): New. * etc/emacs_lldb.py (Lisp_Object): * lisp/emacs-lisp/cl-macs.el (`(,type . ,pred)): * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): * lisp/emacs-lisp/comp.el (comp-known-predicates): * src/alloc.c (cleanup_vector, process_mark_stack): * src/data.c (Ftype_of, syms_of_data): * src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion): * src/pdumper.c (dump_obarray_buckets, dump_obarray, dump_vectorlike): * src/print.c (print_vectorlike_unreadable): * test/lisp/abbrev-tests.el (abbrev-make-abbrev-table-test): * test/lisp/obarray-tests.el (obarrayp-test) (obarrayp-unchecked-content-test, obarray-make-default-test) (obarray-make-with-size-test): Adapt to new type.
* * Fix 'parse-colon-path' entry in 'comp-known-type-specifiers'Andrea Corallo2024-02-221-1/+1
| | | | | * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Fix 'parse-colon-path'.
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* Update handling of advices during preloadJens Schmidt2023-12-041-5/+4
| | | | | | | | | | | * lisp/emacs-lisp/comp-common.el (native-comp-never-optimize-functions): Remove macroexpand and rename-buffer from default value. * lisp/emacs-lisp/comp.el (comp-call-optim-form-call): Document call optimization for advised primitives. * lisp/emacs-lisp/nadvice.el (advice-add): Remove references to TODOs that were completed already earlier. * lisp/loadup.el: Disallow advices during preload. (Bug#67005)
* * Update 'native-comp-never-optimize-functions' versionAndrea Corallo2023-11-221-1/+1
| | | | | * lisp/emacs-lisp/comp-common.el (native-comp-never-optimize-functions): Update version.
* * Add 'eval' to 'native-comp-never-optimize-functions' (bug#67141)Andrea Corallo2023-11-201-1/+2
| | | | | * lisp/emacs-lisp/comp-common.el (native-comp-never-optimize-functions): Add 'eval'.
* Clean-up warnings for non native builds (this time for real)Andrea Corallo2023-11-091-14/+1
| | | | | | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-native-version-dir) (comp-subr-arities-h, native-comp-eln-load-path) (native-comp-enable-subr-trampolines): Remove warning. (comp--compile-ctxt-to-file, comp--init-ctxt, comp--release-ctxt) (comp-el-to-eln-filename) (comp-el-to-eln-rel-filename, native-elisp-load): Declare. * lisp/emacs-lisp/comp-run.el (comp--no-native-compile) (comp-deferred-pending-h, comp-installed-trampolines-h) (native-comp-enable-subr-trampolines): Remove warning. (comp--install-trampoline, comp-el-to-eln-filename) (native-elisp-load): Declare. * lisp/emacs-lisp/comp-common.el: Update.
* Clean-up warnings for non native buildsAndrea Corallo2023-11-091-0/+17
| | | | | | | | | | | | | * lisp/emacs-lisp/comp-common.el (native-comp-enable-subr-trampolines) (comp-installed-trampolines-h, comp-subr-arities-h) (native-comp-eln-load-path, comp-native-version-dir) (comp-deferred-pending-h, comp--no-native-compile): Silence warning. (comp-el-to-eln-rel-filename, native-elisp-load) (comp--release-ctxt, comp--init-ctxt) (comp--compile-ctxt-to-file, comp-el-to-eln-filename) (comp--install-trampoline): Declare function. * lisp/emacs-lisp/comp.el : Update.
* comp: Don't load.el comp when C-h fAndrea Corallo2023-11-091-0/+362
| | | | | * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers) (comp-function-type-spec): Move here.
* comp: Add comp-common.elAndrea Corallo2023-11-091-0/+187
* lisp/emacs-lisp/comp-common.el: New file. (comp-common): New group. (native-comp-verbose, native-comp-never-optimize-functions) (native-comp-async-env-modifier-form, comp-limple-calls) (comp-limple-sets, comp-limple-assignments) (comp-limple-branches, comp-limple-ops) (comp-limple-lock-keywords, comp-log-buffer-name, comp-log) (native-comp-limple-mode, comp-log-to-buffer) (comp-ensure-native-compiler, comp-trampoline-filename) (comp-eln-load-path-eff): Move here * lisp/emacs-lisp/comp-run.el (comp-common): Require. * lisp/emacs-lisp/comp.el (comp-common): Require. * admin/MAINTAINERS: Add comp-common.el * lisp/Makefile.in (COMPILE_FIRST): Likewise. * src/Makefile.in (elnlisp): Likewise.