summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-01-23(struct charset): Remove dependency on hash-table internalsStefan Monnier
`struct charset` kept an index into the internal `key_and_value` array of hash tables, which only worked because of details of how hash-tables are handled. Replace it with a reference to the value stored at that location in the hash-table, which saves us an indirection while at it. * src/charset.h (struct charset): Replace `hash_index` field with `attributes` field. (CHARSET_ATTRIBUTES): Simplify accordingly. (CHARSET_HASH_INDEX): Delete unused macro. * src/charset.c (Fdefine_charset_internal): * src/pdumper.c (dump_charset): Adjust accordingly. (dump_charset_table): Set the referrer since that's needed while dumping Lisp_Object fields.
2024-01-23; Fix DOHASHGerd Möllmann
2024-01-23Correct crash when executing IP within twilight zonePo Lu
* src/sfnt.c (sfnt_address_zp2, sfnt_address_zp1) (sfnt_address_zp0): Don't save into X or Y if the zone is set to the twilight zone and they are NULL.
2024-01-23* src/sfnt.c (sfnt_mul_f26dot6_fixed): Correct typo in last change.Po Lu
2024-01-22* src/regex-emacs.c (forall_firstchar_1): Improve corner caseStefan Monnier
Fixes a "FORALL_FIRSTCHAR: Broken assumption2!!" warning with: "^\\(# *\\)\\([^ ]+?\\) *: *\\(.*?\\(?:\n\\1[ \t]+.*?\\)*\\)[[:space:]]*$"
2024-01-22* src/pdumper.c (dump_object_needs_dumping_p): SimplifyStefan Monnier
(hash_table_contents): Use DOHASH.
2024-01-22Do not overwrite flags of succeeding points during generic movePo Lu
* src/sfnt.c (sfnt_move): Save FLAGS and restore it after X axis movement loop.
2024-01-22Correct values of INSTCTRL flags testedPo Lu
* src/sfnt.c (sfnt_mul_f26dot6_round): New function. (sfnt_mul_f26dot6_fixed): Replace by call to sfnt_mul_fixed_round. (MUL): Round result, as the Apple and MS scalers do. (sfnt_interpret_control_value_program): The instruction control flag which reverts CVT modifications is 2, not 4.
2024-01-21Add an eassert back to XSYMBOLPaul Eggert
Problem reported by Alan Mackenzie in: https://lists.gnu.org/r/emacs-devel/2024-01/msg00755.html * src/lisp.h (XSYMBOL): If the arg is not a bare symbol, then eassert (symbols_with_pos_enabled). This shouldn’t affect code generated for regular builds, and could catch caller errors in debug builds. For debug builds although this slows things down XSYMBOL should still be faster than it was the day before yesterday, as there’s still no need to eassert (SYMBOLP (a)).
2024-01-21Speed up builtin_lisp_symbol when not optimizingPaul Eggert
This should help when building with --enable-checking and compiling with gcc -O0. Problem reorted by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2024-01/msg00770.html * src/lisp.h (lisp_h_builtin_lisp_symbol): New macro, with a body equivalent in effect to the old ‘builtin_lisp_symbol’ but faster when not optimizing. (builtin_lisp_symbol): Use it. If DEFINE_KEY_OPS_AS_MACROS, also define as macro.
2024-01-21Change HASH_UNUSED_ENTRY_KEY from Qunbound to NULL floatMattias Engdegård
This removes hacks from code that had to be careful not to use Qunbound as a hash table key, at the cost of a minor hack in the GC marker. * src/lisp.h (INVALID_LISP_VALUE, HASH_UNUSED_ENTRY_KEY): Define as a null-pointer float. * src/alloc.c (process_mark_stack): Add hack to ignore that value. * src/pdumper.c (dump_object_needs_dumping_p) (pdumper_init_symbol_unbound, pdumper_load): * src/print.c (PRINT_CIRCLE_CANDIDATE_P): Remove hacks for Qunbound.
2024-01-21Make better use of fixnum range in sxhash etcMattias Engdegård
Recent hash table changes reduced the range of sxhash, sxhash-eq etc to [0,2**32) on platforms with 62-bit fixnums. This change makes them use the full fixnum range again. Hash table hashing is unaffected. * src/fns.c (sxhash_eq, sxhash_eql): New. (hash_hash_to_fixnum): Replace with... (reduce_emacs_uint_to_fixnum): ...this. (hashfn_eq, hashfn_eql, Fsxhash_eq, Fsxhash_eql, Fsxhash_equal) (Fsxhash_equal_including_properties): Use the new functions.
2024-01-21Clarify permitted mutation in `maphash` documentationMattias Engdegård
* doc/lispref/hash.texi (Hash Access): * src/fns.c (Fmaphash): Make it clear what the function passed as argument can do. Until now these rules were unwritten, and are still unenforced.
2024-01-21Add C macro for hash table iterationMattias Engdegård
This removes some boilerplate code and further reduces dependencies on hash table implementation internals. * src/lisp.h (DOHASH): New. * src/comp.c (compile_function, Fcomp__compile_ctxt_to_file): * src/composite.c (composition_gstring_cache_clear_font): * src/emacs-module.c (module_global_reference_p): * src/fns.c (Fmaphash): * src/json.c (lisp_to_json_nonscalar_1): * src/minibuf.c (Ftest_completion): * src/print.c (print): Use it instead of a hand-written loop.
2024-01-20Speed up make_lisp_symbol when debuggingPaul Eggert
* src/lisp.h (make_lisp_symbol): In eassert use XBARE_SYMBOL rather than XSYMBOL. This is safe because the symbol must be bare. The change speeds up make_lisp_symbol when debugging.
2024-01-20Simplify and tune XSYMBOLPaul Eggert
* src/lisp.h (XSYMBOL): Simplify and tune. There is no need to examine symbols_with_pos_enabled here, since the arg must be a symbol so if it's not a bare symbol then it must be a symbol_with_pos; and checking whether a symbol is bare is cheap. With Ubuntu 23.10 on a Xeon W-1350, this shrank Emacs’s executable text size by 0.1% and sped up a default build of all *.elc files by 0.4%. Remove unnecessary eassert, since XBARE_SYMBOL and XSYMBOL_WITH_POS have easserts that suffice.
2024-01-20Be more systematic about parens in C source codePaul Eggert
Be more systematic about putting space before paren in calls, and in avoiding unnecessary parentheses in macros. This was partly inspired by my wading through gcc -E output while debugging something else, and seeing too many parens. This patch does not change the generated .o files on my platform.
2024-01-20Omit some parensPaul Eggert
* src/lisp.h (XBARE_SYMBOL, XSYMBOL): Omit parentheses that are no longer needed now that we have symbols with positions and these symbols are never macros.
2024-01-20Pacify gcc -Wsuggest-attribute=mallocPaul Eggert
* src/lisp.h (hash_table_alloc_bytes): Declare with ATTRIBUTE_MALLOC_SIZE ((1)).
2024-01-20Merge from origin/emacs-29Eli Zaretskii
5bb5590dec9 Fix blunder in labeled_narrow_to_region 78ddb32fadb Fix documentation of icon-elements 725a3f32f8b ; Fix typos in symbol names 6653ee66ca5 Improve two docstrings in ox-latex 7d869a04029 Doc fix in auth-source-read-char-choice f149de223bf Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... 1f97a878795 Fix info-xref-tests 51f391998b1 Add @kindex in manuals for existing keybindings on 'C-x x...
2024-01-20Round projs computed executing IP/ISECT instructions and improve IUPPo Lu
* src/sfnt.c (sfnt_multiply_divide_rounded): New function. (sfnt_multiply_divide_signed): Always round values, as fonts which rely on IP to move points in concert with prior motion and subsequently round such points with MDAP are sensitive to minor deviations in the behavior of the former instruction. (load_unscaled): New macro. (IUP_SINGLE_PAIR, sfnt_interpret_iup_1): Compute ratio w/ unscaled points if possible.
2024-01-19Fix another cause of superfluous inotify signals on AndroidPo Lu
* src/android.c (android_select): If the event queue isn't empty upon the initial check, clear all fdsets.
2024-01-18Don't use Qunbound as hash table key when printing (bug#68244)Mattias Engdegård
This flaw could cause an assertion failure. * src/print.c (PRINT_CIRCLE_CANDIDATE_P): Don't consider Qunbound a print-circle candidate; it should never be seen by Lisp anyway.
2024-01-18Only use a hash index size of 1 for tables with size 0 (bug#68244)Mattias Engdegård
This invariant was intended but insufficiently enforced which could lead to an assertion failure. * src/fns.c (hash_index_size): Assume size>0, and return a value >1. (make_hash_table): Only use hash_index_size for size>0.
2024-01-18; * src/androidterm.c (handle_one_android_event): Fix typo.Po Lu
2024-01-17Increase accuracy of IP instructionPo Lu
* src/sfnt.c (sfnt_interpret_ip): Avoid precision loss by retrieving original positions from the unscaled outline, whenever possible.
2024-01-16Update pdumper hashes for buffer and Lisp_Hash_TableMattias Engdegård
* src/pdumper.c (dump_hash_table): Update for changes in recent hash-table patch suites (bug#68244). (dump_buffer): Update for case-fold-search changes (bug#66117).
2024-01-16More efficient hash table thawingMattias Engdegård
* src/fns.c (hash_table_thaw): Don't allocate anything for empty tables. Don't initialise the next vector twice. (maybe_resize_hash_table): Factor out min_size constant.
2024-01-15Simplify 'without-restriction'Gregory Heytings
This simplification is symmetrical to 01fb898420. * src/editfns.c: (Finternal__labeled_widen): Add a call to 'Fwiden', and rename from 'internal--unlabel-restriction'. (unwind_labeled_narrow_to_region): Use the renamed function, and remove the call to 'Fwiden'. (syms_of_editfns): Rename the symbol. * lisp/subr.el (internal--without-restriction): Use the renamed function. (cherry picked from commit 9e9e11648d3d5514de85edfb69f0949a062f4716)
2024-01-15; * src/xterm.c (x_focus_frame): Insert missing unblock_input.Po Lu
2024-01-14Fix blunder in labeled_narrow_to_regionGregory Heytings
* src/editfns.c (labeled_narrow_to_region): Record point before, instead of after, calling narrow-to-region; otherwise point may already have been changed. Fixes bug#66764.
2024-01-14Make object-intervals linear instead of quadraticMattias Engdegård
* src/fns.c (collect_interval, Fobject_intervals): Build the returned list in reverse instead of appending single elements.
2024-01-14Speed up sxhash-equal-including-propertiesMattias Engdegård
This function now no longer conses at all. Previously, it constructed a list structure of all string intervals for the sole purpose of hashing. * src/fns.c (hash_interval): New. (Fsxhash_equal_including_properties): Use it instead of collect_interval.
2024-01-14Retype traverse_interval arg type from Lisp_Object to void *Mattias Engdegård
This is a refactoring. It eliminates a few unnecessary conses and allows for further improvements. * src/intervals.c (traverse_intervals): Change argument type. All callers adapted. * src/fns.c (collect_interval, Fsxhash_equal_including_properties) (Fobject_intervals): * src/print.c (print_check_string_charset_prop) (print_prune_string_charset, print_object, print_interval): Pass a pointer to a Lisp_Object instead of a Lisp_Object.
2024-01-14Correct implementations of FLIPRGON and FLIPRGOFFPo Lu
* src/sfnt.c (sfnt_interpret_fliprgoff) (sfnt_interpret_fliprgon): Reorder arguments to match the order in which arguments are popped by macro wrappers. Fix sundry typos.
2024-01-14Fix bug#65116Po Lu
* src/xterm.c (xi_focus_handle_for_device): Correct typo. (x_focus_frame): Don't focus frames Emacs believes to be focused if they are frames with independent minibuffer frames. (bug#65116)
2024-01-13Hash-table documentation updates (bug#68244)Mattias Engdegård
* doc/lispref/hash.texi (Creating Hash, Other Hash): Manual updates for make-hash-table, hash-table-rehash-size and hash-table-rehash-threshold. * doc/lispref/objects.texi (Hash Table Type): Update example. * src/fns.c (Fhash_table_rehash_size, Fhash_table_rehash_threshold): Update doc strings. * etc/NEWS: Announce changes.
2024-01-13Don't pretend that hash-table-size is usefulMattias Engdegård
* lisp/emacs-lisp/shortdoc.el (hash-table): Remove hash-table-size entry. * doc/lispref/hash.texi (Other Hash): * src/fns.c (Fhash_table_size): Make it clear that hash-table-size is probably not worth using.
2024-01-13Change hash_hash_t to uint32_tMattias Engdegård
This saves a lot of memory and is quite sufficient. Hash functions are adapted to produce a hash_hash_t eventually, which eliminates some useless and information-destroying intermediate hash reduction steps. We still use EMACS_UINT for most of the actual hashing steps before producing the final value; this may be slightly wasteful on 32-bit platforms with 64-bit EMACS_UINT. * src/lisp.h (hash_hash_t): Change to uint32_t. * src/fns.c (reduce_emacs_uint_to_hash_hash): New. (hashfn_eq, hashfn_equal, hashfn_user_defined): Reduce return values to hash_hash_t. (sxhash_string): Remove. Caller changed to hash_string. (sxhash_float, sxhash_list, sxhash_vector, sxhash_bool_vector) (sxhash_bignum): Remove wasteful calls to SXHASH_REDUCE. (hash_hash_to_fixnum): New. (Fsxhash_eq, Fsxhash_eql, Fsxhash_equal) (Fsxhash_equal_including_properties): Convert return values to fixnum.
2024-01-13Use key Qunbound instead of hash value hash_unused for free entriesMattias Engdegård
Previously, free hash table entries were indicated by both hash value hash_unused and key Qunbound; we now rely on the latter only. This allows us to change the hash representation to one that does not have an unused value. * src/lisp.h (hash_unused): Remove. All uses adapted to calling hash_unused_entry_key_p on the key instead. The hash values for unused hash table entries are now undefined; all initialisation and assignment to hash_unused has been removed.
2024-01-13Don't dump QunboundMattias Engdegård
The dumper uses a hash table to keep track of dumped objects but as this clashes with the use of Qunbound for marking unused hash table entries, don't dump that value at all. The symbol name is fixed up after loading. An alternative solution would be to use a different unique value for unused entries. * src/pdumper.c (dump_object_needs_dumping_p): Skip Qunbound. (dump_vectorlike_generic): New function. (pdumper_load): Call it.
2024-01-13Change hash_idx_t to int32_t on all platformsMattias Engdegård
* src/lisp.h (hash_idx_t): Change to int32_t. * src/fns.c (hash_index_size): Adapt to new index type.
2024-01-13Faster hash table growth, starting at zero sizeMattias Engdegård
The algorithms no longer use the rehash_threshold and rehash_size float constants, but vary depending on size. In particular, the table now grows faster, especially from smaller sizes. The default size is now 0, starting empty, which effectively postpones allocation until the first insertion (unless make-hash-table was called with a positive :size); this is a clear gain as long as the table remains empty. The first inserted item will use an initial size of 8 because most tables are small. * src/fns.c (std_rehash_size, std_rehash_threshold): Remove. (hash_index_size): Integer-only computation. (maybe_resize_hash_table): Grow more aggressively. (Fhash_table_rehash_size, Fhash_table_rehash_threshold): Use the constants directly. * src/lisp.h (DEFAULT_HASH_SIZE): New value.
2024-01-13; Reorder struct Lisp_Hash_Table and struct hash_table_testMattias Engdegård
Mainly for efficiency, to keep frequently used fields together.
2024-01-13Share hash table test structsMattias Engdegård
This saves several words in the hash table object at the cost of an indirection at runtime. This seems to be a gain in overall performance. FIXME: We cache hash test objects in a rather clumsy way. A better solution is sought. * src/lisp.h (struct Lisp_Hash_Table): Use a pointer to the test struct. All references adapted. * src/alloc.c (garbage_collect): * src/fns.c (struct hash_table_user_test, hash_table_user_tests) (mark_fns, get_hash_table_user_test): New state for caching test structs, and functions managing it.
2024-01-13Use hash_idx_t for storing hash indicesMattias Engdegård
Now hash_idx_t is a typedef for ptrdiff_t so there is no actual code change, but this allows us to decouple the index width from the Lisp word size. * src/lisp.h (hash_idx_t): New typedef for ptrdiff_t. (struct Lisp_Hash_Table): Use it for indices and sizes: index, next, table_size, index_size, count and next_free. All uses adapted.
2024-01-13Inlined and specialised hash table look-upMattias Engdegård
This improves performance in several ways. Separate functions are used depending on whether the caller has a hash value computed or not. * src/fns.c (hash_lookup_with_hash, hash_lookup_get_hash): New. (hash_lookup): Remove hash return argument. All callers adapted. hash_lookup_with_hash hash_hash_t arg
2024-01-13Store hash values as integers instead of Lisp_ObjectMattias Engdegård
This improves typing, saves pointless tagging and untagging, and prepares for further changes. The new typedef hash_hash_t is an alias for EMACS_UINT, and hash values are still limited to the fixnum range. We now use hash_unused instead of Qnil to mark unused entries. * src/lisp.h (hash_hash_t): New typedef for EMACS_UINT. (hash_unused): New constant. (struct hash_table_test): `hashfn` now returns hash_hash_t. All callers and implementations changed. (struct Lisp_Hash_Table): Retype hash vector to an array of hash_hash_t. All code using it changed accordingly. (HASH_HASH, hash_from_key): * src/fns.c (set_hash_index_slot, hash_index_index) (hash_lookup_with_hash, hash_lookup_get_hash, hash_put): (hash_lookup, hash_put): Retype hash value arguments and return values. All callers adapted.
2024-01-13Use non-Lisp allocation for internal hash-table vectorsMattias Engdegård
Using xmalloc for allocating these arrays is much cheaper than using Lisp vectors since they are no longer marked or swept by the GC, and deallocated much sooner. This makes GC faster and less frequent, and improves temporal locality. Zero-sized tables use NULL for their (0-length) vectors except the index vector which has size 1 and uses a shared constant static vector since it cannot be modified anyway. This makes creation and destruction of zero-sized hash tables very fast; they consume no memory outside the base object. * src/lisp.h (struct Lisp_Hash_Table): Retype the index, next, hash and key_and_value vectors from Lisp_Object to appropriately typed arrays (although hash values are still stored as Lisp fixnums). Add explicit table_size and index_size members. All users updated. * src/alloc.c (gcstat): Add total_hash_table_bytes. (hash_table_allocated_bytes): New. (cleanup_vector): Free hash table vectors when sweeping the object. (hash_table_alloc_bytes, hash_table_free_bytes): New. (sweep_vectors): Update gcstat.total_hash_table_bytes. (total_bytes_of_live_objects): Use it. (purecopy_hash_table): Adapt allocation of hash table vectors. (process_mark_stack): No more Lisp slots in the struct to trace. * src/fns.c (empty_hash_index_vector): New. (allocate_hash_table): Allocate without automatically GCed slots. (alloc_larger_vector): Remove. (make_hash_table, copy_hash_table, maybe_resize_hash_table): Adapt vector allocation and initialisation. * src/pdumper.c (hash_table_freeze, hash_table_thaw, dump_hash_table) (dump_hash_table_contents): Adapt dumping and loading to field changes.
2024-01-13Allow zero hash table sizeMattias Engdegård
This avoids any extra allocation for such vectors, including empty tables read by the Lisp reader, and provides extra safety essentially for free. * src/fns.c (make_hash_table): Allow tables to be 0-sized. The index will always have at least one entry, to avoid extra look-up costs. * src/alloc.c (process_mark_stack): Don't mark pure objects, because empty vectors are pure.