]> git.eshelyaron.com Git - emacs.git/commitdiff
Small speed improvement for JITed lisp function dispatch
authorNickolas Lloyd <ultrageek.lloyd@gmail.com>
Sun, 29 Jan 2017 18:22:06 +0000 (13:22 -0500)
committerNickolas Lloyd <ultrageek.lloyd@gmail.com>
Sun, 29 Jan 2017 18:22:06 +0000 (13:22 -0500)
* src/alloc.c (make-byte-code):
* src/bytecode-jit.c (jit_byte_code__):
* src/bytecode.c [HAVE_LIBJIT] (exec_byte_code):
* src/eval.c (funcall_lambda):
* src/lisp.h (funcall_lambda): Store pointer to bytecode execution function
(either `exec_byte_code' or `jit_exec') in Lisp_Compiled objects to avoid
the need for an extra function call in `exec_byte_code'.

src/alloc.c
src/bytecode-jit.c
src/bytecode.c
src/eval.c
src/lisp.h

index 1a3f747ec5c0ede6c957801ebda3cabae70a2567..fe7bc12f414d45b9ad2c6b08872eea83251f534d 100644 (file)
@@ -3510,6 +3510,7 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
 
   /* set rest size so that total footprint = COMPILED_JIT_CLOSURE + 1 */
   XSETPVECTYPESIZE (p, PVEC_COMPILED, size, COMPILED_JIT_CLOSURE + 1 - size);
+  p->contents[COMPILED_INTERPRETER] = (Lisp_Object )exec_byte_code;
   p->contents[COMPILED_JIT_CTXT] = (Lisp_Object )NULL;
   p->contents[COMPILED_JIT_CLOSURE] = (Lisp_Object )NULL;
   XSETCOMPILED (val, p);
index 0d058c95b071eb9b51b06cdfc3ea9f5b3a3daaa7..974b6aabac2ab8c2ff5eaedeb1e20c9c429e8bcf 100644 (file)
@@ -1588,6 +1588,7 @@ jit_byte_code__ (Lisp_Object byte_code)
     jit_context_build_end (ctxt.libjit_ctxt);
     if (err)
       emacs_abort ();
+    ASET (byte_code, COMPILED_INTERPRETER, (Lisp_Object )jit_exec);
     ASET (byte_code, COMPILED_JIT_CTXT, (Lisp_Object )ctxt.libjit_ctxt);
     ASET (byte_code, COMPILED_JIT_CLOSURE,
          (Lisp_Object )jit_function_to_closure (ctxt.func));
index 8b132caac0a5bc0044f99e22abf11e81154ce1ec..3e64d2f42b68746c038d48923652f363e58a04e5 100644 (file)
@@ -1291,9 +1291,7 @@ exec_byte_code (Lisp_Object byte_code, Lisp_Object args_template,
                ptrdiff_t nargs, Lisp_Object *args)
 {
 #ifdef HAVE_LIBJIT
-  if (AREF (byte_code, COMPILED_JIT_CTXT) != (Lisp_Object )NULL)
-    return jit_exec (byte_code, args_template, nargs, args);
-  else if (byte_code_jit_on)
+  if (byte_code_jit_on)
     {
       jit_byte_code__ (byte_code);
       return jit_exec (byte_code, args_template, nargs, args);
index f2e6ba85214ef1e52a65d261cd8e5eac9bde51ac..57af384f774d8da1ce520d930d79015d3a649a60 100644 (file)
@@ -2954,8 +2954,11 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
             and constants vector yet, fetch them from the file.  */
          if (CONSP (AREF (fun, COMPILED_BYTECODE)))
            Ffetch_bytecode (fun);
-         return exec_byte_code (fun, syms_left,
-                                nargs, arg_vector);
+         Lisp_Object (*interpreter)(Lisp_Object, Lisp_Object,
+                                    ptrdiff_t, Lisp_Object *) =
+           (void *)AREF (fun, COMPILED_INTERPRETER);
+         return interpreter (fun, syms_left,
+                             nargs, arg_vector);
        }
       lexenv = Qnil;
     }
@@ -3029,7 +3032,10 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
         and constants vector yet, fetch them from the file.  */
       if (CONSP (AREF (fun, COMPILED_BYTECODE)))
        Ffetch_bytecode (fun);
-      val = exec_byte_code (fun, Qnil, 0, 0);
+      Lisp_Object (*interpreter)(Lisp_Object, Lisp_Object,
+                                ptrdiff_t, Lisp_Object *) =
+       (void *)AREF (fun, COMPILED_INTERPRETER);
+      val = interpreter (fun, Qnil, 0, 0);
     }
 
   return unbind_to (count, val);
index 931dcef7712e6bc33d23f04f65b7039a0771f20e..79cd85b736b72feae73c31528aec2b3b7e32d022 100644 (file)
@@ -2592,8 +2592,9 @@ enum Lisp_Compiled
     COMPILED_STACK_DEPTH = 3,
     COMPILED_DOC_STRING = 4,
     COMPILED_INTERACTIVE = 5,
-    COMPILED_JIT_CTXT = 6,
-    COMPILED_JIT_CLOSURE = 7
+    COMPILED_INTERPRETER = 6,
+    COMPILED_JIT_CTXT = 7,
+    COMPILED_JIT_CLOSURE = 8
   };
 
 /* Flag bits in a character.  These also get used in termhooks.h.