From: Paul Eggert Date: Mon, 22 Jan 2024 01:18:23 +0000 (-0800) Subject: Speed up builtin_lisp_symbol when not optimizing X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4025b57d6b6f945b6b021ea15fcbbe5a9f1c49f6;p=emacs.git Speed up builtin_lisp_symbol when not optimizing 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. (cherry picked from commit df7c6211cb960b88bc0aaef85babf7e9384d5f2e) --- diff --git a/src/lisp.h b/src/lisp.h index ae78947805e..29d2a08785a 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -409,6 +409,10 @@ 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)) @@ -475,6 +479,7 @@ 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) @@ -1171,9 +1176,9 @@ make_lisp_symbol (struct Lisp_Symbol *sym) } INLINE Lisp_Object -builtin_lisp_symbol (int index) +(builtin_lisp_symbol) (int index) { - return make_lisp_symbol (&lispsym[index]); + return lisp_h_builtin_lisp_symbol (index); } INLINE bool