]> git.eshelyaron.com Git - emacs.git/commitdiff
; Minor reorg of bytecode interpreter/JIT compiler
authorNickolas Lloyd <ultrageek.lloyd@gmail.com>
Fri, 23 Dec 2016 01:05:16 +0000 (20:05 -0500)
committerNickolas Lloyd <ultrageek.lloyd@gmail.com>
Fri, 23 Dec 2016 01:05:16 +0000 (20:05 -0500)
; * src/bytecode.c (exec_byte_code, exec_byte_code__): Use exec_byte_code as
the single entrypoint for both the interpreter and JIT compiler.
; * src/bytecode-jit.c (jit_byte_code): Remove jit_byte_code to be replaced
by exec_byte_code.
; * src/bytecode.h: Add function prototypes.
; * src/eval.c (funcall_lambda): Use exec_byte_code instead of jit_byte_code.
; * src/lisp.h: Update function prototypes.

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

index 095892d067c962f81f24ca315d1007e2173f4bb0..734371dc7724281efa597b497125e3b7916a66fa 100644 (file)
@@ -605,7 +605,7 @@ emacs_jit_init (void)
   JIT_SIG (native_integer_p, jit_type_Lisp_Object, jit_type_Lisp_Object);
 }
 
-static Lisp_Object
+Lisp_Object
 jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
 {
   Lisp_Object *top;
@@ -668,7 +668,7 @@ jit_exec (Lisp_Object byte_code, Lisp_Object args_template, ptrdiff_t nargs, Lis
   }
 }
 
-static void
+void
 jit_byte_code__ (Lisp_Object byte_code)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
@@ -2094,24 +2094,6 @@ jit_byte_code__ (Lisp_Object byte_code)
   }
 }
 
-Lisp_Object
-jit_byte_code (Lisp_Object byte_code, Lisp_Object args_template,
-              ptrdiff_t nargs, Lisp_Object *args)
-{
-  if (AREF (byte_code, COMPILED_JIT_ID))
-    return jit_exec (byte_code, args_template, nargs, args);
-  else if (!byte_code_jit_on)
-    return exec_byte_code (AREF (byte_code, COMPILED_BYTECODE),
-                          AREF (byte_code, COMPILED_CONSTANTS),
-                          AREF (byte_code, COMPILED_STACK_DEPTH),
-                          args_template, nargs, args);
-  else
-    {
-      jit_byte_code__ (byte_code);
-      return jit_exec (byte_code, args_template, nargs, args);
-    }
-}
-
 DEFUN ("jit-compile", Fjit_compile, Sjit_compile, 1, 1, 0,
        doc: /* Function used internally in byte-compiled code.
               The first argument, BYTECODE, is a compiled byte code object. */)
index c88ca5091195a2a7319fbaf5ff90124468346961..76ec066c6371add751fb862e2daebbf5615a86c0 100644 (file)
@@ -137,7 +137,7 @@ the third, MAXDEPTH, the maximum stack depth used in this function.
 If the third argument is incorrect, Emacs may crash.  */)
   (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth)
 {
-  return exec_byte_code (bytestr, vector, maxdepth, Qnil, 0, NULL);
+  return exec_byte_code__ (bytestr, vector, maxdepth, Qnil, 0, NULL);
 }
 
 void
@@ -155,8 +155,8 @@ bcall0 (Lisp_Object f)
    executing BYTESTR.  */
 
 Lisp_Object
-exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
-               Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
+exec_byte_code__ (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
+                 Lisp_Object args_template, ptrdiff_t nargs, Lisp_Object *args)
 {
 #ifdef BYTE_CODE_METER
   int volatile this_op = 0;
@@ -1283,6 +1283,24 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
   return result;
 }
 
+Lisp_Object
+exec_byte_code (Lisp_Object byte_code, Lisp_Object args_template,
+               ptrdiff_t nargs, Lisp_Object *args)
+{
+  if (AREF (byte_code, COMPILED_JIT_ID))
+    return jit_exec (byte_code, args_template, nargs, args);
+  else if (!byte_code_jit_on)
+    return exec_byte_code__ (AREF (byte_code, COMPILED_BYTECODE),
+                            AREF (byte_code, COMPILED_CONSTANTS),
+                            AREF (byte_code, COMPILED_STACK_DEPTH),
+                            args_template, nargs, args);
+  else
+    {
+      jit_byte_code__ (byte_code);
+      return jit_exec (byte_code, args_template, nargs, args);
+    }
+}
+
 /* `args_template' has the same meaning as in exec_byte_code() above.  */
 Lisp_Object
 get_byte_code_arity (Lisp_Object args_template)
index aa59b94395247414bb1b547dd2d237be63aa6d50..25f11f1ce1fc91e68b8a7e597416c9445948e9df 100644 (file)
@@ -301,3 +301,13 @@ struct byte_stack
 
 extern void
 bcall0 (Lisp_Object f);
+
+extern void
+jit_byte_code__ (Lisp_Object);
+
+extern Lisp_Object
+jit_exec (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *);
+
+extern Lisp_Object
+exec_byte_code__ (Lisp_Object, Lisp_Object, Lisp_Object,
+                 Lisp_Object, ptrdiff_t, Lisp_Object *);
index 7d32daf0e4ee391c24531a1a994ee21022a8cd61..f2e6ba85214ef1e52a65d261cd8e5eac9bde51ac 100644 (file)
@@ -2954,8 +2954,8 @@ 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 jit_byte_code (fun, syms_left,
-                               nargs, arg_vector);
+         return exec_byte_code (fun, syms_left,
+                                nargs, arg_vector);
        }
       lexenv = Qnil;
     }
@@ -3029,7 +3029,7 @@ 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 = jit_byte_code (fun, Qnil, 0, 0);
+      val = exec_byte_code (fun, Qnil, 0, 0);
     }
 
   return unbind_to (count, val);
index 65468dfbf29de2c6d33afc2c14513460dd675dca..fc600a50cab2a43ad648f4f48282541c1a8fe8b1 100644 (file)
@@ -4340,13 +4340,11 @@ extern int read_bytecode_char (bool);
 /* Defined in bytecode.c.  */
 extern void syms_of_bytecode (void);
 extern void relocate_byte_stack (struct byte_stack *);
-extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, Lisp_Object,
-                                  Lisp_Object, ptrdiff_t, Lisp_Object *);
+extern Lisp_Object exec_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *);
 extern Lisp_Object get_byte_code_arity (Lisp_Object);
 
 /* Defined in bytecode-jit.c  */
 extern void syms_of_bytecode_jit (void);
-extern Lisp_Object jit_byte_code (Lisp_Object, Lisp_Object, ptrdiff_t, Lisp_Object *);
 
 /* Defined in macros.c.  */
 extern void init_macros (void);