commit 802821b81ac5ad0dee7f26caa519326251b262c1 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Tue Jan 23 23:35:22 2024 -0800 Remove too-tricky make_lisp_symbol optimization Simplify optimization for make_lisp_symbol, so that it’s less tricky and works well enough for gcc -Og or -O2. * src/lisp.h (lisp_h_builtin_lisp_symbol): Remove. (builtin_lisp_symbol) [DEFINE_KEY_OPS_AS_MACROS]: Remove. (make_lisp_symbol_nodebug): New internal static function, which is like the old make_lisp_symbol but without the eassert. (make_lisp_symbol, builtin_lisp_symbol): Use it, so that make_lisp_symbol has the eassert but builtin_lisp_symbol doesn’t. Co-authored-by: Paul Eggert diff --git a/src/lisp.h b/src/lisp.h index 54d2f4d3dd1..09fcd6689bf 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -409,10 +409,6 @@ typedef EMACS_INT Lisp_Word; & ((1 << INTTYPEBITS) - 1))) #define lisp_h_FLOATP(x) TAGGEDP (x, Lisp_Float) #define lisp_h_NILP(x) BASE_EQ (x, Qnil) -/* Equivalent to "make_lisp_symbol (&lispsym[INDEX])", - and typically faster when compiling without optimization. */ -#define lisp_h_builtin_lisp_symbol(index) \ - TAG_PTR (Lisp_Symbol, (index) * sizeof *lispsym) #define lisp_h_SET_SYMBOL_VAL(sym, v) \ (eassert ((sym)->u.s.redirect == SYMBOL_PLAINVAL), \ (sym)->u.s.val.value = (v)) @@ -479,7 +475,6 @@ typedef EMACS_INT Lisp_Word; # define FLOATP(x) lisp_h_FLOATP (x) # define FIXNUMP(x) lisp_h_FIXNUMP (x) # define NILP(x) lisp_h_NILP (x) -# define builtin_lisp_symbol(index) lisp_h_builtin_lisp_symbol (index) # define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v) # define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym) # define SYMBOL_TRAPPED_WRITE_P(sym) lisp_h_SYMBOL_TRAPPED_WRITE_P (sym) @@ -1169,21 +1164,30 @@ XSYMBOL (Lisp_Object a) return XBARE_SYMBOL (a); } +/* Internal use only. */ INLINE Lisp_Object -make_lisp_symbol (struct Lisp_Symbol *sym) +make_lisp_symbol_internal (struct Lisp_Symbol *sym) { /* GCC 7 x86-64 generates faster code if lispsym is - cast to char * rather than to intptr_t. */ + cast to char * rather than to intptr_t. + Do not use eassert here, so that builtin symbols like Qnil compile to + constants; this is needed for some circa-2024 GCCs even with -O2. */ char *symoffset = (char *) ((char *) sym - (char *) lispsym); - Lisp_Object a = TAG_PTR (Lisp_Symbol, symoffset); + return TAG_PTR (Lisp_Symbol, symoffset); +} + +INLINE Lisp_Object +make_lisp_symbol (struct Lisp_Symbol *sym) +{ + Lisp_Object a = make_lisp_symbol_internal (sym); eassert (XBARE_SYMBOL (a) == sym); return a; } INLINE Lisp_Object -(builtin_lisp_symbol) (int index) +builtin_lisp_symbol (int index) { - return lisp_h_builtin_lisp_symbol (index); + return make_lisp_symbol_internal (&lispsym[index]); } INLINE bool commit 33b8d5b6c5a22bab069cdac4bddda932b3d18b13 Author: Stefan Monnier Date: Tue Jan 23 22:30:13 2024 -0500 (struct charset): Remove dependency on hash-table internals `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. diff --git a/src/charset.c b/src/charset.c index f562af90cb2..9633ccaaef9 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1108,18 +1108,18 @@ usage: (define-charset-internal ...) */) ASET (attrs, charset_plist, args[charset_arg_plist]); hash_hash_t hash_code; - charset.hash_index = hash_lookup_get_hash (hash_table, args[charset_arg_name], - &hash_code); - if (charset.hash_index >= 0) + ptrdiff_t hash_index + = hash_lookup_get_hash (hash_table, args[charset_arg_name], + &hash_code); + if (hash_index >= 0) { - new_definition_p = 0; + new_definition_p = false; id = XFIXNAT (CHARSET_SYMBOL_ID (args[charset_arg_name])); - set_hash_value_slot (hash_table, charset.hash_index, attrs); + set_hash_value_slot (hash_table, hash_index, attrs); } else { - charset.hash_index = hash_put (hash_table, args[charset_arg_name], attrs, - hash_code); + hash_put (hash_table, args[charset_arg_name], attrs, hash_code); if (charset_table_used == charset_table_size) { /* Ensure that charset IDs fit into 'int' as well as into the @@ -1150,6 +1150,7 @@ usage: (define-charset-internal ...) */) ASET (attrs, charset_id, make_fixnum (id)); charset.id = id; + charset.attributes = attrs; charset_table[id] = charset; if (charset.method == CHARSET_METHOD_MAP) @@ -2269,6 +2270,16 @@ See also `charset-priority-list' and `set-charset-priority'. */) return charsets; } +/* Not strictly necessary, because all charset attributes are also + reachable from `Vcharset_hash_table`. +void +mark_charset (void) +{ + for (int i = 0; i < charset_table_used; i++) + mark_object (charset_table[i].attributes); +} +*/ + void init_charset (void) diff --git a/src/charset.h b/src/charset.h index ba83cd5ccb2..1edb4a248ac 100644 --- a/src/charset.h +++ b/src/charset.h @@ -150,8 +150,7 @@ struct charset /* Index to charset_table. */ int id; - /* Index to Vcharset_hash_table. */ - ptrdiff_t hash_index; + Lisp_Object attributes; /* Dimension of the charset: 1, 2, 3, or 4. */ int dimension; @@ -289,11 +288,9 @@ extern int emacs_mule_charset[256]; hash_lookup (XHASH_TABLE (Vcharset_hash_table), symbol) /* Return the attribute vector of CHARSET. */ -#define CHARSET_ATTRIBUTES(charset) \ - HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), (charset)->hash_index) +#define CHARSET_ATTRIBUTES(charset) (charset)->attributes #define CHARSET_ID(charset) ((charset)->id) -#define CHARSET_HASH_INDEX(charset) ((charset)->hash_index) #define CHARSET_DIMENSION(charset) ((charset)->dimension) #define CHARSET_CODE_SPACE(charset) ((charset)->code_space) #define CHARSET_CODE_LINEAR_P(charset) ((charset)->code_linear_p) diff --git a/src/pdumper.c b/src/pdumper.c index bff11ada02c..9c9a1ff382c 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2650,9 +2650,11 @@ hash_table_contents (struct Lisp_Hash_Table *h) * sizeof *key_and_value); ptrdiff_t n = 0; - /* Make sure key_and_value ends up in the same order; charset.c - relies on it by expecting hash table indices to stay constant - across the dump. */ + /* Make sure key_and_value ends up in the same order; the `hash_index` + field of `struct composition` relies on it by expecting hash table + indices to stay constant across the dump. + FIXME: Remove such dependency on hash table internals (there might + be another one in `composition_gstring_from_id`). */ DOHASH (h, i) { key_and_value[n++] = HASH_KEY (h, i); @@ -3224,7 +3226,7 @@ dump_charset (struct dump_context *ctx, int cs_i) struct charset out; dump_object_start (ctx, &out, sizeof (out)); DUMP_FIELD_COPY (&out, cs, id); - DUMP_FIELD_COPY (&out, cs, hash_index); + dump_field_lv (ctx, &out, cs, &cs->attributes, WEIGHT_NORMAL); DUMP_FIELD_COPY (&out, cs, dimension); memcpy (out.code_space, &cs->code_space, sizeof (cs->code_space)); if (cs_i < charset_table_used && cs->code_space_mask) @@ -3262,12 +3264,15 @@ dump_charset_table (struct dump_context *ctx) ctx->flags.pack_objects = true; dump_align_output (ctx, DUMP_ALIGNMENT); dump_off offset = ctx->offset; + if (dump_set_referrer (ctx)) + ctx->current_referrer = build_string ("charset_table"); /* We are dumping the entire table, not just the used slots, because otherwise when we restore from the pdump file, the actual size of the table will be smaller than charset_table_size, and we will crash if/when a new charset is defined. */ for (int i = 0; i < charset_table_size; ++i) dump_charset (ctx, i); + dump_clear_referrer (ctx); dump_emacs_reloc_to_dump_ptr_raw (ctx, &charset_table, offset); ctx->flags = old_flags; return offset; commit 13c7249105ec0d1a070c6d4e9f73f3c21d905bc8 Author: Michael Albinus Date: Tue Jan 23 19:24:29 2024 +0100 Fix cus-test-deps * admin/cus-test.el (cus-test-deps): Add the "quail/" subdirectory to default-directory, temporarily. diff --git a/admin/cus-test.el b/admin/cus-test.el index 68907f4f5e5..10d6e34358d 100644 --- a/admin/cus-test.el +++ b/admin/cus-test.el @@ -424,7 +424,12 @@ in the Emacs source directory." (mapatoms ;; This code is mainly from `custom-load-symbol'. (lambda (symbol) - (let ((custom-load-recursion t)) + (let ((custom-load-recursion t) + (load-path + (cons + (expand-file-name + "quail" (file-name-directory (locate-library leim-list-file-name))) + load-path))) (dolist (load (get symbol 'custom-loads)) (cond ((symbolp load) commit 87cf30fba37346a179c6307a29d5d39b39311cef Author: Basil L. Contovounesios Date: Fri Jan 19 13:50:29 2024 +0100 Further shrink eglot--{} Up to and including Emacs 29, :size 0 was an alias for :size 1. Emacs 30 gained support for :size 0 hash tables (bug#68244). * lisp/progmodes/eglot.el (eglot--{}): Define as truly zero-sized. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index c5cfdd3cedd..511000927cf 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -575,7 +575,7 @@ It is nil if Eglot is not byte-complied.") (defvaralias 'eglot-{} 'eglot--{}) -(defconst eglot--{} (make-hash-table :size 1) "The empty JSON object.") +(defconst eglot--{} (make-hash-table :size 0) "The empty JSON object.") (defun eglot--executable-find (command &optional remote) "Like Emacs 27's `executable-find', ignore REMOTE on Emacs 26."