emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] nick.lloyd-bytecode-jit 5b62317 1/2: Small speed improveme


From: Nickolas Lloyd
Subject: [Emacs-diffs] nick.lloyd-bytecode-jit 5b62317 1/2: Small speed improvement for JITed lisp function dispatch
Date: Sun, 29 Jan 2017 18:51:38 +0000 (UTC)

branch: nick.lloyd-bytecode-jit
commit 5b62317b697c04b4120a026e53309e04e15bd9e0
Author: Nickolas Lloyd <address@hidden>
Commit: Nickolas Lloyd <address@hidden>

    Small speed improvement for JITed lisp function dispatch
    
    * 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        |    1 +
 src/bytecode-jit.c |    1 +
 src/bytecode.c     |    4 +---
 src/eval.c         |   12 +++++++++---
 src/lisp.h         |    5 +++--
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 1a3f747..fe7bc12 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -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);
diff --git a/src/bytecode-jit.c b/src/bytecode-jit.c
index 0d058c9..974b6aa 100644
--- a/src/bytecode-jit.c
+++ b/src/bytecode-jit.c
@@ -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));
diff --git a/src/bytecode.c b/src/bytecode.c
index 8b132ca..3e64d2f 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -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);
diff --git a/src/eval.c b/src/eval.c
index f2e6ba8..57af384 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -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);
diff --git a/src/lisp.h b/src/lisp.h
index 931dcef..79cd85b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]