aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix predicate of `plist-member` on `function-history`Stefan Monnier2026-02-201-1/+1
| | | | | | | | | The keys of this plist are strings and should thus be compared with `equal`. `eq` works surprisingly often (because we often happen to use exactly the same string) but not always. * lisp/loadhist.el (loadhist-unload-element): * src/data.c (add_to_function_history): Pass `equal` to `plist-member`.
* Move the Lisp_Fwd.bufoffset field back to the unionHelmut Eller2026-02-121-1/+1
| | | | | | | | * src/lisp.h (struct Lisp_Fwd): With the predicate enum, we can now pack the offset and the predicate into a one-word struct. (XBUFFER_OFFSET): Use the new field name. * src/buffer.c (DEFVAR_PER_BUFFER): Create the one-word struct. * src/data.c (store_symval_forwarding): Use the new field name.
* Introduce an enum Lisp_Fwd_PredicateHelmut Eller2026-02-121-28/+55
| | | | | | | | | | | | Using an enum instead of a symbol makes it obvious that this field is of no concern to the GC. * src/lisp.h (enum Lisp_Fwd_Predicate): New. (struct Lisp_Fwd): Use it instead of a symbol. * src/buffer.c (DEFVAR_PER_BUFFER): Create the necessary enum constant instead of a symbol. * src/data.c (check_fwd_predicate, check_choice): New helpers. (store_symval_forwarding): Use it.
* Remove struct Lisp_Buffer_ObjfwdHelmut Eller2026-02-121-10/+9
| | | | | | | | | | | | | | * src/lisp.h (struct Lisp_Buffer_Objfwd): Deleted. (struct Lisp_Fwd): Add the fields bufoffset and bufpredicate. Make the type a 1-byte bitfield so that the entire struct still fits in two words. (XBUFFER_OFFSET): Renamed from XBUFFER_OBJFWD. * src/buffer.c (DEFVAR_PER_BUFFER, defvar_per_buffer) (buffer_local_value): Update accordingly. * src/data.c (do_symval_forwarding, store_symval_forwarding) (set_internal, default_value, set_default_internal) (Fmake_local_variable, Fkill_local_variable, Flocal_variable_): Use XBUFFER_OFFSET.
* Remove struct Lisp_Kboard_ObjfwdHelmut Eller2026-02-121-6/+6
| | | | | | | | | * src/lisp.h (struct Lisp_Kboard_Objfwd): Deleted ... (struct Lisp_Fwd): ... replaced with field kbdoffset. (DEFVAR_KBOARD): Use new field. * src/data.c (XKBOARD_OFFSET): Renamed from XKBOARD_OBJFWD. (do_symval_forwarding, store_symval_forwarding (set_default_internal): Use it .
* Remove struct Lisp_ObjfwdHelmut Eller2026-02-121-8/+8
| | | | | | | | | | * src/lisp.h (struct Lisp_Objfwd): Deleted. (struct Lisp_Fwd): Replace it with objvar field. (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_LISP_NOPROX): Use the field. * src/lread.c (defvar_lisp): Updated as needed. * src/pdumper.c (dump_field_fwd): Use the field. * src/data.c (XOBJVAR): Renamed and updated from XOBJFWD. (do_symval_forwarding, store_symval_forwarding): Use it.
* Remove struct Lisp_BoolfwdHelmut Eller2026-02-121-5/+5
| | | | | | | | | * src/lisp.h (struct Lisp Boolfwd): Deleted (struct Lisp_Fwd): Replaced it with a boolvar field. (DEFVAR_BOOL): Update. * src/data.c (XBOOLVAR): Renamed from XBOOLFWD. (do_symval_forwarding, store_symval_forwarding): Use it. * src/pdumper.c (dump_field_fwd): Use boolvar field.
* Remove struct Lisp_IntfwdHelmut Eller2026-02-121-5/+5
| | | | | | | | | | It was a struct with a single field. * src/lisp.h (struct Lisp_Intfwd): Deleted. (struct Lisp_Fwd): Add an intvar field instead. (DEFVAR_INT): Update accordingly. * src/data.c (XINTVAR): Updated and renamed from XFIXNUMFWD. (do_symval_forwarding, store_symval_forwarding): Use it.
* Introduce a struct Lisp_FwdHelmut Eller2026-02-121-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This contains the type and an union of Lisp_Objfwd, Lisp_Intfwd etc. lispfwd is now a pointer to a struct Lisp_Fwd; the void *fwdptr field is gone. * src/lisp.h (struct Lisp_Fwd): New. (Lisp_Intfwd, Lisp_Boolfwd, Lisp_Objfwd, Lisp_Buffer_Objfwd) (Lisp_Kboard_Objfwd): The type is in in Lisp_Fwd. (lispwfd): Is now a pointer to struct Lisp_Fwd. (SYMBOL_BLV, SET_SYMBOL_FWD, XFWDTYPE, BUFFER_OBJFWDP): Update accordingly. (defvar_lisp, defvar_lisp_nopro, defvar_bool, defvar_int) (defvar_kboard): These all take now a Lisp_Fwd. (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL, DEFVAR_INT) (DEFVAR_KBOARD): Update for new types. * src/lread.c (defvar_int, defvar_bool, defvar_lisp_nopro) (defvar_lisp, defvar_kboard): Update for new types. * src/pdumper.c (dump_field_fwd, dump_blv): Update accordingly. (dump_fwd_int, dump_fwd_bool, dump_fwd_obj, dump_fwd_buffer_obj) (dump_fwd): Deleted. * src/buffer.c (DEFVAR_PER_BUFFER, defvar_per_buffer, buffer_local_value) (set_buffer_internal_1): Update accordingly for new types. * src/data.c (XBOOLFWD, XKBOARD_OBJFWD, XFIXNUMFWD, XOBJFWD, boundp) (store_symval_forwarding, swap_in_global_binding) (swap_in_symval_forwarding, find_symbol_value, set_internal) (default_value, set_default_internal, make_blv, Fmake_local_variable): Update accordingly.
* ; Add 2026 to copyright years.Sean Whitton2026-01-011-1/+1
|
* Fix recently-introduced ash bugPaul Eggert2025-11-271-4/+5
| | | | | | | | | | Problem reported by John Paul Adrian Glaubitz (bug#79876). * src/data.c (Fash): Don’t assume stdc_leading_zeros, which returns an unsigned integer of unspecified width, returns a value narrower than EMACS_INT. Also, don’t munge the code to worry about stdc_leading_zeros (0); unlike GCC’s __builtin_clz, stdc_leading_zeros works fine on 0. And use a temporary to avoid a cast.
* Fix more mis-declarations of non-const functionsPaul Eggert2025-11-201-2/+2
| | | | | | | | | Problem reported by Helmut Eller in: https://lists.gnu.org/r/emacs-devel/2025-11/msg00809.html * src/data.c (Fsymbol_with_pos_p, Fnatnump): * src/fns.c (Fproper_list_p): * src/gnutls.c (Fgnutls_errorp): Now pure, not const.
* Fix mis-declarations of non-const functionsPaul Eggert2025-11-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | Problem for mpz_get_d_rounded reported by Helmut Eller in: https://lists.gnu.org/r/emacs-devel/2025-11/msg00795.html * lib-src/make-docfile.c (DEFUN_pure): New constant. (write_globals, scan_c_stream): Support "attributes: pure". * src/bignum.h (mpz_get_d_rounded): * src/data.c (Fsymbolp, Fmodule_function_p, Fintegerp, Fnumberp): * src/lisp.h (bignum_to_double, bignum_to_intmax) (bignum_to_uintmax, bignum_bufsize): Now pure, not const, since they depend on current state. For example, Fsymbolp now inspects symbols_with_pos_enabled, and the bignum functions inspect bignum contents in memory. * src/data.c (Feq): * src/xfaces.c (Fface_attribute_relative_p): No longer const, since they might abort when debugging. * src/pdumper.h (pdumper_object_p, pdumper_cold_object_p) (pdumper_find_object_type, pdumper_object_p_precise): These are not const functions. But there is no need to declare them to be pure, either, as they’re inline so the compiler can figure it out.
* Change EQ to move slow code path into a separate functionPip Cet2025-09-221-0/+10
| | | | | * src/data.c (slow_eq): New function. * src/lisp.h (EQ): Call it.
* ; * src/data.c (Fash): GCC argument signedness quibbleMattias Engdegård2025-09-011-1/+1
|
* * src/data.c (Fash): Speed up when argument and result are fixnums.Mattias Engdegård2025-09-011-9/+17
|
* Disallow string data resizing (bug#79784)Mattias Engdegård2025-08-241-29/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Only allow string mutation that is certain not to require string data to be resized and reallocated: writing bytes into a unibyte string, and changing ASCII to ASCII in a multibyte string. This ensures that mutation will never transform a unibyte string to multibyte, that the size of a string in bytes never changes, and that the byte offsets of characters remain the same. Most importantly, it removes a long-standing obstacle to reform of string representation and allow for future performance improvements. * src/data.c (Faset): Disallow resizing string mutation. * src/fns.c (clear_string_char_byte_cache): * src/alloc.c (resize_string_data): Remove. * test/src/data-tests.el (data-aset-string): New test. * test/lisp/subr-tests.el (subr--subst-char-in-string): Skip error cases. * test/src/alloc-tests.el (aset-nbytes-change): Remove test that is no longer relevant. * doc/lispref/strings.texi (Modifying Strings): * doc/lispref/sequences.texi (Array Functions): * doc/lispref/text.texi (Substitution): Update manual. * etc/NEWS: Announce.
* comp.el: Fix minor corner-case annoyancesStefan Monnier2025-07-171-2/+3
| | | | | | * lisp/emacs-lisp/comp.el (comp--native-compile): Avoid `%s` on objects that may not have names. * src/data.c (Ffset): Don't compute trampoline for no-op `fset`.
* Merge from savannah/emacs-30Po Lu2025-03-061-3/+5
|\ | | | | | | 9065423e709 ; Improve documentation of 2 symbol-related functions
| * ; Improve documentation of 2 symbol-related functionsEli Zaretskii2025-03-061-3/+5
| | | | | | | | | | * src/data.c (Fremove_pos_from_symbol, Fbare_symbol): Doc fixes. (Bug#75290)
| * Update copyright year to 2025Stefan Kangas2025-01-021-1/+1
| | | | | | | | Run "TZ=UTC0 admin/update-copyright".
* | ; Grammar fixes for "native-compiled"Stefan Kangas2025-02-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Prefer "native-compiled" to "native compiled". The adjective "native-compiled" with the hyphen is generally more consistent with the typical pattern in English, especially when the compound modifies a noun (e.g., "native-compiled code"). 2. Prefer "natively compiled" to "natively-compiled". The adverb "natively" modifies "compiled", and it is standard not to hyphenate an adverb + adjective combination when the adverb ends in -ly (e.g., "code that is natively compiled"). For example, note that we say "high-speed internet" but "highly performant code". * Makefile.in (dest): * configure.ac (HAVE_NATIVE_COMP): * doc/emacs/building.texi (Lisp Libraries): * doc/lispref/compile.texi (Native Compilation) (Native-Compilation Functions, Native-Compilation Variables): * doc/lispref/functions.texi (What Is a Function, Declare Form): * doc/lispref/loading.texi (How Programs Do Loading, Library Search): * etc/NEWS: * etc/NEWS.28: * etc/NEWS.29: * etc/NEWS.30: * lisp/emacs-lisp/comp-common.el (native-comp-never-optimize-functions) (comp-function-type-spec): * lisp/emacs-lisp/comp-cstr.el: * lisp/subr.el (locate-eln-file): * src/comp.c (SETJMP_NAME, syms_of_comp): * src/data.c (Fsubrp, Fnative_comp_function_p, Fsubr_native_lambda_list): * src/lread.c (Fload): * src/pdumper.c (dump_do_dump_relocation): * test/src/comp-tests.el (lambda-return2): Avoid grammatically incorrect variations on "natively compiled" and "native-compiled". (Bug#56727)
* | Merge branch 'scratch/no-purespace' into 'master'Stefan Kangas2025-02-011-27/+11
|\ \
| * | Pure storage removal: Replace calls to removed functionsPip Cet2024-12-121-20/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (string_bytes, pin_string, valid_lisp_object_p) (process_mark_stack, survives_gc_p, syms_of_alloc): * src/androidterm.c (android_term_init): Replace call to 'build_pure_c_string'. * src/buffer.c (init_buffer_once, syms_of_buffer): * src/bytecode.c (exec_byte_code): * src/callint.c (syms_of_callint): * src/callproc.c (syms_of_callproc): * src/category.c (Fdefine_category): * src/coding.c (syms_of_coding): * src/comp.c (Fcomp__compile_ctxt_to_file0) (maybe_defer_native_compilation, syms_of_comp): * src/data.c (Fsetcar, Fsetcdr, Fdefalias, Faset, syms_of_data): * src/dbusbind.c (syms_of_dbusbind): * src/doc.c (Fsnarf_documentation): * src/emacs-module.c (syms_of_module): * src/eval.c (Finternal__define_uninitialized_variable) (Fdefconst_1, define_error, syms_of_eval): * src/fileio.c (syms_of_fileio): * src/fns.c (Ffillarray, Fclear_string, check_mutable_hash_table): * src/fontset.c (syms_of_fontset): * src/frame.c (make_initial_frame): * src/haikufns.c (syms_of_haikufns): * src/intervals.c (create_root_interval): * src/keyboard.c (syms_of_keyboard): * src/keymap.c (Fmake_sparse_keymap, Fset_keymap_parent) (store_in_keymap, syms_of_keymap): * src/lisp.h: * src/lread.c (Fload, read0, intern_c_string_1, define_symbol) (Fintern, defsubr, syms_of_lread): * src/pdumper.c (Fdump_emacs_portable): * src/pgtkfns.c (syms_of_pgtkfns): * src/pgtkterm.c (syms_of_pgtkterm): * src/process.c (syms_of_process): * src/search.c (syms_of_search): * src/sqlite.c (syms_of_sqlite): * src/syntax.c (syms_of_syntax): * src/treesit.c (syms_of_treesit): * src/w32fns.c (syms_of_w32fns): * src/xdisp.c (syms_of_xdisp): * src/xfaces.c (syms_of_xfaces): * src/xfns.c (syms_of_xfns): * src/xftfont.c (syms_of_xftfont): * src/xterm.c (syms_of_xterm): Remove calls to 'PURE_P', 'CHECK_IMPURE', 'Fpurecopy', and replace calls to 'build_pure_c_string', 'pure_list', 'pure_listn', etc., by impure equivalents.
| * | Pure storage removal: Main partPip Cet2024-12-121-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (pure, PUREBEG, purebeg, pure_size) (pure_bytes_used_before_overflow, pure_bytes_used_lisp) (pure_bytes_used_non_lisp): Remove definitions. (init_strings): Make empty strings impure. (cons_listn): Drop 'cons' argument. (pure_listn): Remove function. (init_vectors): Allocate zero vector manually to avoid freelist issues. (pure_alloc, check_pure_size, find_string_data_in_pure) (make_pure_string, make_pure_c_string, pure_cons, make_pure_float) (make_pure_bignum, make_pure_vector, purecopy_hash_table): Remove functions. (purecopy): Reduce to hash consing our argument. (init_alloc_once_for_pdumper): Adjust to lack of pure space. (pure-bytes-used): Adjust docstring to mark as obsolete. (purify-flag): Keep for hash consing, but adjust docstring. * src/bytecode.c: * src/comp.c: Don't include "puresize.h". * src/conf_post.h (SYSTEM_PURESIZE_EXTRA): Remove definition. * src/data.c (pure_write_error): Remove function. * src/deps.mk: Remove puresize.h dependency throughout. * src/emacs.c: * src/fns.c: * src/intervals.c: * src/keymap.c: Don't include "puresize.h". * src/lisp.h (struct Lisp_Hash_Table): Adjust comment. (pure_listn, pure_list, build_pure_c_string): Remove. * src/w32heap.c (FREEABLE_P): Don't do use 'dumped_data'. (malloc_before_dump, realloc_before_dump, free_before_dump): Remove functions. * src/w32heap.h: Adjust prototype. * lisp/loadup.el: * lisp/startup.el: Remove purespace code.
* | | Signal error when keyword/arg list is malformedRobert Pluim2025-01-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/data.c (syms_of_data): Add Qmalformed_keyword_arg_list error symbol. * src/process.c (Fmake_process, Fmake_pipe_process) (Fserial_process_configure, Fmake_serial_process) (Fmake_network_process): Signal Qmalformed_keyword_arg_list when the argument list length is odd. * src/sound.c (parse_sound): Also here.. * src/w32fns.c (Fw32_notification_notify): ..and here. (Bug#75584)
* | | Remove redundant case_Lisp_Int macroStefan Kangas2025-01-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The case_Lisp_Int macro was originally introduced with different definitions depending on USE_2_TAGS_FOR_INTS. However, since commit 2b5701247845, we have assumed that USE_2_TAGS_FOR_INTS is always defined, and the macro has only a single definition. As a result, the macro is now unnecessary, and replacing it with standard C case labels improves readability and understanding. * src/lisp.h (case_Lisp_Int): Delete macro. * src/alloc.c (process_mark_stack, survives_gc_p): * src/data.c (Fcl_type_of): * src/fns.c (value_cmp, sxhash_obj): * src/pdumper.c (dump_object): * src/print.c (print_object): * src/xfaces.c (face_attr_equal_p): Remove uses of above macro.
* | | Replace call[1-8] with callnStefan Kangas2025-01-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the introduction of the 'calln' macro, the 'call1', 'call2', ..., 'call8' macros are just aliases for the former. This is slightly misleading and potentially unhelpful. The number of arguments N can also easily go out-of-synch with the used alias callN. There is no reason not to replace these aliases with using 'calln' directly. To reduce the risk for mistakes, the tool Coccinelle was used to make these changes. See <https://coccinelle.gitlabpages.inria.fr/website/>. * src/alloc.c, src/androidvfs.c, src/androidfns.c, src/buffer.c: * src/callint.c, src/callproc.c, src/casefiddle.c, src/charset.c: * src/chartab.c, src/cmds.c, src/coding.c, src/composite.c: * src/data.c, src/dbusbind.c, src/dired.c, src/doc.c: * src/emacs.c, src/eval.c, src/fileio.c, src/filelock.c: * src/fns.c, src/frame.c, src/gtkutil.c, src/haikufns.c: * src/haikumenu.c, src/image.c, src/insdel.c, src/intervals.c: * src/keyboard.c, src/keymap.c, src/lisp.h, src/lread.c: * src/minibuf.c, src/nsfns.m, src/nsselect.m, src/pgtkfns.c: * src/pgtkselect.c, src/print.c, src/process.c, src/sort.c: * src/syntax.c, src/textconv.c, src/textprop.c, src/undo.c: * src/w32fns.c, src/window.c, src/xfaces.c, src/xfns.c: * src/xmenu.c, src/xselect.c, src/xterm.c: Replace all uses of 'call1', 'call2', ..., 'call8' with 'calln'.
* | | Prefer calln to CALLN where applicableStefan Kangas2025-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/callint.c (read_file_name): * src/comp.c (CALL0I, CALL1I, CALL2I, CALL4I, declare_imported_func): * src/data.c (Ffset, notify_variable_watchers): * src/eval.c (Ffuncall_with_delayed_message): * src/keymap.c (Fdescribe_buffer_bindings): * src/minibuf.c (Fread_buffer, Fcompleting_read): * src/pdumper.c (Fdump_emacs_portable): * src/print.c (print_vectorlike_unreadable): * src/treesit.c (treesit_traverse_match_predicate) (treesit_build_sparse_tree): Prefer calln to CALLN.
* | | Update copyright year to 2025Paul Eggert2025-01-011-1/+1
|/ / | | | | | | Run "TZ=UTC0 admin/update-copyright".
* | Merge from origin/emacs-30Eli Zaretskii2024-11-021-3/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | 98796f95fa5 Work on proced-tests.el 8a4d13e370c ; * doc/lispref/frames.texi (Yanking Media): Add index en... 0aae02a3741 * lisp/files.el (require-with-check): Be a bit more lenie... cc6a11f4832 (with-peg-rules): Fix references to rulesets (bug#74018) 70f084db2ff ; * etc/NEWS: Fix typo (bug#74066). 9e1abf11fc1 Tweak doc w.r.t to "void function" (bug#73886) 7a8ca202c5e Fix flakey proced refine tests (Bug#73441) 55a8cec013e Another 'void' update
| * Tweak doc w.r.t to "void function" (bug#73886)Stefan Monnier2024-10-271-3/+3
| | | | | | | | | | | | | | | | * doc/lispref/functions.texi (Function Cells): Avoid talking about the function cell being void. * src/data.c (Fboundp, Ffmakunbound, Fsymbol_function): Don't suggest that "void" can be considered as a kind of value.
* | Merge from origin/emacs-30Eli Zaretskii2024-10-271-6/+6
|\ \ | |/ | | | | | | | | | | c78b4d2b31d Fix doc string of 'wdired-use-dired-vertical-movement' b0aaee93fde Update the documentation of void functions 299a1f24075 ; * lisp/vc/log-edit.el (log-edit-diff-function): Grammar... 67a27ff53bf ; Fix typos
| * Update the documentation of void functionsEli Zaretskii2024-10-271-6/+6
| | | | | | | | | | | | | | * doc/lispref/functions.texi (Function Cells): * src/data.c (Ffboundp, Ffmakunbound, Fsymbol_function): Update documentation to the changes of how void functions are represented since Emacs 24.5. (Bug#73886)
* | Merge from origin/emacs-30Eli Zaretskii2024-08-171-1/+3
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5c9de704cc8 ; * admin/make-tarball.txt: Minor copyedits. 3fc16357832 ; * doc/lispref/strings.texi (Text Comparison): Improve i... 45a78ec6c57 * lisp/files.el (require-with-check): Improve error messa... 9a04b99b3d3 ; * src/data.c (Fsubrp): Improve docstring. 4f3e8c3b4ed Improve documentation of ERT ed8904937ec Disambiguate minor-mode variable in its function docstring 505139e0bad Fix project-dired keybinding in manual 9bedb957beb Improve documentation of time-parsing functions # Conflicts: # doc/lispref/os.texi # lisp/calendar/iso8601.el # lisp/calendar/parse-time.el
| * ; * src/data.c (Fsubrp): Improve docstring.Andrea Corallo2024-08-151-1/+3
| |
* | Replace some EQ with BASE_EQMattias Engdegård2024-08-151-6/+6
| | | | | | | | | | | | | | | | | | | | | | * src/eval.c (FletX, Flet, funcall_lambda) (let_shadows_buffer_binding_p): * src/data.c (set_blv_found, set_internal, default_value) (set_default_internal, Flocal_variable_p): * src/buffer.c (Fkill_buffer): (mouse_face_overlay_overlaps, compare_overlays) (report_overlay_modification): BASE_EQ is safe because we don't actually compare symbols here.
* | Reduce type checks in arithcompareMattias Engdegård2024-07-271-30/+56
| | | | | | | | | | | | * src/data.c (coerce_marker, not_number_or_marker): New. (arithcompare): Don't use NUMBERP to check types up-front since we are going to branch on types anyway.
* | * src/data.c (arithcompare): Simplify fixnum/bignum comparisons.Mattias Engdegård2024-07-271-2/+4
| | | | | | | | Noticed by Pip Cet.
* | Simplify and speed up numeric comparisonsMattias Engdegård2024-07-271-84/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | This makes comparison functions (=, /=, <, <=, >, >=, min, max) quite a bit faster (10-20 %). Bytecode ops on fixnums are not affected, nor is `value<`. * src/data.c (arithcompare): Simplify the code to reduce the number of branches. Remove the comparison code argument; instead, return the relation encoded as bits, which can be tested cheaply. All callers adapted. * src/lisp.h (enum Arith_Comparison): Remove. (Cmp_Bit_*, cmp_bits_t): New.
* | Prohibit unbinding of built-in variablesPo Lu2024-07-221-23/+22
|/ | | | | | | | * src/data.c (set_internal): Signal error if a BLV with a redirect or a forwarded symbol is being unbound. * test/src/data-tests.el (binding-test-makunbound-built-in): New test.
* Rename `SUBR_NATIVE_COMPILED` to `NATIVE_COMP_FUNCTION` (bug#71123)Stefan Monnier2024-05-281-5/+5
| | | | | | | | | | | | | | | Keep the name consistent with the naming used in the ELisp world. * src/pdumper.c (dump_object_emacs_ptr, dump_do_fixup): * src/eval.c (eval_sub, funcall_general, funcall_lambda): * src/alloc.c (CHECK_ALLOCATED_AND_LIVE_SYMBOL, survives_gc_p): * src/data.c (Fcl_type_of, Ffset, Fnative_comp_function_p) (Fsubr_native_lambda_list, Finteractive_form): * src/comp.c (check_comp_unit_relocs): * src/bytecode.c (exec_byte_code): * src/lisp.h (NATIVE_COMP_FUNCTIONP, NATIVE_COMP_FUNCTION_DYNP): Rename from `SUBR_NATIVE_COMPILEDP` and `SUBR_NATIVE_COMPILED_DYNP`.
* Rename `subr-native-elisp` to `native-comp-function` (bug#71123)Stefan Monnier2024-05-281-6/+6
| | | | | | | | | | | | | | | | | Now that this type name is displayed in *Help*, it is more important to use a name that is less weird for the unsuspecting user. * lisp/emacs-lisp/cl-preloaded.el (cl-functionp): Adjust to new name of native function's type. (subr-native-elisp-p): Redefine as an obsolete alias. (native-comp-function): Rename from `subr-native-elisp` * src/data.c (Fcl_type_of): Return `Qnative_comp_function` i.s.o `Qsubr_native_elisp`. (Fnative_comp_function_p): Rename from `Fsubr_native_elisp_p`. (syms_of_data): Adjust accordingly. * src/doc.c (Fsubr_documentation): Use new `Fnative_comp_function_p` name.
* Restore specbound keyboard-locals in the correct KBOARDPo Lu2024-05-231-22/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/variables.texi (Intro to Buffer-Local): Fix typo in documentation. * src/data.c (KBOARD_OBJFWDP): Move to lisp.h. (kboard_for_bindings): New variable. (do_symval_forwarding, store_symval_forwarding): Call kboard_for_bindings rather than retrieving this value directly. (set_default_internal): New argument WHERE; if valcontents be a Lisp_Kboard_Objfwd and WHERE be specified, save the binding there. All callers changed. * src/eval.c (specpdl_where): Adjust for changes in structure layout. (specpdl_kboard): New function. (do_specbind): Clear let->where.kbd in ordinary SPECPDL_LETs, and set it to the kboard where the binding will be installed if binding keyboard forwards. (specbind, do_one_unbind, specpdl_unrewind): Provide specpdl_kboard in invocation of set_default_internal. * src/keyboard.c (delete_kboard): Clean thread specpdls of references to kboards. * src/keyboard.h (KBOARD_OBJFWDP): Move from data.c. * src/lisp.h (union specbinding) <let.where>: Convert into union of KBOARD and Lisp_Object. * src/thread.c (all_threads): Export. * src/thread.h: Adjust correspondingly.
* Prefer stdbit.h to count-one-bits.h etcPaul Eggert2024-05-181-90/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | C23's <stdbit.h> in the long run should be better supported than Gnulib's count-one-bits.h and similar headers, so switch to the C23 primitives, with a Gnulib fallback for platforms lacking C23. * admin/merge-gnulib (GNULIB_MODULES): Remove count-leading-zeros, count-one-bits, count-trailing-zeros. Add stdc_bit_width, stdc_count_ones, stdc_trailing_zeros. * lib/count-leading-zeros.c, lib/count-leading-zeros.h: * lib/count-one-bits.c, lib/count-one-bits.h: * lib/count-trailing-zeros.c, lib/count-trailing-zeros.h: Remove. * lib/stdbit.c, lib/stdbit.in.h, lib/stdc_bit_width.c: * lib/stdc_count_ones.c, lib/stdc_leading_zeros.c: * lib/stdc_trailing_zeros.c, m4/stdbit_h.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/data.c: Do not include count-one-bits.h, count-trailing-zeros.h. Instead, rely on lisp.h including stdbit.h. (Flogcount, Fbool_vector_count_population) (Fbool_vector_count_consecutive): Use stdbit.h macros instead of count-one-bits.h and count-trailing-zeros.h macros. (shift_right_ull, count_one_bits_word, pre_value) (count_trailing_zero_bits): Remove; no longer needed. * src/lisp.h: Include stdbit.h instead of count-leading-zeros.h. (elogb): Use stdbit.h macro instead of count-leading-zeros.h macro.
* Use a dedicated type to represent interpreted-function valuesStefan Monnier2024-04-281-15/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* (COMPILED): Rename to CLOSUREStefan Monnier2024-04-281-11/+11
| | | | | | | | | | | | | | | | | | In preparation for the use of `PVEC_COMPILED` objects for interpreted functions, rename them to use a more neutral name. * src/lisp.h (enum pvec_type): Rename `PVEC_COMPILED` to `PVEC_CLOSURE`. (enum Lisp_Compiled): Use `CLOSURE_` prefix i.s.o `COMPILED_`. Also use `CODE` rather than `BYTECODE`. (CLOSUREP): Rename from `COMPILEDP`. (enum Lisp_Closure): Rename from `Lisp_Compiled`. * src/alloc.c, src/bytecode.c, src/comp.c, src/data.c, src/eval.c, * src/fns.c, src/lisp.h, src/lread.c, src/pdumper.c, src/print.c, * src/profiler.c: Rename all uses accordingly. * src/.gdbinit (xclosure): Rename from `xcompiled`. (xcompiled): New obsolete alias. (xpr): Adjust accordingly. Also adjust to new PVEC_CLOSURE tag name.
* Fix implicit declaration of bswap_{32,64}Andreas Schwab2024-03-301-1/+0
| | | | | * src/data.c: Move include of <byteswap.h> ... * src/lisp.h: ... here.
* Add `value<` (bug#69709)Mattias Engdegård2024-03-291-24/+2
| | | | | | | | | | | | | | | | | | | | | | It's a general-purpose polymorphic ordering function, like `<` but for any two values of the same type. * src/data.c (syms_of_data): Add the `type-mismatch` error. (bits_word_to_host_endian): Move... * src/lisp.h (bits_word_to_host_endian): ...here, and declare inline. * src/fns.c (Fstring_lessp): Extract the bulk of this function to... (string_cmp): ...this 3-way comparison function, for use elsewhere. (bool_vector_cmp, value_cmp, Fvaluelt): New. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns): Add `value<`, which is pure and side-effect-free. * test/src/fns-tests.el (fns-value<-ordered, fns-value<-unordered) (fns-value<-type-mismatch, fns-value<-symbol-with-pos) (fns-value<-circle, ert-deftest fns-value<-bool-vector): New tests. * doc/lispref/sequences.texi (Sequence Functions): * doc/lispref/numbers.texi (Comparison of Numbers): * doc/lispref/strings.texi (Text Comparison): Document the new value< function. * etc/NEWS: Announce.
* (primitive-function): New typeStefan Monnier2024-03-181-2/+2
| | | | | | | | | | | | | | | | | | | The type hierarchy and `cl-type-of` code assumed that `subr-primitive` only applies to functions, but since it also accepts special-forms it makes it an unsuitable choice since it can't be a subtype of `compiled-function`. So, use a new type `primitive-function` instead. * lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832). (primitive-function-p): New function. * lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename from `subr-primitive` since `subr-primitive-p` means something else. * src/data.c (Fcl_type_of): Return `primitive-function` instead of `subr-primitive` for C functions. (syms_of_data): Adjust accordingly. * test/src/data-tests.el (data-tests--cl-type-of): Remove workaround.