]> git.eshelyaron.com Git - emacs.git/commitdiff
Bytecode engine fast-path streamlining of plain symbols
authorMattias EngdegÄrd <mattiase@acm.org>
Wed, 31 Jan 2024 16:35:59 +0000 (17:35 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 31 Jan 2024 20:17:11 +0000 (21:17 +0100)
* src/bytecode.c (exec_byte_code):
Only use fast-path optimisations for calls and dynamic variable
reference and setting where the symbol is plain, which is much faster.

(cherry picked from commit 344a846b07dfcc9ad38e510da9115fadae94a477)

src/bytecode.c

index def20b232c65569894eb6d580a854c54b9d450bc..dd805cbd97afed1bc1930532ea9b41cd9dce3076 100644 (file)
@@ -625,9 +625,10 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
        varref:
          {
            Lisp_Object v1 = vectorp[op], v2;
-           if (!SYMBOLP (v1)
-               || XSYMBOL (v1)->u.s.redirect != SYMBOL_PLAINVAL
-               || (v2 = SYMBOL_VAL (XSYMBOL (v1)), BASE_EQ (v2, Qunbound)))
+           if (!BARE_SYMBOL_P (v1)
+               || XBARE_SYMBOL (v1)->u.s.redirect != SYMBOL_PLAINVAL
+               || (v2 = XBARE_SYMBOL (v1)->u.s.val.value,
+                   BASE_EQ (v2, Qunbound)))
              v2 = Fsymbol_value (v1);
            PUSH (v2);
            NEXT;
@@ -699,11 +700,11 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
            Lisp_Object val = POP;
 
            /* Inline the most common case.  */
-           if (SYMBOLP (sym)
+           if (BARE_SYMBOL_P (sym)
                && !BASE_EQ (val, Qunbound)
-               && XSYMBOL (sym)->u.s.redirect == SYMBOL_PLAINVAL
-               && !SYMBOL_TRAPPED_WRITE_P (sym))
-             SET_SYMBOL_VAL (XSYMBOL (sym), val);
+               && XBARE_SYMBOL (sym)->u.s.redirect == SYMBOL_PLAINVAL
+               && !XBARE_SYMBOL (sym)->u.s.trapped_write)
+             SET_SYMBOL_VAL (XBARE_SYMBOL (sym), val);
            else
               set_internal (sym, val, Qnil, SET_INTERNAL_SET);
          }
@@ -790,8 +791,9 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
              do_debug_on_call (Qlambda, count1);
 
            Lisp_Object original_fun = call_fun;
-           if (SYMBOLP (call_fun))
-             call_fun = XSYMBOL (call_fun)->u.s.function;
+           /* Calls to symbols-with-pos don't need to be on the fast path.  */
+           if (BARE_SYMBOL_P (call_fun))
+             call_fun = XBARE_SYMBOL (call_fun)->u.s.function;
            if (COMPILEDP (call_fun))
              {
                Lisp_Object template = AREF (call_fun, COMPILED_ARGLIST);